details: https://code.openbravo.com/erp/devel/pi/rev/5f9aab62bd8a changeset: 31535:5f9aab62bd8a user: Atul Gaware <atul.gaware <at> openbravo.com> date: Tue Feb 14 15:53:39 2017 +0530 summary: Fixes Issue 34987:Not possible to post a payment in that has used as payment method one which uses the “Leave as credit” execution process.
In Leave As Credit execution process added fin payment schedule detail and fin payment detail for credit amount in case of payment in/out with negative amount. diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/executionprocess/LeaveAsCredit.java | 35 ++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diffs (66 lines): diff -r a01dd96ef7eb -r 5f9aab62bd8a modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/executionprocess/LeaveAsCredit.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/executionprocess/LeaveAsCredit.java Thu Feb 16 11:46:12 2017 -0500 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/executionprocess/LeaveAsCredit.java Tue Feb 14 15:53:39 2017 +0530 @@ -1,13 +1,33 @@ +/* + ************************************************************************* + * The contents of this file are subject to the Openbravo Public License + * Version 1.0 (the "License"), being the Mozilla Public License + * Version 1.1 with a permitted attribution clause; you may not use this + * file except in compliance with the License. You may obtain a copy of + * the License at http://www.openbravo.com/legal/license.html + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * The Original Code is Openbravo ERP. + * The Initial Developer of the Original Code is Openbravo SLU + * All portions are Copyright (C) 2011-2017 Openbravo SLU + * All Rights Reserved. + * Contributor(s): ______________________________________. + ************************************************************************* + */ package org.openbravo.advpaymentmngt.executionprocess; import java.math.BigDecimal; import javax.servlet.ServletException; +import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao; import org.openbravo.advpaymentmngt.utility.FIN_PaymentExecutionProcess; import org.openbravo.dal.service.OBDal; import org.openbravo.erpCommon.utility.OBError; import org.openbravo.model.financialmgmt.payment.FIN_Payment; +import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; import org.openbravo.model.financialmgmt.payment.PaymentRun; import org.openbravo.model.financialmgmt.payment.PaymentRunPayment; @@ -15,6 +35,7 @@ @Override public OBError execute(PaymentRun paymentRun) throws ServletException { + AdvPaymentMngtDao dao = new AdvPaymentMngtDao(); paymentRun.setStatus("PE"); OBDal.getInstance().save(paymentRun); for (PaymentRunPayment paymentRunPayment : paymentRun.getFinancialMgmtPaymentRunPaymentList()) { @@ -22,6 +43,20 @@ if (payment.getAmount().compareTo(BigDecimal.ZERO) < 0) { payment.setGeneratedCredit(payment.getAmount().negate()); payment.setAmount(BigDecimal.ZERO); + // Set payment as processed = No to add payment detail for credit amount + if (payment.isProcessed()) { + payment.setProcessed(false); + OBDal.getInstance().save(payment); + OBDal.getInstance().flush(); + } + // Add schedule detail for credit amount + FIN_PaymentScheduleDetail creditScheduleDetail = dao.getNewPaymentScheduleDetail( + payment.getOrganization(), payment.getGeneratedCredit()); + // Add payment detail for credit amount schedule detail + dao.getNewPaymentDetail(payment, creditScheduleDetail, payment.getGeneratedCredit(), + BigDecimal.ZERO, false, null); + // Reset payment as processed = Yes + payment.setProcessed(true); } payment.setStatus(payment.isReceipt() ? "RPR" : "PPM"); paymentRunPayment.setResult("S"); ------------------------------------------------------------------------------ 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