[Reconciliation] Implement Read Only and Display Logic in Java
authorUnai Martirena <unai.martirena@openbravo.com>
Tue, 29 Jul 2014 13:55:27 +0200
changeset 24478 95ea39040fbc
parent 24477 bcf036c0887a
child 24479 7640e931fea8
[Reconciliation] Implement Read Only and Display Logic in Java
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentDisplayLogicActionHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsExpression.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsExpression.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsHandler.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDisplayLogics.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentReadOnlyLogics.java
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Tue Jul 22 17:52:14 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Tue Jul 29 13:55:27 2014 +0200
@@ -49,6 +49,29 @@
 <!--0586B9F7ED4147758536007BF402F1DF-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--0586B9F7ED4147758536007BF402F1DF--></OBUIAPP_PARAMETER>
 
+<!--075F4BA7A03F4548A7A501BAFD073DEE--><OBUIAPP_PARAMETER>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <OBUIAPP_PARAMETER_ID><![CDATA[075F4BA7A03F4548A7A501BAFD073DEE]]></OBUIAPP_PARAMETER_ID>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <NAME><![CDATA[Payment Method Read Only Logic]]></NAME>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <SEQNO><![CDATA[1160]]></SEQNO>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <COLUMNNAME><![CDATA[payment_method_readonly_logic]]></COLUMNNAME>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--075F4BA7A03F4548A7A501BAFD073DEE-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--075F4BA7A03F4548A7A501BAFD073DEE--></OBUIAPP_PARAMETER>
+
 <!--0A9E075CCC6E4D59AAC37E3AEF1FE269--><OBUIAPP_PARAMETER>
 <!--0A9E075CCC6E4D59AAC37E3AEF1FE269-->  <OBUIAPP_PARAMETER_ID><![CDATA[0A9E075CCC6E4D59AAC37E3AEF1FE269]]></OBUIAPP_PARAMETER_ID>
 <!--0A9E075CCC6E4D59AAC37E3AEF1FE269-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -93,7 +116,7 @@
 <!--0E081905DD9646A2AFB296F81C1AA62E-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--0E081905DD9646A2AFB296F81C1AA62E-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--0E081905DD9646A2AFB296F81C1AA62E-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--0E081905DD9646A2AFB296F81C1AA62E-->  <READONLYLOGIC><![CDATA[OB.PropertyStore.get('NotAllowChangeExchange', this.view.windowId) == 'Y']]></READONLYLOGIC>
+<!--0E081905DD9646A2AFB296F81C1AA62E-->  <READONLYLOGIC><![CDATA[@converted_amount_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--0E081905DD9646A2AFB296F81C1AA62E-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.convertedAmountOnChange]]></ONCHANGEFUNCTION>
 <!--0E081905DD9646A2AFB296F81C1AA62E-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--0E081905DD9646A2AFB296F81C1AA62E-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
@@ -149,6 +172,29 @@
 <!--12F5A54CF6FA4702B147CC08BC664051-->  <ONGRIDLOADFUNCTION><![CDATA[OB.APRM.AddPayment.orderInvoiceOnLoadGrid]]></ONGRIDLOADFUNCTION>
 <!--12F5A54CF6FA4702B147CC08BC664051--></OBUIAPP_PARAMETER>
 
+<!--155F39F5EB144A648F409C115D61A489--><OBUIAPP_PARAMETER>
+<!--155F39F5EB144A648F409C115D61A489-->  <OBUIAPP_PARAMETER_ID><![CDATA[155F39F5EB144A648F409C115D61A489]]></OBUIAPP_PARAMETER_ID>
+<!--155F39F5EB144A648F409C115D61A489-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--155F39F5EB144A648F409C115D61A489-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--155F39F5EB144A648F409C115D61A489-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--155F39F5EB144A648F409C115D61A489-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--155F39F5EB144A648F409C115D61A489-->  <NAME><![CDATA[Payment Date Read Only Logic]]></NAME>
+<!--155F39F5EB144A648F409C115D61A489-->  <SEQNO><![CDATA[1190]]></SEQNO>
+<!--155F39F5EB144A648F409C115D61A489-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--155F39F5EB144A648F409C115D61A489-->  <COLUMNNAME><![CDATA[payment_date_readonly_logic]]></COLUMNNAME>
+<!--155F39F5EB144A648F409C115D61A489-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--155F39F5EB144A648F409C115D61A489-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--155F39F5EB144A648F409C115D61A489-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--155F39F5EB144A648F409C115D61A489-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--155F39F5EB144A648F409C115D61A489-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--155F39F5EB144A648F409C115D61A489-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--155F39F5EB144A648F409C115D61A489-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--155F39F5EB144A648F409C115D61A489-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--155F39F5EB144A648F409C115D61A489-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--155F39F5EB144A648F409C115D61A489-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--155F39F5EB144A648F409C115D61A489-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--155F39F5EB144A648F409C115D61A489--></OBUIAPP_PARAMETER>
+
 <!--1CB6D915777343F4BD3317532345B658--><OBUIAPP_PARAMETER>
 <!--1CB6D915777343F4BD3317532345B658-->  <OBUIAPP_PARAMETER_ID><![CDATA[1CB6D915777343F4BD3317532345B658]]></OBUIAPP_PARAMETER_ID>
 <!--1CB6D915777343F4BD3317532345B658-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -197,7 +243,7 @@
 <!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <READONLYLOGIC><![CDATA[@fin_paymend_id@!undefined & @fin_paymend_id@!null]]></READONLYLOGIC>
+<!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <READONLYLOGIC><![CDATA[@fin_financial_account_id_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.financialAccountOnChange]]></ONCHANGEFUNCTION>
 <!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--1D16F7BDCDD04F3A9AD259E84811AA41-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
@@ -251,7 +297,7 @@
 <!--200C902859B746D5BDDC773D0C91C1BB-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--200C902859B746D5BDDC773D0C91C1BB-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--200C902859B746D5BDDC773D0C91C1BB-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--200C902859B746D5BDDC773D0C91C1BB-->  <READONLYLOGIC><![CDATA[OB.PropertyStore.get('NotAllowChangeExchange', this.view.windowId) == 'Y']]></READONLYLOGIC>
+<!--200C902859B746D5BDDC773D0C91C1BB-->  <READONLYLOGIC><![CDATA[@conversion_rate_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--200C902859B746D5BDDC773D0C91C1BB-->  <NUMCOLUMN><![CDATA[4]]></NUMCOLUMN>
 <!--200C902859B746D5BDDC773D0C91C1BB-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.conversionRateOnChange]]></ONCHANGEFUNCTION>
 <!--200C902859B746D5BDDC773D0C91C1BB-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
@@ -360,6 +406,29 @@
 <!--4C09892656344AB1ACF988D57D84B96B-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--4C09892656344AB1ACF988D57D84B96B--></OBUIAPP_PARAMETER>
 
+<!--4CDE749FE6D341B4BCC128ADDAEE6068--><OBUIAPP_PARAMETER>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <OBUIAPP_PARAMETER_ID><![CDATA[4CDE749FE6D341B4BCC128ADDAEE6068]]></OBUIAPP_PARAMETER_ID>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <NAME><![CDATA[Conversion Rate Read Only Logic]]></NAME>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <SEQNO><![CDATA[1210]]></SEQNO>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <COLUMNNAME><![CDATA[conversion_rate_readonly_logic]]></COLUMNNAME>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--4CDE749FE6D341B4BCC128ADDAEE6068--></OBUIAPP_PARAMETER>
+
 <!--52BD390363394BE980D0A55AFC4CDBB9--><OBUIAPP_PARAMETER>
 <!--52BD390363394BE980D0A55AFC4CDBB9-->  <OBUIAPP_PARAMETER_ID><![CDATA[52BD390363394BE980D0A55AFC4CDBB9]]></OBUIAPP_PARAMETER_ID>
 <!--52BD390363394BE980D0A55AFC4CDBB9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -438,6 +507,29 @@
 <!--60C455BF16B6481D8ED5336CAA3C85C7-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
 <!--60C455BF16B6481D8ED5336CAA3C85C7--></OBUIAPP_PARAMETER>
 
+<!--61059745E59240A998ED90DC83E5DA4F--><OBUIAPP_PARAMETER>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <OBUIAPP_PARAMETER_ID><![CDATA[61059745E59240A998ED90DC83E5DA4F]]></OBUIAPP_PARAMETER_ID>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <NAME><![CDATA[Credit to Use Display Logic]]></NAME>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <SEQNO><![CDATA[1140]]></SEQNO>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <COLUMNNAME><![CDATA[credit_to_use_display_logic]]></COLUMNNAME>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentDisplayLogicsExpression")]]></DEFAULTVALUE>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--61059745E59240A998ED90DC83E5DA4F-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
+<!--61059745E59240A998ED90DC83E5DA4F--></OBUIAPP_PARAMETER>
+
 <!--6AF091FD5F1440BB9F0E0C674A168144--><OBUIAPP_PARAMETER>
 <!--6AF091FD5F1440BB9F0E0C674A168144-->  <OBUIAPP_PARAMETER_ID><![CDATA[6AF091FD5F1440BB9F0E0C674A168144]]></OBUIAPP_PARAMETER_ID>
 <!--6AF091FD5F1440BB9F0E0C674A168144-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -484,7 +576,7 @@
 <!--6E03D970D07D4753941F7B06DAF197F3-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--6E03D970D07D4753941F7B06DAF197F3-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--6E03D970D07D4753941F7B06DAF197F3-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--6E03D970D07D4753941F7B06DAF197F3-->  <DISPLAYLOGIC><![CDATA[true]]></DISPLAYLOGIC>
+<!--6E03D970D07D4753941F7B06DAF197F3-->  <DISPLAYLOGIC><![CDATA[@trxtype_display_logic@='Y']]></DISPLAYLOGIC>
 <!--6E03D970D07D4753941F7B06DAF197F3-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.documentOnChange]]></ONCHANGEFUNCTION>
 <!--6E03D970D07D4753941F7B06DAF197F3-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--6E03D970D07D4753941F7B06DAF197F3-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
@@ -586,7 +678,7 @@
 <!--838EF92641044D038600E4C1B6F1C4CB-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--838EF92641044D038600E4C1B6F1C4CB-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--838EF92641044D038600E4C1B6F1C4CB-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--838EF92641044D038600E4C1B6F1C4CB-->  <READONLYLOGIC><![CDATA[@fin_payment_id@!undefined & @fin_paymend_id@!null]]></READONLYLOGIC>
+<!--838EF92641044D038600E4C1B6F1C4CB-->  <READONLYLOGIC><![CDATA[@payment_method_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--838EF92641044D038600E4C1B6F1C4CB-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.paymentMethodOnChange]]></ONCHANGEFUNCTION>
 <!--838EF92641044D038600E4C1B6F1C4CB-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--838EF92641044D038600E4C1B6F1C4CB-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
@@ -638,6 +730,29 @@
 <!--854F44975FB84D20AE8E8DA02999747E-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--854F44975FB84D20AE8E8DA02999747E--></OBUIAPP_PARAMETER>
 
+<!--871DE320B33C4B83BDB4894EE99536E5--><OBUIAPP_PARAMETER>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <OBUIAPP_PARAMETER_ID><![CDATA[871DE320B33C4B83BDB4894EE99536E5]]></OBUIAPP_PARAMETER_ID>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <NAME><![CDATA[Deposit To Read Only Logic]]></NAME>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <SEQNO><![CDATA[1200]]></SEQNO>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <COLUMNNAME><![CDATA[fin_financial_account_id_readonly_logic]]></COLUMNNAME>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--871DE320B33C4B83BDB4894EE99536E5-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--871DE320B33C4B83BDB4894EE99536E5--></OBUIAPP_PARAMETER>
+
 <!--878E7842FC524139BBEE0CAE0C1F3E17--><OBUIAPP_PARAMETER>
 <!--878E7842FC524139BBEE0CAE0C1F3E17-->  <OBUIAPP_PARAMETER_ID><![CDATA[878E7842FC524139BBEE0CAE0C1F3E17]]></OBUIAPP_PARAMETER_ID>
 <!--878E7842FC524139BBEE0CAE0C1F3E17-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -682,7 +797,7 @@
 <!--8A2B3B1A41364852ACD2804CF86A69F5-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--8A2B3B1A41364852ACD2804CF86A69F5-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--8A2B3B1A41364852ACD2804CF86A69F5-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--8A2B3B1A41364852ACD2804CF86A69F5-->  <DISPLAYLOGIC><![CDATA[@difference@ > 0]]></DISPLAYLOGIC>
+<!--8A2B3B1A41364852ACD2804CF86A69F5-->  <DISPLAYLOGIC><![CDATA[@overpayment_action_display_logic@='Y']]></DISPLAYLOGIC>
 <!--8A2B3B1A41364852ACD2804CF86A69F5-->  <NUMCOLUMN><![CDATA[2]]></NUMCOLUMN>
 <!--8A2B3B1A41364852ACD2804CF86A69F5-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--8A2B3B1A41364852ACD2804CF86A69F5-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
@@ -714,6 +829,52 @@
 <!--8B738077BBF041E88B843AB9D98B12B0-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
 <!--8B738077BBF041E88B843AB9D98B12B0--></OBUIAPP_PARAMETER>
 
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD--><OBUIAPP_PARAMETER>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <OBUIAPP_PARAMETER_ID><![CDATA[91BE9BC9D1FE44C2A4CD631AE2474EAD]]></OBUIAPP_PARAMETER_ID>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <NAME><![CDATA[Payment DocumentNo Read Only Logic]]></NAME>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <SEQNO><![CDATA[1150]]></SEQNO>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <COLUMNNAME><![CDATA[payment_documentno_readonly_logic]]></COLUMNNAME>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--91BE9BC9D1FE44C2A4CD631AE2474EAD--></OBUIAPP_PARAMETER>
+
+<!--93DC15C203EB4205BDE0D87AFE185D5C--><OBUIAPP_PARAMETER>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <OBUIAPP_PARAMETER_ID><![CDATA[93DC15C203EB4205BDE0D87AFE185D5C]]></OBUIAPP_PARAMETER_ID>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <NAME><![CDATA[Overpayment Action Display Logic]]></NAME>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <SEQNO><![CDATA[1120]]></SEQNO>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <COLUMNNAME><![CDATA[overpayment_action_display_logic]]></COLUMNNAME>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentDisplayLogicsExpression")]]></DEFAULTVALUE>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--93DC15C203EB4205BDE0D87AFE185D5C-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
+<!--93DC15C203EB4205BDE0D87AFE185D5C--></OBUIAPP_PARAMETER>
+
 <!--94DAEE7477AF40ED9B40E3A546EACD02--><OBUIAPP_PARAMETER>
 <!--94DAEE7477AF40ED9B40E3A546EACD02-->  <OBUIAPP_PARAMETER_ID><![CDATA[94DAEE7477AF40ED9B40E3A546EACD02]]></OBUIAPP_PARAMETER_ID>
 <!--94DAEE7477AF40ED9B40E3A546EACD02-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -740,6 +901,29 @@
 <!--94DAEE7477AF40ED9B40E3A546EACD02-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
 <!--94DAEE7477AF40ED9B40E3A546EACD02--></OBUIAPP_PARAMETER>
 
+<!--967CEF7421094B06B089DEA1D1F6C37D--><OBUIAPP_PARAMETER>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <OBUIAPP_PARAMETER_ID><![CDATA[967CEF7421094B06B089DEA1D1F6C37D]]></OBUIAPP_PARAMETER_ID>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <NAME><![CDATA[Actual Payment Read Only Logic]]></NAME>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <SEQNO><![CDATA[1170]]></SEQNO>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <COLUMNNAME><![CDATA[actual_payment_readonly_logic]]></COLUMNNAME>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--967CEF7421094B06B089DEA1D1F6C37D-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--967CEF7421094B06B089DEA1D1F6C37D--></OBUIAPP_PARAMETER>
+
 <!--97DD674259364196944B4C02B0278305--><OBUIAPP_PARAMETER>
 <!--97DD674259364196944B4C02B0278305-->  <OBUIAPP_PARAMETER_ID><![CDATA[97DD674259364196944B4C02B0278305]]></OBUIAPP_PARAMETER_ID>
 <!--97DD674259364196944B4C02B0278305-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -766,6 +950,29 @@
 <!--97DD674259364196944B4C02B0278305-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
 <!--97DD674259364196944B4C02B0278305--></OBUIAPP_PARAMETER>
 
+<!--9E82150797C64125965C9BA668C2D2B4--><OBUIAPP_PARAMETER>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <OBUIAPP_PARAMETER_ID><![CDATA[9E82150797C64125965C9BA668C2D2B4]]></OBUIAPP_PARAMETER_ID>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <NAME><![CDATA[Document Display Logic]]></NAME>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <SEQNO><![CDATA[1130]]></SEQNO>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <COLUMNNAME><![CDATA[trxtype_display_logic]]></COLUMNNAME>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentDisplayLogicsExpression")]]></DEFAULTVALUE>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--9E82150797C64125965C9BA668C2D2B4-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
+<!--9E82150797C64125965C9BA668C2D2B4--></OBUIAPP_PARAMETER>
+
 <!--A801DA25DEAA404A8C651626CA31B22F--><OBUIAPP_PARAMETER>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <OBUIAPP_PARAMETER_ID><![CDATA[A801DA25DEAA404A8C651626CA31B22F]]></OBUIAPP_PARAMETER_ID>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -787,7 +994,7 @@
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--A801DA25DEAA404A8C651626CA31B22F-->  <DISPLAYLOGIC><![CDATA[@customer_credit@ > 0 & @received_from@!'' & (@issotrx@ == true | @generateCredit@ == 0)]]></DISPLAYLOGIC>
+<!--A801DA25DEAA404A8C651626CA31B22F-->  <DISPLAYLOGIC><![CDATA[@credit_to_use_display_logic@='Y']]></DISPLAYLOGIC>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <AD_FIELDGROUP_ID><![CDATA[CB265F2D7ACF439F9FB5EFBFA0B50363]]></AD_FIELDGROUP_ID>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--A801DA25DEAA404A8C651626CA31B22F-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
@@ -815,7 +1022,7 @@
 <!--A95732C0B3794D79B2E945D50872D931-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--A95732C0B3794D79B2E945D50872D931-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--A95732C0B3794D79B2E945D50872D931-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--A95732C0B3794D79B2E945D50872D931-->  <READONLYLOGIC><![CDATA[@issotrx@=='N']]></READONLYLOGIC>
+<!--A95732C0B3794D79B2E945D50872D931-->  <READONLYLOGIC><![CDATA[@actual_payment_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--A95732C0B3794D79B2E945D50872D931-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.actualPaymentOnChange]]></ONCHANGEFUNCTION>
 <!--A95732C0B3794D79B2E945D50872D931-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--A95732C0B3794D79B2E945D50872D931-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
@@ -874,6 +1081,29 @@
 <!--B2E975E0ADE3445C90DA81F0F492EA1C-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
 <!--B2E975E0ADE3445C90DA81F0F492EA1C--></OBUIAPP_PARAMETER>
 
+<!--B86607BED54F45B89718C80C61878093--><OBUIAPP_PARAMETER>
+<!--B86607BED54F45B89718C80C61878093-->  <OBUIAPP_PARAMETER_ID><![CDATA[B86607BED54F45B89718C80C61878093]]></OBUIAPP_PARAMETER_ID>
+<!--B86607BED54F45B89718C80C61878093-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B86607BED54F45B89718C80C61878093-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B86607BED54F45B89718C80C61878093-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B86607BED54F45B89718C80C61878093-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--B86607BED54F45B89718C80C61878093-->  <NAME><![CDATA[Converted Amount Read Only Logic]]></NAME>
+<!--B86607BED54F45B89718C80C61878093-->  <SEQNO><![CDATA[1180]]></SEQNO>
+<!--B86607BED54F45B89718C80C61878093-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--B86607BED54F45B89718C80C61878093-->  <COLUMNNAME><![CDATA[converted_amount_readonly_logic]]></COLUMNNAME>
+<!--B86607BED54F45B89718C80C61878093-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--B86607BED54F45B89718C80C61878093-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--B86607BED54F45B89718C80C61878093-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--B86607BED54F45B89718C80C61878093-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--B86607BED54F45B89718C80C61878093-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--B86607BED54F45B89718C80C61878093-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--B86607BED54F45B89718C80C61878093-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--B86607BED54F45B89718C80C61878093-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--B86607BED54F45B89718C80C61878093-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--B86607BED54F45B89718C80C61878093-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--B86607BED54F45B89718C80C61878093-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--B86607BED54F45B89718C80C61878093--></OBUIAPP_PARAMETER>
+
 <!--BC5E638E184C4F3AB36B9DA574E0E8BB--><OBUIAPP_PARAMETER>
 <!--BC5E638E184C4F3AB36B9DA574E0E8BB-->  <OBUIAPP_PARAMETER_ID><![CDATA[BC5E638E184C4F3AB36B9DA574E0E8BB]]></OBUIAPP_PARAMETER_ID>
 <!--BC5E638E184C4F3AB36B9DA574E0E8BB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -943,7 +1173,7 @@
 <!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <READONLYLOGIC><![CDATA[@fin_payment_id@!undefined & @fin_paymend_id@!null]]></READONLYLOGIC>
+<!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <READONLYLOGIC><![CDATA[@payment_date_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--E2FB4840B65A44D4B3090A7E3C95FD95-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--E2FB4840B65A44D4B3090A7E3C95FD95--></OBUIAPP_PARAMETER>
@@ -1024,12 +1254,36 @@
 <!--EB46162236C04DC2812C7095A88FA708-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--EB46162236C04DC2812C7095A88FA708-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
 <!--EB46162236C04DC2812C7095A88FA708-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--EB46162236C04DC2812C7095A88FA708-->  <READONLYLOGIC><![CDATA[true]]></READONLYLOGIC>
+<!--EB46162236C04DC2812C7095A88FA708-->  <READONLYLOGIC><![CDATA[@received_from_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--EB46162236C04DC2812C7095A88FA708-->  <NUMCOLUMN><![CDATA[1]]></NUMCOLUMN>
+<!--EB46162236C04DC2812C7095A88FA708-->  <ONCHANGEFUNCTION><![CDATA[OB.APRM.AddPayment.receivedFromOnChange]]></ONCHANGEFUNCTION>
 <!--EB46162236C04DC2812C7095A88FA708-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--EB46162236C04DC2812C7095A88FA708-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--EB46162236C04DC2812C7095A88FA708--></OBUIAPP_PARAMETER>
 
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E--><OBUIAPP_PARAMETER>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <OBUIAPP_PARAMETER_ID><![CDATA[F1D97E6ABE584F209CFCEEF4C6FE4A3E]]></OBUIAPP_PARAMETER_ID>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <NAME><![CDATA[Received From Read Only Logic]]></NAME>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <SEQNO><![CDATA[1220]]></SEQNO>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <COLUMNNAME><![CDATA[received_from_readonly_logic]]></COLUMNNAME>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <DEFAULTVALUE><![CDATA[OB.getFilterExpression("org.openbravo.advpaymentmngt.filterexpression.AddPaymentReadOnlyLogicsExpression")]]></DEFAULTVALUE>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--F1D97E6ABE584F209CFCEEF4C6FE4A3E--></OBUIAPP_PARAMETER>
+
 <!--F2C546F2C45C4AB58494B2D384E6A8E8--><OBUIAPP_PARAMETER>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <OBUIAPP_PARAMETER_ID><![CDATA[F2C546F2C45C4AB58494B2D384E6A8E8]]></OBUIAPP_PARAMETER_ID>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -1050,8 +1304,8 @@
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <ISFIXED><![CDATA[N]]></ISFIXED>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
-<!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
-<!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <READONLYLOGIC><![CDATA[@fin_payment_id@!undefined & @fin_paymend_id@!null]]></READONLYLOGIC>
+<!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <STARTINNEWLINE><![CDATA[Y]]></STARTINNEWLINE>
+<!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <READONLYLOGIC><![CDATA[@payment_documentno_readonly_logic@ == 'Y']]></READONLYLOGIC>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--F2C546F2C45C4AB58494B2D384E6A8E8--></OBUIAPP_PARAMETER>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentDisplayLogicActionHandler.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,114 @@
+/*
+ *************************************************************************
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.servlet.http.HttpSession;
+
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.client.application.Parameter;
+import org.openbravo.client.application.ParameterUtils;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.client.kernel.KernelConstants;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.service.db.DbUtility;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentDisplayLogicActionHandler extends BaseActionHandler {
+  private static Logger log = LoggerFactory.getLogger(AddPaymentDisplayLogicActionHandler.class);
+
+  @Override
+  protected final JSONObject execute(Map<String, Object> parameters, String data) {
+    JSONObject result = new JSONObject();
+    JSONObject values = new JSONObject();
+    JSONObject errorMessage = new JSONObject();
+    OBContext.setAdminMode(true);
+    try {
+      final JSONObject jsonData = new JSONObject(data);
+      final JSONArray affectedParams = jsonData.getJSONArray("affectedParams");
+      final JSONObject params = jsonData.getJSONObject("params");
+
+      Iterator<String> keys = params.keys();
+      while (keys.hasNext()) {
+        String key = keys.next();
+        Object value = params.get(key);
+        parameters.put(key, value);
+      }
+
+      for (int i = 0; i < affectedParams.length(); i++) {
+        Parameter param = OBDal.getInstance().get(Parameter.class, affectedParams.getString(i));
+        Object defaultValue = null;
+        Map<String, String> requestMap = fixRequestMap(parameters);
+        requestMap.put("currentParam", param.getDBColumnName());
+        defaultValue = ParameterUtils.getJSExpressionResult(requestMap,
+            (HttpSession) parameters.get(KernelConstants.HTTP_SESSION), param.getDefaultValue());
+        values.put(param.getDBColumnName(), defaultValue);
+      }
+      result.put("values", values);
+
+      String message = "Ok";
+      errorMessage.put("severity", "success");
+      errorMessage.put("text", message);
+      result.put("message", errorMessage);
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      log.error(e.getMessage(), e);
+      try {
+        Throwable ex = DbUtility.getUnderlyingSQLException(e);
+        String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+        errorMessage = new JSONObject();
+        errorMessage.put("severity", "error");
+        errorMessage.put("title", "Error");
+        errorMessage.put("text", message);
+        result.put("message", errorMessage);
+      } catch (Exception e2) {
+        log.error(e.getMessage(), e2);
+        // do nothing, give up
+      }
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    return result;
+  }
+
+  /*
+   * The request map is <String, Object> because includes the HTTP request and HTTP session, is not
+   * required to handle process parameters
+   */
+  protected Map<String, String> fixRequestMap(Map<String, Object> parameters) {
+    final Map<String, String> retval = new HashMap<String, String>();
+    for (Entry<String, Object> entries : parameters.entrySet()) {
+      if (entries.getKey().equals(KernelConstants.HTTP_REQUEST)
+          || entries.getKey().equals(KernelConstants.HTTP_SESSION)) {
+        continue;
+      }
+      retval.put(entries.getKey(), entries.getValue().toString());
+    }
+    return retval;
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsExpression.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,128 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.application.FilterExpression;
+import org.openbravo.client.application.OBBindingsConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentDisplayLogicsExpression implements FilterExpression {
+  private static final Logger log = LoggerFactory
+      .getLogger(AddPaymentDisplayLogicsExpression.class);
+  @Inject
+  @Any
+  private Instance<AddPaymentDisplayLogicsHandler> addPaymentFilterExpressionHandlers;
+
+  @Override
+  public String getExpression(Map<String, String> requestMap) {
+    String strCurrentParam = "";
+    try {
+      OBContext.setAdminMode(true);
+      final String strWindowId = getWindowId(requestMap);
+
+      AddPaymentDisplayLogicsHandler handler = getHandler(strWindowId);
+      if (handler == null) {
+        throw new OBException(String.format(OBMessageUtils.messageBD("APRM_NOHANDLER")));
+      }
+      strCurrentParam = requestMap.get("currentParam");
+      Parameters param = Parameters.getParameter(strCurrentParam);
+      try {
+        switch (param) {
+        case Document:
+          return handler.getDocumentDisplayLogic(requestMap) ? "Y" : "N";
+        case CreditToUse:
+          return handler.getCreditToUseDisplayLogic(requestMap) ? "Y" : "N";
+        case OverpaymentAction:
+          return handler.getOverpaymentActionDisplayLogic(requestMap) ? "Y" : "N";
+        }
+      } catch (Exception e) {
+        log.error("Error trying to get default value of " + strCurrentParam + " " + e.getMessage(),
+            e);
+        return null;
+      }
+    } catch (JSONException ignore) {
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    log.error("No default value found for param: " + strCurrentParam);
+    return null;
+  }
+
+  private String getWindowId(Map<String, String> requestMap) throws JSONException {
+    final String strContext = requestMap.get("context");
+    JSONObject context = new JSONObject(strContext);
+    return context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
+  }
+
+  private AddPaymentDisplayLogicsHandler getHandler(String strWindowId) {
+    AddPaymentDisplayLogicsHandler handler = null;
+    for (AddPaymentDisplayLogicsHandler nextHandler : addPaymentFilterExpressionHandlers
+        .select(new ComponentProvider.Selector(strWindowId))) {
+      if (handler == null) {
+        handler = nextHandler;
+      } else if (nextHandler.getSeq() < handler.getSeq()) {
+        handler = nextHandler;
+      } else if (nextHandler.getSeq() == handler.getSeq()) {
+        log.warn(
+            "Trying to get handler for window with id {}, there are more than one instance with the same sequence",
+            strWindowId);
+      }
+    }
+    return handler;
+  }
+
+  private enum Parameters {
+    Document("trxtype_display_logic"), CreditToUse("credit_to_use_display_logic"), OverpaymentAction(
+        "overpayment_action_display_logic");
+
+    private String columnname;
+
+    Parameters(String columnname) {
+      this.columnname = columnname;
+    }
+
+    public String getColumnName() {
+      return this.columnname;
+    }
+
+    static Parameters getParameter(String strColumnName) {
+      for (Parameters parameter : Parameters.values()) {
+        if (strColumnName.equals(parameter.getColumnName())) {
+          return parameter;
+        }
+      }
+      return null;
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsHandler.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,53 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+@RequestScoped
+abstract class AddPaymentDisplayLogicsHandler {
+
+  abstract boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException;
+
+  abstract boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException;
+
+  protected abstract long getSeq();
+
+  boolean getOverpaymentActionDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    if (context.has("difference")) {
+      double diff = context.getDouble("difference");
+      BigDecimal difference = new BigDecimal(diff);
+      if (difference.signum() > 0) {
+        return true;
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsExpression.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,141 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.application.FilterExpression;
+import org.openbravo.client.application.OBBindingsConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentReadOnlyLogicsExpression implements FilterExpression {
+  private static final Logger log = LoggerFactory
+      .getLogger(AddPaymentReadOnlyLogicsExpression.class);
+  @Inject
+  @Any
+  private Instance<AddPaymentReadOnlyLogicsHandler> addPaymentFilterExpressionHandlers;
+
+  @Override
+  public String getExpression(Map<String, String> requestMap) {
+    String strCurrentParam = "";
+    try {
+      OBContext.setAdminMode(true);
+      final String strWindowId = getWindowId(requestMap);
+
+      AddPaymentReadOnlyLogicsHandler handler = getHandler(strWindowId);
+      if (handler == null) {
+        throw new OBException(String.format(OBMessageUtils.messageBD("APRM_NOHANDLER")));
+      }
+      strCurrentParam = requestMap.get("currentParam");
+      Parameters param = Parameters.getParameter(strCurrentParam);
+      try {
+        switch (param) {
+        case PaymentDocumentNo:
+          return handler.getPaymentDocumentNoReadOnlyLogic(requestMap) ? "Y" : "N";
+        case ReceivedFrom:
+          return handler.getReceivedFromReadOnlyLogic(requestMap) ? "Y" : "N";
+        case PaymentMethod:
+          return handler.getPaymentMethodReadOnlyLogic(requestMap) ? "Y" : "N";
+        case ActualPayment:
+          return handler.getActualPaymentReadOnlyLogic(requestMap) ? "Y" : "N";
+        case ConvertedAmount:
+          return handler.getConvertedAmountReadOnlyLogic(requestMap) ? "Y" : "N";
+        case PaymentDate:
+          return handler.getPaymentDateReadOnlyLogic(requestMap) ? "Y" : "N";
+        case FinancialAccount:
+          return handler.getFinancialAccountReadOnlyLogic(requestMap) ? "Y" : "N";
+        case ConversionRate:
+          return handler.getConversionRateReadOnlyLogic(requestMap) ? "Y" : "N";
+        }
+      } catch (Exception e) {
+        log.error("Error trying to get default value of " + strCurrentParam + " " + e.getMessage(),
+            e);
+        return null;
+      }
+    } catch (JSONException ignore) {
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    log.error("No default value found for param: " + strCurrentParam);
+    return null;
+  }
+
+  private String getWindowId(Map<String, String> requestMap) throws JSONException {
+    final String strContext = requestMap.get("context");
+    JSONObject context = new JSONObject(strContext);
+    return context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
+  }
+
+  private AddPaymentReadOnlyLogicsHandler getHandler(String strWindowId) {
+    AddPaymentReadOnlyLogicsHandler handler = null;
+    for (AddPaymentReadOnlyLogicsHandler nextHandler : addPaymentFilterExpressionHandlers
+        .select(new ComponentProvider.Selector(strWindowId))) {
+      if (handler == null) {
+        handler = nextHandler;
+      } else if (nextHandler.getSeq() < handler.getSeq()) {
+        handler = nextHandler;
+      } else if (nextHandler.getSeq() == handler.getSeq()) {
+        log.warn(
+            "Trying to get handler for window with id {}, there are more than one instance with the same sequence",
+            strWindowId);
+      }
+    }
+    return handler;
+  }
+
+  private enum Parameters {
+    PaymentDocumentNo("payment_documentno_readonly_logic"), ReceivedFrom(
+        "received_from_readonly_logic"), PaymentMethod("payment_method_readonly_logic"), ActualPayment(
+        "actual_payment_readonly_logic"), ConvertedAmount("converted_amount_readonly_logic"), PaymentDate(
+        "payment_date_readonly_logic"), FinancialAccount("fin_financial_account_id_readonly_logic"), ConversionRate(
+        "conversion_rate_readonly_logic");
+
+    private String columnname;
+
+    Parameters(String columnname) {
+      this.columnname = columnname;
+    }
+
+    public String getColumnName() {
+      return this.columnname;
+    }
+
+    static Parameters getParameter(String strColumnName) {
+      for (Parameters parameter : Parameters.values()) {
+        if (strColumnName.equals(parameter.getColumnName())) {
+          return parameter;
+        }
+      }
+      return null;
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsHandler.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,111 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.PropertyException;
+import org.openbravo.erpCommon.utility.PropertyNotFoundException;
+import org.openbravo.model.ad.ui.Window;
+import org.openbravo.scheduling.ProcessLogger;
+
+@RequestScoped
+abstract class AddPaymentReadOnlyLogicsHandler {
+
+  private static ProcessLogger logger;
+
+  abstract boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap)
+      throws JSONException;
+
+  abstract boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap)
+      throws JSONException;
+
+  abstract boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap)
+      throws JSONException;
+
+  abstract boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap)
+      throws JSONException;
+
+  abstract boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException;
+
+  abstract boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap)
+      throws JSONException;
+
+  protected abstract long getSeq();
+
+  boolean getConvertedAmountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    OBContext.setAdminMode();
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    String strWindow = context.getString("inpwindowId");
+    Window window = OBDal.getInstance().get(Window.class, strWindow == null ? "" : strWindow);
+
+    try {
+      String value = org.openbravo.erpCommon.businessUtility.Preferences.getPreferenceValue(
+          "NotAllowChangeExchange", true, OBContext.getOBContext().getCurrentClient(), OBContext
+              .getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
+          OBContext.getOBContext().getRole(), window);
+      if ("Y".equals(value)) {
+        return true;
+      } else {
+        return false;
+      }
+    } catch (PropertyNotFoundException e) {
+      // logger.log("Property not found \n");
+      return false;
+    } catch (PropertyException e) {
+      // logger.log("PropertyException, there is a conflict for NotAllowChangeExchange property\n");
+      return false;
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  boolean getConversionRateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    OBContext.setAdminMode();
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    String strWindow = context.getString("inpwindowId");
+    Window window = OBDal.getInstance().get(Window.class, strWindow == null ? "" : strWindow);
+
+    try {
+      String value = org.openbravo.erpCommon.businessUtility.Preferences.getPreferenceValue(
+          "NotAllowChangeExchange", true, OBContext.getOBContext().getCurrentClient(), OBContext
+              .getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
+          OBContext.getOBContext().getRole(), window);
+      if ("Y".equals(value)) {
+        return true;
+      } else {
+        return false;
+      }
+    } catch (PropertyNotFoundException e) {
+      // logger.log("Property not found \n");
+      return false;
+    } catch (PropertyException e) {
+      // logger.log("PropertyException, there is a conflict for NotAllowChangeExchange property\n");
+      return false;
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,81 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_IN_WINDOW_ID)
+public class PaymentInAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // "@customer_credit@ > 0 & @received_from@!'' & (@issotrx@ == true | @generateCredit@ == 0)";
+    FIN_Payment paymentIn = getPayment(requestMap);
+    BusinessPartner bpartner = paymentIn.getBusinessPartner();
+    if (bpartner != null) {
+      Organization org = paymentIn.getOrganization();
+      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+      if (customerCredit.signum() > 0) {
+        return true;
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  private FIN_Payment getPayment(Map<String, String> requestMap) throws JSONException {
+    // Current Payment
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    String strFinPaymentId = "";
+    if (context.has("inpfinPaymentId") && !context.isNull("inpfinPaymentId")) {
+      strFinPaymentId = context.getString("inpfinPaymentId");
+    }
+    if (context.has("Fin_Payment_ID") && !context.isNull("Fin_Payment_ID")) {
+      strFinPaymentId = context.getString("Fin_Payment_ID");
+    }
+    FIN_Payment payment = OBDal.getInstance().get(FIN_Payment.class, strFinPaymentId);
+    return payment;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_IN_WINDOW_ID)
+public class PaymentInAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,89 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_OUT_WINDOW_ID)
+public class PaymentOutAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    FIN_Payment paymentOut = getPayment(requestMap);
+    if (getGeneratedCredit(requestMap).signum() == 0) {
+      BusinessPartner bpartner = paymentOut.getBusinessPartner();
+      if (bpartner != null) {
+        Organization org = paymentOut.getOrganization();
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+        if (customerCredit.signum() > 0) {
+          return true;
+        } else {
+          return false;
+        }
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  private FIN_Payment getPayment(Map<String, String> requestMap) throws JSONException {
+    // Current Payment
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    String strFinPaymentId = "";
+    if (context.has("inpfinPaymentId") && !context.isNull("inpfinPaymentId")) {
+      strFinPaymentId = context.getString("inpfinPaymentId");
+    }
+    if (context.has("Fin_Payment_ID") && !context.isNull("Fin_Payment_ID")) {
+      strFinPaymentId = context.getString("Fin_Payment_ID");
+    }
+    FIN_Payment payment = OBDal.getInstance().get(FIN_Payment.class, strFinPaymentId);
+    return payment;
+  }
+
+  BigDecimal getGeneratedCredit(Map<String, String> requestMap) throws JSONException {
+    // Generated Credit of the current Payment
+    return getPayment(requestMap).getGeneratedCredit();
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_OUT_WINDOW_ID)
+public class PaymentOutAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,79 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.invoice.Invoice;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_INVOICE_WINDOW_ID)
+public class PurchaseInvoiceAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    Invoice invoice = getInvoice(context);
+    if (getDefaultGeneratedCredit(requestMap).signum() == 0) {
+      BusinessPartner bpartner = invoice.getBusinessPartner();
+      if (bpartner != null) {
+        Organization org = invoice.getOrganization();
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+        if (customerCredit.signum() > 0) {
+          return true;
+        } else {
+          return false;
+        }
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  Invoice getInvoice(JSONObject context) throws JSONException {
+    return OBDal.getInstance().get(Invoice.class, context.getString("inpcInvoiceId"));
+  }
+
+  BigDecimal getDefaultGeneratedCredit(Map<String, String> requestMap) throws JSONException {
+    return BigDecimal.ZERO;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_INVOICE_WINDOW_ID)
+public class PurchaseInvoiceAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,79 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.order.Order;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_ORDER_WINDOW_ID)
+public class PurchaseOrderAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    Order order = getOrder(context);
+    if (getDefaultGeneratedCredit(requestMap).signum() == 0) {
+      BusinessPartner bpartner = order.getBusinessPartner();
+      if (bpartner != null) {
+        Organization org = order.getOrganization();
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+        if (customerCredit.signum() > 0) {
+          return true;
+        } else {
+          return false;
+        }
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  private Order getOrder(JSONObject context) throws JSONException {
+    return OBDal.getInstance().get(Order.class, context.getString("inpcOrderId"));
+  }
+
+  BigDecimal getDefaultGeneratedCredit(Map<String, String> requestMap) throws JSONException {
+    return BigDecimal.ZERO;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_ORDER_WINDOW_ID)
+public class PurchaseOrderAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,71 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.invoice.Invoice;
+
+@ComponentProvider.Qualifier(APRMConstants.SALES_INVOICE_WINDOW_ID)
+public class SalesInvoiceAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    Invoice invoice = getInvoice(context);
+    BusinessPartner bpartner = invoice.getBusinessPartner();
+    if (bpartner != null) {
+      Organization org = invoice.getOrganization();
+      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+      if (customerCredit.signum() > 0) {
+        return true;
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  Invoice getInvoice(JSONObject context) throws JSONException {
+    return OBDal.getInstance().get(Invoice.class, context.getString("inpcInvoiceId"));
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.SALES_INVOICE_WINDOW_ID)
+public class SalesInvoiceAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.order.Order;
+
+@ComponentProvider.Qualifier(APRMConstants.SALES_ORDER_WINDOW_ID)
+public class SalesOrderAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // "@customer_credit@ > 0 & @received_from@!'' & (@issotrx@ == true | @generateCredit@ == 0)";
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    Order order = getOrder(context);
+    BusinessPartner bpartner = order.getBusinessPartner();
+    if (bpartner != null) {
+      Organization org = order.getOrganization();
+      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+      if (customerCredit.signum() > 0) {
+        return true;
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  private Order getOrder(JSONObject context) throws JSONException {
+    return OBDal.getInstance().get(Order.class, context.getString("inpcOrderId"));
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,67 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.SALES_ORDER_WINDOW_ID)
+public class SalesOrderAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return false;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDisplayLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,93 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
+
+@ComponentProvider.Qualifier(APRMConstants.TRANSACTION_WINDOW_ID)
+public class TransactionAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getDocumentDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    // Document Type
+    return true;
+  }
+
+  @Override
+  boolean getCreditToUseDisplayLogic(Map<String, String> requestMap) throws JSONException {
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    if (context.has("received_from") && !context.isNull("received_from")
+        && !"".equals(context.getString("received_from"))) {
+      String document = context.getString("trxtype");
+      String strBusinessPartner = context.getString("received_from");
+      if (getDefaultGeneratedCredit(requestMap).signum() == 0 || "RCIN".equals(document)) {
+        BusinessPartner bpartner = OBDal.getInstance().get(BusinessPartner.class,
+            strBusinessPartner);
+        Organization org = OBDal.getInstance().get(Organization.class, context.get("ad_org_id"));
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner,
+            "RCIN".equals(document), org);
+        if (customerCredit.signum() > 0) {
+          return true;
+        } else {
+          return false;
+        }
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
+
+  private FIN_FinaccTransaction getTransaction(Map<String, String> requestMap) throws JSONException {
+    // Current Payment
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    String strFinFinaccTransactionIdd = "";
+    if (context.has("inpfinFinaccTransactionId") && !context.isNull("inpfinFinaccTransactionId")) {
+      strFinFinaccTransactionIdd = context.getString("inpfinFinaccTransactionId");
+    }
+    if (context.has("Fin_Finacc_Transaction_ID") && !context.isNull("Fin_Finacc_Transaction_ID")) {
+      strFinFinaccTransactionIdd = context.getString("Fin_Finacc_Transaction_ID");
+    }
+    FIN_FinaccTransaction transaction = OBDal.getInstance().get(FIN_FinaccTransaction.class,
+        strFinFinaccTransactionIdd);
+    return transaction;
+  }
+
+  BigDecimal getDefaultGeneratedCredit(Map<String, String> requestMap) throws JSONException {
+    return BigDecimal.ZERO;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentReadOnlyLogics.java	Tue Jul 29 13:55:27 2014 +0200
@@ -0,0 +1,78 @@
+/*
+ *************************************************************************
+ * 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.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.TRANSACTION_WINDOW_ID)
+public class TransactionAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+  private static final long SEQUENCE = 100l;
+
+  protected long getSeq() {
+    return SEQUENCE;
+  }
+
+  @Override
+  boolean getPaymentDocumentNoReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getReceivedFromReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getPaymentMethodReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getActualPaymentReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    JSONObject context = new JSONObject(requestMap.get("context"));
+    String document = null;
+    if (context.has("inptrxtype") && !context.isNull("inptrxtype")) {
+      document = context.getString("inptrxtype");
+    }
+    if (context.has("issotrx") && !context.isNull("issotrx")) {
+      document = context.getString("trxtype");
+    }
+    if ("BPD".equals(document) || "RCIN".equals(document)) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  @Override
+  boolean getPaymentDateReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return false;
+  }
+
+  @Override
+  boolean getFinancialAccountReadOnlyLogic(Map<String, String> requestMap) throws JSONException {
+    return true;
+  }
+}
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js	Tue Jul 22 17:52:14 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js	Tue Jul 29 13:55:27 2014 +0200
@@ -385,7 +385,9 @@
       receivedFrom = form.getItem('received_from').getValue() || '',
       totalGLItems = new BigDecimal(String(form.getItem('amount_gl_items').getValue() || 0)),
       diffAmt = actualPayment.add(credit).subtract(total),
-      expectedDiffAmt = expectedPayment.add(credit).subtract(total).add(totalGLItems);
+      expectedDiffAmt = expectedPayment.add(credit).subtract(total).add(totalGLItems),
+      affectedParams = [],
+      displayLogicValues = {};
   differenceItem.setValue(Number(diffAmt.toString()));
   if (expectedDiffAmt.signum() === 0) {
     expectedDifferenceItem.setValue(Number(diffAmt.toString()));
@@ -395,6 +397,8 @@
   if (diffAmt.signum() !== 0) {
     OB.APRM.AddPayment.updateDifferenceActions(form);
   }
+  affectedParams.push(form.getField('overpayment_action_display_logic').paramId);
+  OB.APRM.AddPayment.recalcDisplayLogicOrReadOnlyLogic(form, null, affectedParams);
 };
 
 OB.APRM.AddPayment.updateDifferenceActions = function (form) {
@@ -732,14 +736,63 @@
 
 OB.APRM.AddPayment.documentOnChange = function (item, view, form, grid) {
   var document = form.getItem('trxtype').getValue(),
-      issotrx = form.getItem('issotrx');
+      issotrx = form.getItem('issotrx'),
+      affectedParams = [];
   if (document === 'RCIN') {
     issotrx.setValue(true);
   } else {
     issotrx.setValue(false);
   }
+  affectedParams.push(form.getField('credit_to_use_display_logic').paramId);
+  affectedParams.push(form.getField('actual_payment_readonly_logic').paramId);
+  OB.APRM.AddPayment.recalcDisplayLogicOrReadOnlyLogic(form, view, affectedParams);
 };
 
+OB.APRM.AddPayment.receivedFromOnChange = function (item, view, form, grid) {
+  var affectedParams = [];
+  affectedParams.push(form.getField('credit_to_use_display_logic').paramId);
+  OB.APRM.AddPayment.recalcDisplayLogicOrReadOnlyLogic(form, view, affectedParams);
+};
+
+OB.APRM.AddPayment.recalcDisplayLogicOrReadOnlyLogic = function (form, view, affectedParams) {
+  var callbackOnProcessActionHandler, params = {},
+      thisform, thisview;
+  thisform = form;
+  thisview = view;
+  params.context = form.paramWindow.getContextInfo();
+  params.context.inpwindowId = form.paramWindow.parentWindow.windowId;
+
+  callbackDisplayLogicActionHandler = function (response, data, request) {
+    var i, field, def, values = data.values;
+
+    for (i in values) {
+      if (values.hasOwnProperty(i)) {
+        def = values[i];
+        field = thisform.getItem(i);
+        if (field) {
+          if (isc.isA.Object(def)) {
+            if (def.identifier && def.value) {
+              field.valueMap = field.valueMap || {};
+              field.valueMap[def.value] = def.identifier;
+              field.setValue(def.value);
+            }
+          } else {
+            field.setValue(thisform.paramWindow.getTypeSafeValue(field.typeInstance, def));
+          }
+        }
+      }
+    }
+    if (thisview) {
+    	view.handleReadOnlyLogic();
+    }
+    thisform.markForRedraw();
+  };
+
+  OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.AddPaymentDisplayLogicActionHandler', {
+    affectedParams: affectedParams,
+    params: params
+  }, {}, callbackDisplayLogicActionHandler);
+};
 
 OB.APRM.AddPayment.onProcess = function (view, actionHandlerCall) {
   var orderInvoiceGrid = view.theForm.getItem('order_invoice').canvas.viewGrid,