details: https://code.openbravo.com/erp/devel/pi/rev/cdc00e66f2c2 changeset: 34829:cdc00e66f2c2 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Tue Oct 02 17:45:00 2018 +0200 summary: Fixed issue 39318 Wrong accounting entry for a doubtful debt payment if the invoice has more than one payment plan detail
When more that one payment schedule detail, set the doubtful debt amount correctly. diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java | 13 ++++++++- 1 files changed, 11 insertions(+), 2 deletions(-) diffs (31 lines): diff -r 334861bec141 -r cdc00e66f2c2 modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java Fri Sep 28 01:58:48 2018 +0530 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java Tue Oct 02 17:45:00 2018 +0200 @@ -132,16 +132,25 @@ private void updateDoubtfulDebtScheduleDetails(FIN_PaymentSchedule salesInvoicePaymentSchedule, BigDecimal debtAmount) { + BigDecimal debtAmountAux = debtAmount; for (FIN_PaymentScheduleDetail psd : salesInvoicePaymentSchedule .getFINPaymentScheduleDetailInvoicePaymentScheduleList()) { if (psd.getPaymentDetails() == null) { // Pending amount should be greater or equals than the doubtful debt amount - if (psd.getAmount().compareTo(debtAmount) >= 0) { - psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().add(debtAmount)); + if (psd.getAmount().compareTo(debtAmountAux) >= 0) { + psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().add(debtAmountAux)); + OBDal.getInstance().save(psd); + } else { + psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().add(psd.getAmount())); + debtAmountAux = getDifferenceOrZero(debtAmountAux, psd); OBDal.getInstance().save(psd); } } } } + private BigDecimal getDifferenceOrZero(BigDecimal debtAmountAux, FIN_PaymentScheduleDetail psd) { + return debtAmountAux.subtract(psd.getAmount()).compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO + : debtAmountAux.subtract(psd.getAmount()); + } } _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits