details: https://code.openbravo.com/erp/devel/pi/rev/28835f34e438 changeset: 32259:28835f34e438 user: Armaignac <collazoandy4 <at> gmail.com> date: Tue May 23 15:51:17 2017 -0400 summary: Fixes issue 34432: Accounting information not grouped by invoice when posting
Accounting information was not properly grouped when posting a payment related with one invoice created from several orders. Accounting info was splitted by order when this is not necessary and confusing for end user. Now if there is a previous Payment Detail that belongs to the same Invoice, the amounts are added. details: https://code.openbravo.com/erp/devel/pi/rev/3c6074899262 changeset: 32260:3c6074899262 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Thu Jun 01 16:33:07 2017 +0200 summary: Related to issue 34432: Code review improvements Use BigDecimal.ZERO instead of new BigDecimal(0) and BigDecimal.ONE instead of new BigDecimal(1). Changed totalAmount = amount.add(totalAmount) with totalAmount = totalAmount.add(amount) which is more understandable. diffstat: src/org/openbravo/erpCommon/ad_forms/AcctServer.java | 9 +++++++++ src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java | 10 +++++++++- src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java | 10 +++++++++- src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java | 10 +++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diffs (112 lines): diff -r 0d4ef3abdea4 -r 3c6074899262 src/org/openbravo/erpCommon/ad_forms/AcctServer.java --- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java Thu Jun 01 16:58:38 2017 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java Thu Jun 01 16:33:07 2017 +0200 @@ -3070,6 +3070,9 @@ amountAndWriteOff.put("amount", paymentDetail.getAmount()); amountAndWriteOff.put("writeoff", paymentDetail.getWriteoffAmount()); + // This value indicates that the current payment detail amount must be added to the previous one + amountAndWriteOff.put("merged", BigDecimal.ZERO); + // If the Payment Detail has either an Invoice or an Order associated to it if (psi != null || pso != null) { // If the Payment Detail has no Order associated to it, or it has an Invoice associated and is @@ -3102,11 +3105,17 @@ paymentDetail.getAmount().add(paymentDetailPrevious.getAmount())); amountAndWriteOff.put("writeoff", paymentDetail.getWriteoffAmount().add(paymentDetailPrevious.getWriteoffAmount())); + if (fieldProvider != null) { FieldProviderFactory.setField(fieldProvider, "MergedPaymentDetailId", paymentDetailPreviousId); } } + // If there is a previous Payment Detail that belongs to the same Invoice, the amounts + // should be added. + else if (psdPrevious != null && psdPrevious.getInvoicePaymentSchedule() == psi) { + amountAndWriteOff.put("merged", BigDecimal.ONE); + } } } diff -r 0d4ef3abdea4 -r 3c6074899262 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java --- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Thu Jun 01 16:58:38 2017 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java Thu Jun 01 16:33:07 2017 +0200 @@ -120,6 +120,7 @@ FieldProviderFactory[] data = new FieldProviderFactory[paymentDetails.size()]; String psId = null; String pdId = null; + BigDecimal totalAmount = BigDecimal.ZERO; OBContext.setAdminMode(); try { for (int i = 0; i < data.length; i++) { @@ -166,7 +167,14 @@ psId = psi != null ? psi.getId() : null; continue; } else { - FieldProviderFactory.setField(data[i], "Amount", amount.toString()); + if (amountAndWriteOff.get("merged").compareTo(BigDecimal.ONE) == 0) { + // keeps only the current line while merging the amounts + data[i - 1] = null; + totalAmount = totalAmount.add(amount); + } else { + totalAmount = amount; + } + FieldProviderFactory.setField(data[i], "Amount", totalAmount.toString()); } psId = psi != null ? psi.getId() : null; diff -r 0d4ef3abdea4 -r 3c6074899262 src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java --- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java Thu Jun 01 16:58:38 2017 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java Thu Jun 01 16:33:07 2017 +0200 @@ -94,6 +94,7 @@ FieldProviderFactory[] data = new FieldProviderFactory[paymentDetails.size()]; String psId = null; String pdId = null; + BigDecimal totalAmount = BigDecimal.ZERO; OBContext.setAdminMode(); try { for (int i = 0; i < data.length; i++) { @@ -138,7 +139,14 @@ psId = psi != null ? psi.getId() : null; continue; } else { - FieldProviderFactory.setField(data[i], "Amount", amount.toString()); + if (amountAndWriteOff.get("merged").compareTo(BigDecimal.ONE) == 0) { + // keeps only the current line while merging the amounts + data[i - 1] = null; + totalAmount = totalAmount.add(amount); + } else { + totalAmount = amount; + } + FieldProviderFactory.setField(data[i], "Amount", totalAmount.toString()); } psId = psi != null ? psi.getId() : null; diff -r 0d4ef3abdea4 -r 3c6074899262 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java --- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java Thu Jun 01 16:58:38 2017 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java Thu Jun 01 16:33:07 2017 +0200 @@ -168,6 +168,7 @@ FieldProviderFactory[] data = new FieldProviderFactory[paymentDetails.size()]; FIN_PaymentSchedule ps = null; FIN_PaymentDetail pd = null; + BigDecimal totalAmount = BigDecimal.ZERO; OBContext.setAdminMode(); try { for (int i = 0; i < data.length; i++) { @@ -211,7 +212,14 @@ ps = psi; continue; } else { - FieldProviderFactory.setField(data[i], "Amount", amount.toString()); + if (amountAndWriteOff.get("merged").compareTo(BigDecimal.ONE) == 0) { + // keeps only the current line while merging the amounts + data[i - 1] = null; + totalAmount = totalAmount.add(amount); + } else { + totalAmount = amount; + } + FieldProviderFactory.setField(data[i], "Amount", totalAmount.toString()); } ps = psi; ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits