details:   https://code.openbravo.com/erp/devel/pi/rev/e5fb94b24cfc
changeset: 30287:e5fb94b24cfc
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Wed Sep 14 15:36:20 2016 +0530
summary:   Fixes issue 33859: Wrong Total Gross Amount in orders and invoices

Wrong Total Gross Amount in orders and invoices as the changes made in tax tab 
records do not recalculate it.

For Purchase Order and Sales Order, Tax tab is made read only so only record 
are created, modified and deleted only through order lines.
Manual insertion, updation and deletion is not possible.

In case of Sales Invoice and Purchase Invoices, records created by invoice line 
are marked with recalculate flag = Yes.
Read Only logic based on this flag does not allow user to modify fields tax, 
tax amount and taxable amount of invoice tax records.
Event handler restricts user to delete invoice tax records with recalculate 
flag = Yes.
To avoid event handlers interference with 
ReorderCascadingChildDeletionsHandler.java, on Invoice deletetion, before 
deleting invoice tax records, flag recalculate is set = No

details:   https://code.openbravo.com/erp/devel/pi/rev/df9155c88ab2
changeset: 30288:df9155c88ab2
user:      David Miguelez <david.miguelez <at> openbravo.com>
date:      Thu Sep 08 16:36:16 2016 +0200
summary:   Fixes Issue 24191. Improves performance for Accounting Background 
Process.

Adds Index in FIN_FINACC_TRANSACTION Table.
Modifies query in AcctServer_data to properly limit the results returned.
Modifies query in AcctServer_data to remove the order clause.
Persist information about Accounting Schemas in Java code so it is no longer
necessary to access the Database everytime to retrive that information.

details:   https://code.openbravo.com/erp/devel/pi/rev/682415bc0aa9
changeset: 30289:682415bc0aa9
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Sep 13 18:24:02 2016 +0200
summary:   Related to issue 24191: Code review improvements

- Move AcctSchemaStructureProvider.java to same folder as 
OrganizationStructureProvider.java.
- Rename acctSchemaSP variable to acctSchemaProvider in OBContext.java.
- Remove unused data variable in AcctSchema.java.
- Add commentary to explain why we send limit manually to xsql query in 
AcctServer.java.
- Do not send numberRegisters parameter to AcctServerData.select as we are 
already sending the limit.
- Undo changes in AcctServerData.periodOpen method and create new 
AcctServerData.selectPeriodOpen method to avoid a functional API change.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/ReorderCascadingChildDeletionsHandler.java
 |   4 +-
 src-db/database/model/tables/FIN_FINACC_TRANSACTION.xml                        
                                                |   3 +
 src-db/database/sourcedata/AD_COLUMN.xml                                       
                                                |   6 +-
 src-db/database/sourcedata/AD_MESSAGE.xml                                      
                                                |  12 +
 src-db/database/sourcedata/AD_TAB.xml                                          
                                                |   4 +-
 src/org/openbravo/dal/core/OBContext.java                                      
                                                |  21 ++
 src/org/openbravo/dal/security/AcctSchemaStructureProvider.java                
                                                |  75 ++++++++++
 src/org/openbravo/erpCommon/ad_forms/AcctSchema.java                           
                                                |  15 +-
 src/org/openbravo/erpCommon/ad_forms/AcctServer.java                           
                                                |  17 +-
 src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql                      
                                                |  30 +++-
 src/org/openbravo/event/InvoiceTaxEventHandler.java                            
                                                |  51 ++++++
 11 files changed, 215 insertions(+), 23 deletions(-)

diffs (truncated from 439 to 300 lines):

diff -r df28f074cc4a -r 682415bc0aa9 
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/ReorderCascadingChildDeletionsHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/ReorderCascadingChildDeletionsHandler.java
    Thu Sep 15 16:56:55 2016 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/ReorderCascadingChildDeletionsHandler.java
    Tue Sep 13 18:24:02 2016 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2011 Openbravo SLU 
+ * All portions are Copyright (C) 2011-2016 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -80,6 +80,8 @@
       otc.add(Restrictions.eq(InvoiceTax.PROPERTY_INVOICE, 
event.getTargetInstance()));
       List<InvoiceTax> otList = otc.list();
       for (InvoiceTax ot : otList) {
+        // Before delete InvoiceTax set recalculate=N to avoid raise error in 
InvoiceTaxEventHandler
+        ot.setRecalculate(false);
         OBDal.getInstance().remove(ot);
       }
     }
diff -r df28f074cc4a -r 682415bc0aa9 
src-db/database/model/tables/FIN_FINACC_TRANSACTION.xml
--- a/src-db/database/model/tables/FIN_FINACC_TRANSACTION.xml   Thu Sep 15 
16:56:55 2016 +0200
+++ b/src-db/database/model/tables/FIN_FINACC_TRANSACTION.xml   Tue Sep 13 
18:24:02 2016 +0200
@@ -212,6 +212,9 @@
       <index name="FIN_FINACC_TRANSACTION_POSTED" unique="false">
         <index-column name="POSTED"/>
       </index>
+      <index name="FIN_FINACC_TRX_RECONCILIATION" unique="false">
+        <index-column name="FIN_RECONCILIATION_ID"/>
+      </index>
       <unique name="FIN_FINACC_TRANSACTION_UN">
         <unique-column name="FIN_PAYMENT_ID"/>
       </unique>
diff -r df28f074cc4a -r 682415bc0aa9 src-db/database/sourcedata/AD_COLUMN.xml
--- a/src-db/database/sourcedata/AD_COLUMN.xml  Thu Sep 15 16:56:55 2016 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml  Tue Sep 13 18:24:02 2016 +0200
@@ -68457,7 +68457,7 @@
 <!--3850-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--3850-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
 <!--3850-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
-<!--3850-->  <READONLYLOGIC><![CDATA[@Processed@='Y']]></READONLYLOGIC>
+<!--3850-->  <READONLYLOGIC><![CDATA[@Processed@='Y' | 
@Recalculate@='Y']]></READONLYLOGIC>
 <!--3850-->  <ISIDENTIFIER><![CDATA[Y]]></ISIDENTIFIER>
 <!--3850-->  <SEQNO><![CDATA[2]]></SEQNO>
 <!--3850-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
@@ -68800,7 +68800,7 @@
 <!--3859-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--3859-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
 <!--3859-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
-<!--3859-->  <READONLYLOGIC><![CDATA[@Processed@='Y']]></READONLYLOGIC>
+<!--3859-->  <READONLYLOGIC><![CDATA[@Processed@='Y' | 
@Recalculate@='Y']]></READONLYLOGIC>
 <!--3859-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
 <!--3859-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--3859-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -68839,7 +68839,7 @@
 <!--3860-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--3860-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
 <!--3860-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
-<!--3860-->  <READONLYLOGIC><![CDATA[@Processed@='Y']]></READONLYLOGIC>
+<!--3860-->  <READONLYLOGIC><![CDATA[@Processed@='Y' | 
@Recalculate@='Y']]></READONLYLOGIC>
 <!--3860-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
 <!--3860-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--3860-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
diff -r df28f074cc4a -r 682415bc0aa9 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Thu Sep 15 16:56:55 2016 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Tue Sep 13 18:24:02 2016 +0200
@@ -19225,6 +19225,18 @@
 <!--459ADF41A2F748B2AFC916760C046C28-->  
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--459ADF41A2F748B2AFC916760C046C28--></AD_MESSAGE>
 
+<!--45B3380FBF8A4F81AB0F9729FF599292--><AD_MESSAGE>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  
<AD_MESSAGE_ID><![CDATA[45B3380FBF8A4F81AB0F9729FF599292]]></AD_MESSAGE_ID>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  
<VALUE><![CDATA[CannotDeleteInvoiceTax]]></VALUE>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  <MSGTEXT><![CDATA[It is not possible 
to delete an invoice tax record with recalculate flag checked.]]></MSGTEXT>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--45B3380FBF8A4F81AB0F9729FF599292-->  
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--45B3380FBF8A4F81AB0F9729FF599292--></AD_MESSAGE>
+
 <!--45FB8C27317D441CAFD96F2EE0005EA1--><AD_MESSAGE>
 <!--45FB8C27317D441CAFD96F2EE0005EA1-->  
<AD_MESSAGE_ID><![CDATA[45FB8C27317D441CAFD96F2EE0005EA1]]></AD_MESSAGE_ID>
 <!--45FB8C27317D441CAFD96F2EE0005EA1-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r df28f074cc4a -r 682415bc0aa9 src-db/database/sourcedata/AD_TAB.xml
--- a/src-db/database/sourcedata/AD_TAB.xml     Thu Sep 15 16:56:55 2016 +0200
+++ b/src-db/database/sourcedata/AD_TAB.xml     Tue Sep 13 18:24:02 2016 +0200
@@ -2927,7 +2927,7 @@
 <!--236-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--236-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--236-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--236-->  <UIPATTERN><![CDATA[STD]]></UIPATTERN>
+<!--236-->  <UIPATTERN><![CDATA[RO]]></UIPATTERN>
 <!--236-->  <HQLORDERBYCLAUSE><![CDATA[lineNo]]></HQLORDERBYCLAUSE>
 <!--236-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--236-->  
<DISABLE_PARENT_KEY_PROPERTY><![CDATA[N]]></DISABLE_PARENT_KEY_PROPERTY>
@@ -3887,7 +3887,7 @@
 <!--295-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--295-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--295-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--295-->  <UIPATTERN><![CDATA[STD]]></UIPATTERN>
+<!--295-->  <UIPATTERN><![CDATA[RO]]></UIPATTERN>
 <!--295-->  <HQLORDERBYCLAUSE><![CDATA[lineNo]]></HQLORDERBYCLAUSE>
 <!--295-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--295-->  
<DISABLE_PARENT_KEY_PROPERTY><![CDATA[N]]></DISABLE_PARENT_KEY_PROPERTY>
diff -r df28f074cc4a -r 682415bc0aa9 src/org/openbravo/dal/core/OBContext.java
--- a/src/org/openbravo/dal/core/OBContext.java Thu Sep 15 16:56:55 2016 +0200
+++ b/src/org/openbravo/dal/core/OBContext.java Tue Sep 13 18:24:02 2016 +0200
@@ -43,6 +43,7 @@
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.util.Check;
+import org.openbravo.dal.security.AcctSchemaStructureProvider;
 import org.openbravo.dal.security.EntityAccessChecker;
 import org.openbravo.dal.security.OrganizationStructureProvider;
 import org.openbravo.dal.service.OBDal;
@@ -552,6 +553,7 @@
   private Set<String> writableOrganizations;
   private String userLevel;
   private Map<String, OrganizationStructureProvider> 
organizationStructureProviderByClient;
+  private Map<String, AcctSchemaStructureProvider> 
acctSchemaStructureProviderByClient;
   private EntityAccessChecker entityAccessChecker;
 
   // the "0" user is the administrator
@@ -778,6 +780,7 @@
     writableOrganizations = null;
     userLevel = null;
     organizationStructureProviderByClient = null;
+    acctSchemaStructureProviderByClient = null;
     entityAccessChecker = null;
 
     isAdministrator = false;
@@ -841,6 +844,7 @@
       }
 
       organizationStructureProviderByClient = new HashMap<String, 
OrganizationStructureProvider>();
+      acctSchemaStructureProviderByClient = new HashMap<String, 
AcctSchemaStructureProvider>();
 
       // first take the passed role, if any
       // now check if the default role is active, if not another one needs
@@ -1058,6 +1062,23 @@
     return orgProvider;
   }
 
+  public AcctSchemaStructureProvider getAcctSchemaStructureProvider() {
+    return getAcctSchemaStructureProvider(getCurrentClient().getId());
+  }
+
+  public AcctSchemaStructureProvider getAcctSchemaStructureProvider(String 
clientId) {
+    AcctSchemaStructureProvider acctSchemaProvider = 
acctSchemaStructureProviderByClient
+        .get(clientId);
+
+    // create one
+    if (acctSchemaProvider == null) {
+      acctSchemaProvider = 
OBProvider.getInstance().get(AcctSchemaStructureProvider.class);
+      acctSchemaProvider.setClientId(clientId);
+      acctSchemaStructureProviderByClient.put(clientId, acctSchemaProvider);
+    }
+    return acctSchemaProvider;
+  }
+
   public String[] getReadableOrganizations() {
     if (readableOrganizations == null) {
       setReadableOrganizations(getRole());
diff -r df28f074cc4a -r 682415bc0aa9 
src/org/openbravo/dal/security/AcctSchemaStructureProvider.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/dal/security/AcctSchemaStructureProvider.java   Tue Sep 
13 18:24:02 2016 +0200
@@ -0,0 +1,75 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2016 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.dal.security;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.Query;
+import org.openbravo.base.provider.OBNotSingleton;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+
+public class AcctSchemaStructureProvider implements OBNotSingleton {
+
+  private Map<String, List<String>> acctSchemaByOrg = new HashMap<String, 
List<String>>();
+  private String clientId;
+
+  public String getClientId() {
+    return clientId;
+  }
+
+  public void setClientId(String clientId) {
+    this.clientId = clientId;
+  }
+
+  public List<String> getAcctSchemas(String orgID, String clientID) {
+    if (acctSchemaByOrg.containsKey(orgID)) {
+      return acctSchemaByOrg.get(orgID);
+    } else {
+      initialize(orgID, clientID);
+      return getAcctSchemas(orgID, clientID);
+    }
+  }
+
+  private synchronized void initialize(String orgId, String clientID) {
+    if (getClientId() == null) {
+      setClientId(OBContext.getOBContext().getCurrentClient().getId());
+    }
+    acctSchemaByOrg.put(orgId, getAcctSchemasFromDB(orgId, clientID));
+  }
+
+  @SuppressWarnings("unchecked")
+  private ArrayList<String> getAcctSchemasFromDB(String orgId, String 
clientID) {
+    String where = " select a.id"
+        + " from OrganizationAcctSchema as oas"
+        + " join oas.accountingSchema as a"
+        + " where oas.client.id = :clientId"
+        + " and (ad_isorgincluded(:orgId, oas.organization.id, oas.client.id) 
<> -1 or :orgId = '0')"
+        + " and a.active = true" + " and oas.active = true" + " group by a.id";
+
+    final Query qry = OBDal.getInstance().getSession().createQuery(where);
+    qry.setParameter("clientId", clientID);
+    qry.setParameter("orgId", orgId);
+    return (ArrayList<String>) qry.list();
+  }
+}
diff -r df28f074cc4a -r 682415bc0aa9 
src/org/openbravo/erpCommon/ad_forms/AcctSchema.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctSchema.java      Thu Sep 15 
16:56:55 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctSchema.java      Tue Sep 13 
18:24:02 2016 +0200
@@ -11,7 +11,7 @@
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
  * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
  * Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2010 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -22,6 +22,7 @@
 import javax.servlet.ServletException;
 
 import org.apache.log4j.Logger;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.database.ConnectionProvider;
 
 public final class AcctSchema implements Serializable {
@@ -240,15 +241,9 @@
       String AD_Client_ID, String AD_Org_ID) {
     // Create New
     ArrayList<Object> list = new ArrayList<Object>();
-    AcctSchemaData[] data = null;
-    try {
-      data = AcctSchemaData.selectAcctSchemas(conn, AD_Client_ID, AD_Org_ID);
-      for (int i = 0; data.length > i; i++) {
-        String as = data[i].cAcctschemaId;
-        list.add(new AcctSchema(conn, as));
-      }
-    } catch (ServletException e) {
-      log4jAcctSchema.warn(e);
+    for (String as : OBContext.getOBContext().getAcctSchemaStructureProvider()
+        .getAcctSchemas(AD_Org_ID, AD_Client_ID)) {
+      list.add(new AcctSchema(conn, as));
     }
     // Save
     return list;
diff -r df28f074cc4a -r 682415bc0aa9 
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Thu Sep 15 
16:56:55 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Tue Sep 13 
18:24:02 2016 +0200
@@ -66,6 +66,7 @@
 import org.openbravo.model.common.currency.ConversionRateDoc;
 import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.AcctSchemaTableDocType;
+import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.model.common.invoice.ReversedInvoice;
 import 
org.openbravo.model.financialmgmt.accounting.FIN_FinancialAccountAccounting;
@@ -399,8 +400,11 @@
       final Set<String> orgSet = OBContext.getOBContext()
           
.getOrganizationStructureProvider(AD_Client_ID).getChildTree(AD_Org_ID, true);
       String strOrgs = Utility.getInStrSet(orgSet);
+      // Send limit manually to SQL because auto-generated query doesn't limit 
properly

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

Reply via email to