details: https://code.openbravo.com/erp/devel/pi/rev/7194ff6bfb76
changeset: 21333:7194ff6bfb76
user: Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at>
openbravo.com>
date: Wed Oct 16 20:27:37 2013 +0530
summary: Fixes Issue 24848: Closed period verification should not be performed
when trying to process a document not configured to generate accounting, closed
period verification should not be performed.
diffstat:
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java
| 150 ++++++++-
1 files changed, 132 insertions(+), 18 deletions(-)
diffs (196 lines):
diff -r c978371677b2 -r 7194ff6bfb76
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
Mon Oct 21 10:55:56 2013 +0200
+++
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java
Wed Oct 16 20:27:37 2013 +0530
@@ -11,14 +11,16 @@
* 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-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
*************************************************************************
*/
package org.openbravo.advpaymentmngt.process;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
@@ -33,13 +35,18 @@
import org.openbravo.erpCommon.utility.OBDateUtils;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.Utility;
+import
org.openbravo.model.financialmgmt.accounting.FIN_FinancialAccountAccounting;
import org.openbravo.model.financialmgmt.payment.FIN_BankStatement;
+import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment;
import org.openbravo.model.financialmgmt.payment.FIN_Reconciliation;
import org.openbravo.model.financialmgmt.payment.FIN_ReconciliationLine_v;
+import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
import org.openbravo.scheduling.ProcessBundle;
public class FIN_ReconciliationProcess implements
org.openbravo.scheduling.Process {
private static AdvPaymentMngtDao dao;
+ Set<FIN_FinaccTransaction> transactionsToBePosted = new
HashSet<FIN_FinaccTransaction>();
public void execute(ProcessBundle bundle) throws Exception {
dao = new AdvPaymentMngtDao();
@@ -78,24 +85,35 @@
bundle.setResult(msg);
return;
} else {
- for (FIN_ReconciliationLine_v recLine :
reconciliation.getFINReconciliationLineVList()) {
- boolean orgLegalWithAccounting =
FIN_Utility.periodControlOpened(recLine
-
.getFinancialAccountTransaction().getReconciliation().TABLE_NAME, recLine
- .getFinancialAccountTransaction().getReconciliation().getId(),
recLine
-
.getFinancialAccountTransaction().getReconciliation().TABLE_NAME + "_ID", "LE");
- if
(!FIN_Utility.isPeriodOpen(recLine.getFinancialAccountTransaction().getClient()
- .getId(), AcctServer.DOCTYPE_Reconciliation, recLine
- .getFinancialAccountTransaction().getOrganization().getId(),
-
OBDateUtils.formatDate(recLine.getFinancialAccountTransaction().getDateAcct()))
- && orgLegalWithAccounting) {
- msg.setType("Error");
- msg.setTitle(Utility.messageBD(conProvider, "Error", language));
-
msg.setMessage(String.format(Utility.parseTranslation(conProvider, vars,
language,
- "@APRM_PeriodNotAvailableClearedItem@"),
recLine.getIdentifier()));
- bundle.setResult(msg);
- OBDal.getInstance().rollbackAndClose();
- return;
+ if (getDocumentConfirmation(conProvider, recordID)) {
+ for (FIN_ReconciliationLine_v recLine :
reconciliation.getFINReconciliationLineVList()) {
+ boolean orgLegalWithAccounting =
FIN_Utility.periodControlOpened(recLine
+
.getFinancialAccountTransaction().getReconciliation().TABLE_NAME, recLine
+
.getFinancialAccountTransaction().getReconciliation().getId(), recLine
+
.getFinancialAccountTransaction().getReconciliation().TABLE_NAME + "_ID", "LE");
+ if
(!FIN_Utility.isPeriodOpen(recLine.getFinancialAccountTransaction().getClient()
+ .getId(), AcctServer.DOCTYPE_Reconciliation, recLine
+ .getFinancialAccountTransaction().getOrganization().getId(),
+
OBDateUtils.formatDate(recLine.getFinancialAccountTransaction().getDateAcct()))
+ && orgLegalWithAccounting) {
+ msg.setType("Error");
+ msg.setTitle(Utility.messageBD(conProvider, "Error",
language));
+
msg.setMessage(String.format(Utility.parseTranslation(conProvider, vars,
language,
+ "@APRM_PeriodNotAvailableClearedItem@"),
recLine.getIdentifier()));
+ bundle.setResult(msg);
+ OBDal.getInstance().rollbackAndClose();
+ return;
+ }
}
+ } else {
+ msg.setType("Error");
+ msg.setTitle(Utility.messageBD(conProvider, "Error", language));
+ msg.setMessage(String.format(Utility.parseTranslation(conProvider,
vars, language,
+ "@DocumentDisabled@")));
+ bundle.setResult(msg);
+ OBDal.getInstance().rollbackAndClose();
+ return;
+
}
}
reconciliation.setProcessed(true);
@@ -153,6 +171,102 @@
}
}
+ public List<FIN_FinaccTransaction> getTransactionList(FIN_Reconciliation
reconciliation) {
+ OBContext.setAdminMode();
+ List<FIN_FinaccTransaction> transactions = null;
+ try {
+ OBCriteria<FIN_FinaccTransaction> trans =
OBDal.getInstance().createCriteria(
+ FIN_FinaccTransaction.class);
+ trans.add(Restrictions.eq(FIN_FinaccTransaction.PROPERTY_RECONCILIATION,
reconciliation));
+ trans.setFilterOnReadableClients(false);
+ trans.setFilterOnReadableOrganization(false);
+ transactions = trans.list();
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ return transactions;
+ }
+
+ /*
+ * Checks if this step (Reconciliation) is configured to generate accounting
for the selected
+ * financial account
+ */
+ public boolean getDocumentConfirmation(ConnectionProvider conn, String
strRecordId) {
+ OBContext.setAdminMode();
+ try {
+ FIN_Reconciliation reconciliation =
OBDal.getInstance().get(FIN_Reconciliation.class,
+ strRecordId);
+ List<FIN_FinaccTransaction> transactions =
getTransactionList(reconciliation);
+ List<FIN_FinancialAccountAccounting> accounts =
reconciliation.getAccount()
+ .getFINFinancialAccountAcctList();
+ for (FIN_FinaccTransaction transaction : transactions) {
+ FIN_Payment payment = transaction.getFinPayment();
+ // If payment exists, check Payment Method + financial Account
Configuration
+ if (payment != null) {
+ OBCriteria<FinAccPaymentMethod> obCriteria =
OBDal.getInstance().createCriteria(
+ FinAccPaymentMethod.class);
+ obCriteria.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT,
+ reconciliation.getAccount()));
+
obCriteria.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD,
+ payment.getPaymentMethod()));
+ obCriteria.setFilterOnReadableClients(false);
+ obCriteria.setFilterOnReadableOrganization(false);
+ List<FinAccPaymentMethod> lines = obCriteria.list();
+ for (FIN_FinancialAccountAccounting account : accounts) {
+ if (payment.isReceipt()) {
+ if (("INT").equals(lines.get(0).getINUponClearingUse())
+ && account.getInTransitPaymentAccountIN() != null) {
+ transactionsToBePosted.add(transaction);
+ } else if (("DEP").equals(lines.get(0).getINUponClearingUse())
+ && account.getDepositAccount() != null) {
+ transactionsToBePosted.add(transaction);
+ } else if (("CLE").equals(lines.get(0).getINUponClearingUse())
+ && account.getClearedPaymentAccount() != null) {
+ transactionsToBePosted.add(transaction);
+ }
+ } else {
+ if (("INT").equals(lines.get(0).getOUTUponClearingUse())
+ && account.getFINOutIntransitAcct() != null) {
+ transactionsToBePosted.add(transaction);
+ } else if (("WIT").equals(lines.get(0).getOUTUponClearingUse())
+ && account.getWithdrawalAccount() != null) {
+ transactionsToBePosted.add(transaction);
+ } else if (("CLE").equals(lines.get(0).getOUTUponClearingUse())
+ && account.getClearedPaymentAccountOUT() != null) {
+ transactionsToBePosted.add(transaction);
+ }
+ }
+ }
+ } else if (transaction.getGLItem() != null) {
+ for (FIN_FinancialAccountAccounting account : accounts) {
+ if ("BPD".equals(transaction.getTransactionType())
+ && account.getClearedPaymentAccount() != null) {
+ transactionsToBePosted.add(transaction);
+ } else if ("BPW".equals(transaction.getTransactionType())
+ && account.getClearedPaymentAccountOUT() != null) {
+ transactionsToBePosted.add(transaction);
+ }
+ }
+ } else {
+ for (FIN_FinancialAccountAccounting account : accounts) {
+ if ("BF".equals(transaction.getTransactionType())
+ && account.getClearedPaymentAccountOUT() != null) {
+ transactionsToBePosted.add(transaction);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ return false;
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ if (transactionsToBePosted.size() == 0) {
+ return false;
+ }
+ return true;
+ }
+
private boolean isLastReconciliation(FIN_Reconciliation reconciliation) {
final OBCriteria<FIN_Reconciliation> obc =
OBDal.getInstance().createCriteria(
FIN_Reconciliation.class);
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits