details:   https://code.openbravo.com/erp/devel/main/rev/d465a61fc647
changeset: 25126:d465a61fc647
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Mon Nov 24 20:20:57 2014 +0530
summary:   Fixes Issues 27820:Error when posting 
Payment/Transaction/Reconciliation
referencing a cash vat invoice linked to several orders

Issue is a regression due to related fix for issue 26571. Cast Vat lines
were posted as many times the no. of orders linked with cash vat invoices.
So now posting is based on the payment details so the relevant cash vat line
associated with it is posted though it is looped as many times as the no. of
orders linked.

details:   https://code.openbravo.com/erp/devel/main/rev/5361662343f4
changeset: 25127:5361662343f4
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Tue Nov 25 11:51:55 2014 +0100
summary:   Related with issue 28242: Delete preference along with window 
personalization

When a grid view is saved and set as default two records are added:
- One to the OBUIAPP_UIPersonalization with the description of the view
- One to the Preference table, using the OBUIAPP_DefaultSavedView property, 
whose value is the ID of the record added to the OBUIAPP_UIPersonalization table

The problem of this issue was that when the a default saved view was removed 
from the OBUIAPP_UIPersonalization table, its corresponding entry from the 
Preference table was not removed. This resulted in not making the initial 
request to load the grid because it was detected that the view had a default 
saved view (using the preference), and not doing it after loading the window 
personalization because the view description was removed from 
OBUIAPP_UIPersonalization.

The first step of the issue, included in this changeset, removes the Preference 
associated with a default saved view when it is deleted from 
OBUIAPP_UIPersonalization. This prevents the data from being inconsistent. The 
second and final step will consist in loading the grid even when the data is 
inconsistent, to fix the cases where the data is already inconsistent.

details:   https://code.openbravo.com/erp/devel/main/rev/58de83084d74
changeset: 25128:58de83084d74
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Tue Nov 25 12:08:01 2014 +0100
summary:   Fixed issue 28242: Load grid even with inconsistent default view info

Before the previous changeset was applied, it was possible to have a preference 
that specified that a certain grid had a default saved view, but that the 
referenced default saved view did not actually exists. When this happened the 
grid was not loaded until the user pressed the Refresh button.

To fix this, now the inconsistent default view info is detected and the grid is 
loaded once it is detected that the default view does not actually exists.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/WindowPersonalizationEventHandler.java
 |  55 +++++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
                  |   2 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
                |  11 +-
 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java              
                                            |   2 +-
 src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java                        
                                            |   2 +-
 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java                 
                                            |   2 +-
 
src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java
                             |  11 +-
 7 files changed, 73 insertions(+), 12 deletions(-)

diffs (202 lines):

diff -r 547ca19bda33 -r 58de83084d74 
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/WindowPersonalizationEventHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/WindowPersonalizationEventHandler.java
        Fri Dec 05 06:56:57 2014 +0000
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/WindowPersonalizationEventHandler.java
        Tue Nov 25 12:08:01 2014 +0100
@@ -19,18 +19,25 @@
 
 package org.openbravo.client.application.event;
 
+import java.util.List;
+
 import javax.enterprise.event.Observes;
 
 import org.apache.log4j.Logger;
+import org.hibernate.criterion.Restrictions;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.client.application.UIPersonalization;
+import org.openbravo.client.kernel.event.EntityDeleteEvent;
 import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
 import org.openbravo.client.kernel.event.EntityUpdateEvent;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.domain.Preference;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.Window;
 import org.openbravo.service.db.DalConnectionProvider;
@@ -46,8 +53,7 @@
     return entities;
   }
 
-  public void onUpdate(@Observes
-  EntityUpdateEvent event) {
+  public void onUpdate(@Observes EntityUpdateEvent event) {
     if (!isValidEvent(event)) {
       return;
     }
@@ -66,4 +72,49 @@
       throw new OBException(Utility.messageBD(conn, 
"OBUIAPP_TabFieldMandatory", language));
     }
   }
+
+  public void onDelete(@Observes EntityDeleteEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    final UIPersonalization uiPersonalization = (UIPersonalization) 
event.getTargetInstance();
+    deleteDefaultViewPreferences(uiPersonalization);
+  }
+
+  /**
+   * Given an UIPersonalization, deletes the OBUIAPP_DefaultSavedView 
preferences that reference it
+   */
+  private void deleteDefaultViewPreferences(UIPersonalization 
uiPersonalization) {
+    try {
+      List<Preference> preferenceList = this
+          .getDefaultViewPreferencesForUiPersonalization(uiPersonalization);
+      // don't do a client access check, the preference to delete might belong 
to another client
+      // (i.e. System)
+      OBContext.setAdminMode(false);
+      for (Preference preference : preferenceList) {
+        OBDal.getInstance().remove(preference);
+      }
+    } catch (Exception e) {
+      logger.error("Error while deleting a default view preference", e);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  /**
+   * Given an UIPersonalization, returns the list of OBUIAPP_DefaultSavedView 
preferences that
+   * reference it
+   */
+  private List<Preference> getDefaultViewPreferencesForUiPersonalization(
+      UIPersonalization uiPersonalization) {
+    OBCriteria<Preference> preferenceCriteria = OBDal.getInstance()
+        .createCriteria(Preference.class);
+    // filter out the preferences that do not store the default view
+    preferenceCriteria.add(Restrictions
+        .eq(Preference.PROPERTY_PROPERTY, "OBUIAPP_DefaultSavedView"));
+    // filter out the preferences whose default view is not the one being 
deleted
+    preferenceCriteria
+        .add(Restrictions.eq(Preference.PROPERTY_SEARCHKEY, 
uiPersonalization.getId()));
+    return preferenceCriteria.list();
+  }
 }
diff -r 547ca19bda33 -r 58de83084d74 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Fri Dec 05 06:56:57 2014 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Tue Nov 25 12:08:01 2014 +0100
@@ -369,6 +369,8 @@
       if (!lazyFiltering) {
         if (!this.standardWindow.checkIfDefaultSavedView()) {
           this.viewGrid.fetchData(this.viewGrid.getCriteria());
+        } else {
+          this.dataLoadDelayedForDefaultSavedView = true;
         }
       }
       this.refreshContents = false;
diff -r 547ca19bda33 -r 58de83084d74 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
       Fri Dec 05 06:56:57 2014 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
       Tue Nov 25 12:08:01 2014 +0100
@@ -548,8 +548,8 @@
 
     // find the default view, the personalizations are
     // returned in order of prio, then do sort by name
-    if (this.getClass().personalization.views) {
-      views = this.getClass().personalization.views;
+    views = this.getClass().personalization.views;
+    if (views && isc.isA.Array(views) && views.length > 0) {
       length = views.length;
 
       this.getClass().personalization.views.sort(function (v1, v2) {
@@ -598,6 +598,13 @@
           }
         }
       }
+    } else {
+      if (this.view.dataLoadDelayedForDefaultSavedView) {
+        // it might happen that the load of the initial grid data was delayed 
because it had a 
+        // default saved view, but then the default saved view is not returned 
by the WindowSettingsActionHandler.
+        // in that case, detect it and load the grid now
+        this.view.viewGrid.fetchData(this.view.viewGrid.getCriteria());
+      }
     }
 
     // restore focus as the focusitem may have been hidden now
diff -r 547ca19bda33 -r 58de83084d74 
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Fri Dec 
05 06:56:57 2014 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Tue Nov 
25 12:08:01 2014 +0100
@@ -387,7 +387,7 @@
                   .getInvoice()
                   : null);
           docLine.setDoubtFulDebtAmount(new 
BigDecimal(data[i].getField("DoubtFulDebtAmount")));
-          docLine.setInvoiceTaxCashVAT_V(strPaymentId);
+          docLine.setInvoiceTaxCashVAT_V(paymentDetail_ID);
         }
         docLine.setIsPrepayment(data[i].getField("isprepayment"));
         docLine.setCGlItemId(data[i].getField("cGlItemId"));
diff -r 547ca19bda33 -r 58de83084d74 
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java   Fri Dec 05 
06:56:57 2014 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java   Tue Nov 25 
12:08:01 2014 +0100
@@ -301,7 +301,7 @@
                 
.getFINPaymentScheduleDetailList().get(0).getInvoicePaymentSchedule().getInvoice()
                 : null);
         docLine.m_Record_Id2 = data[i].getField("recordId2");
-        docLine.setInvoiceTaxCashVAT_V(detail.getFinPayment().getId());
+        docLine.setInvoiceTaxCashVAT_V(Line_ID);
         list.add(docLine);
       } finally {
         OBContext.restorePreviousMode();
diff -r 547ca19bda33 -r 58de83084d74 
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Fri Dec 
05 06:56:57 2014 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java    Tue Nov 
25 12:08:01 2014 +0100
@@ -699,7 +699,7 @@
         // Cambiar line to reflect BPs
         FIN_PaymentDetail paymentDetail = 
OBDal.getInstance().get(FIN_PaymentDetail.class,
             finPaymentDetailID);
-        detail.setInvoiceTaxCashVAT_V(paymentDetail.getFinPayment().getId());
+        detail.setInvoiceTaxCashVAT_V(finPaymentDetailID);
         fact = createFactPaymentDetails(detail, paymentDetail, as, conn, fact, 
Fact_Acct_Group_ID,
             Fact_Acct_Group_ID2);
       }
diff -r 547ca19bda33 -r 58de83084d74 
src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java
--- 
a/src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java
    Fri Dec 05 06:56:57 2014 +0000
+++ 
b/src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java
    Tue Nov 25 12:08:01 2014 +0100
@@ -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) 2013 Openbravo SLU
+ * All portions are Copyright (C) 2013-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -50,19 +50,20 @@
     this.invoiceTaxCashVAT_V = invoiceTaxCashVAT_V;
   }
 
-  public void setInvoiceTaxCashVAT_V(String finPaymentID) {
-    if (StringUtils.isBlank(finPaymentID)) {
+  public void setInvoiceTaxCashVAT_V(String finPaymentDetailID) {
+    if (StringUtils.isBlank(finPaymentDetailID)) {
       this.invoiceTaxCashVAT_V = new ArrayList<InvoiceTaxCashVAT_V>();
     } else {
       try {
         OBContext.setAdminMode(true);
         final StringBuffer hql = new StringBuffer();
         hql.append(" as itcv ");
-        hql.append(" where itcv." + InvoiceTaxCashVAT_V.PROPERTY_PAYMENT + 
".id = :finPaymentID ");
+        hql.append(" where itcv." + InvoiceTaxCashVAT_V.PROPERTY_PAYMENTDETAILS
+            + ".id = :finPaymentDetailID ");
         hql.append(" and itcv." + InvoiceTaxCashVAT_V.PROPERTY_CANCELED + " = 
false");
         OBQuery<InvoiceTaxCashVAT_V> obq = OBDal.getInstance().createQuery(
             InvoiceTaxCashVAT_V.class, hql.toString());
-        obq.setNamedParameter("finPaymentID", finPaymentID);
+        obq.setNamedParameter("finPaymentDetailID", finPaymentDetailID);
         obq.setFilterOnReadableClients(false);
         obq.setFilterOnReadableOrganization(false);
 

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to