[Reconciliation Refactor] Removes session check implementation for reconciliation. UI check: updated not changed. Server check: hibernate lock
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Wed, 17 Sep 2014 14:26:26 +0200
changeset 24678 2bf04c456587
parent 24677 2eba7d34bea9
child 24679 0aa49ea74295
[Reconciliation Refactor] Removes session check implementation for reconciliation. UI check: updated not changed. Server check: hibernate lock
modules/org.openbravo.advpaymentmngt/src-db/database/model/modifiedTables/FIN_RECONCILIATION.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/CheckRecordChangedActionHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/MatchStatementActionHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/MatchStatementOnLoadActionHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/UnMatchTransactionActionHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/APRM_MatchingUtility.java
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/modifiedTables/FIN_RECONCILIATION.xml	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/modifiedTables/FIN_RECONCILIATION.xml	Wed Sep 17 14:26:26 2014 +0200
@@ -21,10 +21,6 @@
         <default><![CDATA[P]]></default>
         <onCreateDefault/>
       </column>
-      <column name="EM_APRM_PROCESSING_SESSION" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
-        <default/>
-        <onCreateDefault/>
-      </column>
       <check name="EM_APRM_REC_PRINTDET_CHK"><![CDATA[EM_APRM_PRINTDETAILED IN ('Y', 'N')]]></check>
       <check name="EM_APRM_REC_PRINTSUM_CHK"><![CDATA[EM_APRM_PRINTSUMMARY IN ('Y', 'N')]]></check>
     </table>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Wed Sep 17 14:26:26 2014 +0200
@@ -777,41 +777,6 @@
 <!--18096D8809024E67A36E636EA0D9D0E7-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--18096D8809024E67A36E636EA0D9D0E7--></AD_COLUMN>
 
-<!--1BF56D6D34B44896AB89633FA1E112B0--><AD_COLUMN>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_COLUMN_ID><![CDATA[1BF56D6D34B44896AB89633FA1E112B0]]></AD_COLUMN_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <NAME><![CDATA[EM_Aprm_Processing_Session]]></NAME>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <DESCRIPTION><![CDATA[Session ID processing this record]]></DESCRIPTION>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <HELP><![CDATA[Session ID processing this record]]></HELP>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <COLUMNNAME><![CDATA[EM_Aprm_Processing_Session]]></COLUMNNAME>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_TABLE_ID><![CDATA[B1B7075C46934F0A9FD4C4D0F1457B42]]></AD_TABLE_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISKEY><![CDATA[N]]></ISKEY>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISPARENT><![CDATA[N]]></ISPARENT>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <SEQNO><![CDATA[290]]></SEQNO>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_ELEMENT_ID><![CDATA[BF32646C0ABD41258D004CAA1915DF44]]></AD_ELEMENT_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <POSITION><![CDATA[28]]></POSITION>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
-<!--1BF56D6D34B44896AB89633FA1E112B0-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--1BF56D6D34B44896AB89633FA1E112B0--></AD_COLUMN>
-
 <!--1CDAC09BBD9A46AE8FD9D5249092B6EF--><AD_COLUMN>
 <!--1CDAC09BBD9A46AE8FD9D5249092B6EF-->  <AD_COLUMN_ID><![CDATA[1CDAC09BBD9A46AE8FD9D5249092B6EF]]></AD_COLUMN_ID>
 <!--1CDAC09BBD9A46AE8FD9D5249092B6EF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -8751,6 +8716,38 @@
 <!--A6F530DEA28844FE90B788AD0E437106-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--A6F530DEA28844FE90B788AD0E437106--></AD_COLUMN>
 
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0--><AD_COLUMN>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_COLUMN_ID><![CDATA[A7389A5DCC6D4D33B9ED1785EC5BA3A0]]></AD_COLUMN_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <NAME><![CDATA[bslUpdated]]></NAME>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <COLUMNNAME><![CDATA[bslUpdated]]></COLUMNNAME>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_TABLE_ID><![CDATA[BC21981DCF0846338D631887BEDFE7FA]]></AD_TABLE_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_REFERENCE_ID><![CDATA[16]]></AD_REFERENCE_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISUPDATEABLE><![CDATA[N]]></ISUPDATEABLE>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <SEQNO><![CDATA[190]]></SEQNO>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_ELEMENT_ID><![CDATA[607]]></AD_ELEMENT_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--A7389A5DCC6D4D33B9ED1785EC5BA3A0--></AD_COLUMN>
+
 <!--A7AA3F7ABB27453795B97A175662F61A--><AD_COLUMN>
 <!--A7AA3F7ABB27453795B97A175662F61A-->  <AD_COLUMN_ID><![CDATA[A7AA3F7ABB27453795B97A175662F61A]]></AD_COLUMN_ID>
 <!--A7AA3F7ABB27453795B97A175662F61A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Wed Sep 17 14:26:26 2014 +0200
@@ -8073,6 +8073,33 @@
 <!--74BA3651D26349AEA134E0CB79CC3A61-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--74BA3651D26349AEA134E0CB79CC3A61--></AD_FIELD>
 
+<!--75E24F44C2F34699A21222ACA723244E--><AD_FIELD>
+<!--75E24F44C2F34699A21222ACA723244E-->  <AD_FIELD_ID><![CDATA[75E24F44C2F34699A21222ACA723244E]]></AD_FIELD_ID>
+<!--75E24F44C2F34699A21222ACA723244E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--75E24F44C2F34699A21222ACA723244E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--75E24F44C2F34699A21222ACA723244E-->  <NAME><![CDATA[bslUpdated]]></NAME>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--75E24F44C2F34699A21222ACA723244E-->  <AD_TAB_ID><![CDATA[ED54A4E24196476596955286D403461E]]></AD_TAB_ID>
+<!--75E24F44C2F34699A21222ACA723244E-->  <AD_COLUMN_ID><![CDATA[A7389A5DCC6D4D33B9ED1785EC5BA3A0]]></AD_COLUMN_ID>
+<!--75E24F44C2F34699A21222ACA723244E-->  <PROPERTY><![CDATA[bslUpdated]]></PROPERTY>
+<!--75E24F44C2F34699A21222ACA723244E-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--75E24F44C2F34699A21222ACA723244E-->  <DISPLAYLENGTH><![CDATA[0]]></DISPLAYLENGTH>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--75E24F44C2F34699A21222ACA723244E-->  <SEQNO><![CDATA[0]]></SEQNO>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--75E24F44C2F34699A21222ACA723244E-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--75E24F44C2F34699A21222ACA723244E-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--75E24F44C2F34699A21222ACA723244E-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--75E24F44C2F34699A21222ACA723244E-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--75E24F44C2F34699A21222ACA723244E-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--75E24F44C2F34699A21222ACA723244E-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--75E24F44C2F34699A21222ACA723244E--></AD_FIELD>
+
 <!--762F50D5DFA74180B0E88B3FCBFE13DE--><AD_FIELD>
 <!--762F50D5DFA74180B0E88B3FCBFE13DE-->  <AD_FIELD_ID><![CDATA[762F50D5DFA74180B0E88B3FCBFE13DE]]></AD_FIELD_ID>
 <!--762F50D5DFA74180B0E88B3FCBFE13DE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Sep 17 14:26:26 2014 +0200
@@ -1201,6 +1201,18 @@
 <!--C5133F7FD55D4AF6B8B7FB527BFB9920-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--C5133F7FD55D4AF6B8B7FB527BFB9920--></AD_MESSAGE>
 
+<!--C6F7E24F731242D49A73C8C1A835A252--><AD_MESSAGE>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <AD_MESSAGE_ID><![CDATA[C6F7E24F731242D49A73C8C1A835A252]]></AD_MESSAGE_ID>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <VALUE><![CDATA[APRM_StaleDate]]></VALUE>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <MSGTEXT><![CDATA[This record has already been changed by another user or process.]]></MSGTEXT>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--C6F7E24F731242D49A73C8C1A835A252-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--C6F7E24F731242D49A73C8C1A835A252--></AD_MESSAGE>
+
 <!--CAB70EC8598D40E0BFFD7F0FB8538080--><AD_MESSAGE>
 <!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_MESSAGE_ID><![CDATA[CAB70EC8598D40E0BFFD7F0FB8538080]]></AD_MESSAGE_ID>
 <!--CAB70EC8598D40E0BFFD7F0FB8538080-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml	Wed Sep 17 14:26:26 2014 +0200
@@ -204,7 +204,7 @@
 <!--BC21981DCF0846338D631887BEDFE7FA-->  <HQLQUERY><![CDATA[select bsl.transactionDate as banklineDate, case when bp is null then bsl.bpartnername  else bp.name end AS businessPartner, bsl.referenceNo as referenceNo, bsl.cramount - bsl.dramount as amount, bsl.id as match, bsl.matchingtype as affinity, 
 case when fat is null then false else true end AS cleared,
 bsl.matchingtype as matchingtype, bsl.id as id, 
-fat.transactionDate as transactionDate, transactionBP.name as transactionBPName, fat.depositAmount - fat.paymentAmount as transactionAmount, bsl.lineNo as lineNo, fat as fin_finacc_transaction_id, bsl.description, case when bsl.cramount - bsl.dramount >0 then 'D' else 'P' end as type, bsl.matchedDocument, transactionGLItem.name as transactionGLItemName, glitem.name as glitemName
+fat.transactionDate as transactionDate, transactionBP.name as transactionBPName, fat.depositAmount - fat.paymentAmount as transactionAmount, bsl.lineNo as lineNo, fat as fin_finacc_transaction_id, bsl.description, case when bsl.cramount - bsl.dramount >0 then 'D' else 'P' end as type, bsl.matchedDocument, transactionGLItem.name as transactionGLItemName, glitem.name as glitemName, bsl.updated as bslUpdated
  @selectClause@
 from FIN_BankStatementLine as bsl
  join bsl.bankStatement as bs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/CheckRecordChangedActionHandler.java	Wed Sep 17 14:26:26 2014 +0200
@@ -0,0 +1,80 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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.advpaymentmngt.actionHandler;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.financialmgmt.payment.FIN_BankStatementLine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CheckRecordChangedActionHandler extends BaseActionHandler {
+  private static final Logger log = LoggerFactory.getLogger(CheckRecordChangedActionHandler.class);
+
+  @Override
+  protected JSONObject execute(Map<String, Object> parameters, String data) {
+    JSONObject result = new JSONObject();
+    JSONObject errorMessage = new JSONObject();
+    try {
+      OBContext.setAdminMode(true);
+      final JSONObject jsonData = new JSONObject(data);
+      final String strBankStatementLineId = jsonData.getString("bankStatementLineId");
+      final long updated = jsonData.getLong("updated");
+      final FIN_BankStatementLine bsline = OBDal.getInstance().get(FIN_BankStatementLine.class,
+          strBankStatementLineId);
+      Date bbddBSLUpdated = bsline.getUpdated();
+      // Remove milliseconds to compare against updated from UI
+      Calendar calendar = Calendar.getInstance();
+      calendar.setTime(bbddBSLUpdated);
+      calendar.setLenient(true);
+      calendar.set(Calendar.MILLISECOND, 0);
+      if (updated != calendar.getTimeInMillis()) {
+        errorMessage = new JSONObject();
+        errorMessage.put("severity", "error");
+        errorMessage.put("title", "Error");
+        errorMessage.put("text", OBMessageUtils.messageBD("APRM_StaleDate"));
+        result.put("message", errorMessage);
+        return result;
+      }
+    } catch (JSONException e) {
+      log.error("Error parsing JSON Object.", e);
+      try {
+        errorMessage = new JSONObject();
+        errorMessage.put("severity", "error");
+        errorMessage.put("title", "Error");
+        errorMessage.put("text", "");
+        result.put("message", errorMessage);
+      } catch (Exception e2) {
+        log.error("Message could not be built", e2);
+      }
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    return result;
+  }
+}
\ No newline at end of file
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/MatchStatementActionHandler.java	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/MatchStatementActionHandler.java	Wed Sep 17 14:26:26 2014 +0200
@@ -53,7 +53,7 @@
       final FIN_Reconciliation lastReconciliation = TransactionsDao.getLastReconciliation(
           finAccount, "N");
       strReconciliationId = lastReconciliation.getId();
-      APRM_MatchingUtility.setProcessingReconciliation(lastReconciliation);
+      // APRM_MatchingUtility.setProcessingReconciliation(lastReconciliation);
       if (APRM_MatchingUtility.updateReconciliation(lastReconciliation, finAccount, true)) {
         final VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
         final JSONObject msg = new JSONObject();
@@ -80,7 +80,7 @@
       }
     } finally {
       OBContext.restorePreviousMode();
-      APRM_MatchingUtility.setNotProcessingReconciliation(strReconciliationId);
+      // APRM_MatchingUtility.setNotProcessingReconciliation(strReconciliationId);
     }
     return jsonResponse;
   }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/MatchStatementOnLoadActionHandler.java	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/MatchStatementOnLoadActionHandler.java	Wed Sep 17 14:26:26 2014 +0200
@@ -70,10 +70,7 @@
       if (reconciliation == null) {
         // Create a new reconciliation
         reconciliation = APRM_MatchingUtility.addNewDraftReconciliation(financialAccount);
-        APRM_MatchingUtility.setProcessingReconciliation(reconciliation);
       } else {
-        // Reuse last reconciliation
-        APRM_MatchingUtility.setProcessingReconciliation(reconciliation);
         APRM_MatchingUtility.fixMixedLines(reconciliation);
         APRM_MatchingUtility.updateReconciliation(reconciliation, financialAccount, false);
       }
@@ -113,7 +110,6 @@
       }
     } finally {
       OBContext.restorePreviousMode();
-      APRM_MatchingUtility.setNotProcessingReconciliation(strReconciliationId);
     }
 
     return jsonResponse;
@@ -122,7 +118,6 @@
   private int runAutoMatchingAlgorithm(String strReconciliationId,
       final String strFinancialAccountId, final FIN_FinancialAccount financialAccount,
       FIN_Reconciliation reconciliation) throws InterruptedException, SQLException {
-    APRM_MatchingUtility.setProcessingReconciliation(reconciliation);
     final MatchingAlgorithm ma = financialAccount.getMatchingAlgorithm();
     final FIN_MatchingTransaction matchingTransaction = new FIN_MatchingTransaction(
         ma.getJavaClassName());
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/UnMatchTransactionActionHandler.java	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/UnMatchTransactionActionHandler.java	Wed Sep 17 14:26:26 2014 +0200
@@ -19,6 +19,8 @@
 
 package org.openbravo.advpaymentmngt.actionHandler;
 
+import java.util.Calendar;
+import java.util.Date;
 import java.util.Map;
 
 import org.codehaus.jettison.json.JSONObject;
@@ -29,8 +31,8 @@
 import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.model.financialmgmt.payment.FIN_BankStatementLine;
 import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
-import org.openbravo.model.financialmgmt.payment.FIN_Reconciliation;
 import org.openbravo.service.db.DbUtility;
+import org.openbravo.service.json.OBStaleObjectException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,21 +43,25 @@
   protected JSONObject execute(Map<String, Object> parameters, String data) {
     JSONObject result = new JSONObject();
     JSONObject errorMessage = new JSONObject();
-    String reconciliationId = null;
     try {
       OBContext.setAdminMode(true);
       final JSONObject jsonData = new JSONObject(data);
       final String strBankStatementLineId = jsonData.getString("bankStatementLineId");
+      final long updated = jsonData.getLong("updated");
       final FIN_BankStatementLine bsline = OBDal.getInstance().get(FIN_BankStatementLine.class,
           strBankStatementLineId);
+      Date bbddBSLUpdated = bsline.getUpdated();
+      // Remove milis
+      Calendar calendar = Calendar.getInstance();
+      calendar.setTime(bbddBSLUpdated);
+      calendar.setLenient(true);
+      calendar.set(Calendar.MILLISECOND, 0);
+      if (updated != calendar.getTimeInMillis()) {
+        throw new OBStaleObjectException("@APRM_StaleDate@");
+      }
       final FIN_FinaccTransaction transaction = bsline.getFinancialAccountTransaction();
 
       if (transaction != null) {
-        final FIN_Reconciliation reconciliation = transaction.getReconciliation();
-        if (reconciliation != null) {
-          reconciliationId = reconciliation.getId();
-          APRM_MatchingUtility.setProcessingReconciliation(reconciliation);
-        }
         APRM_MatchingUtility.unmatch(bsline);
       }
     } catch (Exception e) {
@@ -74,8 +80,8 @@
       }
     } finally {
       OBContext.restorePreviousMode();
-      APRM_MatchingUtility.setNotProcessingReconciliation(reconciliationId);
     }
     return result;
   }
+
 }
\ No newline at end of file
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/APRM_MatchingUtility.java	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/APRM_MatchingUtility.java	Wed Sep 17 14:26:26 2014 +0200
@@ -20,12 +20,10 @@
 package org.openbravo.advpaymentmngt.utility;
 
 import java.math.BigDecimal;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 
 import javax.servlet.http.HttpSession;
 
@@ -33,8 +31,11 @@
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
 import org.hibernate.ScrollMode;
 import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
 import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
@@ -56,7 +57,6 @@
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.erpCommon.utility.Utility;
-import org.openbravo.model.ad.access.Session;
 import org.openbravo.model.ad.datamodel.Table;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.currency.Currency;
@@ -197,6 +197,28 @@
   }
 
   /**
+   * Process to get and lock a Bank Statement Line. Required for processes which should manage
+   * concurrency
+   * 
+   * @param id
+   *          String containing Bank Statement Line id.
+   * @return Returns related Bank Statement line object performing a select for update
+   */
+  public static FIN_BankStatementLine getLockedBSL(String id) {
+    FIN_BankStatementLine result = null;
+    final StringBuilder hqlString = new StringBuilder();
+    hqlString.append(" select e");
+    hqlString.append(" from FIN_BankStatementLine as e");
+    hqlString.append(" where e.id = :id");
+    final Session session = OBDal.getInstance().getSession();
+    Query query = session.createQuery(hqlString.toString());
+    query.setParameter("id", id);
+    query.setLockMode("e", LockMode.PESSIMISTIC_WRITE);
+    result = (FIN_BankStatementLine) query.uniqueResult();
+    return result;
+  }
+
+  /**
    * Match a bank statement line with a financial account transaction. If the bank statement has
    * associated a transaction, it is first unmatched and then matched against the given transaction.
    * 
@@ -210,13 +232,12 @@
    *         is controlled by the throwException boolean parameter
    * 
    */
-  public static boolean matchBankStatementLine(final FIN_BankStatementLine bankStatementLine,
+  public static boolean matchBankStatementLine(final FIN_BankStatementLine _bankStatementLine,
       final FIN_FinaccTransaction transaction, final FIN_Reconciliation reconciliation,
       final String matchLevel, boolean throwException) {
     try {
       OBContext.setAdminMode(true);
-      // OBDal.getInstance().getSession().buildLockRequest(LockOptions.NONE)
-      // .lock(BankStatementLine.ENTITY_NAME, bankStatementLine);
+      FIN_BankStatementLine bankStatementLine = getLockedBSL(_bankStatementLine.getId());
 
       if (transaction != null) {
         // Unmatch the previous line
@@ -297,9 +318,10 @@
    * @param bsline
    *          Bank Statement Line to be unmatched from a transaction
    */
-  public static void unmatch(final FIN_BankStatementLine bsline) {
+  public static void unmatch(final FIN_BankStatementLine _bsline) {
     try {
       OBContext.setAdminMode(true);
+      FIN_BankStatementLine bsline = getLockedBSL(_bsline.getId());
       final FIN_FinaccTransaction finTrans = bsline.getFinancialAccountTransaction();
       if (finTrans != null) {
         finTrans.setReconciliation(null);
@@ -359,7 +381,7 @@
    * @param bsline
    *          Bank Statement Line.
    */
-  public static void mergeBankStatementLine(FIN_BankStatementLine bsline) {
+  private static void mergeBankStatementLine(FIN_BankStatementLine bsline) {
     BigDecimal totalCredit = bsline.getCramount();
     BigDecimal totalDebit = bsline.getDramount();
     FIN_BankStatement bs = bsline.getBankStatement();
@@ -527,38 +549,6 @@
   }
 
   /**
-   * Wait till a reconciliation is not being processed by an active session different from the
-   * current context session
-   * 
-   * @param reconciliation
-   *          The reconciliation that is being processing
-   */
-  public static void waitIfNecessary(FIN_Reconciliation reconciliation) throws InterruptedException {
-    try {
-      OBContext.setAdminMode(true);
-      final String contextSessionId = getContextSessionId();
-      final String reconciliationProcessSessionId = reconciliation.getAprmProcessingSession();
-      Session reconciliationProcessSession = null;
-
-      if (StringUtils.isNotBlank(reconciliationProcessSessionId)) {
-        reconciliationProcessSession = OBDal.getInstance().get(Session.class,
-            reconciliationProcessSessionId);
-      }
-      while (reconciliation.isProcessNow()
-          && !StringUtils.equals(contextSessionId, reconciliationProcessSessionId)
-          && reconciliationProcessSession != null && reconciliationProcessSession.isSessionActive()) {
-        TimeUnit.MILLISECONDS.sleep(200);
-        OBDal.getInstance().refresh(reconciliation);
-        if (reconciliationProcessSession != null) {
-          OBDal.getInstance().refresh(reconciliationProcessSession);
-        }
-      }
-    } finally {
-      OBContext.restorePreviousMode();
-    }
-  }
-
-  /**
    * Returns the current context session ID (from HttpSession)
    * 
    * @return ID with the #AD_SESSION_ID
@@ -569,47 +559,6 @@
   }
 
   /**
-   * Sets the reconciliation as being processed pointing to the session ID that have requested it
-   * and flushes to the database.
-   * 
-   * If the reconciliation is being processed by another active session, then this method will wait
-   * until the other process unlock it (see {@link #waitIfNecessary(FIN_Reconciliation)}.
-   * 
-   */
-  public static void setProcessingReconciliation(final FIN_Reconciliation reconciliation)
-      throws InterruptedException, SQLException {
-    waitIfNecessary(reconciliation);
-    reconciliation.setProcessNow(true);
-    reconciliation.setAprmProcessingSession(getContextSessionId());
-    // Necessary to save in database the session id
-    OBDal.getInstance().save(reconciliation);
-    OBDal.getInstance().flush();
-    OBDal.getInstance().getConnection().commit();
-  }
-
-  /**
-   * Sets the reconciliation as not being processed, removes the information about the session ID
-   * that previously processed it and flushes to the database
-   * 
-   */
-  public static void setNotProcessingReconciliation(final String reconciliationId) {
-    if (StringUtils.isNotBlank(reconciliationId)) {
-      try {
-        OBContext.setAdminMode(true);
-        final FIN_Reconciliation reconciliation = OBDal.getInstance().get(FIN_Reconciliation.class,
-            reconciliationId);
-        reconciliation.setProcessNow(false);
-        reconciliation.setAprmProcessingSession(null);
-        OBDal.getInstance().save(reconciliation);
-      } finally {
-        OBContext.restorePreviousMode();
-      }
-
-      OBDal.getInstance().flush();
-    }
-  }
-
-  /**
    * Get the bank statement lines that are not yet matched to a transaction for the given financial
    * account. If the reconciliation passed as parameter is the last one, the method filters by the
    * bank statement lines with transaction date less or equal than the reconciliation's ending date
@@ -757,7 +706,7 @@
    * transaction
    * 
    */
-  public static void splitBankStatementLine(final FIN_Reconciliation reconciliation,
+  private static void splitBankStatementLine(final FIN_Reconciliation reconciliation,
       final FIN_BankStatementLine bankStatementLine, final FIN_FinaccTransaction transaction) {
     try {
       OBContext.setAdminMode(true);
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js	Wed Sep 17 14:26:26 2014 +0200
@@ -96,19 +96,33 @@
         var processId = '154CB4F9274A479CB38A285E16984539',
             grid = me.grid,
             record = me.record,
-            standardWindow = grid.view.parentWindow.view.standardWindow;
-
-        var process = standardWindow.openProcess({
-          callerField: me,
-          paramWindow: true,
-          processId: processId,
-          windowId: grid.view.windowId,
-          externalParams: {
-            bankStatementLineId: record.id,
-            transactionDate: record.transactionDate
-          },
-          windowTitle: OB.I18N.getLabel('APRM_MATCHTRANSACTION_SEARCH_BUTTON', [this.title])
-        });
+            standardWindow = grid.view.parentWindow.view.standardWindow, 
+            process, 
+            callback, 
+            bankStatementLineId = me.record.id, 
+            updated = me.record.bslUpdated.getTime() + me.record.bslUpdated.getTimezoneOffset() * 60000,
+            view = me.grid.view;
+	    callback = function (response, data, request) {
+	      view.onRefreshFunction(view);
+	      if (data && data.message && data.message.severity === 'error') {
+	        view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, data.message.title, data.message.text);
+	      }else{
+            var process = standardWindow.openProcess({
+              callerField: me,
+              paramWindow: true,
+              processId: processId,
+              windowId: grid.view.windowId,
+              externalParams: {
+                bankStatementLineId: record.id,
+                transactionDate: record.transactionDate
+              },
+              windowTitle: OB.I18N.getLabel('APRM_MATCHTRANSACTION_SEARCH_BUTTON', [this.title])
+            });
+	      }
+	    };
+	    OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.CheckRecordChangedActionHandler', {
+	      bankStatementLineId: bankStatementLineId, updated: updated
+	    }, {}, callback);
       }
     });
 
@@ -120,18 +134,32 @@
         var processId = 'E68790A7B65F4D45AB35E2BAE34C1F39',
             grid = me.grid,
             record = me.record,
-            standardWindow = grid.view.parentWindow.view.standardWindow;
-
-        var process = standardWindow.openProcess({
-          callerField: me,
-          paramWindow: true,
-          processId: processId,
-          windowId: grid.view.windowId,
-          externalParams: {
-            bankStatementLineId: me.record.id
-          },
-          windowTitle: OB.I18N.getLabel('APRM_MATCHTRANSACTION_ADD_BUTTON', [this.title])
-        });
+            standardWindow = grid.view.parentWindow.view.standardWindow, 
+            process, 
+            callback, 
+            bankStatementLineId = me.record.id, 
+            updated = me.record.bslUpdated.getTime() + me.record.bslUpdated.getTimezoneOffset() * 60000,
+            view = me.grid.view;
+	    callback = function (response, data, request) {
+	      view.onRefreshFunction(view);
+	      if (data && data.message && data.message.severity === 'error') {
+	        view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, data.message.title, data.message.text);
+	      }else{
+	        process = standardWindow.openProcess({
+	            callerField: me,
+	            paramWindow: true,
+	            processId: processId,
+	            windowId: grid.view.windowId,
+	            externalParams: {
+	              bankStatementLineId: me.record.id
+	            },
+	            windowTitle: OB.I18N.getLabel('APRM_MATCHTRANSACTION_ADD_BUTTON', [this.title])
+	          });
+	      }
+	    };
+	    OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.CheckRecordChangedActionHandler', {
+	      bankStatementLineId: bankStatementLineId, updated: updated
+	    }, {}, callback);
       }
     });
 
@@ -141,7 +169,7 @@
       originalPrompt: OB.I18N.getLabel('APRM_MATCHTRANSACTION_DELETE_BUTTON'),
       prompt: OB.I18N.getLabel('APRM_MATCHTRANSACTION_DELETE_BUTTON'),
       action: function () {
-        var callback, bankStatementLineId = me.record.id,
+        var callback, bankStatementLineId = me.record.id, updated = me.record.bslUpdated.getTime() + me.record.bslUpdated.getTimezoneOffset() * 60000,
             view = me.grid.view;
         callback = function (response, data, request) {
           view.onRefreshFunction(view);
@@ -150,7 +178,7 @@
           }
         };
         OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.UnMatchTransactionActionHandler', {
-          bankStatementLineId: bankStatementLineId
+          bankStatementLineId: bankStatementLineId, updated: updated
         }, {}, callback);
       }
     });
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java	Wed Sep 17 11:23:17 2014 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataToJsonConverter.java	Wed Sep 17 14:26:26 2014 +0200
@@ -391,12 +391,12 @@
       // See issue https://issues.openbravo.com/view.php?id=22971
       return "";
     }
+    if (value instanceof Timestamp) {
+      return xmlDateTimeFormat.format(value);
+    }
     if (value instanceof Date) {
       return xmlDateFormat.format(value);
     }
-    if (value instanceof Timestamp) {
-      return xmlDateTimeFormat.format(value);
-    }
     return value;
   }