details: https://code.openbravo.com/erp/devel/pi/rev/c4509d74fe33 changeset: 22828:c4509d74fe33 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Wed Apr 02 17:56:36 2014 +0200 summary: Fixed issue 26144, fixed issue 26145
details: https://code.openbravo.com/erp/devel/pi/rev/f7078a85289e changeset: 22829:f7078a85289e user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Thu Apr 03 13:30:46 2014 +0200 summary: Related to issue 25696 proper ipsc to the reconciliations diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java | 48 +--- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java | 51 ----- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java | 8 +- src/org/openbravo/event/PaidStatusEventHandler.java | 100 ++++++++++ 4 files changed, 120 insertions(+), 87 deletions(-) diffs (293 lines): diff -r 7b40264aab15 -r f7078a85289e 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 Thu Apr 03 12:39:27 2014 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java Thu Apr 03 13:30:46 2014 +0200 @@ -692,7 +692,7 @@ } // Do not restore paid amounts if the payment is awaiting execution. - boolean restorePaidAmounts = (FIN_Utility.seqnumberpaymentstatus(payment.getStatus())) <= (FIN_Utility + boolean restorePaidAmounts = (FIN_Utility.seqnumberpaymentstatus(payment.getStatus())) == (FIN_Utility .seqnumberpaymentstatus(FIN_Utility.invoicePaymentStatus(payment))); // Initialize amounts payment.setProcessed(false); @@ -746,7 +746,7 @@ for (FIN_PaymentScheduleDetail paymentScheduleDetail : paymentDetail .getFINPaymentScheduleDetailList()) { Boolean invoicePaidold = paymentScheduleDetail.isInvoicePaid(); - if (invoicePaidold) { + if (invoicePaidold | paymentScheduleDetail.getInvoicePaymentSchedule() == null) { BigDecimal psdWriteoffAmount = paymentScheduleDetail.getWriteoffAmount(); BigDecimal psdAmount = paymentScheduleDetail.getAmount(); BigDecimal amount = psdAmount.add(psdWriteoffAmount); @@ -832,38 +832,22 @@ paymentScheduleDetail.getOrderPaymentSchedule(), psdAmount.negate(), psdWriteoffAmount.negate()); } - - // when generating credit for a BP SO_CreditUsed is also updated - if (paymentScheduleDetail.getInvoicePaymentSchedule() == null - && paymentScheduleDetail.getOrderPaymentSchedule() == null - && paymentScheduleDetail.getPaymentDetails().getGLItem() == null - && restorePaidAmounts && !paymentDetail.isRefund()) { - // BP SO_CreditUsed - if (isReceipt) { - increaseCustomerCredit(businessPartner, amount); - } else { - decreaseCustomerCredit(businessPartner, amount); - } - } - - if (paymentScheduleDetail.getOrderPaymentSchedule() != null && restorePaidAmounts) { - FIN_AddPayment.updatePaymentScheduleAmounts( - paymentScheduleDetail.getOrderPaymentSchedule(), psdAmount.negate(), - psdWriteoffAmount.negate()); - } - // when generating credit for a BP SO_CreditUsed is also updated - if (paymentScheduleDetail.getInvoicePaymentSchedule() == null - && paymentScheduleDetail.getOrderPaymentSchedule() == null - && paymentScheduleDetail.getPaymentDetails().getGLItem() == null - && restorePaidAmounts && !paymentDetail.isRefund()) { - // BP SO_CreditUsed - if (isReceipt) { - increaseCustomerCredit(businessPartner, amount); - } else { - decreaseCustomerCredit(businessPartner, amount); + if (restorePaidAmounts) { + // when generating credit for a BP SO_CreditUsed is also updated + if (paymentScheduleDetail.getInvoicePaymentSchedule() == null + && paymentScheduleDetail.getOrderPaymentSchedule() == null + && paymentScheduleDetail.getPaymentDetails().getGLItem() == null + && restorePaidAmounts && !paymentDetail.isRefund()) { + // BP SO_CreditUsed + if (isReceipt) { + increaseCustomerCredit(businessPartner, amount); + } else { + decreaseCustomerCredit(businessPartner, amount); + } } } } + if (strAction.equals("R") || (strAction.equals("RE") && paymentScheduleDetail.getInvoicePaymentSchedule() == null @@ -1039,7 +1023,7 @@ for (final FIN_PaymentScheduleDetail paymentScheduleDetail : paymentDetail .getFINPaymentScheduleDetailList()) { Boolean invoicePaidold = paymentScheduleDetail.isInvoicePaid(); - if (invoicePaidold) { + if (invoicePaidold | paymentScheduleDetail.getInvoicePaymentSchedule() == null) { paymentScheduleDetail.setInvoicePaid(false); } BigDecimal outStandingAmt = BigDecimal.ZERO; diff -r 7b40264aab15 -r f7078a85289e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java Thu Apr 03 12:39:27 2014 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java Thu Apr 03 13:30:46 2014 +0200 @@ -34,10 +34,7 @@ import org.openbravo.erpCommon.utility.OBDateUtils; import org.openbravo.erpCommon.utility.OBError; import org.openbravo.erpCommon.utility.Utility; -import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount; -import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail; -import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; import org.openbravo.model.financialmgmt.payment.FIN_Reconciliation; import org.openbravo.model.financialmgmt.payment.FIN_ReconciliationLine_v; import org.openbravo.scheduling.ProcessBundle; @@ -111,28 +108,6 @@ OBDal.getInstance().save(reconciliation); OBDal.getInstance().flush(); - Boolean invoicePaidold = false; - for (FIN_FinaccTransaction finacctransaction : reconciliation.getFINFinaccTransactionList()) { - if (finacctransaction.getFinPayment() != null) { - for (FIN_PaymentDetail pd : finacctransaction.getFinPayment().getFINPaymentDetailList()) { - for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) { - invoicePaidold = psd.isInvoicePaid(); - if (!invoicePaidold) { - if ((FIN_Utility.invoicePaymentStatus(finacctransaction.getFinPayment() - .getPaymentMethod(), reconciliation.getAccount(), finacctransaction - .getFinPayment().isReceipt()).equals(finacctransaction.getFinPayment() - .getStatus()))) { - psd.setInvoicePaid(true); - } - if (psd.isInvoicePaid()) { - FIN_Utility.updatePaymentAmounts(psd); - } - } - } - } - FIN_Utility.updateBusinessPartnerCredit(finacctransaction.getFinPayment()); - } - } // *********************** // Reactivate Reconciliation // *********************** @@ -194,32 +169,6 @@ OBDal.getInstance().save(reconciliation); OBDal.getInstance().flush(); Boolean invoicePaidold = false; - - for (FIN_FinaccTransaction finacctransaction : reconciliation.getFINFinaccTransactionList()) { - if (finacctransaction.getFinPayment() != null) { - for (FIN_PaymentDetail pd : finacctransaction.getFinPayment().getFINPaymentDetailList()) { - for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) { - invoicePaidold = psd.isInvoicePaid(); - if (invoicePaidold) { - if (FIN_Utility.invoicePaymentStatus( - finacctransaction.getFinPayment().getPaymentMethod(), - reconciliation.getAccount(), finacctransaction.getFinPayment().isReceipt()) - .equals(finacctransaction.getFinPayment().getStatus())) { - boolean restore = (FIN_Utility.seqnumberpaymentstatus(finacctransaction - .getFinPayment().getStatus())) <= (FIN_Utility - .seqnumberpaymentstatus(FIN_Utility.invoicePaymentStatus(finacctransaction - .getFinPayment().getPaymentMethod(), reconciliation.getAccount(), - finacctransaction.getFinPayment().isReceipt()))); - if (restore) { - FIN_Utility.restorePaidAmounts(psd); - } - } - } - } - } - } - } - } reconciliation.setProcessNow(false); OBDal.getInstance().save(reconciliation); diff -r 7b40264aab15 -r f7078a85289e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java Thu Apr 03 12:39:27 2014 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java Thu Apr 03 13:30:46 2014 +0200 @@ -116,12 +116,13 @@ } if (psd.isInvoicePaid()) { FIN_Utility.updatePaymentAmounts(psd); + FIN_Utility.updateBusinessPartnerCredit(payment); } OBDal.getInstance().save(psd); } } } - FIN_Utility.updateBusinessPartnerCredit(payment); + } else { transaction.setStatus(transaction.getDepositAmount().compareTo( transaction.getPaymentAmount()) > 0 ? "RDNC" : "PWNC"); @@ -186,9 +187,8 @@ for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) { invoicePaidold = psd.isInvoicePaid(); if (invoicePaidold) { - boolean restore = (FIN_Utility.seqnumberpaymentstatus(payment.isReceipt() ? "RPR" - : "PPM")) < (FIN_Utility.seqnumberpaymentstatus(FIN_Utility - .invoicePaymentStatus(payment))); + boolean restore = (FIN_Utility.seqnumberpaymentstatus(payment.getStatus())) == (FIN_Utility + .seqnumberpaymentstatus(FIN_Utility.invoicePaymentStatus(payment))); if (restore) { FIN_Utility.restorePaidAmounts(psd); } diff -r 7b40264aab15 -r f7078a85289e src/org/openbravo/event/PaidStatusEventHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/openbravo/event/PaidStatusEventHandler.java Thu Apr 03 13:30:46 2014 +0200 @@ -0,0 +1,100 @@ +/* + ************************************************************************* + * 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) 2014 Openbravo SLU + * All Rights Reserved. + * Contributor(s): ______________________________________. + ************************************************************************* + */ +package org.openbravo.event; + +import javax.enterprise.event.Observes; + +import org.apache.log4j.Logger; +import org.openbravo.advpaymentmngt.utility.FIN_Utility; +import org.openbravo.base.model.Entity; +import org.openbravo.base.model.ModelProvider; +import org.openbravo.base.model.Property; +import org.openbravo.client.kernel.event.EntityPersistenceEventObserver; +import org.openbravo.client.kernel.event.EntityUpdateEvent; +import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; +import org.openbravo.model.financialmgmt.payment.FIN_PaymentDetail; +import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; + +public class PaidStatusEventHandler extends EntityPersistenceEventObserver { + private static Entity[] entities = { ModelProvider.getInstance().getEntity( + FIN_FinaccTransaction.ENTITY_NAME) }; + protected Logger logger = Logger.getLogger(this.getClass()); + public static final String STATUS_CLEARED = "RPPC"; + public static final String STATUS_DEPOSIT = "RDNC"; + public static final String STATUS_WITHDRAWN = "PWNC"; + + @Override + protected Entity[] getObservedEntities() { + return entities; + } + + public void onUpdate(@Observes + EntityUpdateEvent event) { + if (!isValidEvent(event)) { + return; + } + + final Entity transactionEntity = ModelProvider.getInstance().getEntity( + FIN_FinaccTransaction.ENTITY_NAME); + final Property statusProperty = transactionEntity + .getProperty(FIN_FinaccTransaction.PROPERTY_STATUS); + String oldStatus = (String) event.getPreviousState(statusProperty); + String newStatus = (String) event.getCurrentState(statusProperty); + final FIN_FinaccTransaction transaction = (FIN_FinaccTransaction) event.getTargetInstance(); + + if ((oldStatus.equals(STATUS_DEPOSIT) | oldStatus.equals(STATUS_WITHDRAWN)) + & newStatus.equals(STATUS_CLEARED)) { + + Boolean invoicePaidold = false; + + if (transaction.getFinPayment() != null) { + for (FIN_PaymentDetail pd : transaction.getFinPayment().getFINPaymentDetailList()) { + for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) { + invoicePaidold = psd.isInvoicePaid(); + if (!invoicePaidold) { + if (newStatus.equals(transaction.getFinPayment().getStatus())) { + psd.setInvoicePaid(true); + } + if (psd.isInvoicePaid()) { + FIN_Utility.updatePaymentAmounts(psd); + FIN_Utility.updateBusinessPartnerCredit(transaction.getFinPayment()); + } + } + } + } + } + + } else if ((newStatus.equals(STATUS_DEPOSIT) | newStatus.equals(STATUS_WITHDRAWN)) + & oldStatus.equals(STATUS_CLEARED)) { + Boolean invoicePaidold = false; + if (transaction.getFinPayment() != null) { + for (FIN_PaymentDetail pd : transaction.getFinPayment().getFINPaymentDetailList()) { + for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) { + invoicePaidold = psd.isInvoicePaid(); + if (invoicePaidold) { + if (oldStatus.equals(FIN_Utility.invoicePaymentStatus(transaction.getFinPayment()))) { + FIN_Utility.restorePaidAmounts(psd); + } + } + } + } + } + } + } +} \ No newline at end of file ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
