Code for Tax adjustment in Free text Invoice in MSD axapta

This is a Code for Tax adjustment in Free text Invoice in axapta. You can try this code in job to check the effect of adjustment.

 CustInvoiceTable _custInvoiceTable;   
 CustInvoiceCalcTax custInvoiceCalcTax;   
 TaxFreeInvoice _taxFreeInvoice;   
 TaxRegulation _taxRegulation;   
 ;   
 ttsbegin;   
 select firstonly _custInvoiceTable where _custInvoiceTable.InvoiceId == "test5";   
 custInvoiceCalcTax = new CustInvoiceCalcTax_Table(_custInvoiceTable);   
 _taxFreeInvoice = new TaxFreeInvoice(custInvoiceCalcTax);   
 _taxFreeInvoice.calc();   
 _taxRegulation = TaxRegulation::newTaxRegulation(_taxFreeInvoice);   
 _taxRegulation.allocateAmount(33.47);   
 _taxRegulation.saveTaxRegulation();