
Hi,
I have a service to create a sales order, where i pass the Qty,SalesPrice and LineAmount.
I want to say that if Qty*SalesPrice sent to the service really equal the lineAmount sent then keep it. However, if it's wrong then i want recalculate SalesPrice based on the sent LineAmount
My question is, which is the correct method to use, salesLine.calcLineAmount() or salesLine.calcLineAmountForced() or salesLine.calcLineAmountForcedInteraction()? what's the difference?
salesLine.SalesQty = _reqLine.Qty(); //assume reqLine is defined
salesLine.SalesPrice = _reqLine.Price();
real x= salesLine.calcLineAmount();
real y = salesLine.calcLineAmountForced();
real z = salesLine.salesLine.calcLineAmountForcedInteraction(); //this one need a parameter to be passed
if(x != _reqLine.LineAmount())
{
salesLine.SalesPrice = _reqLine.LineAmount()/salesLine.Qty;
}
salesLine.LineAmount = _reqLine.LineAmount(); The correct calculation includes more things than just quantity and unit price. There may be discounts, for instance.
If you want the line amount to always match the result of calcLineAmount(), you shouldn't try to set LineAmount by yourself - you should call calcLineAmount() in both cases.
When you call the calculation, the system checks if the line amount wasn't set manually. Overwriting it may be a bad idea. If done interactively, the system may ask the user for a decision. Or you may force the recalculation, losing the amount set manually. That's what the other methods are about.