Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
$5 difference due to rounding?
Message
 
 
To
15/11/2006 16:31:07
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01169448
Message ID:
01170091
Views:
15
>You should have zero. I've spent my five hours over this in 1990 (mFoxPlus then), and the crux of the matter is that you shouldn't apply any percentage, coefficient or whatever multiplication to any numbers added - only to each number in turn. If you want to calculate 1% out of 100 numbers, and 1% of their total, it's a safe bet you'll be a few cents off each time, because of the rounding.
>
>Now on each of these numbers you have this commission calculated once - when the document was saved. Save this commission as well, and never calculate it again. Just add the value as it is saved in the commission field, and you'll have zero discrepancy. No such field? Add it.
>
>BTW, for Fox folks here, "memo" is a "memorandum on consignment" and has nothing to do with memo fields.

Ok, going back to the problem. The commissions are saved in the table. I haven't yet found when they are saved, but I know how they were calculated.

Anyway, I have the commissions saved for multiple invoices (for some reference number). Each invoice may have an order and in the orders table we have a certain field identifying the category.

Each invoice may have only one order.

So, I'm re-calculating the commissions per each invoice and sum them to put into the appropriate category for the reference number (one reference number may have 1 or multiple invoices).

At the end Commission paid (saved in the table) should match sum of commissions per category unless the data were altered after the fact. And I have them matched except for particular record where I see the difference. I had not time to find out what exactly happenned, because it several of my test cases I saw discrepancies in one (or sometimes 2 + ) records.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform