Thursday, March 15, 2018

Resetting and Recalculating Tax amount for sales Order in DAX

//Resetting and Recalculating Tax amount for sales Order in DAX

static void San_Reset_RecalculateSalesTaxValue(Args _args)
{
    SalesTable                  salesTable;
    TaxRegulation            taxRegulation;
    SalesTotals                 salesTotals;
    SalesId                        salesId ="";
    ;
    salesTable = SalesTable::find(SalesId);
    if (salesTable)
    {
        salesTotals = SalesTotals::construct(salesTable, SalesUpdate::All);
        salesTotals.calc();
        taxRegulation = TaxRegulation::newTaxRegulation(salesTotals.tax(), null,salestable.TableId, salestable.RecId);
        if (taxRegulation.taxLinesExist())
        {
            taxRegulation.resetTaxRegulation();
            taxRegulation.saveTaxRegulation();
            info("Tax Amount resetted and recalculated for new lines");
        }
    }
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...