details:   https://code.openbravo.com/erp/devel/pi/rev/b1bad782acb0
changeset: 29988:b1bad782acb0
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Mon Sep 05 00:11:51 2016 +0530
summary:   Fixes issue 33877: Accounting default values not transferred from 
child orgs

While creating default accounting configuration for business partner, schema 
configuration is also checked for child organization if no configurartion 
exists for org or its parent org.

Default accounts will be created retrieving first the accounting schema of 
current organization, then from parent organizations and then from children 
organizations.

For example, in case we have different accounting schemas for F&B 
International, F&B España and F&B España Norte, when creating a business 
partner for each of these organizations the order will be the following:
F&B International: F&B International - F&B España - F&B España Norte
F&B España: F&B España - F&B International - F&B España Norte
F&B España Norte: F&B España Norte - F&B España - F&B International

diffstat:

 src-db/database/model/triggers/C_BPARTNER_TRG.xml |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (50 lines):

diff -r 6c462af756e8 -r b1bad782acb0 
src-db/database/model/triggers/C_BPARTNER_TRG.xml
--- a/src-db/database/model/triggers/C_BPARTNER_TRG.xml Mon Sep 05 12:36:52 
2016 +0200
+++ b/src-db/database/model/triggers/C_BPARTNER_TRG.xml Mon Sep 05 00:11:51 
2016 +0530
@@ -60,7 +60,7 @@
         v_C_AcctSchema_ID:=null;
        FOR Cur_Defaults IN
        (
-               SELECT AD_IsOrgIncluded(:new.AD_Org_ID, a.AD_Org_ID, 
:new.AD_Client_ID),
+               SELECT AD_IsOrgIncluded(:new.AD_Org_ID, a.AD_Org_ID, 
:new.AD_Client_ID), AD_IsOrgIncluded(a.AD_Org_ID, :new.AD_Org_ID, 
:new.AD_Client_ID),
     a.ad_sequence_bp_id, a.isbpnewaccount, a.acct_length, a.subacct_length, 
a.createdby, a.updatedby,  a.C_AcctSchema_ID, 
     d1.ad_client_id, d1.C_Receivable_Acct, d1.C_Prepayment_Acct, 
d1.V_Liability_Acct,  d1.V_Liability_Services_Acct, 
     d1.V_Prepayment_Acct, d1.status, d1.ISACTIVE 
@@ -68,8 +68,12 @@
                WHERE d1.C_BP_Group_ID=:new.C_BP_Group_ID
                AND d1.C_AcctSchema_ID = a.C_AcctSchema_ID
                AND a.ISACTIVE = 'Y'
-               AND AD_IsOrgIncluded(:new.AD_Org_ID, a.AD_Org_ID, 
:new.AD_Client_ID)<>-1
-               ORDER BY 1
+               AND (AD_IsOrgIncluded(:new.AD_Org_ID, a.AD_Org_ID, 
:new.AD_Client_ID) <> -1
+               OR AD_IsOrgIncluded(a.AD_Org_ID, :new.AD_Org_ID, 
:new.AD_Client_ID) <> -1)
+               ORDER BY CASE WHEN AD_IsOrgIncluded(:new.AD_Org_ID, 
a.AD_Org_ID, :new.AD_Client_ID) <> -1
+               THEN AD_IsOrgIncluded(:new.AD_Org_ID, a.AD_Org_ID, 
:new.AD_Client_ID)
+               ELSE AD_IsOrgIncluded(a.AD_Org_ID, :new.AD_Org_ID, 
:new.AD_Client_ID)
+               END
        )
        LOOP
        
@@ -187,15 +191,19 @@
   v_C_AcctSchema_ID:=null;
   v_count:=0;
               FOR Cur_Defaults2 IN (
-              SELECT AD_IsOrgIncluded(:new.AD_Org_ID, oa.AD_Org_ID, 
:new.AD_Client_ID),
+              SELECT AD_IsOrgIncluded(:new.AD_Org_ID, oa.AD_Org_ID, 
:new.AD_Client_ID), AD_IsOrgIncluded(oa.AD_Org_ID, :new.AD_Org_ID, 
:new.AD_Client_ID),
               oa.ad_sequence_bp_id, oa.isbpnewaccount, oa.acct_length, 
oa.subacct_length, oa.createdby, oa.updatedby,
               d2.E_Expense_Acct, d2.E_Prepayment_Acct, d2.AD_Client_ID, 
d2.C_AcctSchema_ID, d2.ISACTIVE
               FROM C_AcctSchema_Default d2, AD_Org_AcctSchema oa 
               WHERE d2.C_AcctSchema_ID = oa.C_AcctSchema_ID
               AND oa.ISACTIVE = 'Y'
               AND oA.AD_Client_ID = d2.AD_Client_ID
-              AND AD_IsOrgIncluded(:new.AD_Org_ID, oa.AD_Org_ID, 
:new.AD_Client_ID)<>-1
-              ORDER BY 1
+              AND (AD_IsOrgIncluded(:new.AD_Org_ID, oa.AD_Org_ID, 
:new.AD_Client_ID) <> -1
+              OR AD_IsOrgIncluded(oa.AD_Org_ID, :new.AD_Org_ID, 
:new.AD_Client_ID) <> -1)
+              ORDER BY CASE WHEN AD_IsOrgIncluded(:new.AD_Org_ID, 
oa.AD_Org_ID, :new.AD_Client_ID) <> -1
+              THEN AD_IsOrgIncluded(:new.AD_Org_ID, oa.AD_Org_ID, 
:new.AD_Client_ID)
+              ELSE AD_IsOrgIncluded(oa.AD_Org_ID, :new.AD_Org_ID, 
:new.AD_Client_ID)
+              END
        ) 
   LOOP
        

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to