>Hi Nadya,
>
>At a quick glance, it does seem that a few SELECT - SQL statements will be simpler. And it might be easier to write your own code than to unwind someone else's.
>
>To get consistent results among different results, you might consider doing more complicated selection tasks in some sort of function or class, so that you can change the calculations in one single place. But if it is only Bill_Main and Bill_Detail, even that doesn't seem warranted in this case. Unless you have lots of additional complicated details (such as special discounts).
>
>I did something like this (a centralized function) in order to get consistent results for calculating, and preparing other data, for reports on shoe prices. But the details are quite involved in this case.
>
Actually, there are several other related tables and Notes[], etc. for the Bill in addition to Details.
My problem currently is, why Amount calculated by select SQL doesn't match this
.nTotalAmount = .nTotalAmount + .Details[m.i].oTabBillDet.oFields.Amount && Let's calculate total amount
in a loop for every Detail line.
I tried to trace this code, but there were so many objects involved, that I stopped.
Anyway, I invited two more people and I think I figured this out now and the Amounts are going to match after I'll fix the problem.
UPDATE. Yes, now I'm getting better results and can proceed with the other logic.
The original problem I introduced myself.
Anyway, the complexity of all these classes is beyond the mere mortal brain... :(
If it's not broken, fix it until it is.
My Blog