details:   https://code.openbravo.com/erp/devel/pi/rev/21d7a77fe6d3
changeset: 13153:21d7a77fe6d3
user:      Ioritz Cia <ioritz.cia <at> openbravo.com>
date:      Thu Jul 14 11:42:26 2011 +0200
summary:   Fixes issue 17646: The Payment Report does not show data properly.

diffstat:

 
modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java
 |  106 +--------
 1 files changed, 15 insertions(+), 91 deletions(-)

diffs (173 lines):

diff -r 1d3dde7f5915 -r 21d7a77fe6d3 
modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java
--- 
a/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java
        Wed Jul 13 15:16:57 2011 +0200
+++ 
b/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java
        Thu Jul 14 11:42:26 2011 +0200
@@ -91,7 +91,6 @@
     Currency transCurrency;
     BigDecimal transAmount = null;
     ConversionRate convRate = null;
-    ArrayList<FieldProvider> groupedData = new ArrayList<FieldProvider>();
 
     OBContext.setAdminMode();
     try {
@@ -342,11 +341,6 @@
 
         for (int i = 0; i < strOrdCritList.length; i++) {
           if (strOrdCritList[i].contains("Date")) {
-            /*
-             * hsqlScript.append(",  coalesce(pay.");
-             * hsqlScript.append(FIN_Payment.PROPERTY_PAYMENTDATE); 
hsqlScript.append(", inv.");
-             * hsqlScript.append(Invoice.PROPERTY_INVOICEDATE); 
hsqlScript.append(")");
-             */
             hsqlScript.append(", inv.");
             hsqlScript.append(Invoice.PROPERTY_INVOICEDATE);
           }
@@ -397,14 +391,6 @@
       FIN_PaymentScheduleDetail[] FIN_PaymentScheduleDetail = new 
FIN_PaymentScheduleDetail[0];
       FIN_PaymentScheduleDetail = 
obqPSDList.toArray(FIN_PaymentScheduleDetail);
 
-      FIN_PaymentDetail finPaymDetail;
-      FIN_PaymentSchedule finPaymSchedule;
-      Boolean mustGroup;
-      String previousInvoiceId = null;
-      String previousPaymentId = null;
-      BigDecimal amountSum = BigDecimal.ZERO;
-      FieldProvider previousRow = null;
-      ConversionRate previousConvRate = null;
       long milisecDayConv = (1000 * 60 * 60 * 24);
       boolean isReceipt = false;
 
@@ -569,6 +555,7 @@
 
         }
 
+        // transactional and base amounts
         transAmount = FIN_PaymentScheduleDetail[i].getAmount();
 
         Currency baseCurrency = OBDal.getInstance().get(Currency.class, 
strConvertCurrency);
@@ -579,14 +566,16 @@
           convRate = this.getConversionRate(transCurrency, baseCurrency, 
strConversionDate);
 
           if (convRate != null) {
-            transAmount = FIN_PaymentScheduleDetail[i].getAmount();
-            // baseAmount
-            if (isReceipt)
+            if (isReceipt) {
+              FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", 
transAmount.toString());
               FieldProviderFactory.setField(data[i], "BASE_AMOUNT",
                   
transAmount.multiply(convRate.getMultipleRateBy()).toString());
-            else
+            } else {
+              FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", 
transAmount.negate()
+                  .toString());
               FieldProviderFactory.setField(data[i], "BASE_AMOUNT",
                   
transAmount.multiply(convRate.getMultipleRateBy()).negate().toString());
+            }
           } else {
             FieldProvider[] fp = new FieldProvider[1];
             HashMap<String, String> hm = new HashMap<String, String>();
@@ -602,6 +591,13 @@
           }
         } else {
           convRate = null;
+          if (isReceipt) {
+            FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", 
transAmount.toString());
+            FieldProviderFactory.setField(data[i], "BASE_AMOUNT", 
transAmount.toString());
+          } else {
+            FieldProviderFactory.setField(data[i], "TRANS_AMOUNT", 
transAmount.negate().toString());
+            FieldProviderFactory.setField(data[i], "BASE_AMOUNT", 
transAmount.negate().toString());
+          }
         }
 
         // currency
@@ -609,58 +605,6 @@
         // baseCurrency
         FieldProviderFactory.setField(data[i], "TRANS_CURRENCY", 
transCurrency.getISOCode());
 
-        finPaymDetail = FIN_PaymentScheduleDetail[i].getPaymentDetails();
-        finPaymSchedule = 
FIN_PaymentScheduleDetail[i].getInvoicePaymentSchedule();
-
-        if (finPaymDetail != null && finPaymSchedule != null) {
-          mustGroup = 
finPaymDetail.getFinPayment().getId().equalsIgnoreCase(previousPaymentId)
-              && 
finPaymSchedule.getInvoice().getId().equalsIgnoreCase(previousInvoiceId);
-          previousInvoiceId = finPaymSchedule.getInvoice().getId();
-          previousPaymentId = finPaymDetail.getFinPayment().getId();
-        } else if (finPaymDetail != null && finPaymSchedule == null) {
-          mustGroup = 
finPaymDetail.getFinPayment().getId().equalsIgnoreCase(previousPaymentId)
-              && previousInvoiceId == null;
-          previousPaymentId = finPaymDetail.getFinPayment().getId();
-          previousInvoiceId = null;
-        } else if (finPaymDetail == null && finPaymSchedule != null) {
-          mustGroup = previousPaymentId == null
-              && 
finPaymSchedule.getInvoice().getId().equalsIgnoreCase(previousInvoiceId);
-          previousPaymentId = null;
-          previousInvoiceId = finPaymSchedule.getInvoice().getId();
-        } else {
-          mustGroup = false;
-        }
-
-        if (mustGroup) {
-          amountSum = amountSum.add(transAmount);
-        } else {
-          if (previousRow != null) {
-            if (previousRow.getField("ISRECEIPT").equalsIgnoreCase("Y"))
-              FieldProviderFactory.setField(previousRow, "TRANS_AMOUNT", 
amountSum.toString());
-            else
-              FieldProviderFactory.setField(previousRow, "TRANS_AMOUNT", 
amountSum.negate()
-                  .toString());
-            if (previousConvRate == null) {
-              if (previousRow.getField("ISRECEIPT").equalsIgnoreCase("Y"))
-                FieldProviderFactory.setField(previousRow, "BASE_AMOUNT", 
amountSum.toString());
-              else
-                FieldProviderFactory.setField(previousRow, "BASE_AMOUNT", 
amountSum.negate()
-                    .toString());
-            } else {
-              if (previousRow.getField("ISRECEIPT").equalsIgnoreCase("Y"))
-                FieldProviderFactory.setField(previousRow, "BASE_AMOUNT",
-                    
amountSum.multiply(previousConvRate.getMultipleRateBy()).toString());
-              else
-                FieldProviderFactory.setField(previousRow, "BASE_AMOUNT",
-                    
amountSum.multiply(previousConvRate.getMultipleRateBy()).negate().toString());
-            }
-            groupedData.add(previousRow);
-          }
-          previousRow = data[i];
-          previousConvRate = convRate;
-          amountSum = transAmount;
-        }
-
         // group_crit_id this is the column that has the ids of the grouping 
criteria selected
         if (strGroupCrit.equalsIgnoreCase("APRM_FATS_BPARTNER")) {
           FieldProviderFactory.setField(data[i], "GROUP_CRIT_ID", 
data[i].getField("BPARTNER"));
@@ -678,31 +622,11 @@
         } else {
           FieldProviderFactory.setField(data[i], "GROUP_CRIT_ID", "");
         }
-
       }
-
-      if (convRate != null) {
-        if (isReceipt) {
-          FieldProviderFactory.setField(previousRow, "TRANS_AMOUNT", 
amountSum.toString());
-          FieldProviderFactory.setField(previousRow, "BASE_AMOUNT",
-              amountSum.multiply(convRate.getMultipleRateBy()).toString());
-          groupedData.add(previousRow);
-        } else {
-          FieldProviderFactory.setField(previousRow, "TRANS_AMOUNT", 
amountSum.negate().toString());
-          FieldProviderFactory.setField(previousRow, "BASE_AMOUNT",
-              
amountSum.multiply(convRate.getMultipleRateBy()).negate().toString());
-          groupedData.add(previousRow);
-        }
-      } else {
-        FieldProviderFactory.setField(previousRow, "TRANS_AMOUNT", 
amountSum.toString());
-        FieldProviderFactory.setField(previousRow, "BASE_AMOUNT", 
amountSum.toString());
-        groupedData.add(previousRow);
-      }
-
     } finally {
       OBContext.restorePreviousMode();
     }
-    return (FieldProvider[]) groupedData.toArray(new 
FieldProvider[groupedData.size()]);
+    return data;
   }
 
   public ConversionRate getConversionRate(Currency transCurrency, Currency 
baseCurrency,

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to