Deferred Tax

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
  • This is a technical, step-by-step newbie/oldie attempt at extending ADempiere for usability. Another deep-end tutorial from red1


(This is a stub. Please help expand it)

Business Logic

  • What i intend to do is to write a ModelValidator that uses AOP (aspect oriented programming) principle in intercepting Invoice BEFORE POST to change the facts to Tax_Liability and then during Payment BEFORE POST to transfer the Facts to TAX_DUE
  • There can be logic in the ModelValidator to ensure that the Invoice is for Services product and is qualified for VAT. The Payment part's logic handles to make sure its transfering the right fact in the accounts.

Technical Logic

  • OCCURENCE 1: Doc_Invoice.FactsCreate()
  • OCCURENCE 2: Doc_Payment.FactsCreate()
  • CODE INTERCEPTION 1: fact.creatline(..,..,..,..,..);


  1. First I try to create my own Model Validator so that I can debug it to make it work correctly.
  2. Then I shall transfer it to a Script ModelValidator so that I can easily teleport it anywhere I want without harming the ozone layer.

Using MyValidator

  • Now, to do the first TODO, I do it by good old copy/paste from MyValidator
  • Then I introduce my stub for a BEFORE_POST, putting a break there to POC up to that point.



  • So I will try it under the DocValidate implementation, as:
if (po.get_TableName().equals(MInvoice.Table_Name) && timing == TIMING_BEFORE_POST) {
  // check other stuff such as the Product is Service and has right VAT Tax ID
  // get to the Fact and change it.
  • Finally i worked out a POC method to exchange the Tax_Credit/Tax_Due with Tax_Liability:


  • In order to get to this proof that it works!:


See Also