
Hi Experts,
I'm trying to put sales tax on PO header in AX2009 using below code
//for header
void createPOHeaderSalesTax(PurchTable _purchTable)
{
TmpTaxWorkTrans tmpTax;
PurchTable purchTable;
PurchTotals purchTotalsSet;
TaxRegulation taxRegulation;
TmpTaxRegulation tmpTaxRegulation;
;
ttsbegin;
purchTable = PurchTable::find( 'XYZ');
purchTotalsSet = PurchTotals::newPurchTable(purchTable);
purchTotalsSet.calc();
taxRegulation = TaxRegulation::newTaxRegulation(purchTotalsSet.tax(), null);
tmpTaxRegulation = taxRegulation.tmpTaxRegulation();
while select tmpTaxRegulation
where tmpTaxRegulation.TaxCode == CustomTable.TaxCode
{
tmpTaxRegulation.SourceRegulateAmountCur = 2;
tmpTaxRegulation.update();
}
taxRegulation.saveTaxRegulation();
ttscommit;
}
and for lines
//for line
void createPOLinesSalesTax(PurchLine _purchLine, POLinesTaxIntegrationLog poLinesSalesTaxLog)
{
PurchTotals purchTotalsSet;
TaxRegulation taxRegulation;
TmpTaxWorkTrans tmpTaxWorkTrans;
TmpTaxRegulation tmpTaxRegulation;
PurchTable purchTable;
TaxAmountCur taxAmountCur;
;
purchTable = PurchTable::find('XYZ');
ttsbegin;
purchTotalsSet = PurchTotals::newPurchTable(purchTable);
purchTotalsSet.calc();
purchTotalsSet.tax().sourceSingleLine(true, true);
taxAmountCur = purchTotalsSet.tax().totalTaxAmountSingleLine(_purchLine.TableId, _purchLine.RecId, true);
taxRegulation = TaxRegulation::newTaxRegulation(purchTotalsSet.tax(), null);
tmpTaxRegulation = taxRegulation.tmpTaxRegulation();
while select tmpTaxRegulation
where tmpTaxRegulation.TaxCode == poLinesSalesTaxLog.TaxCode
{
tmpTaxRegulation.SourceRegulateAmountCur = taxAmountCur;
tmpTaxRegulation.update();
}
taxRegulation.saveTaxRegulation();
ttscommit;
Issue is that above code sets value in Adjusted amount, but I want tax value on sales tax amount column in below screen.
I tried to update value in tmpTaxRegulation.SourceTaxAmountCur column but it throws error. cannot edit a record in Tax Trans (TmpTaxTrans). The record has never been selected.
Kinldy help me to sort it out..