You need to sign in to do that
Don't have an account?
Precision in calculation of sales price, list price and discount
Hi,
Can someone explain how to solve this? On the opportunity line item level, there are 2 standard fields called "List Price" and "Sales Price" defined as Currency(16,2). We have a custom field called Discount__c defined as Percent(12,6).
We have a trigger that will calculate Sales Price or Discount depending on which is changed. The following example shows the results obtained on the sandbox environment.
List Price = 4.75
Discount = 50%
results in Sales Price of 2.38 (Displayed) or 2.375 (stored)
List Price = 4.75
Sales Price = 2.375 (entered)
upon saving,
Sales Price = 2.38 (displayed and stored) and Discount = 49.894737%
My question is, if Sales Price is already defined as 16,2 why is the value stored with 3 decimal (2.375)? Ideally we'll need 3 or more precision.
Thank you.
EDIT:
This is really weird and causing our trigger to not work as expected. In our trigger, we compare the old Sales Price and Discount in a loop and depending on what changed, we calculate either new Sales Price or Discount.
The IF statement:
>> if(Trigger.oldMap.get(oli.id).UnitPrice != oli.UnitPrice && Trigger.oldMap.get(oli.id).Discount__c == oli.Discount__c) {
What happens is if I change the Sales Price (Unit Price) once, then it calculates a new discount. Now, if I change the Sales Price again without changing the discount values, it thinks the discount is not the same this time around and goes to another loop that calculates Sales Price. I printed out the old and new values the second time and I'm seeing 14 number precision on the old discount as opposed to the set 6 precision.
An example of a calculate discount is below:
>> 57.89473684210527 57.894737
The weirdest part is if I enter 2 then 3 the second time for sales price, I'm seeing 2 and 3 when I print out the variables on another dummy field. But the actual Sales Price field is still showing 2 in the GUI.
What's going on??
Ohh come on EXPERTS.. Give us a solution!!!!!!!
Till i read this post i thought its a bug in SF. In my case I am not using trigger(its PE). But even i want the discount to be changed when SalesPrice is changed. I am sure many of you have come across this... Please do suggest..