GST/TAX at sales order and sales line level through X++

GST/TAX at sales order and sales line level through X++

MCP · Azure DevOpsYour delivery board, readable by an agentMCP · DataverseOne consent, and the data layer opensMCP · Dynamics 365 F&OConnecting F&O to an agent Microsoft hasn’t documented
Sales order GST:

Total GST of Sales order can be seen from following screen in AX 2012


X++ code to achieve this;
X++
static void SalesTax_Per_SalesOrder(Args _args)
{
    TaxTmpWorkTransForm     taxTmpWorkTransForm;
    SalesTotals             salesTotals;
    TaxSales                taxSales;
    SalesLine               salesLine;
    container               cont;
    salesTotals = SalesTotals::construct(SalesTable::find("SAOR000770"));
    salesTotals.calc();
    cont         = salesTotals.displayFieldsCurrency(salesTotals.currencyCode());
    info(strFmt("Sales order total GST: %1", conpeek(cont, TradeTotals::posTaxTotal())));
}

X++ code to achieve this;
This code will print GST against each sales line for selected/passed sales order
X++
static void SalesTax_Per_SalesLine(Args _args)
{
    TaxTmpWorkTransForm     taxTmpWorkTransForm;
    SalesTotals             salesTotals;
    TaxSales                taxSales;
    SalesLine               salesLine;
    salesTotals = SalesTotals::construct(SalesTable::find("SAOR000770"));
    salesTotals.calc();
    taxSales = salesTotals.tax();
    taxTmpWorkTransForm = TaxTmpWorkTransForm::construct();
    taxTmpWorkTransForm.parmTaxObject(taxSales);
    While select SalesLine where salesLine.SalesId == 'SAOR000770'
    {
        taxTmpWorkTransForm.updateTaxShowTaxesSourceSingleLine(tableNum(SalesLine), salesLine.RecId, true);
        info(strFmt('%1',taxTmpWorkTransForm.parmTaxAmountCurTotal()));
    }
}
Previous article← How to get Next RecId through X++
Discussion

Ask a question or leave feedback

This is a review interaction. The WordPress version will store, thread and moderate comments.

Thanks — submitted for moderation in this review.
Search the whole site · Ctrl/⌘ + K