Get tax codes for charge line/purchase order line/invoice line

X++ to go through tax codes:

    PurchTotals             purchTotals;
    TaxPurch                taxPurch;
    TmpTaxWorkTrans         tmpTaxWorkTrans;
    VendInvoiceInfoTable    vendInvoiceInfoTable;
    MarkupTrans             markupTrans;

    // Invoice
    purchTotals = PurchTotals::newParmTable(
                vendInvoiceInfoTable,
                PurchUpdate::All,
                AccountOrder::None,
                vendInvoiceInfoTable.ParmId,
                '',
                vendInvoiceInfoTable.Ordering);
    purchTotals.calc();
    taxPurch = purchTotals.tax();

    // PO
    taxPurch = PurchTotals::getTax(purchTable);


  
    taxPurch.showTaxesSourceSingleLine(markupTrans.TableId, markupTrans.RecId, true); // markupTrans could be also PurchLine, VendInvoiceInfoLine
    tmpTaxWorkTrans = taxPurch.tmpTaxWorkTrans();

    while select tmpTaxWorkTrans
            where   tmpTaxWorkTrans.SourceRecId     == markupTrans.RecId
                 && tmpTaxWorkTrans.SourceTableId   == markupTrans.TableId
    {
        info(strFmt("code: %1, amount %2", tmpTaxWorkTrans.TaxCode, tmpTaxWorkTrans.TaxAmount));
    }



 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.

Blog Tags