Fixes Issue 22663. Allows to Import lines with older date, but not
authorDavid Miguelez <david.miguelez@openbravo.com>
Tue, 29 Jan 2013 12:47:05 +0100
changeset 19483 f01e796f420f
parent 19482 4c1fdc3c495d
child 19484 c23ede3e6755
Fixes Issue 22663. Allows to Import lines with older date, but not
to process them.
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_BankStatementProcess.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Jan 29 12:40:45 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Jan 29 12:47:05 2013 +0100
@@ -540,6 +540,17 @@
 <!--8E01FDCFBE034863898A47F1AE37BB15-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--8E01FDCFBE034863898A47F1AE37BB15--></AD_MESSAGE>
 
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F--><AD_MESSAGE>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <AD_MESSAGE_ID><![CDATA[8EF25E4AD4EF46E4BCE4E0FACAFC717F]]></AD_MESSAGE_ID>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <VALUE><![CDATA[APRM_BankStatementLineWrongDateWarning]]></VALUE>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <MSGTEXT><![CDATA[Bank statement line with wrong date. Cannot process lines previous to ]]></MSGTEXT>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--8EF25E4AD4EF46E4BCE4E0FACAFC717F--></AD_MESSAGE>
+
 <!--92EC1935A8B947BA83EF82DBD169CA8B--><AD_MESSAGE>
 <!--92EC1935A8B947BA83EF82DBD169CA8B-->  <AD_MESSAGE_ID><![CDATA[92EC1935A8B947BA83EF82DBD169CA8B]]></AD_MESSAGE_ID>
 <!--92EC1935A8B947BA83EF82DBD169CA8B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -804,6 +815,17 @@
 <!--C5133F7FD55D4AF6B8B7FB527BFB9920-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--C5133F7FD55D4AF6B8B7FB527BFB9920--></AD_MESSAGE>
 
+<!--CAB70EC8598D40E0BFFD7F0FB8538080--><AD_MESSAGE>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_MESSAGE_ID><![CDATA[CAB70EC8598D40E0BFFD7F0FB8538080]]></AD_MESSAGE_ID>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <VALUE><![CDATA[APRM_BankStatementLineWrongDateWarning2]]></VALUE>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <MSGTEXT><![CDATA[Check the lines with Line No.:]]></MSGTEXT>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--CAB70EC8598D40E0BFFD7F0FB8538080--></AD_MESSAGE>
+
 <!--CCA38D3048F04C1FA6F05AD56CF81B5D--><AD_MESSAGE>
 <!--CCA38D3048F04C1FA6F05AD56CF81B5D-->  <AD_MESSAGE_ID><![CDATA[CCA38D3048F04C1FA6F05AD56CF81B5D]]></AD_MESSAGE_ID>
 <!--CCA38D3048F04C1FA6F05AD56CF81B5D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_BankStatementProcess.java	Tue Jan 29 12:40:45 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_BankStatementProcess.java	Tue Jan 29 12:47:05 2013 +0100
@@ -54,22 +54,30 @@
         if (maxBSLDate != null) {
           for (FIN_BankStatementLine bsl : bankStatement.getFINBankStatementLineList()) {
             if (bsl.getTransactionDate().compareTo(maxBSLDate) <= 0) {
-              msg.setType("Error");
-              msg.setTitle(FIN_Utility.messageBD("Error"));
-              String pattern = OBPropertiesProvider.getInstance().getOpenbravoProperties()
-                  .getProperty("dateFormat.java");
-              msg.setMessage(FIN_Utility.messageBD("APRM_BankStatementLineWrongDate")
-                  + Utility.formatDate(maxBSLDate, pattern));
-              bundle.setResult(msg);
-              return;
+              if (!msg.getMessage().equals("")) {
+                msg.setMessage(msg.getMessage() + ", " + bsl.getLineNo());
+              } else {
+                msg.setType("Warning");
+                msg.setTitle(FIN_Utility.messageBD("Warning"));
+                String pattern = OBPropertiesProvider.getInstance().getOpenbravoProperties()
+                    .getProperty("dateFormat.java");
+                msg.setMessage(msg.getMessage()
+                    + FIN_Utility.messageBD("APRM_BankStatementLineWrongDateWarning")
+                    + Utility.formatDate(maxBSLDate, pattern) + ". "
+                    + FIN_Utility.messageBD("APRM_BankStatementLineWrongDateWarning2") + " "
+                    + bsl.getLineNo());
+              }
             }
           }
         }
 
-        bankStatement.setProcessed(true);
-        bankStatement.setAPRMProcessBankStatement("R");
-        OBDal.getInstance().save(bankStatement);
-        OBDal.getInstance().flush();
+        if (msg.getType() == null && !msg.getType().toLowerCase().equals("warning")) {
+          // Success
+          bankStatement.setProcessed(true);
+          bankStatement.setAPRMProcessBankStatement("R");
+          OBDal.getInstance().save(bankStatement);
+          OBDal.getInstance().flush();
+        }
       } else if (strAction.equals("R")) {
         // *************************
         // Reactivate Bank Statement
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java	Tue Jan 29 12:40:45 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_BankStatementImport.java	Tue Jan 29 12:47:05 2013 +0100
@@ -175,7 +175,8 @@
       OBDal.getInstance().rollbackAndClose();
       return getMyError();
     }
-    if (getMyError() != null && !getMyError().getType().toLowerCase().equals("success")) {
+    if (getMyError() != null && !getMyError().getType().toLowerCase().equals("success")
+        && !getMyError().getType().toLowerCase().equals("warning")) {
       OBDal.getInstance().rollbackAndClose();
       return getMyError();
     } else if (getMyError() != null && getMyError().getType().toLowerCase().equals("success")) {
@@ -190,6 +191,8 @@
         setMyError(msg);
       }
       return getMyError();
+    } else if (getMyError() != null && getMyError().getType().toLowerCase().equals("warning")) {
+      return getMyError();
     } else {
       return getOBError(conn, vars, "@APRM_BankStatementNo@ " + bankStatement.getDocumentNo()
           + "<br/>" + numberOfLines + " " + "@RowsInserted@", "Success", "Success");