[aprm-windows]Dont use parent window context variables in Order Invoice grid Transformer
authorUnai Martirena <unai.martirena@openbravo.com>
Mon, 12 May 2014 13:57:18 +0200
changeset 23572 fb91561fed19
parent 23571 812ed4485b9c
child 23573 3675d1334e67
[aprm-windows]Dont use parent window context variables in Order Invoice grid Transformer
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/hqlinjections/AddPaymentOrderInvoicesTransformer.java
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Mon May 12 13:29:00 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Mon May 12 13:57:18 2014 +0200
@@ -314,6 +314,39 @@
 <!--11881AC652AE430D949736FDC7265A26-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--11881AC652AE430D949736FDC7265A26--></AD_COLUMN>
 
+<!--121298B6ACAE489D805166216681C6D4--><AD_COLUMN>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_COLUMN_ID><![CDATA[121298B6ACAE489D805166216681C6D4]]></AD_COLUMN_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--121298B6ACAE489D805166216681C6D4-->  <NAME><![CDATA[paymentMethodName]]></NAME>
+<!--121298B6ACAE489D805166216681C6D4-->  <COLUMNNAME><![CDATA[paymentMethodName]]></COLUMNNAME>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_TABLE_ID><![CDATA[58AF4D3E594B421A9A7307480736F03E]]></AD_TABLE_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--121298B6ACAE489D805166216681C6D4-->  <SEQNO><![CDATA[50]]></SEQNO>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_ELEMENT_ID><![CDATA[533E204A46FD4BB9AED3D9FC26EEC67C]]></AD_ELEMENT_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--121298B6ACAE489D805166216681C6D4-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--121298B6ACAE489D805166216681C6D4-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--121298B6ACAE489D805166216681C6D4-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--121298B6ACAE489D805166216681C6D4-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--121298B6ACAE489D805166216681C6D4-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--121298B6ACAE489D805166216681C6D4-->  <ENTITY_ALIAS><![CDATA[COALESCE(ipsfp.name, opsfp.name)]]></ENTITY_ALIAS>
+<!--121298B6ACAE489D805166216681C6D4--></AD_COLUMN>
+
 <!--1309F42BE35D4E71A2185623688E5628--><AD_COLUMN>
 <!--1309F42BE35D4E71A2185623688E5628-->  <AD_COLUMN_ID><![CDATA[1309F42BE35D4E71A2185623688E5628]]></AD_COLUMN_ID>
 <!--1309F42BE35D4E71A2185623688E5628-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -774,6 +807,39 @@
 <!--2198B37AF80C4020ACAADFA677917352-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--2198B37AF80C4020ACAADFA677917352--></AD_COLUMN>
 
+<!--2295DC7A28FE4F9DA842F453E2FF2F41--><AD_COLUMN>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_COLUMN_ID><![CDATA[2295DC7A28FE4F9DA842F453E2FF2F41]]></AD_COLUMN_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <NAME><![CDATA[businessPartnerName]]></NAME>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <COLUMNNAME><![CDATA[businessPartnerName]]></COLUMNNAME>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_TABLE_ID><![CDATA[58AF4D3E594B421A9A7307480736F03E]]></AD_TABLE_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <SEQNO><![CDATA[70]]></SEQNO>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_ELEMENT_ID><![CDATA[DD07FB0992434B66BBFB08EA274E720A]]></AD_ELEMENT_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41-->  <ENTITY_ALIAS><![CDATA[COALESCE(invbp.name, ordbp.name)]]></ENTITY_ALIAS>
+<!--2295DC7A28FE4F9DA842F453E2FF2F41--></AD_COLUMN>
+
 <!--2298A150A1A146FCB0D016E5BE55A607--><AD_COLUMN>
 <!--2298A150A1A146FCB0D016E5BE55A607-->  <AD_COLUMN_ID><![CDATA[2298A150A1A146FCB0D016E5BE55A607]]></AD_COLUMN_ID>
 <!--2298A150A1A146FCB0D016E5BE55A607-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2328,7 +2394,7 @@
 <!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <SEQNO><![CDATA[110]]></SEQNO>
+<!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <SEQNO><![CDATA[130]]></SEQNO>
 <!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--56C419FF5BA0444181AF7DDB7BFF78A3-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -3165,8 +3231,7 @@
 <!--730009446F744A618995ABF5DA3F692E-->  <NAME><![CDATA[paymentMethod]]></NAME>
 <!--730009446F744A618995ABF5DA3F692E-->  <COLUMNNAME><![CDATA[paymentMethod]]></COLUMNNAME>
 <!--730009446F744A618995ABF5DA3F692E-->  <AD_TABLE_ID><![CDATA[58AF4D3E594B421A9A7307480736F03E]]></AD_TABLE_ID>
-<!--730009446F744A618995ABF5DA3F692E-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
-<!--730009446F744A618995ABF5DA3F692E-->  <AD_REFERENCE_VALUE_ID><![CDATA[F378D8FAEF9441F29D3974ADE211BF98]]></AD_REFERENCE_VALUE_ID>
+<!--730009446F744A618995ABF5DA3F692E-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
 <!--730009446F744A618995ABF5DA3F692E-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
 <!--730009446F744A618995ABF5DA3F692E-->  <ISKEY><![CDATA[N]]></ISKEY>
 <!--730009446F744A618995ABF5DA3F692E-->  <ISPARENT><![CDATA[N]]></ISPARENT>
@@ -3188,7 +3253,7 @@
 <!--730009446F744A618995ABF5DA3F692E-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--730009446F744A618995ABF5DA3F692E-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--730009446F744A618995ABF5DA3F692E-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--730009446F744A618995ABF5DA3F692E-->  <ENTITY_ALIAS><![CDATA[@paymentMethod@]]></ENTITY_ALIAS>
+<!--730009446F744A618995ABF5DA3F692E-->  <ENTITY_ALIAS><![CDATA[COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id)]]></ENTITY_ALIAS>
 <!--730009446F744A618995ABF5DA3F692E--></AD_COLUMN>
 
 <!--74C8BD1CFDD44F86840A223FE75F63D7--><AD_COLUMN>
@@ -5654,15 +5719,14 @@
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <HELP><![CDATA[A Business Partner is anyone with whom you transact.  This can include a customer, vendor, employee or any combination of these.]]></HELP>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <COLUMNNAME><![CDATA[businessPartner]]></COLUMNNAME>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <AD_TABLE_ID><![CDATA[58AF4D3E594B421A9A7307480736F03E]]></AD_TABLE_ID>
-<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
-<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <AD_REFERENCE_VALUE_ID><![CDATA[56DEFF37A33F46D1AC918C97C4447EAF]]></AD_REFERENCE_VALUE_ID>
+<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISKEY><![CDATA[N]]></ISKEY>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <SEQNO><![CDATA[50]]></SEQNO>
+<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <SEQNO><![CDATA[60]]></SEQNO>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -5677,7 +5741,7 @@
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ENTITY_ALIAS><![CDATA[@businessPartner@]]></ENTITY_ALIAS>
+<!--8DEAEE4918C64D0AA2CFE36695F4C3E4-->  <ENTITY_ALIAS><![CDATA[COALESCE(inv.businessPartner.id, ord.businessPartner.id)]]></ENTITY_ALIAS>
 <!--8DEAEE4918C64D0AA2CFE36695F4C3E4--></AD_COLUMN>
 
 <!--90282A7E59A24C5AA3E030D91B622863--><AD_COLUMN>
@@ -5696,7 +5760,7 @@
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--90282A7E59A24C5AA3E030D91B622863-->  <SEQNO><![CDATA[80]]></SEQNO>
+<!--90282A7E59A24C5AA3E030D91B622863-->  <SEQNO><![CDATA[100]]></SEQNO>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -5711,7 +5775,7 @@
 <!--90282A7E59A24C5AA3E030D91B622863-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--90282A7E59A24C5AA3E030D91B622863-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--90282A7E59A24C5AA3E030D91B622863-->  <ENTITY_ALIAS><![CDATA[@expectedAmount@]]></ENTITY_ALIAS>
+<!--90282A7E59A24C5AA3E030D91B622863-->  <ENTITY_ALIAS><![CDATA[COALESCE(ips.amount, ops.amount)]]></ENTITY_ALIAS>
 <!--90282A7E59A24C5AA3E030D91B622863--></AD_COLUMN>
 
 <!--9220C8010FFB4EAABB8B367633EA9454--><AD_COLUMN>
@@ -8032,7 +8096,7 @@
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--A9E1940399DD4CC99AD4DC19426AEF90-->  <SEQNO><![CDATA[70]]></SEQNO>
+<!--A9E1940399DD4CC99AD4DC19426AEF90-->  <SEQNO><![CDATA[90]]></SEQNO>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -8047,7 +8111,7 @@
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ENTITY_ALIAS><![CDATA[@expectedDate@]]></ENTITY_ALIAS>
+<!--A9E1940399DD4CC99AD4DC19426AEF90-->  <ENTITY_ALIAS><![CDATA[COALESCE(ips.expectedDate, ops.expectedDate)]]></ENTITY_ALIAS>
 <!--A9E1940399DD4CC99AD4DC19426AEF90--></AD_COLUMN>
 
 <!--A9FAC7D05AED45A28899DDFDF1D1D6E0--><AD_COLUMN>
@@ -8171,7 +8235,7 @@
 <!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <SEQNO><![CDATA[100]]></SEQNO>
+<!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <SEQNO><![CDATA[120]]></SEQNO>
 <!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--AE6E63C1ADE84D5E890DA26711CD0AF5-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -8239,7 +8303,7 @@
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--AEF30836571D49FB96C42D7DD85FDDED-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--AEF30836571D49FB96C42D7DD85FDDED-->  <SEQNO><![CDATA[110]]></SEQNO>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -8254,7 +8318,7 @@
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--AEF30836571D49FB96C42D7DD85FDDED-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--AEF30836571D49FB96C42D7DD85FDDED-->  <ENTITY_ALIAS><![CDATA[@invoicedAmount@]]></ENTITY_ALIAS>
+<!--AEF30836571D49FB96C42D7DD85FDDED-->  <ENTITY_ALIAS><![CDATA[COALESCE(inv.grandTotalAmount, ord.grandTotalAmount)]]></ENTITY_ALIAS>
 <!--AEF30836571D49FB96C42D7DD85FDDED--></AD_COLUMN>
 
 <!--B0140FD7843840979CB847D51E858ABA--><AD_COLUMN>
@@ -10057,7 +10121,7 @@
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
-<!--FB1A5BDF874A4F48A02C77987296A3AD-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--FB1A5BDF874A4F48A02C77987296A3AD-->  <SEQNO><![CDATA[80]]></SEQNO>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
@@ -10072,7 +10136,7 @@
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
-<!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ENTITY_ALIAS><![CDATA[@transactionDate@]]></ENTITY_ALIAS>
+<!--FB1A5BDF874A4F48A02C77987296A3AD-->  <ENTITY_ALIAS><![CDATA[COALESCE(inv.invoiceDate, ord.orderDate)]]></ENTITY_ALIAS>
 <!--FB1A5BDF874A4F48A02C77987296A3AD--></AD_COLUMN>
 
 <!--FC4BD746E20E4D8B8149D1BD10DD495B--><AD_COLUMN>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml	Mon May 12 13:29:00 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml	Mon May 12 13:57:18 2014 +0200
@@ -170,6 +170,18 @@
 <!--519F3CD67106443CBF25694F1BB6E92B-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--519F3CD67106443CBF25694F1BB6E92B--></AD_ELEMENT>
 
+<!--533E204A46FD4BB9AED3D9FC26EEC67C--><AD_ELEMENT>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <AD_ELEMENT_ID><![CDATA[533E204A46FD4BB9AED3D9FC26EEC67C]]></AD_ELEMENT_ID>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <COLUMNNAME><![CDATA[paymentMethodName]]></COLUMNNAME>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <NAME><![CDATA[Payment Method]]></NAME>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <PRINTNAME><![CDATA[Payment Method]]></PRINTNAME>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--533E204A46FD4BB9AED3D9FC26EEC67C--></AD_ELEMENT>
+
 <!--56CC0941477A4250AD07527AE15FAC61--><AD_ELEMENT>
 <!--56CC0941477A4250AD07527AE15FAC61-->  <AD_ELEMENT_ID><![CDATA[56CC0941477A4250AD07527AE15FAC61]]></AD_ELEMENT_ID>
 <!--56CC0941477A4250AD07527AE15FAC61-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -968,6 +980,18 @@
 <!--DB85AA94D6DF4D7CB29CE7999B15F9C7-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--DB85AA94D6DF4D7CB29CE7999B15F9C7--></AD_ELEMENT>
 
+<!--DD07FB0992434B66BBFB08EA274E720A--><AD_ELEMENT>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <AD_ELEMENT_ID><![CDATA[DD07FB0992434B66BBFB08EA274E720A]]></AD_ELEMENT_ID>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <COLUMNNAME><![CDATA[businessPartnerName]]></COLUMNNAME>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <NAME><![CDATA[Business Partner]]></NAME>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <PRINTNAME><![CDATA[Business Partner]]></PRINTNAME>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--DD07FB0992434B66BBFB08EA274E720A-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--DD07FB0992434B66BBFB08EA274E720A--></AD_ELEMENT>
+
 <!--DE92C5C14E9647D5B4E71F0C8E89E984--><AD_ELEMENT>
 <!--DE92C5C14E9647D5B4E71F0C8E89E984-->  <AD_ELEMENT_ID><![CDATA[DE92C5C14E9647D5B4E71F0C8E89E984]]></AD_ELEMENT_ID>
 <!--DE92C5C14E9647D5B4E71F0C8E89E984-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Mon May 12 13:29:00 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Mon May 12 13:57:18 2014 +0200
@@ -4839,6 +4839,32 @@
 <!--4C3D2B4E7CD14390BF20A8FB5474EE32-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--4C3D2B4E7CD14390BF20A8FB5474EE32--></AD_FIELD>
 
+<!--4C4DA8A450BA4A3E8A939800585D7244--><AD_FIELD>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <AD_FIELD_ID><![CDATA[4C4DA8A450BA4A3E8A939800585D7244]]></AD_FIELD_ID>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <NAME><![CDATA[Payment Method]]></NAME>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <AD_TAB_ID><![CDATA[BE20AB937FC64221A86E93ECA0DF1C1D]]></AD_TAB_ID>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <AD_COLUMN_ID><![CDATA[121298B6ACAE489D805166216681C6D4]]></AD_COLUMN_ID>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <SEQNO><![CDATA[30]]></SEQNO>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--4C4DA8A450BA4A3E8A939800585D7244-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--4C4DA8A450BA4A3E8A939800585D7244--></AD_FIELD>
+
 <!--4C85D478837741C4A3AD74CFF852A470--><AD_FIELD>
 <!--4C85D478837741C4A3AD74CFF852A470-->  <AD_FIELD_ID><![CDATA[4C85D478837741C4A3AD74CFF852A470]]></AD_FIELD_ID>
 <!--4C85D478837741C4A3AD74CFF852A470-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -8169,32 +8195,6 @@
 <!--7D538189D5BA4F889FCFE3E6B410A671-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--7D538189D5BA4F889FCFE3E6B410A671--></AD_FIELD>
 
-<!--7D735958F5AC45FEA24318DBC909E170--><AD_FIELD>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <AD_FIELD_ID><![CDATA[7D735958F5AC45FEA24318DBC909E170]]></AD_FIELD_ID>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <NAME><![CDATA[Payment Method]]></NAME>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <AD_TAB_ID><![CDATA[BE20AB937FC64221A86E93ECA0DF1C1D]]></AD_TAB_ID>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <AD_COLUMN_ID><![CDATA[730009446F744A618995ABF5DA3F692E]]></AD_COLUMN_ID>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <SEQNO><![CDATA[30]]></SEQNO>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
-<!--7D735958F5AC45FEA24318DBC909E170-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
-<!--7D735958F5AC45FEA24318DBC909E170--></AD_FIELD>
-
 <!--7DC34559B3FAB45BE040007F0100784A--><AD_FIELD>
 <!--7DC34559B3FAB45BE040007F0100784A-->  <AD_FIELD_ID><![CDATA[7DC34559B3FAB45BE040007F0100784A]]></AD_FIELD_ID>
 <!--7DC34559B3FAB45BE040007F0100784A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -9232,8 +9232,8 @@
 <!--80D2CCB125DAECE6E040007F01000DDE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--80D2CCB125DAECE6E040007F01000DDE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--80D2CCB125DAECE6E040007F01000DDE-->  <NAME><![CDATA[Add Payment]]></NAME>
-<!--80D2CCB125DAECE6E040007F01000DDE-->  <DESCRIPTION><![CDATA[Add Payment]]></DESCRIPTION>
-<!--80D2CCB125DAECE6E040007F01000DDE-->  <HELP><![CDATA[Select sales invoices or sales orders that you want to match to this payment]]></HELP>
+<!--80D2CCB125DAECE6E040007F01000DDE-->  <DESCRIPTION><![CDATA[Add Payment button.]]></DESCRIPTION>
+<!--80D2CCB125DAECE6E040007F01000DDE-->  <HELP><![CDATA[Launches a process to add a payment to the selected invoice.]]></HELP>
 <!--80D2CCB125DAECE6E040007F01000DDE-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--80D2CCB125DAECE6E040007F01000DDE-->  <AD_TAB_ID><![CDATA[290]]></AD_TAB_ID>
 <!--80D2CCB125DAECE6E040007F01000DDE-->  <AD_COLUMN_ID><![CDATA[78A3367822B35459E040007F01012510]]></AD_COLUMN_ID>
@@ -14961,8 +14961,8 @@
 <!--AD7C15BA367642AFB471EFAFD768FB2D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--AD7C15BA367642AFB471EFAFD768FB2D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--AD7C15BA367642AFB471EFAFD768FB2D-->  <NAME><![CDATA[Add Payment]]></NAME>
-<!--AD7C15BA367642AFB471EFAFD768FB2D-->  <DESCRIPTION><![CDATA[Add Payment]]></DESCRIPTION>
-<!--AD7C15BA367642AFB471EFAFD768FB2D-->  <HELP><![CDATA[Select sales invoices or sales orders that you want to match to this payment]]></HELP>
+<!--AD7C15BA367642AFB471EFAFD768FB2D-->  <DESCRIPTION><![CDATA[Add Payment button.]]></DESCRIPTION>
+<!--AD7C15BA367642AFB471EFAFD768FB2D-->  <HELP><![CDATA[Launches a process to add a payment to the selected invoice.]]></HELP>
 <!--AD7C15BA367642AFB471EFAFD768FB2D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--AD7C15BA367642AFB471EFAFD768FB2D-->  <AD_TAB_ID><![CDATA[263]]></AD_TAB_ID>
 <!--AD7C15BA367642AFB471EFAFD768FB2D-->  <AD_COLUMN_ID><![CDATA[78A3367822B35459E040007F01012510]]></AD_COLUMN_ID>
@@ -19351,6 +19351,32 @@
 <!--E215E9D7AE7B4C12E040007F01001D97-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--E215E9D7AE7B4C12E040007F01001D97--></AD_FIELD>
 
+<!--E40D003712A2492395ACB57BFBFE6720--><AD_FIELD>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <AD_FIELD_ID><![CDATA[E40D003712A2492395ACB57BFBFE6720]]></AD_FIELD_ID>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <NAME><![CDATA[Business Partner]]></NAME>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <AD_TAB_ID><![CDATA[BE20AB937FC64221A86E93ECA0DF1C1D]]></AD_TAB_ID>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <AD_COLUMN_ID><![CDATA[2295DC7A28FE4F9DA842F453E2FF2F41]]></AD_COLUMN_ID>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <SEQNO><![CDATA[40]]></SEQNO>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--E40D003712A2492395ACB57BFBFE6720-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--E40D003712A2492395ACB57BFBFE6720--></AD_FIELD>
+
 <!--E452E6D8D7D14E56BFD0D9EFD22C2B4A--><AD_FIELD>
 <!--E452E6D8D7D14E56BFD0D9EFD22C2B4A-->  <AD_FIELD_ID><![CDATA[E452E6D8D7D14E56BFD0D9EFD22C2B4A]]></AD_FIELD_ID>
 <!--E452E6D8D7D14E56BFD0D9EFD22C2B4A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -19886,34 +19912,6 @@
 <!--E94A5003EABA4427A3C891AFE24C5CE8-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--E94A5003EABA4427A3C891AFE24C5CE8--></AD_FIELD>
 
-<!--E9A737BCD8C54A24B7F12072645540F2--><AD_FIELD>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <AD_FIELD_ID><![CDATA[E9A737BCD8C54A24B7F12072645540F2]]></AD_FIELD_ID>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <NAME><![CDATA[Business Partner]]></NAME>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <DESCRIPTION><![CDATA[Anyone who takes part in daily business operations by acting as a customer, employee, etc.]]></DESCRIPTION>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <HELP><![CDATA[A Business Partner is anyone with whom you transact.  This can include a customer, vendor, employee or any combination of these.]]></HELP>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <AD_TAB_ID><![CDATA[BE20AB937FC64221A86E93ECA0DF1C1D]]></AD_TAB_ID>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <AD_COLUMN_ID><![CDATA[8DEAEE4918C64D0AA2CFE36695F4C3E4]]></AD_COLUMN_ID>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <SEQNO><![CDATA[40]]></SEQNO>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
-<!--E9A737BCD8C54A24B7F12072645540F2-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
-<!--E9A737BCD8C54A24B7F12072645540F2--></AD_FIELD>
-
 <!--E9CC9F3F554F4F669C65DBDF55E8F0C6--><AD_FIELD>
 <!--E9CC9F3F554F4F669C65DBDF55E8F0C6-->  <AD_FIELD_ID><![CDATA[E9CC9F3F554F4F669C65DBDF55E8F0C6]]></AD_FIELD_ID>
 <!--E9CC9F3F554F4F669C65DBDF55E8F0C6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml	Mon May 12 13:29:00 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml	Mon May 12 13:57:18 2014 +0200
@@ -71,10 +71,14 @@
 from FIN_Payment_ScheduleDetail as psd
 left outer join psd.orderPaymentSchedule as ops  
 left outer join ops.order as ord 
+left outer join ord.businessPartner as ordbp
 left outer join ops.fINPaymentPriority as opriority 
+left outer join ops.finPaymentmethod opsfp
 left outer join psd.invoicePaymentSchedule as ips  
-left outer join ips.invoice as inv 
+left outer join ips.invoice as inv
+left outer join inv.businessPartner as invbp
 left outer join ips.fINPaymentPriority as ipriority 
+left outer join ips.finPaymentmethod as ipsfp
 left outer join psd.organization as org 
 left outer join org.organizationInformationList as oinfo 
 where @whereClause@
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Mon May 12 13:29:00 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Mon May 12 13:57:18 2014 +0200
@@ -320,6 +320,33 @@
 <!--5AA317DFDE564327BD5051B52939574E-->  <EM_OBANALY_SHOWINREPORT><![CDATA[N]]></EM_OBANALY_SHOWINREPORT>
 <!--5AA317DFDE564327BD5051B52939574E--></OBUIAPP_PARAMETER>
 
+<!--6AF091FD5F1440BB9F0E0C674A168144--><OBUIAPP_PARAMETER>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <OBUIAPP_PARAMETER_ID><![CDATA[6AF091FD5F1440BB9F0E0C674A168144]]></OBUIAPP_PARAMETER_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <NAME><![CDATA[Sales Transaction]]></NAME>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <DESCRIPTION><![CDATA[An indication that a transfer of goods and money between business partners is occurring.]]></DESCRIPTION>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <HELP><![CDATA[The Sales Transaction checkbox indicates if this item is a Sales Transaction.]]></HELP>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <SEQNO><![CDATA[230]]></SEQNO>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <COLUMNNAME><![CDATA[issotrx]]></COLUMNNAME>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <DEFAULTVALUE><![CDATA[@issotrx@]]></DEFAULTVALUE>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <AD_ELEMENT_ID><![CDATA[1106]]></AD_ELEMENT_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <OBUIAPP_PROCESS_ID><![CDATA[9BED7889E1034FE68BD85D5D16857320]]></OBUIAPP_PROCESS_ID>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <DISPLAYLOGIC><![CDATA[false]]></DISPLAYLOGIC>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--6AF091FD5F1440BB9F0E0C674A168144-->  <EM_OBANALY_SHOWINREPORT><![CDATA[N]]></EM_OBANALY_SHOWINREPORT>
+<!--6AF091FD5F1440BB9F0E0C674A168144--></OBUIAPP_PARAMETER>
+
 <!--7783E23035DA4DBC8DD694EBBD4A1E5F--><OBUIAPP_PARAMETER>
 <!--7783E23035DA4DBC8DD694EBBD4A1E5F-->  <OBUIAPP_PARAMETER_ID><![CDATA[7783E23035DA4DBC8DD694EBBD4A1E5F]]></OBUIAPP_PARAMETER_ID>
 <!--7783E23035DA4DBC8DD694EBBD4A1E5F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/hqlinjections/AddPaymentOrderInvoicesTransformer.java	Mon May 12 13:29:00 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/hqlinjections/AddPaymentOrderInvoicesTransformer.java	Mon May 12 13:57:18 2014 +0200
@@ -16,6 +16,7 @@
  * Contributor(s):  ______________________________________.
  *************************************************************************
  */
+
 package org.openbravo.advpaymentmngt.hqlinjections;
 
 import java.util.Map;
@@ -23,8 +24,6 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.client.kernel.ComponentProvider;
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.service.datasource.hql.HqlQueryTransformer;
 import org.openbravo.service.db.DalConnectionProvider;
 
@@ -38,189 +37,186 @@
     String hqlQuery = _hqlQuery;
     // Retrieve Parameters
     String transactionType = requestParameters.get("transaction_type");
-    final String strInvoiceId = requestParameters.get("@Invoice.id@");
-    // Initialize Variables
-    boolean isSalesTransaction = "true".equals(requestParameters.get("@Invoice.salesTransaction@")) ? true
-        : false;
+    String strBusinessPartnerId = requestParameters.get("received_from");
+    String strCurrencyId = requestParameters.get("c_currency_id");
+    String strFinPaymentMethodId = requestParameters.get("fin_paymentmethod_id");
+    boolean isSalesTransaction = "true".equals(requestParameters.get("issotrx")) ? true : false;
+
     String transformedHql = null;
     StringBuffer selectClause = new StringBuffer();
     StringBuffer whereClause = new StringBuffer();
     StringBuffer groupByClause = new StringBuffer();
 
-    if (strInvoiceId != null) {
+    if ("I".equals(transactionType)) {
 
-      final Invoice invoice = OBDal.getInstance().get(Invoice.class, strInvoiceId);
-      isSalesTransaction = invoice.isSalesTransaction();
-
-      if ("I".equals(transactionType)) {
-
-        // Create Select Clause
+      // Create Select Clause
         selectClause.append(getAggregatorFunction("psd.id") + " as paymentScheduleDetail, ");
         selectClause.append(getAggregatorFunction("ord.documentNo") + " as salesOrderNo, ");
-        selectClause.append(" inv.documentNo as invoiceNo, ");
-        selectClause
-            .append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id) as paymentMethod, ");
-        selectClause
-            .append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id) as businessPartner, ");
-        selectClause.append(" COALESCE(inv.invoiceDate, ord.orderDate) as transactionDate, ");
-        selectClause.append(" COALESCE(ips.expectedDate, ops.expectedDate) as expectedDate, ");
-        selectClause.append(" COALESCE(ips.amount, ops.amount) as expectedAmount, ");
-        selectClause
-            .append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) as invoicedAmount, ");
-        selectClause.append(" SUM(psd.amount) as outstandingAmount, ");
-        selectClause.append(" 0 as amount ");
+      selectClause.append(" inv.documentNo as invoiceNo, ");
+      selectClause
+          .append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id) as paymentMethod, ");
+      selectClause.append(" COALESCE(ipsfp.name, opsfp.name) as paymentMethodName, ");
+      selectClause
+          .append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id) as businessPartner, ");
+      selectClause.append(" COALESCE(invbp.name, ordbp.name) as businessPartnerName, ");
+      selectClause.append(" COALESCE(inv.invoiceDate, ord.orderDate) as transactionDate, ");
+      selectClause.append(" COALESCE(ips.expectedDate, ops.expectedDate) as expectedDate, ");
+      selectClause.append(" COALESCE(ips.amount, ops.amount) as expectedAmount, ");
+      selectClause
+          .append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) as invoicedAmount, ");
+      selectClause.append(" SUM(psd.amount) as outstandingAmount, ");
+      selectClause.append(" 0 as amount ");
 
-        // Create WhereClause
-        whereClause.append(" psd.paymentDetails is null ");
-        whereClause.append(" and (oinfo is null or oinfo.active = true) ");
-        whereClause.append(" and ((inv is not null ");
-        if (invoice.getBusinessPartner() != null) {
-          whereClause.append(" and inv.businessPartner.id = '"
-              + invoice.getBusinessPartner().getId() + "'");
-        }
-        if (invoice.getPaymentMethod() != null) {
-          whereClause.append(" and inv.paymentMethod.id = '" + invoice.getPaymentMethod().getId()
-              + "'");
-        }
-        whereClause.append(" and inv.salesTransaction = " + isSalesTransaction);
-        whereClause.append(" and inv.currency.id = '" + invoice.getCurrency().getId() + "' )) ");
+      // Create WhereClause
+      whereClause.append(" psd.paymentDetails is null ");
+      whereClause.append(" and (oinfo is null or oinfo.active = true) ");
+      whereClause.append(" and ((inv is not null ");
+      if (strBusinessPartnerId != null) {
+        whereClause.append(" and inv.businessPartner.id = '" + strBusinessPartnerId + "'");
+      }
+      if (strFinPaymentMethodId != null) {
+        whereClause.append(" and ips.finPaymentmethod.id = '" + strFinPaymentMethodId + "'");
+      }
+      whereClause.append(" and inv.salesTransaction = " + isSalesTransaction);
+      whereClause.append(" and inv.currency.id = '" + strCurrencyId + "' )) ");
 
-        // Create GroupBy Clause
-        groupByClause.append(" inv.documentNo, ");
-        groupByClause.append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id), ");
-        groupByClause.append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id), ");
-        groupByClause.append(" COALESCE(inv.invoiceDate, ord.orderDate), ");
-        groupByClause.append(" COALESCE(ips.expectedDate, ops.expectedDate), ");
-        groupByClause.append(" COALESCE(ips.amount, ops.amount), ");
-        groupByClause.append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) ");
+      // Create GroupBy Clause
+      groupByClause.append(" inv.documentNo, ");
+      groupByClause.append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id), ");
+      groupByClause.append(" COALESCE(ipsfp.name, opsfp.name), ");
+      groupByClause.append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id), ");
+      groupByClause.append(" COALESCE(invbp.name, ordbp.name), ");
+      groupByClause.append(" COALESCE(inv.invoiceDate, ord.orderDate), ");
+      groupByClause.append(" COALESCE(ips.expectedDate, ops.expectedDate), ");
+      groupByClause.append(" COALESCE(ips.amount, ops.amount), ");
+      groupByClause.append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) ");
 
-        // Replace where filters and having count clause
-        if (requestParameters.containsKey("criteria")) {
-          String criteria = requestParameters.get("criteria");
-          hqlQuery = replaceFiltersAndHavingClause(hqlQuery, criteria, transactionType);
-        } else {
-          hqlQuery = hqlQuery.replace("@havingClause@", "");
-        }
-
-      } else if ("O".equals(transactionType)) {
-
-        // Create Select Clause
-        selectClause.append(getAggregatorFunction("psd.id") + " as paymentScheduleDetail, ");
-        selectClause.append(" ord.documentNo as salesOrderNo, ");
-        selectClause.append(getAggregatorFunction("inv.documentNo") + " as invoiceNo, ");
-        selectClause
-            .append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id) as paymentMethod, ");
-        selectClause
-            .append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id) as businessPartner, ");
-        selectClause.append(" COALESCE(inv.invoiceDate, ord.orderDate) as transactionDate, ");
-        selectClause.append(" COALESCE(ips.expectedDate, ops.expectedDate) as expectedDate, ");
-        selectClause.append(" COALESCE(ips.amount, ops.amount) as expectedAmount, ");
-        selectClause
-            .append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) as invoicedAmount, ");
-        selectClause.append(" SUM(psd.amount) as outstandingAmount, ");
-        selectClause.append(" 0 as amount ");
-
-        // Create WhereClause
-        whereClause.append(" psd.paymentDetails is null ");
-        whereClause.append(" and (oinfo is null or oinfo.active = true) ");
-        whereClause.append(" and ((ord is not null ");
-        if (invoice.getBusinessPartner() != null) {
-          whereClause.append(" and ord.businessPartner.id = '"
-              + invoice.getBusinessPartner().getId() + "'");
-        }
-        if (invoice.getPaymentMethod() != null) {
-          whereClause.append(" and ord.paymentMethod.id = '" + invoice.getPaymentMethod().getId()
-              + "'");
-        }
-        whereClause.append(" and ord.salesTransaction = " + isSalesTransaction);
-        whereClause.append(" and ord.currency.id = '" + invoice.getCurrency().getId() + "' )) ");
-
-        // Create GroupBy Clause
-        groupByClause.append(" ord.documentNo, ");
-        groupByClause.append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id), ");
-        groupByClause.append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id), ");
-        groupByClause.append(" COALESCE(inv.invoiceDate, ord.orderDate), ");
-        groupByClause.append(" COALESCE(ips.expectedDate, ops.expectedDate), ");
-        groupByClause.append(" COALESCE(ips.amount, ops.amount), ");
-        groupByClause.append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) ");
-
-        // Replace where filters and having count clause
-        if (requestParameters.containsKey("criteria")) {
-          String criteria = requestParameters.get("criteria");
-          hqlQuery = replaceFiltersAndHavingClause(hqlQuery, criteria, transactionType);
-        } else {
-          hqlQuery = hqlQuery.replace("@havingClause@", "");
-        }
-
+      // Replace where filters and having count clause
+      if (requestParameters.containsKey("criteria")) {
+        String criteria = requestParameters.get("criteria");
+        hqlQuery = replaceFiltersAndHavingClause(hqlQuery, criteria, transactionType);
       } else {
-        // Create Select Clause
-        selectClause.append(" psd.id as paymentScheduleDetail, ");
-        selectClause.append(" ord.documentNo as salesOrderNo, ");
-        selectClause.append(" inv.documentNo as invoiceNo, ");
-        selectClause
-            .append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id) as paymentMethod, ");
-        selectClause
-            .append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id) as businessPartner, ");
-        selectClause.append(" COALESCE(inv.invoiceDate, ord.orderDate) as transactionDate, ");
-        selectClause.append(" COALESCE(ips.expectedDate, ops.expectedDate) as expectedDate, ");
-        selectClause.append(" COALESCE(ips.amount, ops.amount) as expectedAmount, ");
-        selectClause
-            .append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) as invoicedAmount, ");
-        selectClause.append(" psd.amount as outstandingAmount, ");
-        selectClause.append(" 0 as amount ");
-
-        // Create WhereClause
-        whereClause.append(" psd.paymentDetails is null ");
-        whereClause.append(" and (oinfo is null or oinfo.active = true) ");
-        whereClause.append(" and ((inv is not null ");
-        if (invoice.getBusinessPartner() != null) {
-          whereClause.append(" and inv.businessPartner.id = '"
-              + invoice.getBusinessPartner().getId() + "'");
-        }
-        if (invoice.getPaymentMethod() != null) {
-          whereClause.append(" and inv.paymentMethod.id = '" + invoice.getPaymentMethod().getId()
-              + "'");
-        }
-        whereClause.append(" and inv.salesTransaction = " + isSalesTransaction);
-        whereClause.append(" and inv.currency.id = '" + invoice.getCurrency().getId() + "' ) ");
-        whereClause.append(" or (ord is not null ");
-        if (invoice.getBusinessPartner() != null) {
-          whereClause.append(" and ord.businessPartner.id = '"
-              + invoice.getBusinessPartner().getId() + "'");
-        }
-        if (invoice.getPaymentMethod() != null) {
-          whereClause.append(" and ord.paymentMethod.id = '" + invoice.getPaymentMethod().getId()
-              + "'");
-        }
-        whereClause.append(" and ord.salesTransaction = " + isSalesTransaction);
-        whereClause.append(" and ord.currency.id = '" + invoice.getCurrency().getId() + "' )) ");
-
-        // There is no Group By Clause
-        hqlQuery = hqlQuery.replace("group by", "");
-
-        // Replace where filters and having count clause
-        if (requestParameters.containsKey("criteria")) {
-          String criteria = requestParameters.get("criteria");
-          hqlQuery = replaceFiltersAndHavingClause(hqlQuery, criteria, transactionType);
-        } else {
-          hqlQuery = hqlQuery.replace("@havingClause@", "");
-        }
+        hqlQuery = hqlQuery.replace("@havingClause@", "");
       }
 
-      // Remove alias @@ from Order By clause
-      if (requestParameters.containsKey("_sortBy")) {
-        String sortBy = requestParameters.get("_sortBy");
-        if (sortBy.startsWith("-")) {
-          sortBy = sortBy.substring(1);
-        }
-        hqlQuery = hqlQuery.replace("@" + sortBy + "@", sortBy);
+    } else if ("O".equals(transactionType)) {
+
+      // Create Select Clause
+        selectClause.append(getAggregatorFunction("psd.id") + " as paymentScheduleDetail, ");
+      selectClause.append(" ord.documentNo as salesOrderNo, ");
+        selectClause.append(getAggregatorFunction("inv.documentNo") + " as invoiceNo, ");
+      selectClause
+          .append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id) as paymentMethod, ");
+      selectClause.append(" COALESCE(ipsfp.name, opsfp.name) as paymentMethodName, ");
+      selectClause
+          .append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id) as businessPartner, ");
+      selectClause.append(" COALESCE(invbp.name, ordbp.name) as businessPartnerName, ");
+      selectClause.append(" COALESCE(inv.invoiceDate, ord.orderDate) as transactionDate, ");
+      selectClause.append(" COALESCE(ips.expectedDate, ops.expectedDate) as expectedDate, ");
+      selectClause.append(" COALESCE(ips.amount, ops.amount) as expectedAmount, ");
+      selectClause
+          .append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) as invoicedAmount, ");
+      selectClause.append(" SUM(psd.amount) as outstandingAmount, ");
+      selectClause.append(" 0 as amount ");
+
+      // Create WhereClause
+      whereClause.append(" psd.paymentDetails is null ");
+      whereClause.append(" and (oinfo is null or oinfo.active = true) ");
+      whereClause.append(" and ((ord is not null ");
+      if (strBusinessPartnerId != null) {
+        whereClause.append(" and ord.businessPartner.id = '" + strBusinessPartnerId + "'");
+      }
+      if (strFinPaymentMethodId != null) {
+        whereClause.append(" and ops.finPaymentmethod.id = '" + strFinPaymentMethodId + "'");
+      }
+      whereClause.append(" and ord.salesTransaction = " + isSalesTransaction);
+      whereClause.append(" and ord.currency.id = '" + strCurrencyId + "' )) ");
+
+      // Create GroupBy Clause
+      groupByClause.append(" ord.documentNo, ");
+      groupByClause.append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id), ");
+      groupByClause.append(" COALESCE(ipsfp.name, opsfp.name), ");
+      groupByClause.append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id), ");
+      groupByClause.append(" COALESCE(invbp.name, ordbp.name), ");
+      groupByClause.append(" COALESCE(inv.invoiceDate, ord.orderDate), ");
+      groupByClause.append(" COALESCE(ips.expectedDate, ops.expectedDate), ");
+      groupByClause.append(" COALESCE(ips.amount, ops.amount), ");
+      groupByClause.append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) ");
+
+      // Replace where filters and having count clause
+      if (requestParameters.containsKey("criteria")) {
+        String criteria = requestParameters.get("criteria");
+        hqlQuery = replaceFiltersAndHavingClause(hqlQuery, criteria, transactionType);
+      } else {
+        hqlQuery = hqlQuery.replace("@havingClause@", "");
       }
 
-      transformedHql = hqlQuery.replace("@selectClause@ ", selectClause.toString());
-      transformedHql = transformedHql.replace("@whereClause@ ", whereClause.toString());
-      transformedHql = transformedHql.replace("@groupByClause@", groupByClause.toString());
+    } else {
+      // Create Select Clause
+      selectClause.append(" psd.id as paymentScheduleDetail, ");
+      selectClause.append(" ord.documentNo as salesOrderNo, ");
+      selectClause.append(" inv.documentNo as invoiceNo, ");
+      selectClause
+          .append(" COALESCE(ips.finPaymentmethod.id, ops.finPaymentmethod.id) as paymentMethod, ");
+      selectClause.append(" COALESCE(ipsfp.name, opsfp.name) as paymentMethodName, ");
+      selectClause
+          .append(" COALESCE(inv.businessPartner.id, ord.businessPartner.id) as businessPartner, ");
+      selectClause.append(" COALESCE(invbp.name, ordbp.name) as businessPartnerName, ");
+      selectClause.append(" COALESCE(inv.invoiceDate, ord.orderDate) as transactionDate, ");
+      selectClause.append(" COALESCE(ips.expectedDate, ops.expectedDate) as expectedDate, ");
+      selectClause.append(" COALESCE(ips.amount, ops.amount) as expectedAmount, ");
+      selectClause
+          .append(" COALESCE(inv.grandTotalAmount, ord.grandTotalAmount) as invoicedAmount, ");
+      selectClause.append(" psd.amount as outstandingAmount, ");
+      selectClause.append(" 0 as amount ");
+
+      // Create WhereClause
+      whereClause.append(" psd.paymentDetails is null ");
+      whereClause.append(" and (oinfo is null or oinfo.active = true) ");
+      whereClause.append(" and ((inv is not null ");
+      if (strBusinessPartnerId != null) {
+        whereClause.append(" and inv.businessPartner.id = '" + strBusinessPartnerId + "'");
+      }
+      if (strFinPaymentMethodId != null) {
+        whereClause.append(" and ips.finPaymentmethod.id = '" + strFinPaymentMethodId + "'");
+      }
+      whereClause.append(" and inv.salesTransaction = " + isSalesTransaction);
+      whereClause.append(" and inv.currency.id = '" + strCurrencyId + "' ) ");
+      whereClause.append(" or (ord is not null ");
+      if (strBusinessPartnerId != null) {
+        whereClause.append(" and ord.businessPartner.id = '" + strBusinessPartnerId + "'");
+      }
+      if (strFinPaymentMethodId != null) {
+        whereClause.append(" and ops.finPaymentmethod.id = '" + strFinPaymentMethodId + "'");
+      }
+      whereClause.append(" and ord.salesTransaction = " + isSalesTransaction);
+      whereClause.append(" and ord.currency.id = '" + strCurrencyId + "' )) ");
+
+      // There is no Group By Clause
+      hqlQuery = hqlQuery.replace("group by", "");
+
+      // Replace where filters and having count clause
+      if (requestParameters.containsKey("criteria")) {
+        String criteria = requestParameters.get("criteria");
+        hqlQuery = replaceFiltersAndHavingClause(hqlQuery, criteria, transactionType);
+      } else {
+        hqlQuery = hqlQuery.replace("@havingClause@", "");
+      }
     }
 
+    // Remove alias @@ from Order By clause
+    if (requestParameters.containsKey("_sortBy")) {
+      String sortBy = requestParameters.get("_sortBy");
+      if (sortBy.startsWith("-")) {
+        sortBy = sortBy.substring(1);
+      }
+      hqlQuery = hqlQuery.replace("@" + sortBy + "@", sortBy);
+    }
+
+    transformedHql = hqlQuery.replace("@selectClause@ ", selectClause.toString());
+    transformedHql = transformedHql.replace("@whereClause@ ", whereClause.toString());
+    transformedHql = transformedHql.replace("@groupByClause@", groupByClause.toString());
+
     return transformedHql;
   }
 
@@ -267,16 +263,6 @@
 
           } else if ("invoiceNo".equals(fieldName)) {
             hqlQuery = hqlQuery.replace("@invoiceNo@", "inv.documentNo");
-          } else if ("paymentMethod".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@paymentMethod@", "ips.finPaymentmethod.id");
-          } else if ("businessPartner".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@businessPartner@", "inv.businessPartner.id");
-          } else if ("transactionDate".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@transactionDate@", "inv.invoiceDate");
-          } else if ("expectedAmount".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@expectedAmount@", "ips.amount");
-          } else if ("invoicedAmount".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@invoicedAmount@", "inv.grandTotalAmount");
           } else if ("outstandingAmount".equals(fieldName)) {
             // Remove the aggregate function from where clause and put in having clause
             if (havingClause.length() <= 0) {
@@ -329,16 +315,6 @@
               strReplaced = strReplaced.substring(0, strReplaced.indexOf(" and"));
             }
             havingClause.append(strReplaced);
-          } else if ("paymentMethod".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@paymentMethod@", "ops.finPaymentmethod.id");
-          } else if ("businessPartner".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@businessPartner@", "ord.businessPartner.id");
-          } else if ("transactionDate".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@transactionDate@", "ord.orderDate");
-          } else if ("expectedAmount".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@expectedAmount@", "ops.amount");
-          } else if ("invoicedAmount".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@invoicedAmount@", "ord.grandTotalAmount");
           } else if ("outstandingAmount".equals(fieldName)) {
             // Remove the aggregate function from where clause and put in having clause
             if (havingClause.length() <= 0) {
@@ -373,16 +349,6 @@
             hqlQuery = hqlQuery.replace("@salesOrderNo@", "ord.documentNo");
           } else if ("invoiceNo".equals(fieldName)) {
             hqlQuery = hqlQuery.replace("@invoiceNo@", "inv.documentNo");
-          } else if ("paymentMethod".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@paymentMethod@", "ops.finPaymentmethod.id");
-          } else if ("businessPartner".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@businessPartner@", "ord.businessPartner.id");
-          } else if ("transactionDate".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@transactionDate@", "ord.orderDate");
-          } else if ("expectedAmount".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@expectedAmount@", "ops.amount");
-          } else if ("invoicedAmount".equals(fieldName)) {
-            hqlQuery = hqlQuery.replace("@invoicedAmount@", "ord.grandTotalAmount");
           } else if ("outstandingAmount".equals(fieldName)) {
             hqlQuery = hqlQuery.replace("@outstandingAmount@", "psd.amount");
           }
@@ -406,8 +372,9 @@
    * @param havingClause
    * @return
    */
-  private String replaceHavingClause(String hqlQuery, String strToReplace,
+  private String replaceHavingClause(String _hqlQuery, String strToReplace,
       String strToReplaceBeginning, String strToReplaceWith, StringBuffer havingClause) {
+    String hqlQuery = _hqlQuery;
     String strReplaced = null;
     int beginIndex = hqlQuery.indexOf(strToReplaceBeginning);
     int endIndexParenthesis = hqlQuery.indexOf(" ) ", beginIndex);