This question was **closed** Jul 24, 2017 at 09:01 PM by Sam for the following reason: Unanswered

I've read the documents and other posts here but I'm still not coming up with spot on amounts

Suppose I've got an order and do the following for each line item:

1.) Get item price

2.) Subtract any line item level discount percentages

3.) Subtract discount line item discount amounts

4.) Subtract any order level discount percentages (proportionally)

5.) Subtract any order level discount amounts

6.) Multiply by tax rate to get tax.

Out of this, I store the result from each calculation in a Java class object.

Once I've done this for all line items, I loop through my objects and add up the net amount and the tax amount. At this point right before I write my final result to the database, I round.

In a good number of my orders, I am 1 penny off either in the total or the total tax.

Just to make sure I understand, Clover only rounds at the very end of the process, right? Line item level detail data is left in raw unrounded form. Is this the way it should be or should I be rounding with each calculation? I seem to match most of the time when I don't round until the end but for the life of me I cannot figure why I have a significant number of records that are a penny off.

Thanks in advance!

Suppose I've got an order and do the following for each line item:

1.) Get item price

2.) Subtract any line item level discount percentages

3.) Subtract discount line item discount amounts

4.) Subtract any order level discount percentages (proportionally)

5.) Subtract any order level discount amounts

6.) Multiply by tax rate to get tax.

Out of this, I store the result from each calculation in a Java class object.

Once I've done this for all line items, I loop through my objects and add up the net amount and the tax amount. At this point right before I write my final result to the database, I round.

In a good number of my orders, I am 1 penny off either in the total or the total tax.

Just to make sure I understand, Clover only rounds at the very end of the process, right? Line item level detail data is left in raw unrounded form. Is this the way it should be or should I be rounding with each calculation? I seem to match most of the time when I don't round until the end but for the life of me I cannot figure why I have a significant number of records that are a penny off.

Thanks in advance!

Comment

Copyright © 2010-16 DZone, Inc. - All rights reserved.

- Anonymous
- Sign in
- Create
- Ask a question
- Post an idea
- Create an article
- Spaces
- App Market Developer Platform
- Clover GO
- Ideas & Feedback
- Semi-Integration
- Explore
- Topics
- Questions
- Ideas
- Articles