details:   https://code.openbravo.com/erp/devel/pi/rev/16b9d36614a8
changeset: 29620:16b9d36614a8
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Wed Jun 08 11:58:42 2016 +0530
summary:   Fixes issue 33082: Payment Schedule Detail duplicated in "Modify 
Payment Plan"

Avoid creation of payment schedule detail for cancelled psd if there exists for 
a payment detail.

details:   https://code.openbravo.com/erp/devel/pi/rev/ae98f8c22523
changeset: 29621:ae98f8c22523
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Wed Jun 15 14:20:57 2016 +0200
summary:   Related to issue 33082: Code review improvements

diffstat:

 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ModifyPaymentPlanActionHandler.java
 |  22 ++++++++-
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 463564b77a03 -r ae98f8c22523 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ModifyPaymentPlanActionHandler.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ModifyPaymentPlanActionHandler.java
   Wed Jun 15 09:06:46 2016 +0200
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ModifyPaymentPlanActionHandler.java
   Wed Jun 15 14:20:57 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) 2012 Openbravo SLU
+ * All portions are Copyright (C) 2012-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -270,15 +270,29 @@
       while (ite.hasNext()) {
         FIN_PaymentDetail pd = ite.next();
         BigDecimal amount = canceledPSDs.get(pd);
-        FIN_PaymentScheduleDetail psd = dao.getNewPaymentScheduleDetail(ps, 
null, amount,
-            BigDecimal.ZERO, pd);
-        psd.setCanceled(true);
+        if (!existsPaymentScheduleDetail(pd)) {
+          FIN_PaymentScheduleDetail psd = dao.getNewPaymentScheduleDetail(ps, 
null, amount,
+              BigDecimal.ZERO, pd);
+          psd.setCanceled(true);
+        }
       }
       return;
     }
   }
 
   /**
+   * Returns the payment schedule detail for payment detail
+   * 
+   */
+  private boolean existsPaymentScheduleDetail(FIN_PaymentDetail pd) {
+    OBCriteria<FIN_PaymentScheduleDetail> obcPSD = 
OBDal.getInstance().createCriteria(
+        FIN_PaymentScheduleDetail.class);
+    
obcPSD.add(Restrictions.eq(FIN_PaymentScheduleDetail.PROPERTY_PAYMENTDETAILS, 
pd));
+    obcPSD.setMaxResults(1);
+    return obcPSD.uniqueResult() != null;
+  }
+
+  /**
    * Returns the set of payment schedule detail elements for payments that 
have been canceled
    * 
    */

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to