Adding WhereClause for GL_Distribution

Description

GL Distribution is a powerful feature. It can replace some elements of FactLine to another if certain conditions are satisfied. This set of condition is limited by account elements (Org, Account, Activity, Campaign...).
There are situations in our accounting when it is necessary to extend the conditions from the primary document or further.
__________________

I want to offer a solution that extends the functionality of GL_Distribution.
1. Create column "WhereClause" in table GL_Distribution.
2. Here we can write any SQL-code, which must return TRUE or FALSE.
3. If SQL code return TRUE, then this GL_Distribution is get, else - discarded.
4. In WhereClause we can use special variables indicated by $$, for example $Record_ID$. This special variables will be replaced by the corresponding values from current FactLine. For example $AD_Table_ID$ will by replaced by 318 when Invoice is posting.

We need modify some class:
1) MDistribution - add new methods
public static MDistribution[] get
public static MDistribution[] get
(see attached file)

2) Fact.java in method public boolean distribute() replace calls old method
MDistribution[] distributions = MDistribution.get (dLine.getAccount(),
m_postingType, m_doc.getC_DocType_ID());

for

MDistribution[] distributions = MDistribution.get (dLine.getAccount(),
m_postingType, m_doc.getC_DocType_ID(), dLine);

and replace old method
distributions = MDistribution.get (dLine.getCtx(), dLine.getC_AcctSchema_ID(),
m_postingType, m_doc.getC_DocType_ID(),
dLine.getAD_Org_ID(), dLine.getAccount_ID(),
dLine.getM_Product_ID(), dLine.getC_BPartner_ID(), dLine.getC_Project_ID(),
dLine.getC_Campaign_ID(), dLine.getC_Activity_ID(), dLine.getAD_OrgTrx_ID(),
dLine.getC_SalesRegion_ID(), dLine.getC_LocTo_ID(), dLine.getC_LocFrom_ID(),
dLine.getUser1_ID(), dLine.getUser2_ID());

for

distributions = MDistribution.get (dLine.getCtx(), dLine.getC_AcctSchema_ID(),
m_postingType, m_doc.getC_DocType_ID(),
dLine.getAD_Org_ID(), dLine.getAccount_ID(),
dLine.getM_Product_ID(), dLine.getC_BPartner_ID(), dLine.getC_Project_ID(),
dLine.getC_Campaign_ID(), dLine.getC_Activity_ID(), dLine.getAD_OrgTrx_ID(),
dLine.getC_SalesRegion_ID(), dLine.getC_LocTo_ID(), dLine.getC_LocFrom_ID(),
dLine.getUser1_ID(), dLine.getUser2_ID(), dLine);

Environment

None

Attachments

2
  • 15 Apr 2017, 04:51 PM
  • 15 Apr 2017, 04:51 PM

Activity

Show:

Carlos Ruiz May 9, 2020 at 6:44 PM

Carlos Ruiz April 18, 2017 at 11:46 AM

Thanks ,

I would suggest to implement that in the iDempiere way using @ like context variables, and then using the Env.parseVariable methods passing the MFactAcct as the PO parameter.

Regards,

Carlos Ruiz

Duplicate

Details

Assignee

Reporter

Components

Affects versions

Priority

Created April 15, 2017 at 5:15 PM
Updated July 1, 2020 at 7:52 PM
Resolved May 9, 2020 at 6:44 PM