Deferred Tax
From ADempiere
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
Contents
Background
(This is a stub. Please help expand it)
- The Thailand Usability project uses Deferred Tax in VAT when the Invoice for services is completed.
- Then during Payment process of that Invoice, its Accounting transfers that to Tax_Due or Tax_Credit.
- This is a good case for using a ModelValidator and the result is a MyValidatorThailand.
- Some pretty good validators to learn from are LCO_Validator and creating new Tax via a Script ModelValidator.
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()
- MODEL: FACT_ACCT
- CODE INTERCEPTION 1: fact.creatline(..,..,..,..,..);
TODO
- First I try to create my own Model Validator so that I can debug it to make it work correctly.
- 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.
BEFORE_POST SNIP
- Again, I can find a sample to do this in LCO_Validator:
- 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!: