question

mkonnekt avatar image
mkonnekt asked mkonnekt commented

How does clover do roundups in calculations?

I have an order with the following items and discount of $2.38. However, on sending clover line item discounts (since one of the order items doesn't need to be discounted), the calculated discount becomes different in value.

Please confirm the Clover side calculation: [Item1 = $8.99], [Item2 = $6.99], [Item 3 = $6.99 + modifiers as m1 = $0.25, m2 = $0.5], [Item4 = $1.20]. Total discount is $2.38 and has to applied to all items except item4.

If I proportionately distribute discount to all line items1-3 but do roundups to 2 decimal places each time, the total discount applied becomes $2.42 not $2.38.

Sum of all items to be discounted = $23.72 = 8.99+6.99+6.99+0.25+0.50 Discount = $2.38 Item1 discount = $0.91 = 8.99 * 2.38 / 23.72. Similarly, Item2 discount = $0.71, Item3's = $.80 = ($0.71+$0.03+$0.06)

Total discount = $2.42 = $0.91+0.71+0.80

The rounding up is causing the error. What can be done in this case to ensure total discount sent is what is applied?

Discounts
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mkonnekt avatar image mkonnekt commented ·

Ok thanks. I'll go through the source code at github. There is one unanswered part above, does Clover apply line item discounts to modifiers in the line item? This is when the discount is a $ amount and a line item (eg. Item3 above) has priced modifiers. I am not seeing that in my orders so wanted to get a confirmation from you and if Clover doesn't then a workaround to ensure our calculations match.

0 Likes 0 ·

1 Answer

Jacob Abrams avatar image
Jacob Abrams answered mkonnekt commented
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mkonnekt avatar image mkonnekt commented ·

Ok thanks. I'll go through the source code at github. There is one unanswered part above, does Clover apply line item discounts to modifiers in the line item? This is when the discount is a $ amount and a line item (eg. Item3 above) has priced modifiers. I am not seeing that in my orders so wanted to get a confirmation from you and if Clover doesn't then a workaround to ensure our calculations match.

0 Likes 0 ·

Welcome to the
Clover Developer Community