Search code examples
crystal-reportsrounding

SAP rounding formula - where does rounding occur?


I'm doing some integration with SAP and a custom application. The calculated values for 'Total' and 'Price after Discount' are off half of the time.

Given 'Quantity', 'Unit Price' and 'Discount %', how is their calculations formulated?

This is the formula I've been using to get 'Total' so far and it doesn't always match up:

Let R = Round to two decimal places away from zero

Total = R(Quantity * Unit Price) - R(R(Quantity* Unit Price) * R(Discount/100))

But as you can see, if I plug in the first line of Quantity: 11217, Unit Price 0.3 and Discount: 65, I get a different result of 1177.78

What tweak to my formula then should I make so I consistently match with SAP's ('Total' and 'Price after Discount')?

wth SAP?!


Solution

  • After a lot of trial and errors, I finally figured out SAP's algorithm to get 'Total':

    Let R = Round to two decimal places away from zero
    
    Total = R(Quantity * Unit Price * (100 - Discount%) / 100)
    

    I had to take out rounding on each step and not use 'Original Price - Discount'