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;  
 }  

4 comments:

  1. Hi Tony

    Can this code be used to change the posted tax value of some free text inoices I have imported and posted into a client site with an incorrect tax code? Does it actually post he revised GST into the Tax ledger accounts?

    Thanks

    Steve

    ReplyDelete
  2. Hi Sirs.

    Thank this work perfect adjusting o Ledger Journals (I tested in X++),
    But what do we do ... if we want to change the values only on the TaxTrans table (the amounts), Just like can be changed on Purchase Orders, and is represented in the corresponding invoice,
    Hoy can I change the Tax Amounts not to the TAX GROUPS in the JOURNALS, I need to do it in the TAXTRANS table for each amount by the TAXCODE. (this can be do it in the purchase order)

    Thanks
    If you hve the answer

    Genaro Gambino

    ReplyDelete
  3. I will recommend anyone looking for Business loan to Le_Meridian they helped me with Four Million USD loan to startup my Quilting business and it's was fast When obtaining a loan from them it was surprising at how easy they were to work with. They can finance up to the amount of $500,000.000.00 (Five Hundred Million Dollars) in any region of the world as long as there 1.9% ROI can be guaranteed on the projects.The process was fast and secure. It was definitely a positive experience.Avoid scammers on here and contact Le_Meridian Funding Service On. lfdsloans@lemeridianfds.com / lfdsloans@outlook.com. WhatsApp...+ 19893943740. if you looking for business loan.

    ReplyDelete