Guys sorry for the delay. This is used in Ax 2009.
void GSTItem_TaxCalculation()
{
TmpTaxDocument tmpTax;
PurchCalcTax PurchCalcTax;
SalesTotals salesTotals;
PurchTotals purchTotals;
ITaxableDocument taxableDocument;
ITaxDocumentComponentLineEnumerator lineEnumerator;
ITaxDocument taxDocumentObject;
real taxTotalGTE,taxtotal,SGST,CGST,IGST;
ITaxDocumentMeasure taxMeasure;
ITaxDocumentMeasureEnumerator taxMeasureEnumerator;
ITaxDocumentMeasureValue partyTaxMeasureValue;
int j,Line_loop;
;
// SGST_Value = 0; CGST_Value = 0; IGST_Value = 0;
purchTotals = PurchTotals::POconstruct(PurchTable::find(vendPurchOrderJour.PurchId));
taxableDocument = TaxableDocumentObject::construct(purchTotals.parmTaxableDocumentDescriptor());
taxDocumentObject = TaxBusinessService::calculateTax(taxableDocument);
if (taxDocumentObject)
{
taxTotalGTE = taxDocumentObject.getTotalTax().amountTransactionCurrency();
// Calculation of Tax amount for Tax type GST and Tax component SGST
Line_Loop = 0;
lineEnumerator = taxDocumentObject.componentLines(“GST”,“SGST”);
while (lineEnumerator.moveNext())
{
Line_Loop++;
taxMeasureEnumerator = lineEnumerator.current().measures();
while (taxMeasureEnumerator.moveNext())
{
j++;
if (j == 3)
{
partyTaxMeasureValue = taxMeasureEnumerator.current().value();
SGST_Arr[Line_Loop] = partyTaxMeasureValue.amountTransactionCurrency();
j=0;
break;
}
}
}
// Calculation of Tax amount for Tax type GST and Tax component CGST
Line_Loop = 0;
lineEnumerator = taxDocumentObject.componentLines(“GST”,“CGST”);
while (lineEnumerator.moveNext())
{
Line_Loop++;
taxMeasureEnumerator = lineEnumerator.current().measures();
while (taxMeasureEnumerator.moveNext())
{
j++;
if (j == 3)
{
partyTaxMeasureValue = taxMeasureEnumerator.current().value();
CGST_Arr[Line_Loop] = partyTaxMeasureValue.amountTransactionCurrency();
j=0;
break;
}
}
}
// Calculation of Tax amount for Tax type GST and Tax component IGST
Line_Loop = 0;
lineEnumerator = taxDocumentObject.componentLines(“GST”,“IGST”);
while (lineEnumerator.moveNext())
{
Line_Loop++;
taxMeasureEnumerator = lineEnumerator.current().measures();
while (taxMeasureEnumerator.moveNext())
{
j++;
if (j == 3)
{
partyTaxMeasureValue = taxMeasureEnumerator.current().value();
IGST_Arr[Line_Loop] = partyTaxMeasureValue.amountTransactionCurrency();
j=0;
break;
}
}
}
}
}
Array has to be declare in the classdeclaration itself.
You have to create the below method in the PurchTotals class.
static PurchTotals POconstruct(Common _purchTable,
PurchUpdate _specQty = PurchUpdate::All,
AccountOrder _sumBy = AccountOrder::None,
ParmId _parmId = ‘’,
PurchId _sumPurchId = ‘’,
DocumentStatus _documentStatus = DocumentStatus::None)
{
PurchTable purchTable;
;
if (_purchTable.TableId)
{
if (_purchTable.TableId == tablenum(PurchParmTable))
{
purchTable = _purchTable.purchTable();
}
else
{
purchTable = _purchTable;
}
if (_parmId == ‘’)
return new PurchTotals_Trans(_purchTable, _specQty);
}
Else
{
return null;
}
}