Monday, 8 February 2016

How to Calculate total sales order or sales quotation amount / discounts / tax etc., through code in Ax 2012

static void Raj_TotalSalesCalculate(Args _args)
{
    SalesTotals   salesTotals;

    SalesTable   salesTable;
    container   displayFields;
    str    totalTax, amountWithoutTax, amountInclTax,exchrate;

    salesTable = salesTable::find('001271');
    salesTotals  =  SalesTotals::construct(salesTable, salesUpdate::All);
    salesTotals.calc();
    displayFields =  salesTotals.displayFieldsCurrency(salesTotals.currencyCode());

    exchrate         = conPeek(displayFields,TradeTotals::posExchRate());
    amountWithoutTax  = conpeek(displayFields, TradeTotals::posBalance());
    amountInclTax   = conpeek(displayFields, TradeTotals::posTotalAmount());
    totalTax    = conpeek(displayFields,TradeTotals::posTaxTotal());
 
    info(strFmt("%1--%2--%3",amountWithoutTax,amountInclTax,totalTax));

}

Withholding tax for purchase order

display real withholdTax()
{
    PurchTable      purchTable;
    PurchTotals     _purchTotals;
   
   
    purchTable  = PurchTable::findRecId(callingTable.RecId);
    _purchTotals = PurchTotals::newPurchTable(purchTable);
    _purchTotals.calc();
    return  _purchTotals.taxWithhold_IN().taxAmountCurTotal();
 

}

No comments:

Post a Comment