Showing posts with label Tax. Show all posts
Showing posts with label Tax. Show all posts

Saturday, February 26, 2011

X++ code for adjusting tax on journals and free text invoices

 static void ExampleLedgerJournalTaxAdjust(Args _args)  
 {  
   LedgerJOurnalTrans         ledgerJournalTrans;  
   TaxLedgerJournalCalculate  taxLedgerJournalCalculate;  
   TaxLedgerJournal           taxLedgerJournal;  
   TaxRegulation              taxRegulation;  
   ;  
   
   ttsbegin;  
   
   // Find a ledgerJournalTrans record  
   select firstonly LedgerJournalTrans  
   where LedgerJournalTrans.JournalNum == "000185_010";  
   
   
   taxLedgerJournal = TaxLedgerJournal::construct(TaxJournalCall::Journal, ledgerJournalTrans, null);  
   taxRegulation    = new TaxRegulation();  
   taxLedgerJournal.calcAndPost();  
   taxRegulation.setTax(taxLedgerJournal);  
   taxRegulation.createSumsFromTmp();  
   taxRegulation.allocateAmount(6.99);  
   taxRegulation.saveTaxRegulation();  
   
   ttscommit;  
 }  
   
 static void FreeTextTaxAdjust(Args _args)  
 {  
   CustInvoiceTable    custInvoiceTable;  
   CustInvoiceCalcTax  custInvoiceCalcTax;  
   TaxFreeInvoice      taxFreeInvoice;  
   TaxRegulation       taxRegulation;  
   ;  
   
   ttsbegin;  
   
   select firstonly custInvoiceTable  
   where custInvoiceTable.InvoiceId == "Inv135";  
   
   custInvoiceCalcTax = new CustInvoiceCalcTax_Table(custInvoiceTable);  
   taxFreeInvoice     = new TaxFreeInvoice(custInvoiceCalcTax);  
   taxFreeInvoice.calc();  
   taxRegulation = TaxRegulation::newTaxRegulation(taxFreeInvoice);  
   taxRegulation.allocateAmount(35.77);  
   taxRegulation.saveTaxRegulation();  
   
   ttscommit;  
 }