Monday, 12 November 2018

How to get sales order totals in D365 F&O/ AX 7 x++

Below is the the piece code we can use for getting the sales order totals.

class SW_CST_Tableid2name
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {   
        SalesTotals salesTotals;
        SalesTable salesTable;
        SalesLine salesLine;

        TaxAmountCur salesAmt,taxAmount,amt1,discountAmt,totcharges,totOfOrder,contributionRatio;
        Tax tax;

        ;
        salesTable = SalesTable::find("SO00094903");
        salesLine = SalesLine::find(salesTable.SalesId);
        salesTotals = SalesTotals::construct(salesTable, SalesUpdate::All);
        tax = Tax::construct(NoYes::No);

        salesAmt    = salesTotals.totalBalance();
        taxAmount   = salesTotals.totalTaxAmount();
        discountAmt = salesTotals.totalEndDisc();
        totcharges  = salesTotals.totalMarkup();
        totOfOrder  = salesTotals.totalAmount();
        //contributionRatio   = salesTotals.totalContributionRatio();

        info(Strfmt("Subtotal Amount %1",salesAmt ));
        info(Strfmt("The tax amount is %1",taxAmount ));
        info(Strfmt("The Discount is %1",discountAmt ));
        info(Strfmt("Charges/ Markup %1",totcharges ));
        info(Strfmt("Invoice Amount %1",totOfOrder ));
        info(Strfmt("Contribution ratio %1",contributionRatio ));
    }

}

No comments:

Post a Comment

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...