Fixes issue 20619: Reverse Payment
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Fri, 01 Jun 2012 18:22:37 +0200
changeset 16736 1c31c7f3d244
parent 16735 8466c9b3c506
child 16737 db05e34ca917
Fixes issue 20619: Reverse Payment
modules/org.openbravo.advpaymentmngt/src-db/database/model/modifiedTables/FIN_PAYMENT.xml
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_MESSAGE.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODEL_OBJECT.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS.xml
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS_PARA.xml
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
src-db/database/model/tables/FIN_PAYMENT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_REF_LIST.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/modifiedTables/FIN_PAYMENT.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/modifiedTables/FIN_PAYMENT.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -17,5 +17,9 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="EM_APRM_REVERSEPAYMENT" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
+      </column>
     </table>
   </database>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -2361,7 +2361,7 @@
 <!--7DC34559B3F2B45BE040007F0100784A-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--7DC34559B3F2B45BE040007F0100784A-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7DC34559B3F2B45BE040007F0100784A-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--7DC34559B3F2B45BE040007F0100784A-->  <POSITION><![CDATA[32]]></POSITION>
+<!--7DC34559B3F2B45BE040007F0100784A-->  <POSITION><![CDATA[35]]></POSITION>
 <!--7DC34559B3F2B45BE040007F0100784A-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7DC34559B3F2B45BE040007F0100784A-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7DC34559B3F2B45BE040007F0100784A-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -2394,7 +2394,7 @@
 <!--7DC34559B3F3B45BE040007F0100784A-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--7DC34559B3F3B45BE040007F0100784A-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7DC34559B3F3B45BE040007F0100784A-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--7DC34559B3F3B45BE040007F0100784A-->  <POSITION><![CDATA[33]]></POSITION>
+<!--7DC34559B3F3B45BE040007F0100784A-->  <POSITION><![CDATA[36]]></POSITION>
 <!--7DC34559B3F3B45BE040007F0100784A-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7DC34559B3F3B45BE040007F0100784A-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7DC34559B3F3B45BE040007F0100784A-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -2463,7 +2463,7 @@
 <!--7FCAAFE989BCA375E040007F01007F0A-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--7FCAAFE989BCA375E040007F01007F0A-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7FCAAFE989BCA375E040007F01007F0A-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--7FCAAFE989BCA375E040007F01007F0A-->  <POSITION><![CDATA[34]]></POSITION>
+<!--7FCAAFE989BCA375E040007F01007F0A-->  <POSITION><![CDATA[37]]></POSITION>
 <!--7FCAAFE989BCA375E040007F01007F0A-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7FCAAFE989BCA375E040007F01007F0A-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7FCAAFE989BCA375E040007F01007F0A-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -3756,7 +3756,7 @@
 <!--87AA1068F10642CAE040007F010011D5-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--87AA1068F10642CAE040007F010011D5-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--87AA1068F10642CAE040007F010011D5-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
-<!--87AA1068F10642CAE040007F010011D5-->  <POSITION><![CDATA[35]]></POSITION>
+<!--87AA1068F10642CAE040007F010011D5-->  <POSITION><![CDATA[38]]></POSITION>
 <!--87AA1068F10642CAE040007F010011D5-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--87AA1068F10642CAE040007F010011D5-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--87AA1068F10642CAE040007F010011D5-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -7064,6 +7064,43 @@
 <!--BF61CD8A1E034B32B4F7770EDA6064DF-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--BF61CD8A1E034B32B4F7770EDA6064DF--></AD_COLUMN>
 
+<!--C09E190928152D28E040007F01002523--><AD_COLUMN>
+<!--C09E190928152D28E040007F01002523-->  <AD_COLUMN_ID><![CDATA[C09E190928152D28E040007F01002523]]></AD_COLUMN_ID>
+<!--C09E190928152D28E040007F01002523-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C09E190928152D28E040007F01002523-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C09E190928152D28E040007F01002523-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C09E190928152D28E040007F01002523-->  <NAME><![CDATA[EM_APRM_ReversePayment]]></NAME>
+<!--C09E190928152D28E040007F01002523-->  <DESCRIPTION><![CDATA[Create an opposite payment which reverts selected.]]></DESCRIPTION>
+<!--C09E190928152D28E040007F01002523-->  <HELP><![CDATA[Create an opposite payment which reverts selected.]]></HELP>
+<!--C09E190928152D28E040007F01002523-->  <COLUMNNAME><![CDATA[EM_APRM_ReversePayment]]></COLUMNNAME>
+<!--C09E190928152D28E040007F01002523-->  <AD_TABLE_ID><![CDATA[D1A97202E832470285C9B1EB026D54E2]]></AD_TABLE_ID>
+<!--C09E190928152D28E040007F01002523-->  <AD_REFERENCE_ID><![CDATA[28]]></AD_REFERENCE_ID>
+<!--C09E190928152D28E040007F01002523-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--C09E190928152D28E040007F01002523-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--C09E190928152D28E040007F01002523-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--C09E190928152D28E040007F01002523-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--C09E190928152D28E040007F01002523-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--C09E190928152D28E040007F01002523-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--C09E190928152D28E040007F01002523-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--C09E190928152D28E040007F01002523-->  <SEQNO><![CDATA[450]]></SEQNO>
+<!--C09E190928152D28E040007F01002523-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--C09E190928152D28E040007F01002523-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C09E190928152D28E040007F01002523-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--C09E190928152D28E040007F01002523-->  <AD_ELEMENT_ID><![CDATA[C09E18A3FCFEC058E040007F010024F4]]></AD_ELEMENT_ID>
+<!--C09E190928152D28E040007F01002523-->  <AD_PROCESS_ID><![CDATA[29D17F515727436DBCE32BC6CA28382B]]></AD_PROCESS_ID>
+<!--C09E190928152D28E040007F01002523-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--C09E190928152D28E040007F01002523-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--C09E190928152D28E040007F01002523-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--C09E190928152D28E040007F01002523-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--C09E190928152D28E040007F01002523-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--C09E190928152D28E040007F01002523-->  <POSITION><![CDATA[39]]></POSITION>
+<!--C09E190928152D28E040007F01002523-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--C09E190928152D28E040007F01002523-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--C09E190928152D28E040007F01002523-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--C09E190928152D28E040007F01002523-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--C09E190928152D28E040007F01002523-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--C09E190928152D28E040007F01002523--></AD_COLUMN>
+
 <!--C2C87639AA9846F2955E7CB6862FA57B--><AD_COLUMN>
 <!--C2C87639AA9846F2955E7CB6862FA57B-->  <AD_COLUMN_ID><![CDATA[C2C87639AA9846F2955E7CB6862FA57B]]></AD_COLUMN_ID>
 <!--C2C87639AA9846F2955E7CB6862FA57B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -12,6 +12,18 @@
 <!--093017D15DE649259C329641ADC41321-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--093017D15DE649259C329641ADC41321--></AD_ELEMENT>
 
+<!--256AB5C3D6144B2C9884CF0FA4D81911--><AD_ELEMENT>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <AD_ELEMENT_ID><![CDATA[256AB5C3D6144B2C9884CF0FA4D81911]]></AD_ELEMENT_ID>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <COLUMNNAME><![CDATA[PaymentDate]]></COLUMNNAME>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <NAME><![CDATA[Payment Date]]></NAME>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <PRINTNAME><![CDATA[Payment Date]]></PRINTNAME>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--256AB5C3D6144B2C9884CF0FA4D81911-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--256AB5C3D6144B2C9884CF0FA4D81911--></AD_ELEMENT>
+
 <!--36C60E53F1274EDA827ED5146A2B13D1--><AD_ELEMENT>
 <!--36C60E53F1274EDA827ED5146A2B13D1-->  <AD_ELEMENT_ID><![CDATA[36C60E53F1274EDA827ED5146A2B13D1]]></AD_ELEMENT_ID>
 <!--36C60E53F1274EDA827ED5146A2B13D1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -483,6 +495,20 @@
 <!--B40C938A247779EFE040A8C0916618AE-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--B40C938A247779EFE040A8C0916618AE--></AD_ELEMENT>
 
+<!--C09E18A3FCFEC058E040007F010024F4--><AD_ELEMENT>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <AD_ELEMENT_ID><![CDATA[C09E18A3FCFEC058E040007F010024F4]]></AD_ELEMENT_ID>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <COLUMNNAME><![CDATA[EM_APRM_ReversePayment]]></COLUMNNAME>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <NAME><![CDATA[Reverse Payment]]></NAME>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <PRINTNAME><![CDATA[Reverse Payment]]></PRINTNAME>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <DESCRIPTION><![CDATA[Create an opposite payment which reverts selected.]]></DESCRIPTION>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <HELP><![CDATA[Create an opposite payment which reverts selected.]]></HELP>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--C09E18A3FCFEC058E040007F010024F4-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--C09E18A3FCFEC058E040007F010024F4--></AD_ELEMENT>
+
 <!--C8E8009C6BF5427EA930515F217F768E--><AD_ELEMENT>
 <!--C8E8009C6BF5427EA930515F217F768E-->  <AD_ELEMENT_ID><![CDATA[C8E8009C6BF5427EA930515F217F768E]]></AD_ELEMENT_ID>
 <!--C8E8009C6BF5427EA930515F217F768E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -10279,6 +10279,64 @@
 <!--BE902DC15B9B49F8828C71AD5722716D-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--BE902DC15B9B49F8828C71AD5722716D--></AD_FIELD>
 
+<!--C09E17BE0013A6E3E040007F01002527--><AD_FIELD>
+<!--C09E17BE0013A6E3E040007F01002527-->  <AD_FIELD_ID><![CDATA[C09E17BE0013A6E3E040007F01002527]]></AD_FIELD_ID>
+<!--C09E17BE0013A6E3E040007F01002527-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C09E17BE0013A6E3E040007F01002527-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C09E17BE0013A6E3E040007F01002527-->  <NAME><![CDATA[Reverse Payment]]></NAME>
+<!--C09E17BE0013A6E3E040007F01002527-->  <DESCRIPTION><![CDATA[Create an opposite payment which reverts selected.]]></DESCRIPTION>
+<!--C09E17BE0013A6E3E040007F01002527-->  <HELP><![CDATA[Create an opposite payment which reverts selected.]]></HELP>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C09E17BE0013A6E3E040007F01002527-->  <AD_TAB_ID><![CDATA[C4B6506838E14A349D6717D6856F1B56]]></AD_TAB_ID>
+<!--C09E17BE0013A6E3E040007F01002527-->  <AD_COLUMN_ID><![CDATA[C09E190928152D28E040007F01002523]]></AD_COLUMN_ID>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--C09E17BE0013A6E3E040007F01002527-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y' & (@status@='RPR' | @status@='PPM' | @status@='PWNC' | @status@='RDNC' | @status@='RPPC') & @FIN_Rev_Payment_ID@ = '']]></DISPLAYLOGIC>
+<!--C09E17BE0013A6E3E040007F01002527-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--C09E17BE0013A6E3E040007F01002527-->  <SEQNO><![CDATA[260]]></SEQNO>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C09E17BE0013A6E3E040007F01002527-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--C09E17BE0013A6E3E040007F01002527-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--C09E17BE0013A6E3E040007F01002527-->  <GRID_SEQNO><![CDATA[0]]></GRID_SEQNO>
+<!--C09E17BE0013A6E3E040007F01002527-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--C09E17BE0013A6E3E040007F01002527-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--C09E17BE0013A6E3E040007F01002527-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--C09E17BE0013A6E3E040007F01002527-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--C09E17BE0013A6E3E040007F01002527--></AD_FIELD>
+
+<!--C09E8640A3C40A32E040007F01003809--><AD_FIELD>
+<!--C09E8640A3C40A32E040007F01003809-->  <AD_FIELD_ID><![CDATA[C09E8640A3C40A32E040007F01003809]]></AD_FIELD_ID>
+<!--C09E8640A3C40A32E040007F01003809-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C09E8640A3C40A32E040007F01003809-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C09E8640A3C40A32E040007F01003809-->  <NAME><![CDATA[Reverse Payment]]></NAME>
+<!--C09E8640A3C40A32E040007F01003809-->  <DESCRIPTION><![CDATA[Create an opposite payment which reverts selected.]]></DESCRIPTION>
+<!--C09E8640A3C40A32E040007F01003809-->  <HELP><![CDATA[Create an opposite payment which reverts selected.]]></HELP>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C09E8640A3C40A32E040007F01003809-->  <AD_TAB_ID><![CDATA[F7A52FDAAA0346EFA07D53C125B40404]]></AD_TAB_ID>
+<!--C09E8640A3C40A32E040007F01003809-->  <AD_COLUMN_ID><![CDATA[C09E190928152D28E040007F01002523]]></AD_COLUMN_ID>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--C09E8640A3C40A32E040007F01003809-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y' & (@status@='RPR' | @status@='PPM' | @status@='PWNC' | @status@='RDNC' | @status@='RPPC') & @FIN_Rev_Payment_ID@ = '']]></DISPLAYLOGIC>
+<!--C09E8640A3C40A32E040007F01003809-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--C09E8640A3C40A32E040007F01003809-->  <SEQNO><![CDATA[260]]></SEQNO>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C09E8640A3C40A32E040007F01003809-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--C09E8640A3C40A32E040007F01003809-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--C09E8640A3C40A32E040007F01003809-->  <GRID_SEQNO><![CDATA[0]]></GRID_SEQNO>
+<!--C09E8640A3C40A32E040007F01003809-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--C09E8640A3C40A32E040007F01003809-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--C09E8640A3C40A32E040007F01003809-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--C09E8640A3C40A32E040007F01003809-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--C09E8640A3C40A32E040007F01003809--></AD_FIELD>
+
 <!--C12ED5C93034481EAA90C46C242EE15A--><AD_FIELD>
 <!--C12ED5C93034481EAA90C46C242EE15A-->  <AD_FIELD_ID><![CDATA[C12ED5C93034481EAA90C46C242EE15A]]></AD_FIELD_ID>
 <!--C12ED5C93034481EAA90C46C242EE15A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -870,6 +870,17 @@
 <!--EFA31753A0BB4C4AB3E6BC741FEE811E-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--EFA31753A0BB4C4AB3E6BC741FEE811E--></AD_MESSAGE>
 
+<!--EFA91F88357E42B4826349C32C9E0383--><AD_MESSAGE>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <AD_MESSAGE_ID><![CDATA[EFA91F88357E42B4826349C32C9E0383]]></AD_MESSAGE_ID>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <VALUE><![CDATA[APRM_PaymentReversed]]></VALUE>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <MSGTEXT><![CDATA[Payment can not be reactivated as it has been reversed. Please undo reversal prior to reactivate this payment.]]></MSGTEXT>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--EFA91F88357E42B4826349C32C9E0383-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--EFA91F88357E42B4826349C32C9E0383--></AD_MESSAGE>
+
 <!--F0BBB5C1155F46378B6FF74A8F561046--><AD_MESSAGE>
 <!--F0BBB5C1155F46378B6FF74A8F561046-->  <AD_MESSAGE_ID><![CDATA[F0BBB5C1155F46378B6FF74A8F561046]]></AD_MESSAGE_ID>
 <!--F0BBB5C1155F46378B6FF74A8F561046-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -1079,4 +1090,15 @@
 <!--FF8081813108A518013108B682CF000E-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--FF8081813108A518013108B682CF000E--></AD_MESSAGE>
 
+<!--FFE9DD4433F54133B8C273D965939E39--><AD_MESSAGE>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <AD_MESSAGE_ID><![CDATA[FFE9DD4433F54133B8C273D965939E39]]></AD_MESSAGE_ID>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <VALUE><![CDATA[APRM_CreditConsumed]]></VALUE>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <MSGTEXT><![CDATA[Payment can not be reversed. Some of the credit from this payment has already been used. Please undo credit consumption prior to reverse this payment.]]></MSGTEXT>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--FFE9DD4433F54133B8C273D965939E39-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--FFE9DD4433F54133B8C273D965939E39--></AD_MESSAGE>
+
 </data>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -168,6 +168,18 @@
 <!--DC6F77826AD54AEF865E47C8FC356143-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--DC6F77826AD54AEF865E47C8FC356143--></AD_MODEL_OBJECT>
 
+<!--DF09705B3D7F4756A1E741FB3E73B825--><AD_MODEL_OBJECT>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <AD_MODEL_OBJECT_ID><![CDATA[DF09705B3D7F4756A1E741FB3E73B825]]></AD_MODEL_OBJECT_ID>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <ACTION><![CDATA[P]]></ACTION>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <CLASSNAME><![CDATA[org.openbravo.advpaymentmngt.process.FIN_PaymentProcess]]></CLASSNAME>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <AD_PROCESS_ID><![CDATA[29D17F515727436DBCE32BC6CA28382B]]></AD_PROCESS_ID>
+<!--DF09705B3D7F4756A1E741FB3E73B825-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--DF09705B3D7F4756A1E741FB3E73B825--></AD_MODEL_OBJECT>
+
 <!--E7D054B44F5848B6B6FC5923EBA4E1DE--><AD_MODEL_OBJECT>
 <!--E7D054B44F5848B6B6FC5923EBA4E1DE-->  <AD_MODEL_OBJECT_ID><![CDATA[E7D054B44F5848B6B6FC5923EBA4E1DE]]></AD_MODEL_OBJECT_ID>
 <!--E7D054B44F5848B6B6FC5923EBA4E1DE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -41,6 +41,25 @@
 <!--15C8708DFC464C2D91286E59624FDD18-->  <ISADVANCEDFEATURE><![CDATA[N]]></ISADVANCEDFEATURE>
 <!--15C8708DFC464C2D91286E59624FDD18--></AD_PROCESS>
 
+<!--29D17F515727436DBCE32BC6CA28382B--><AD_PROCESS>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <AD_PROCESS_ID><![CDATA[29D17F515727436DBCE32BC6CA28382B]]></AD_PROCESS_ID>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <VALUE><![CDATA[Reverse Payment]]></VALUE>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <NAME><![CDATA[Reverse Payment]]></NAME>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ACCESSLEVEL><![CDATA[1]]></ACCESSLEVEL>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISUSERSTARTABLE><![CDATA[N]]></ISUSERSTARTABLE>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISREPORT><![CDATA[N]]></ISREPORT>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <UIPATTERN><![CDATA[S]]></UIPATTERN>
+<!--29D17F515727436DBCE32BC6CA28382B-->  <ISADVANCEDFEATURE><![CDATA[N]]></ISADVANCEDFEATURE>
+<!--29D17F515727436DBCE32BC6CA28382B--></AD_PROCESS>
+
 <!--2EED9BC16DB34D2B80BA40A21564BECF--><AD_PROCESS>
 <!--2EED9BC16DB34D2B80BA40A21564BECF-->  <AD_PROCESS_ID><![CDATA[2EED9BC16DB34D2B80BA40A21564BECF]]></AD_PROCESS_ID>
 <!--2EED9BC16DB34D2B80BA40A21564BECF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -127,6 +127,23 @@
 <!--8BEBA07E78124B2B92B764D9B452B209-->  <AD_ELEMENT_ID><![CDATA[800080]]></AD_ELEMENT_ID>
 <!--8BEBA07E78124B2B92B764D9B452B209--></AD_PROCESS_PARA>
 
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632--><AD_PROCESS_PARA>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <AD_PROCESS_PARA_ID><![CDATA[8ED43FD56EE041F2BBC1C0AE0A56D632]]></AD_PROCESS_PARA_ID>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <NAME><![CDATA[Payment Date]]></NAME>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <AD_PROCESS_ID><![CDATA[29D17F515727436DBCE32BC6CA28382B]]></AD_PROCESS_ID>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <COLUMNNAME><![CDATA[paymentDate]]></COLUMNNAME>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632-->  <AD_ELEMENT_ID><![CDATA[256AB5C3D6144B2C9884CF0FA4D81911]]></AD_ELEMENT_ID>
+<!--8ED43FD56EE041F2BBC1C0AE0A56D632--></AD_PROCESS_PARA>
+
 <!--9728F9CADE45497E9F583A76B7DE3BE6--><AD_PROCESS_PARA>
 <!--9728F9CADE45497E9F583A76B7DE3BE6-->  <AD_PROCESS_PARA_ID><![CDATA[9728F9CADE45497E9F583A76B7DE3BE6]]></AD_PROCESS_PARA_ID>
 <!--9728F9CADE45497E9F583A76B7DE3BE6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -169,6 +186,27 @@
 <!--A7B47A5637A74910ADC70CD66E6C6A29-->  <AD_ELEMENT_ID><![CDATA[210]]></AD_ELEMENT_ID>
 <!--A7B47A5637A74910ADC70CD66E6C6A29--></AD_PROCESS_PARA>
 
+<!--D04309BB0DA14B5789FB76C141ED464C--><AD_PROCESS_PARA>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_PROCESS_PARA_ID><![CDATA[D04309BB0DA14B5789FB76C141ED464C]]></AD_PROCESS_PARA_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <NAME><![CDATA[Action]]></NAME>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <DESCRIPTION><![CDATA[A drop down list box indicating the next step to take.]]></DESCRIPTION>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <HELP><![CDATA[The Action field indicates the Action to be performed for this element.]]></HELP>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_PROCESS_ID><![CDATA[29D17F515727436DBCE32BC6CA28382B]]></AD_PROCESS_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_REFERENCE_VALUE_ID><![CDATA[66F2DCC800A34F94923444C29478E70A]]></AD_REFERENCE_VALUE_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <COLUMNNAME><![CDATA[action]]></COLUMNNAME>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <DEFAULTVALUE><![CDATA[RV]]></DEFAULTVALUE>
+<!--D04309BB0DA14B5789FB76C141ED464C-->  <AD_ELEMENT_ID><![CDATA[152]]></AD_ELEMENT_ID>
+<!--D04309BB0DA14B5789FB76C141ED464C--></AD_PROCESS_PARA>
+
 <!--E2EB0EFA3CE741C1848590D270CEBE2B--><AD_PROCESS_PARA>
 <!--E2EB0EFA3CE741C1848590D270CEBE2B-->  <AD_PROCESS_PARA_ID><![CDATA[E2EB0EFA3CE741C1848590D270CEBE2B]]></AD_PROCESS_PARA_ID>
 <!--E2EB0EFA3CE741C1848590D270CEBE2B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Fri Jun 01 08:53:46 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Fri Jun 01 18:22:37 2012 +0200
@@ -33,8 +33,10 @@
 import org.openbravo.advpaymentmngt.dao.TransactionsDao;
 import org.openbravo.advpaymentmngt.exception.NoExecutionProcessFoundException;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
@@ -71,7 +73,8 @@
     try {
       // retrieve custom params
       final String strAction = (String) bundle.getParams().get("action");
-
+      // This parameter is used inside this class
+      String isReversedPayment = (String) bundle.getParams().get("isReversedPayment");
       // retrieve standard params
       final String recordID = (String) bundle.getParams().get("Fin_Payment_ID");
       final FIN_Payment payment = dao.getObject(FIN_Payment.class, recordID);
@@ -188,10 +191,12 @@
               .concat("...").toString() : description.toString();
           payment.setDescription(truncateDescription);
 
-          if (paymentAmount.compareTo(payment.getAmount()) != 0)
+          if (paymentAmount.compareTo(payment.getAmount()) != 0) {
             payment.setUsedCredit(paymentAmount.subtract(payment.getAmount()));
-          if (payment.getUsedCredit().compareTo(BigDecimal.ZERO) != 0)
+          }
+          if (payment.getUsedCredit().compareTo(BigDecimal.ZERO) != 0) {
             updateUsedCredit(payment);
+          }
 
           payment.setWriteoffAmount(paymentWriteOfAmount);
           payment.setProcessed(true);
@@ -347,6 +352,175 @@
         }
 
         // ***********************
+        // Reverse Payment
+        // ***********************
+      } else if (strAction.equals("RV")) {
+        FIN_Payment reversedPayment = (FIN_Payment) DalUtil.copy(payment, false);
+        final String paymentDate = (String) bundle.getParams().get("paymentdate");
+        OBContext.setAdminMode();
+        try {
+          if (BigDecimal.ZERO.compareTo(payment.getGeneratedCredit()) != 0
+              && BigDecimal.ZERO.compareTo(payment.getUsedCredit()) != 0) {
+            throw new OBException("@APRM_CreditConsumed@");
+          } else if (BigDecimal.ZERO.compareTo(payment.getGeneratedCredit()) != 0
+              && BigDecimal.ZERO.compareTo(payment.getUsedCredit()) == 0) {
+            reversedPayment.setUsedCredit(payment.getGeneratedCredit());
+            reversedPayment.setGeneratedCredit(BigDecimal.ZERO);
+          } else {
+            reversedPayment.setUsedCredit(BigDecimal.ZERO);
+            reversedPayment.setGeneratedCredit(BigDecimal.ZERO);
+          }
+          reversedPayment.setDocumentNo("*R*"
+              + FIN_Utility.getDocumentNo(payment.getDocumentType(), "FIN_Payment"));
+          reversedPayment.setPaymentDate(FIN_Utility.getDate(paymentDate));
+          reversedPayment.setDescription("");
+          reversedPayment.setProcessed(false);
+          reversedPayment.setPosted("N");
+          reversedPayment.setProcessNow(false);
+          reversedPayment.setAPRMProcessPayment("P");
+          reversedPayment.setStatus("RPAP");
+          // Amounts
+          reversedPayment.setAmount(payment.getAmount().negate());
+          reversedPayment.setWriteoffAmount(payment.getWriteoffAmount().negate());
+          reversedPayment.setFinancialTransactionAmount(payment.getFinancialTransactionAmount()
+              .negate());
+          OBDal.getInstance().save(reversedPayment);
+
+          List<FIN_PaymentDetail> reversedDetails = new ArrayList<FIN_PaymentDetail>();
+
+          OBDal.getInstance().save(reversedPayment);
+          List<FIN_Payment_Credit> credits = payment.getFINPaymentCreditList();
+
+          for (FIN_PaymentDetail pd : payment.getFINPaymentDetailList()) {
+            FIN_PaymentDetail reversedPaymentDetail = (FIN_PaymentDetail) DalUtil.copy(pd, false);
+            reversedPaymentDetail.setFinPayment(reversedPayment);
+            reversedPaymentDetail.setAmount(pd.getAmount().negate());
+            reversedPaymentDetail.setWriteoffAmount(pd.getWriteoffAmount().negate());
+            if (pd.isRefund()) {
+              reversedPaymentDetail.setPrepayment(true);
+              reversedPaymentDetail.setRefund(false);
+              reversedPayment.setGeneratedCredit(reversedPayment.getGeneratedCredit().add(
+                  pd.getAmount()));
+              credits = new ArrayList<FIN_Payment_Credit>();
+              OBDal.getInstance().save(reversedPayment);
+            } else if (pd.isPrepayment()
+                && pd.getFINPaymentScheduleDetailList().get(0).getOrderPaymentSchedule() == null) {
+              reversedPaymentDetail.setPrepayment(true);
+              reversedPaymentDetail.setRefund(true);
+            }
+            List<FIN_PaymentScheduleDetail> reversedSchedDetails = new ArrayList<FIN_PaymentScheduleDetail>();
+            OBDal.getInstance().save(reversedPaymentDetail);
+            // Create or update PSD of orders and invoices to set the new outstanding amount
+            for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
+              if (psd.getInvoicePaymentSchedule() != null || psd.getOrderPaymentSchedule() != null) {
+                OBCriteria<FIN_PaymentScheduleDetail> unpaidSchedDet = OBDal.getInstance()
+                    .createCriteria(FIN_PaymentScheduleDetail.class);
+                if (psd.getInvoicePaymentSchedule() != null)
+                  unpaidSchedDet.add(Restrictions.eq(
+                      FIN_PaymentScheduleDetail.PROPERTY_INVOICEPAYMENTSCHEDULE,
+                      psd.getInvoicePaymentSchedule()));
+                if (psd.getOrderPaymentSchedule() != null)
+                  unpaidSchedDet.add(Restrictions.eq(
+                      FIN_PaymentScheduleDetail.PROPERTY_ORDERPAYMENTSCHEDULE,
+                      psd.getOrderPaymentSchedule()));
+                unpaidSchedDet.add(Restrictions
+                    .isNull(FIN_PaymentScheduleDetail.PROPERTY_PAYMENTDETAILS));
+                List<FIN_PaymentScheduleDetail> openPSDs = unpaidSchedDet.list();
+                // If invoice/order not fully paid, update outstanding amount
+                if (openPSDs.size() > 0) {
+                  FIN_PaymentScheduleDetail openPSD = openPSDs.get(0);
+                  BigDecimal openAmount = openPSD.getAmount().add(psd.getAmount());
+                  if (openAmount.compareTo(BigDecimal.ZERO) == 0) {
+                    OBDal.getInstance().remove(openPSD);
+                  } else {
+                    openPSD.setAmount(openAmount);
+                  }
+                } else {
+                  // If invoice is fully paid create a new schedule detail.
+                  FIN_PaymentScheduleDetail openPSD = (FIN_PaymentScheduleDetail) DalUtil.copy(psd,
+                      false);
+                  openPSD.setPaymentDetails(null);
+                  // Amounts
+                  openPSD.setWriteoffAmount(BigDecimal.ZERO);
+                  openPSD.setAmount(psd.getAmount());
+
+                  openPSD.setCanceled(false);
+                  OBDal.getInstance().save(openPSD);
+                }
+              }
+              FIN_PaymentScheduleDetail reversedPaymentSchedDetail = (FIN_PaymentScheduleDetail) DalUtil
+                  .copy(psd, false);
+              reversedPaymentSchedDetail.setPaymentDetails(reversedPaymentDetail);
+              // Amounts
+              reversedPaymentSchedDetail.setWriteoffAmount(psd.getWriteoffAmount().negate());
+              reversedPaymentSchedDetail.setAmount(psd.getAmount().negate());
+
+              List<FIN_OrigPaymentScheduleDetail> reversedOrigSchedDetails = new ArrayList<FIN_OrigPaymentScheduleDetail>();
+
+              for (FIN_OrigPaymentScheduleDetail opsd : psd.getFINOrigPaymentScheduleDetailList()) {
+                FIN_OrigPaymentScheduleDetail reversedOPSD = (FIN_OrigPaymentScheduleDetail) DalUtil
+                    .copy(opsd, false);
+                reversedOPSD.setAmount(opsd.getAmount().negate());
+                reversedOPSD.setPaymentScheduleDetail(reversedPaymentSchedDetail);
+                reversedOPSD.setWriteoffAmount(opsd.getWriteoffAmount().negate());
+                OBDal.getInstance().save(reversedOPSD);
+                reversedOrigSchedDetails.add(reversedOPSD);
+              }
+              reversedPaymentSchedDetail
+                  .setFINOrigPaymentScheduleDetailList(reversedOrigSchedDetails);
+              OBDal.getInstance().save(reversedPaymentSchedDetail);
+              reversedSchedDetails.add(reversedPaymentSchedDetail);
+            }
+            reversedPaymentDetail.setFINPaymentScheduleDetailList(reversedSchedDetails);
+            OBDal.getInstance().save(reversedPaymentDetail);
+            reversedDetails.add(reversedPaymentDetail);
+          }
+          reversedPayment.setFINPaymentDetailList(reversedDetails);
+          OBDal.getInstance().save(reversedPayment);
+
+          List<FIN_Payment_Credit> reversedCredits = new ArrayList<FIN_Payment_Credit>();
+          for (FIN_Payment_Credit pc : credits) {
+            FIN_Payment_Credit reversedPaymentCredit = (FIN_Payment_Credit) DalUtil.copy(pc, false);
+            reversedPaymentCredit.setAmount(pc.getAmount().negate());
+            reversedPaymentCredit.setCreditPaymentUsed(pc.getCreditPaymentUsed());
+            pc.getCreditPaymentUsed().setUsedCredit(
+                pc.getCreditPaymentUsed().getUsedCredit().add(pc.getAmount().negate()));
+            reversedPaymentCredit.setPayment(reversedPayment);
+            OBDal.getInstance().save(pc.getCreditPaymentUsed());
+            OBDal.getInstance().save(reversedPaymentCredit);
+            reversedCredits.add(reversedPaymentCredit);
+          }
+
+          reversedPayment.setFINPaymentCreditList(reversedCredits);
+          OBDal.getInstance().save(reversedPayment);
+
+          List<ConversionRateDoc> conversions = new ArrayList<ConversionRateDoc>();
+          for (ConversionRateDoc cr : payment.getCurrencyConversionRateDocList()) {
+            ConversionRateDoc reversedCR = (ConversionRateDoc) DalUtil.copy(cr, false);
+            reversedCR.setForeignAmount(cr.getForeignAmount().negate());
+            reversedCR.setPayment(reversedPayment);
+            OBDal.getInstance().save(reversedCR);
+            conversions.add(reversedCR);
+          }
+          reversedPayment.setCurrencyConversionRateDocList(conversions);
+          OBDal.getInstance().save(reversedPayment);
+
+          OBDal.getInstance().flush();
+        } finally {
+          OBContext.restorePreviousMode();
+        }
+        HashMap<String, Object> parameterMap = new HashMap<String, Object>();
+        parameterMap.put("Fin_Payment_ID", reversedPayment.getId());
+        parameterMap.put("action", "P");
+        parameterMap.put("isReversedPayment", "Y");
+        bundle.setParams(parameterMap);
+        execute(bundle);
+        payment.setReversedPayment(reversedPayment);
+        OBDal.getInstance().save(payment);
+        OBDal.getInstance().flush();
+        return;
+
+        // ***********************
         // Reactivate Payment
         // ***********************
       } else if (strAction.equals("R")) {
@@ -360,6 +534,16 @@
           OBDal.getInstance().rollbackAndClose();
           return;
         }
+        // Reversed Payment
+        if (payment.getReversedPayment() != null) {
+          msg.setType("Error");
+          msg.setTitle(Utility.messageBD(conProvider, "Error", language));
+          msg.setMessage(Utility.parseTranslation(conProvider, vars, language,
+              "@APRM_PaymentReversed@"));
+          bundle.setResult(msg);
+          OBDal.getInstance().rollbackAndClose();
+          return;
+        }
         // Transaction exists
         if (hasTransaction(payment)) {
           msg.setType("Error");
@@ -392,8 +576,9 @@
         payment.setAmount(BigDecimal.ZERO);
         payment.setFinancialTransactionAmount(BigDecimal.ZERO);
 
+        payment.setDescription("");
+
         payment.setStatus("RPAP");
-        payment.setDescription("");
         payment.setAPRMProcessPayment("P");
         OBDal.getInstance().save(payment);
         OBDal.getInstance().flush();
@@ -419,6 +604,14 @@
           List<FIN_PaymentDetail> paymentDetails = payment.getFINPaymentDetailList();
           List<ConversionRateDoc> conversionRates = payment.getCurrencyConversionRateDocList();
           Set<String> invoiceDocNos = new HashSet<String>();
+          // Undo Reversed payment relationship
+          List<FIN_Payment> revPayments = new ArrayList<FIN_Payment>();
+          for (FIN_Payment reversedPayment : payment.getFINPaymentReversedPaymentList()) {
+            reversedPayment.setReversedPayment(null);
+            OBDal.getInstance().save(reversedPayment);
+          }
+          payment.setFINPaymentReversedPaymentList(revPayments);
+          OBDal.getInstance().save(payment);
           for (FIN_PaymentDetail paymentDetail : paymentDetails) {
             // If an original payment plan is defined, all the details are removed, before removing
             // the payment schedule details associated lines
@@ -489,14 +682,24 @@
                   decreaseCustomerCredit(businessPartner, amount);
                 }
               }
+              removedPDS.add(paymentScheduleDetail);
               FIN_AddPayment.mergePaymentScheduleDetails(paymentScheduleDetail);
-              removedPDS.add(paymentScheduleDetail);
-
             }
             paymentDetail.getFINPaymentScheduleDetailList().removeAll(removedPDS);
             OBDal.getInstance().getSession().refresh(paymentDetail);
-            removedPD.add(paymentDetail);
-            removedPDIds.add(paymentDetail.getId());
+            // If there is any schedule detail with amount zero, those are deleted
+            for (FIN_PaymentScheduleDetail psd : removedPDS) {
+              if (BigDecimal.ZERO.compareTo(psd.getAmount()) == 0
+                  && BigDecimal.ZERO.compareTo(psd.getWriteoffAmount()) == 0) {
+                paymentDetail.getFINPaymentScheduleDetailList().remove(psd);
+                OBDal.getInstance().getSession().refresh(paymentDetail);
+                OBDal.getInstance().remove(psd);
+              }
+            }
+            if (paymentDetail.getFINPaymentScheduleDetailList().size() == 0) {
+              removedPD.add(paymentDetail);
+              removedPDIds.add(paymentDetail.getId());
+            }
             OBDal.getInstance().save(paymentDetail);
           }
           for (String pdToRm : removedPDIds) {
@@ -508,7 +711,7 @@
           OBDal.getInstance().save(payment);
 
           if (payment.getGeneratedCredit().compareTo(BigDecimal.ZERO) == 0
-              && payment.getUsedCredit().compareTo(BigDecimal.ZERO) == 1) {
+              && payment.getUsedCredit().compareTo(BigDecimal.ZERO) != 0) {
             undoUsedCredit(payment, vars, invoiceDocNos);
           }
 
@@ -698,7 +901,10 @@
       OBDal.getInstance().save(payment);
       OBDal.getInstance().flush();
 
-      if (!updateOriginalPaymentPlanInformation(payment)) {
+      // When payment is reversed, original payment plan is updated to reverse a particular original
+      // payment plan details (the ones related with payment which is reverted) so this step can be
+      // skipped
+      if (!"Y".equals(isReversedPayment) && !updateOriginalPaymentPlanInformation(payment)) {
         msg.setType("Error");
         msg.setMessage(Utility.parseTranslation(conProvider, vars, language,
             "@CouldNotUpdateOriginalPaymentPlan@"));
--- a/src-db/database/model/tables/FIN_PAYMENT.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/src-db/database/model/tables/FIN_PAYMENT.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -137,6 +137,10 @@
         <default/>
         <onCreateDefault><![CDATA[AMOUNT]]></onCreateDefault>
       </column>
+      <column name="FIN_REV_PAYMENT_ID" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="FIN_AD_CLIENT_PAYMENTS">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
@@ -167,6 +171,9 @@
       <foreign-key foreignTable="C_PROJECT" name="FIN_PAYMENT_PROJECT">
         <reference local="C_PROJECT_ID" foreign="C_PROJECT_ID"/>
       </foreign-key>
+      <foreign-key foreignTable="FIN_PAYMENT" name="FIN_PAYMENT_REVERSED">
+        <reference local="FIN_REV_PAYMENT_ID" foreign="FIN_PAYMENT_ID"/>
+      </foreign-key>
       <check name="FIN_PAYMENT_BP_CREDIT_CHECK"><![CDATA[((C_BPARTNER_ID IS NULL) AND (COALESCE(GENERATED_CREDIT, 0) = 0)) OR (C_BPARTNER_ID IS NOT NULL)]]></check>
       <check name="FIN_PAYMENT_CREATE_ALGORIT_CHK"><![CDATA[CREATEDBYALGORITHM IN ('Y', 'N')]]></check>
       <check name="FIN_PAYMENT_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -223920,7 +223920,7 @@
 <!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <POSITION><![CDATA[36]]></POSITION>
+<!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <POSITION><![CDATA[32]]></POSITION>
 <!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--260DB5AFD2154D6DA6B72BFD78334DEF-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -226435,7 +226435,7 @@
 <!--4028C9BC2DA5C491012DA6832A1003A8-->  <AD_CALLOUT_ID><![CDATA[40289C202E28D30F012E29062DCC004E]]></AD_CALLOUT_ID>
 <!--4028C9BC2DA5C491012DA6832A1003A8-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--4028C9BC2DA5C491012DA6832A1003A8-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--4028C9BC2DA5C491012DA6832A1003A8-->  <POSITION><![CDATA[37]]></POSITION>
+<!--4028C9BC2DA5C491012DA6832A1003A8-->  <POSITION><![CDATA[33]]></POSITION>
 <!--4028C9BC2DA5C491012DA6832A1003A8-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--4028C9BC2DA5C491012DA6832A1003A8-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--4028C9BC2DA5C491012DA6832A1003A8-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -226472,7 +226472,7 @@
 <!--4028C9BC2DA5C491012DA689D11F03BD-->  <AD_CALLOUT_ID><![CDATA[40289C202E28D30F012E29062DCC004E]]></AD_CALLOUT_ID>
 <!--4028C9BC2DA5C491012DA689D11F03BD-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--4028C9BC2DA5C491012DA689D11F03BD-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--4028C9BC2DA5C491012DA689D11F03BD-->  <POSITION><![CDATA[38]]></POSITION>
+<!--4028C9BC2DA5C491012DA689D11F03BD-->  <POSITION><![CDATA[34]]></POSITION>
 <!--4028C9BC2DA5C491012DA689D11F03BD-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--4028C9BC2DA5C491012DA689D11F03BD-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--4028C9BC2DA5C491012DA689D11F03BD-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -252445,7 +252445,7 @@
 <!--7891269C83D9655DE040007F010155CE-->  <AD_CALLOUT_ID><![CDATA[056C5E9668194D478889D8043BFBF95C]]></AD_CALLOUT_ID>
 <!--7891269C83D9655DE040007F010155CE-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7891269C83D9655DE040007F010155CE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--7891269C83D9655DE040007F010155CE-->  <POSITION><![CDATA[3]]></POSITION>
+<!--7891269C83D9655DE040007F010155CE-->  <POSITION><![CDATA[10]]></POSITION>
 <!--7891269C83D9655DE040007F010155CE-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7891269C83D9655DE040007F010155CE-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7891269C83D9655DE040007F010155CE-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -252481,7 +252481,7 @@
 <!--7891269C83DB655DE040007F010155CE-->  <AD_CALLOUT_ID><![CDATA[40289C202E28D30F012E29062DCC004E]]></AD_CALLOUT_ID>
 <!--7891269C83DB655DE040007F010155CE-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7891269C83DB655DE040007F010155CE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--7891269C83DB655DE040007F010155CE-->  <POSITION><![CDATA[2]]></POSITION>
+<!--7891269C83DB655DE040007F010155CE-->  <POSITION><![CDATA[11]]></POSITION>
 <!--7891269C83DB655DE040007F010155CE-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7891269C83DB655DE040007F010155CE-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7891269C83DB655DE040007F010155CE-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -252555,7 +252555,7 @@
 <!--7891269C83DD655DE040007F010155CE-->  <AD_CALLOUT_ID><![CDATA[40289C202E28D30F012E29062DCC004E]]></AD_CALLOUT_ID>
 <!--7891269C83DD655DE040007F010155CE-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7891269C83DD655DE040007F010155CE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--7891269C83DD655DE040007F010155CE-->  <POSITION><![CDATA[4]]></POSITION>
+<!--7891269C83DD655DE040007F010155CE-->  <POSITION><![CDATA[13]]></POSITION>
 <!--7891269C83DD655DE040007F010155CE-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7891269C83DD655DE040007F010155CE-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7891269C83DD655DE040007F010155CE-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -252627,7 +252627,7 @@
 <!--7891269C83E0655DE040007F010155CE-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--7891269C83E0655DE040007F010155CE-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--7891269C83E0655DE040007F010155CE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--7891269C83E0655DE040007F010155CE-->  <POSITION><![CDATA[1]]></POSITION>
+<!--7891269C83E0655DE040007F010155CE-->  <POSITION><![CDATA[16]]></POSITION>
 <!--7891269C83E0655DE040007F010155CE-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--7891269C83E0655DE040007F010155CE-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--7891269C83E0655DE040007F010155CE-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -285856,6 +285856,42 @@
 <!--C0A3BFF2713A4EDAA70B5982472835D4-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--C0A3BFF2713A4EDAA70B5982472835D4--></AD_COLUMN>
 
+<!--C0B0C57D6210C545E040007F01005E8C--><AD_COLUMN>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_COLUMN_ID><![CDATA[C0B0C57D6210C545E040007F01005E8C]]></AD_COLUMN_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <NAME><![CDATA[ReversedPayment]]></NAME>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <DESCRIPTION><![CDATA[Payment which reverses current payment]]></DESCRIPTION>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <HELP><![CDATA[Payment which reverses current payment]]></HELP>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <COLUMNNAME><![CDATA[FIN_Rev_Payment_ID]]></COLUMNNAME>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_TABLE_ID><![CDATA[D1A97202E832470285C9B1EB026D54E2]]></AD_TABLE_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_REFERENCE_ID><![CDATA[18]]></AD_REFERENCE_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_REFERENCE_VALUE_ID><![CDATA[5E77652CBFEB4F03A3A0629642D024DD]]></AD_REFERENCE_VALUE_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISUPDATEABLE><![CDATA[N]]></ISUPDATEABLE>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <SEQNO><![CDATA[460]]></SEQNO>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_ELEMENT_ID><![CDATA[C0B77441B02C9E5FE040007F01005E72]]></AD_ELEMENT_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISSESSIONATTR><![CDATA[Y]]></ISSESSIONATTR>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <POSITION><![CDATA[40]]></POSITION>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--C0B0C57D6210C545E040007F01005E8C-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--C0B0C57D6210C545E040007F01005E8C--></AD_COLUMN>
+
 <!--C0FF55F981BB47279B6BA18A2D811482--><AD_COLUMN>
 <!--C0FF55F981BB47279B6BA18A2D811482-->  <AD_COLUMN_ID><![CDATA[C0FF55F981BB47279B6BA18A2D811482]]></AD_COLUMN_ID>
 <!--C0FF55F981BB47279B6BA18A2D811482-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -28175,6 +28175,20 @@
 <!--BFA91469430F42078C630B261DF37ECC-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--BFA91469430F42078C630B261DF37ECC--></AD_ELEMENT>
 
+<!--C0B77441B02C9E5FE040007F01005E72--><AD_ELEMENT>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <AD_ELEMENT_ID><![CDATA[C0B77441B02C9E5FE040007F01005E72]]></AD_ELEMENT_ID>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <COLUMNNAME><![CDATA[FIN_Rev_Payment_ID]]></COLUMNNAME>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <NAME><![CDATA[Reversed Payment]]></NAME>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <PRINTNAME><![CDATA[Reversed Payment]]></PRINTNAME>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <DESCRIPTION><![CDATA[Payment which reverses current payment]]></DESCRIPTION>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <HELP><![CDATA[Payment which reverses current payment]]></HELP>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C0B77441B02C9E5FE040007F01005E72-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--C0B77441B02C9E5FE040007F01005E72--></AD_ELEMENT>
+
 <!--C0FEDDACE59D4AA59AFB2D1D65D748E0--><AD_ELEMENT>
 <!--C0FEDDACE59D4AA59AFB2D1D65D748E0-->  <AD_ELEMENT_ID><![CDATA[C0FEDDACE59D4AA59AFB2D1D65D748E0]]></AD_ELEMENT_ID>
 <!--C0FEDDACE59D4AA59AFB2D1D65D748E0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -219691,6 +219691,66 @@
 <!--C07CAB5D284A4D91A00EC11D3AB874C1-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--C07CAB5D284A4D91A00EC11D3AB874C1--></AD_FIELD>
 
+<!--C0B77441B0399E5FE040007F01005E72--><AD_FIELD>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_FIELD_ID><![CDATA[C0B77441B0399E5FE040007F01005E72]]></AD_FIELD_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C0B77441B0399E5FE040007F01005E72-->  <NAME><![CDATA[Reversed Payment]]></NAME>
+<!--C0B77441B0399E5FE040007F01005E72-->  <DESCRIPTION><![CDATA[Payment which reverses current payment]]></DESCRIPTION>
+<!--C0B77441B0399E5FE040007F01005E72-->  <HELP><![CDATA[Payment which reverses current payment]]></HELP>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_TAB_ID><![CDATA[C4B6506838E14A349D6717D6856F1B56]]></AD_TAB_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_COLUMN_ID><![CDATA[C0B0C57D6210C545E040007F01005E8C]]></AD_COLUMN_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_FIELDGROUP_ID><![CDATA[402880E72F1C15A5012F1C7AA98B00E8]]></AD_FIELDGROUP_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--C0B77441B0399E5FE040007F01005E72-->  <DISPLAYLOGIC><![CDATA[@FIN_Rev_Payment_ID@ ! '']]></DISPLAYLOGIC>
+<!--C0B77441B0399E5FE040007F01005E72-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--C0B77441B0399E5FE040007F01005E72-->  <SEQNO><![CDATA[280]]></SEQNO>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C0B77441B0399E5FE040007F01005E72-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--C0B77441B0399E5FE040007F01005E72-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C0B77441B0399E5FE040007F01005E72-->  <GRID_SEQNO><![CDATA[0]]></GRID_SEQNO>
+<!--C0B77441B0399E5FE040007F01005E72-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--C0B77441B0399E5FE040007F01005E72-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--C0B77441B0399E5FE040007F01005E72-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--C0B77441B0399E5FE040007F01005E72-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--C0B77441B0399E5FE040007F01005E72--></AD_FIELD>
+
+<!--C0B77441B0409E5FE040007F01005E72--><AD_FIELD>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_FIELD_ID><![CDATA[C0B77441B0409E5FE040007F01005E72]]></AD_FIELD_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C0B77441B0409E5FE040007F01005E72-->  <NAME><![CDATA[ReversedPayment]]></NAME>
+<!--C0B77441B0409E5FE040007F01005E72-->  <DESCRIPTION><![CDATA[Payment which reverses current payment]]></DESCRIPTION>
+<!--C0B77441B0409E5FE040007F01005E72-->  <HELP><![CDATA[Payment which reverses current payment]]></HELP>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_TAB_ID><![CDATA[F7A52FDAAA0346EFA07D53C125B40404]]></AD_TAB_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_COLUMN_ID><![CDATA[C0B0C57D6210C545E040007F01005E8C]]></AD_COLUMN_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_FIELDGROUP_ID><![CDATA[402880E72F1C15A5012F1C7AA98B00E8]]></AD_FIELDGROUP_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--C0B77441B0409E5FE040007F01005E72-->  <DISPLAYLOGIC><![CDATA[@FIN_Rev_Payment_ID@ ! '']]></DISPLAYLOGIC>
+<!--C0B77441B0409E5FE040007F01005E72-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--C0B77441B0409E5FE040007F01005E72-->  <SEQNO><![CDATA[280]]></SEQNO>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--C0B77441B0409E5FE040007F01005E72-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--C0B77441B0409E5FE040007F01005E72-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C0B77441B0409E5FE040007F01005E72-->  <GRID_SEQNO><![CDATA[0]]></GRID_SEQNO>
+<!--C0B77441B0409E5FE040007F01005E72-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--C0B77441B0409E5FE040007F01005E72-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--C0B77441B0409E5FE040007F01005E72-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--C0B77441B0409E5FE040007F01005E72-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--C0B77441B0409E5FE040007F01005E72--></AD_FIELD>
+
 <!--C0D8C02023484E71A34CB658616F5011--><AD_FIELD>
 <!--C0D8C02023484E71A34CB658616F5011-->  <AD_FIELD_ID><![CDATA[C0D8C02023484E71A34CB658616F5011]]></AD_FIELD_ID>
 <!--C0D8C02023484E71A34CB658616F5011-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REFERENCE.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/src-db/database/sourcedata/AD_REFERENCE.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -4624,6 +4624,18 @@
 <!--66E310A87A844A51B8BAD2884E996CD6-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--66E310A87A844A51B8BAD2884E996CD6--></AD_REFERENCE>
 
+<!--66F2DCC800A34F94923444C29478E70A--><AD_REFERENCE>
+<!--66F2DCC800A34F94923444C29478E70A-->  <AD_REFERENCE_ID><![CDATA[66F2DCC800A34F94923444C29478E70A]]></AD_REFERENCE_ID>
+<!--66F2DCC800A34F94923444C29478E70A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--66F2DCC800A34F94923444C29478E70A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--66F2DCC800A34F94923444C29478E70A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--66F2DCC800A34F94923444C29478E70A-->  <NAME><![CDATA[FIN_Payment Reverse Actions]]></NAME>
+<!--66F2DCC800A34F94923444C29478E70A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--66F2DCC800A34F94923444C29478E70A-->  <ISBASEREFERENCE><![CDATA[N]]></ISBASEREFERENCE>
+<!--66F2DCC800A34F94923444C29478E70A-->  <PARENTREFERENCE_ID><![CDATA[17]]></PARENTREFERENCE_ID>
+<!--66F2DCC800A34F94923444C29478E70A-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--66F2DCC800A34F94923444C29478E70A--></AD_REFERENCE>
+
 <!--6C11958E975D4DF8A38E7F4A119A3077--><AD_REFERENCE>
 <!--6C11958E975D4DF8A38E7F4A119A3077-->  <AD_REFERENCE_ID><![CDATA[6C11958E975D4DF8A38E7F4A119A3077]]></AD_REFERENCE_ID>
 <!--6C11958E975D4DF8A38E7F4A119A3077-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Jun 01 08:53:46 2012 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Jun 01 18:22:37 2012 +0200
@@ -8627,6 +8627,18 @@
 <!--474F41E63A2B4EE6B1321CCB24C14929-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--474F41E63A2B4EE6B1321CCB24C14929--></AD_REF_LIST>
 
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E--><AD_REF_LIST>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <AD_REF_LIST_ID><![CDATA[497D2BEDD3E24B8E9B3206E465EE0A5E]]></AD_REF_LIST_ID>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <VALUE><![CDATA[RV]]></VALUE>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <NAME><![CDATA[Reverse Payment]]></NAME>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <AD_REFERENCE_ID><![CDATA[66F2DCC800A34F94923444C29478E70A]]></AD_REFERENCE_ID>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--497D2BEDD3E24B8E9B3206E465EE0A5E--></AD_REF_LIST>
+
 <!--49A96D77C74A44EA90AED7C50BBAFAE1--><AD_REF_LIST>
 <!--49A96D77C74A44EA90AED7C50BBAFAE1-->  <AD_REF_LIST_ID><![CDATA[49A96D77C74A44EA90AED7C50BBAFAE1]]></AD_REF_LIST_ID>
 <!--49A96D77C74A44EA90AED7C50BBAFAE1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>