details: https://code.openbravo.com/erp/devel/pi/rev/8ca50f74a19d changeset: 35998:8ca50f74a19d user: Nono Carballo <nonofce <at> gmail.com> date: Fri May 31 14:49:20 2019 -0400 summary: Fixes issue 40965: Update audit info when creating reversal payment
The reversal payment is generated as a copy of the original payment. After the creation of the reversal payment, audit information is updated. diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java | 20 +++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diffs (100 lines): diff -r 1e6839146494 -r 8ca50f74a19d modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java Tue Jun 04 16:04:47 2019 +0000 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java Fri May 31 14:49:20 2019 -0400 @@ -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) 2010-2018 Openbravo SLU + * All portions are Copyright (C) 2010-2019 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************* @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.Date; @@ -39,6 +40,7 @@ import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.base.exception.OBException; import org.openbravo.base.provider.OBProvider; +import org.openbravo.base.structure.BaseOBObject; import org.openbravo.base.weld.WeldUtils; import org.openbravo.client.kernel.RequestContext; import org.openbravo.dal.core.DalUtil; @@ -73,6 +75,9 @@ public BigDecimal ZERO = BigDecimal.ZERO; static Logger log4j = LogManager.getLogger(); + private static final String CREATED_BY_PROPERTY = "createdBy"; + private static final String CREATION_DATE_PROPERTY = "creationDate"; + @Override public void execute(ProcessBundle bundle) throws Exception { @@ -514,6 +519,9 @@ // *********************** } else if (strAction.equals("RV")) { FIN_Payment reversedPayment = (FIN_Payment) DalUtil.copy(payment, false); + final Calendar calendar = Calendar.getInstance(); + final Date now = calendar.getTime(); + updateAuditInformation(reversedPayment, now); OBContext.setAdminMode(); try { if (BigDecimal.ZERO.compareTo(payment.getGeneratedCredit()) != 0 @@ -550,6 +558,7 @@ for (FIN_PaymentDetail pd : payment.getFINPaymentDetailList()) { FIN_PaymentDetail reversedPaymentDetail = (FIN_PaymentDetail) DalUtil.copy(pd, false); + updateAuditInformation(reversedPaymentDetail, now); reversedPaymentDetail.setFinPayment(reversedPayment); reversedPaymentDetail.setAmount(pd.getAmount().negate()); reversedPaymentDetail.setWriteoffAmount(pd.getWriteoffAmount().negate()); @@ -605,6 +614,7 @@ // If invoice is fully paid create a new schedule detail. FIN_PaymentScheduleDetail openPSD = (FIN_PaymentScheduleDetail) DalUtil.copy(psd, false); + updateAuditInformation(openPSD, now); openPSD.setPaymentDetails(null); // Amounts openPSD.setWriteoffAmount(BigDecimal.ZERO); @@ -617,6 +627,7 @@ FIN_PaymentScheduleDetail reversedPaymentSchedDetail = (FIN_PaymentScheduleDetail) DalUtil .copy(psd, false); + updateAuditInformation(reversedPaymentSchedDetail, now); reversedPaymentSchedDetail.setPaymentDetails(reversedPaymentDetail); // Amounts reversedPaymentSchedDetail.setWriteoffAmount(psd.getWriteoffAmount().negate()); @@ -647,6 +658,7 @@ List<FIN_Payment_Credit> reversedCredits = new ArrayList<FIN_Payment_Credit>(); for (FIN_Payment_Credit pc : credits) { FIN_Payment_Credit reversedPaymentCredit = (FIN_Payment_Credit) DalUtil.copy(pc, false); + updateAuditInformation(reversedPaymentCredit, now); reversedPaymentCredit.setAmount(pc.getAmount().negate()); reversedPaymentCredit.setCreditPaymentUsed(pc.getCreditPaymentUsed()); pc.getCreditPaymentUsed() @@ -664,6 +676,7 @@ List<ConversionRateDoc> conversions = new ArrayList<ConversionRateDoc>(); for (ConversionRateDoc cr : payment.getCurrencyConversionRateDocList()) { ConversionRateDoc reversedCR = (ConversionRateDoc) DalUtil.copy(cr, false); + updateAuditInformation(reversedCR, now); reversedCR.setForeignAmount(cr.getForeignAmount().negate()); reversedCR.setPayment(reversedPayment); OBDal.getInstance().save(reversedCR); @@ -1189,6 +1202,11 @@ } } + private void updateAuditInformation(BaseOBObject baseOBject, final Date now) { + baseOBject.set(CREATION_DATE_PROPERTY, now); + baseOBject.set(CREATED_BY_PROPERTY, OBContext.getOBContext().getUser()); + } + /** * Method used to update the credit used when the user doing invoice processing or payment * processing _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits