Most of the times consultants get a requirement to calculate the discount for the supply chain documents such as Purchase Orders and Sales Orders.
The key to do this calculation is to use PurchTotals class.
Here is the code mentioned below where we are calculating the discount for a purchase order : -
class CalculateTotalsOfPurchaseOrder
{
public static void main(Args _args)
{
PurchTotals purchTotals;
PurchTable purchTable = PurchTable::find('PO012345');
AmountCur totalAmount;
purchTotals = PurchTotals::newPurchTable(purchTable);
purchTotals.calc();
totalAmount = purchTotals.purchTotalAmount();
info(strFmt('Purchase order: %1 - Total value: %2', purchTable.PurchId, totalAmount));
}
}
That's all for now. Please let us know your questions or feedback in comments section !!!!
No comments:
Post a Comment