web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / DAX Beginners / How to: Calculate purchase ...

How to: Calculate purchase order Subtotal Amount

Christian Silva Profile Picture Christian Silva 707

Today, Celeb Kiran has asked me on my post How to: Calculate purchase order total value how get the Subtotal Amount instead of Total Amount.
Since one man’s doubt is another man’s doubt I have decided to post how to get the PO Subtotal amount modifying the previous code and adding some comments.

This value can also be found on Totals form, which can be accessed through:
Accounts payable/Common/Purchase orders/All purchase orders/Tab – Purchase Order/Group – View/Totals

Today I will use the PO BRMF-000018. The difference between Subtotal and total amount makes it a perfect example.

As always, I will use a job as example:

static void _GetPurchTotals(Args _args)
{
    PurchTotals purchTotals;
    PurchTable  purchTable  = PurchTable::find('BRMF-000018'); //Purchase order Number

    AmountCur  totalAmount;
    AmountCur  subTotalAmount;
    ;

    // Initializing PurhTotals using the PO BRMF-000018 as parameter
    purchTotals = PurchTotals::newPurchTable(purchTable);
    // Calculating values
    purchTotals.calc();

    // Total Amount
    totalAmount     = purchTotals.purchTotalAmount();
    // SubTotal Amount
    subTotalAmount  = purchTotals.purchBalance();

    // Displaying Results
    setPrefix('Purchase Order');
    setPrefix(purchTable.PurchId);
    info(strFmt('Subtotal amount: %1', subTotalAmount));
    info(strFmt('Total amount: %1', totalAmount));
}

Executing the code, the infolog shows the following results:


This was originally posted here.

Comments

*This post is locked for comments