Get Sales Order Totals using X++
We can make use of standard class SalesTotals to get the Totals subform related fields data through X++. SalesTotals returns a container with lot of fields in it, Some of them i have listed below.
static void SalesOrderTotal(Args _args)
{
SalesTotals salesTotals;
SalesTable salesTable;
container displayFields;
str totalTax, amountInclTax, amountWithoutTaxTxt;
AmountMST amountWithoutTax;
salesTable = salesTable::find('S000076');
salesTotals = SalesTotals::construct(salesTable, salesUpdate::All);
salesTotals.calc();
displayFields = salesTotals.displayFieldsCurrency(salesTotals.currencyCode());
amountWithoutTaxTxt = conpeek(displayFields, TradeTotals::posBalance());
amountWithoutTax = str2num(amountWithoutTaxTxt);
amountInclTax = conpeek(displayFields, TradeTotals::posTotalAmount());
totalTax = conpeek(displayFields,TradeTotals::posTaxTotal());
}
Comments
Post a Comment