[Core][APRM] Allow reversal document type definition.
authorMikel Irurita <mikel.irurita@openbravo.com>
Tue, 08 Mar 2011 17:56:33 +0100
changeset 11116 3ef22b6a0523
parent 11115 af8ac7dfdebc
child 11117 3664b5719f23
[Core][APRM] Allow reversal document type definition.
New column has been added to Document Type for setting it as reversal.
The column has on create default 'N' and a modulescript has been included
to update existing document types.
Document Types with 'ARC' and 'APC' are considered as reversal.
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
referencedata/standard/Initial_Setup.xml
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/tables/C_DOCTYPE.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_FIELD.xml
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReversalDocumentTypes.class
src-util/modulescript/src/org/openbravo/modulescript/UpdateReversalDocumentTypes.java
src-util/modulescript/src/org/openbravo/modulescript/UpdateReversalDocumentTypes_Data.xsql
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Tue Mar 08 17:51:47 2011 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Tue Mar 08 17:56:33 2011 +0100
@@ -111,6 +111,7 @@
       cur_order_schdet_ISOPEN BOOLEAN:=false;
       fetch_next_order_item BOOLEAN:=true;
       v_TargetDocBaseType C_DOCTYPE.DocBaseType%TYPE;
+      v_isReversal C_DOCTYPE.IsReversal%TYPE;
       v_MultiplierARC NUMBER:=1;
       v_pendingAmount NUMBER;
       v_plannedDate DATE;
@@ -161,11 +162,11 @@
         RAISE_APPLICATION_ERROR(-20000, '@APRM_INVOICE_MAN_PAYMENTS@');
       END IF;
       -- Is it a Credit Memo
-      SELECT docbasetype
-        INTO v_TargetDocBaseType
+      SELECT docbasetype, isreversal
+        INTO v_TargetDocBaseType, v_isReversal
       FROM c_doctype
       WHERE c_doctype_id=v_DocTypeTarget_ID;
-      IF v_TargetDocBaseType in ('ARC','APC') THEN
+      IF (v_TargetDocBaseType in ('ARC','APC') or v_isReversal='Y') THEN
         v_MultiplierARC:=-1;
       END IF;
 
--- a/referencedata/standard/Initial_Setup.xml	Tue Mar 08 17:51:47 2011 +0100
+++ b/referencedata/standard/Initial_Setup.xml	Tue Mar 08 17:56:33 2011 +0100
@@ -357,6 +357,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="0CD50184705A42CCBECA4EC967646440" identifier="MM Shipment">
     <id>0CD50184705A42CCBECA4EC967646440</id>
@@ -379,6 +380,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="15C8DCE82DA841968ABCD614FED68576" identifier="Proposal">
     <id>15C8DCE82DA841968ABCD614FED68576</id>
@@ -401,6 +403,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="15F495A6290040F194A9AA4622FE0C01" identifier="Prepay Order">
     <id>15F495A6290040F194A9AA4622FE0C01</id>
@@ -423,6 +426,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="2030AD7DD4284E2B936E261662EF735A" identifier="MM Receipt">
     <id>2030AD7DD4284E2B936E261662EF735A</id>
@@ -445,6 +449,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="2D7C15F0F44E4F289A729415EFD700C1" identifier="Return Material">
     <id>2D7C15F0F44E4F289A729415EFD700C1</id>
@@ -467,6 +472,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="3DDDC41E36534A79B7CC1B725472882D" identifier="Inventory Move">
     <id>3DDDC41E36534A79B7CC1B725472882D</id>
@@ -489,6 +495,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="40EE9B1CD3B345FABEFDA62B407B407F" identifier="AR Invoice">
     <id>40EE9B1CD3B345FABEFDA62B407B407F</id>
@@ -511,6 +518,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="42B7DE94BC324C3F9CC0934375E90FFF" identifier="AP CreditMemo">
     <id>42B7DE94BC324C3F9CC0934375E90FFF</id>
@@ -533,6 +541,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>true</reversal>
   </DocumentType>
   <DocumentType id="51005B2C07EB41C5A2E7C25A4640ACD7" identifier="GL Journal">
     <id>51005B2C07EB41C5A2E7C25A4640ACD7</id>
@@ -555,6 +564,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="511A9371A0F74195AA3F6D66C722729D" identifier="POS Order">
     <id>511A9371A0F74195AA3F6D66C722729D</id>
@@ -577,6 +587,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="5C6E02993E9B4FCA81C07955EF676C62" identifier="AP Invoice">
     <id>5C6E02993E9B4FCA81C07955EF676C62</id>
@@ -599,6 +610,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="5EA6556D24034412B5F26F6BA7245318" identifier="Matched Invoices">
     <id>5EA6556D24034412B5F26F6BA7245318</id>
@@ -621,6 +633,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="6543EB94DC664371BAF61B8E8AC121F3" identifier="Bank Statement">
     <id>6543EB94DC664371BAF61B8E8AC121F3</id>
@@ -643,6 +656,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="6B13D02AD3C44C4CB0CFBD1288E0CB10" identifier="Physical Inventory">
     <id>6B13D02AD3C44C4CB0CFBD1288E0CB10</id>
@@ -665,6 +679,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="6F3BBCA488F6474A806C59FD1137CBF5" identifier="Purchase Requisition">
     <id>6F3BBCA488F6474A806C59FD1137CBF5</id>
@@ -687,6 +702,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="76E7C671FCE34556908E563F825C2937" identifier="Warehouse Order">
     <id>76E7C671FCE34556908E563F825C2937</id>
@@ -709,6 +725,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="808F8818F724497D94282AC83493F394" identifier="Purchase Order">
     <id>808F8818F724497D94282AC83493F394</id>
@@ -731,6 +748,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="857F464FDEE34F6DB5AEC50981419FBF" identifier="Settlement">
     <id>857F464FDEE34F6DB5AEC50981419FBF</id>
@@ -753,6 +771,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="8F343D831EA6434D9720FECAF5FB957E" identifier="Debt Payment Management">
     <id>8F343D831EA6434D9720FECAF5FB957E</id>
@@ -775,6 +794,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="9883CB89E41E496D987D8838C3CE0DC7" identifier="Matched Purchase Orders">
     <id>9883CB89E41E496D987D8838C3CE0DC7</id>
@@ -797,6 +817,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="A0C72093D5614867906A6E878F96FBBD" identifier="Depreciation">
     <id>A0C72093D5614867906A6E878F96FBBD</id>
@@ -819,6 +840,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="A58B8296E0ED42E386468D4527DE8F30" identifier="Cash Journal">
     <id>A58B8296E0ED42E386468D4527DE8F30</id>
@@ -841,6 +863,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="B476CFAE109047DEB5BC9AC80A03297A" identifier="AR Credit Memo">
     <id>B476CFAE109047DEB5BC9AC80A03297A</id>
@@ -863,6 +886,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>true</reversal>
   </DocumentType>
   <DocumentType id="B968C737ED3E4C808E425A72CC445DFE" identifier="Manual Settlement">
     <id>B968C737ED3E4C808E425A72CC445DFE</id>
@@ -885,6 +909,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="CB6EEA256BBC41109911215C5A14D39B" identifier="Standard Order">
     <id>CB6EEA256BBC41109911215C5A14D39B</id>
@@ -907,6 +932,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="D132517AE775435B8EB2832CC61FCAB1" identifier="AR Receipt">
     <id>D132517AE775435B8EB2832CC61FCAB1</id>
@@ -929,6 +955,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="E7F4802D902A42A59143DCCBEDE4DE85" identifier="Credit Order">
     <id>E7F4802D902A42A59143DCCBEDE4DE85</id>
@@ -951,6 +978,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="EC0B46C525A0417DA286823864620991" identifier="Production">
     <id>EC0B46C525A0417DA286823864620991</id>
@@ -973,6 +1001,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="ED1E059C9CF54062BA43B79F3EB89C77" identifier="AP Payment">
     <id>ED1E059C9CF54062BA43B79F3EB89C77</id>
@@ -995,6 +1024,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <DocumentType id="F8CC92C7234644DEAD9F63174F45B2BF" identifier="MM Shipment Indirect">
     <id>F8CC92C7234644DEAD9F63174F45B2BF</id>
@@ -1017,6 +1047,7 @@
     <filterByOrganization>false</filterByOrganization>
     <documentCancelled xsi:nil="true"/>
     <expense>false</expense>
+    <reversal>false</reversal>
   </DocumentType>
   <ADSequence id="01A4350CC9044517BA7B1B05EEF065FF" identifier="MM Shipment Indirect">
     <id>01A4350CC9044517BA7B1B05EEF065FF</id>
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Mar 08 17:51:47 2011 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Tue Mar 08 17:56:33 2011 +0100
@@ -130,6 +130,7 @@
   FINISH_PROCESS BOOLEAN:=FALSE;
   END_PROCESSING BOOLEAN:=FALSE;
   v_TargetDocBaseType C_DOCTYPE.DocBaseType%TYPE;
+  v_isReversal C_DOCTYPE.IsReversal%TYPE;
   v_MultiplierARC NUMBER:=1;
   v_is_included NUMBER:=0;
   v_available_period NUMBER:=0;
@@ -634,12 +635,13 @@
      *************************************************************************/
     DECLARE
       v_DocBaseType C_DOCTYPE.DocBaseType%TYPE;
+      v_DocTypeIsSOtrx C_DOCTYPE.IsSOtrx%TYPE;
     BEGIN
       -- Is it a Credit Memo?
-      SELECT DocBaseType INTO v_DocBaseType
+      SELECT DocBaseType, IsReversal, issotrx INTO v_DocBaseType, v_isReversal, v_DocTypeIsSOtrx
       FROM C_DOCTYPE
       WHERE C_DocType_ID=v_DocType_ID;
-      IF (v_DocBaseType IN('ARC', 'API')) THEN
+      IF (v_DocBaseType IN('ARC', 'API') or (v_isReversal='Y' and v_DocTypeIsSOtrx='Y') or (v_isReversal='N' and v_DocTypeIsSOtrx='N')) THEN
         v_Multiplier:=-1;
       END IF;
     END;
@@ -1437,10 +1439,10 @@
           AND IsValid!='Y';
 
         -- Is it a Credit Memo:4
-        SELECT DocBaseType INTO v_TargetDocBaseType
+        SELECT DocBaseType, isreversal INTO v_TargetDocBaseType, v_isReversal
         FROM C_DOCTYPE
         WHERE C_DocType_ID=v_DocTypeTarget_ID;
-        IF (v_TargetDocBaseType in ('ARC','APC')) THEN
+        IF (v_TargetDocBaseType in ('ARC','APC') or v_isReversal='Y') THEN
           v_MultiplierARC:=-1;
         END IF;
 
--- a/src-db/database/model/tables/C_DOCTYPE.xml	Tue Mar 08 17:51:47 2011 +0100
+++ b/src-db/database/model/tables/C_DOCTYPE.xml	Tue Mar 08 17:56:33 2011 +0100
@@ -105,6 +105,10 @@
         <default><![CDATA[N]]></default>
         <onCreateDefault/>
       </column>
+      <column name="ISREVERSAL" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_SEQUENCE" name="AD_SEQUENCE_DOCTYPEDOC">
         <reference local="DOCNOSEQUENCE_ID" foreign="AD_SEQUENCE_ID"/>
       </foreign-key>
@@ -136,6 +140,7 @@
       </unique>
       <check name="C_DOCTYPE_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
       <check name="C_DOCTYPE_ISDOCNOCONTROLLE_CHK"><![CDATA[ISDOCNOCONTROLLED IN ('Y', 'N')]]></check>
+      <check name="C_DOCTYPE_ISREVERSAL_CHECK"><![CDATA[ISREVERSAL IN ('Y', 'N')]]></check>
       <check name="C_DOCTYPE_ISSOTRX_CHECK"><![CDATA[ISSOTRX IN ('Y', 'N')]]></check>
       <check name="C_DOCTYPE_ORGFILTERED_CHECK"><![CDATA[ORGFILTERED IN ('Y', 'N')]]></check>
     </table>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Tue Mar 08 17:51:47 2011 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Mar 08 17:56:33 2011 +0100
@@ -312226,6 +312226,40 @@
 <!--9D6E31238ECAD811E040007F01004363-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--9D6E31238ECAD811E040007F01004363--></AD_COLUMN>
 
+<!--9DA88EFA815811C8E040007F01002646--><AD_COLUMN>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_COLUMN_ID><![CDATA[9DA88EFA815811C8E040007F01002646]]></AD_COLUMN_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--9DA88EFA815811C8E040007F01002646-->  <NAME><![CDATA[Reversal]]></NAME>
+<!--9DA88EFA815811C8E040007F01002646-->  <DESCRIPTION><![CDATA[This is a reversing transaction]]></DESCRIPTION>
+<!--9DA88EFA815811C8E040007F01002646-->  <HELP><![CDATA[The Reversal check box indicates if this is a reversal of a prior transaction.]]></HELP>
+<!--9DA88EFA815811C8E040007F01002646-->  <COLUMNNAME><![CDATA[Isreversal]]></COLUMNNAME>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_TABLE_ID><![CDATA[217]]></AD_TABLE_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--9DA88EFA815811C8E040007F01002646-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--9DA88EFA815811C8E040007F01002646-->  <SEQNO><![CDATA[61]]></SEQNO>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_ELEMENT_ID><![CDATA[1476]]></AD_ELEMENT_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--9DA88EFA815811C8E040007F01002646-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--9DA88EFA815811C8E040007F01002646-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--9DA88EFA815811C8E040007F01002646-->  <POSITION><![CDATA[27]]></POSITION>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--9DA88EFA815811C8E040007F01002646-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--9DA88EFA815811C8E040007F01002646-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--9DA88EFA815811C8E040007F01002646--></AD_COLUMN>
+
 <!--9F3ADE0CE0734BE2BD059AAEFCF1D51C--><AD_COLUMN>
 <!--9F3ADE0CE0734BE2BD059AAEFCF1D51C-->  <AD_COLUMN_ID><![CDATA[9F3ADE0CE0734BE2BD059AAEFCF1D51C]]></AD_COLUMN_ID>
 <!--9F3ADE0CE0734BE2BD059AAEFCF1D51C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Tue Mar 08 17:51:47 2011 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Tue Mar 08 17:56:33 2011 +0100
@@ -221061,6 +221061,31 @@
 <!--9DA7B752449946E4AF301200F0F16DDE-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
 <!--9DA7B752449946E4AF301200F0F16DDE--></AD_FIELD>
 
+<!--9DA88EFA815E11C8E040007F01002646--><AD_FIELD>
+<!--9DA88EFA815E11C8E040007F01002646-->  <AD_FIELD_ID><![CDATA[9DA88EFA815E11C8E040007F01002646]]></AD_FIELD_ID>
+<!--9DA88EFA815E11C8E040007F01002646-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--9DA88EFA815E11C8E040007F01002646-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--9DA88EFA815E11C8E040007F01002646-->  <NAME><![CDATA[Reversal]]></NAME>
+<!--9DA88EFA815E11C8E040007F01002646-->  <DESCRIPTION><![CDATA[This is a reversing transaction]]></DESCRIPTION>
+<!--9DA88EFA815E11C8E040007F01002646-->  <HELP><![CDATA[The Reversal check box indicates if this is a reversal of a prior transaction.]]></HELP>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--9DA88EFA815E11C8E040007F01002646-->  <AD_TAB_ID><![CDATA[167]]></AD_TAB_ID>
+<!--9DA88EFA815E11C8E040007F01002646-->  <AD_COLUMN_ID><![CDATA[9DA88EFA815811C8E040007F01002646]]></AD_COLUMN_ID>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--9DA88EFA815E11C8E040007F01002646-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--9DA88EFA815E11C8E040007F01002646-->  <SEQNO><![CDATA[190]]></SEQNO>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--9DA88EFA815E11C8E040007F01002646-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--9DA88EFA815E11C8E040007F01002646-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--9DA88EFA815E11C8E040007F01002646-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--9DA88EFA815E11C8E040007F01002646-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--9DA88EFA815E11C8E040007F01002646-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--9DA88EFA815E11C8E040007F01002646--></AD_FIELD>
+
 <!--9DADE14ACAF441DEB4E2B7966FB704B1--><AD_FIELD>
 <!--9DADE14ACAF441DEB4E2B7966FB704B1-->  <AD_FIELD_ID><![CDATA[9DADE14ACAF441DEB4E2B7966FB704B1]]></AD_FIELD_ID>
 <!--9DADE14ACAF441DEB4E2B7966FB704B1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReversalDocumentTypes.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UpdateReversalDocumentTypes.java	Tue Mar 08 17:56:33 2011 +0100
@@ -0,0 +1,43 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.modulescript;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class UpdateReversalDocumentTypes extends ModuleScript {
+
+  @Override
+  public void execute() {
+    
+    // Untill now a document type is identified as reversal if its document base type is 'ARC' or 'APC'
+    // New column has been added to allow a generic way of marking document as reversal
+    // This script updates this column to 'Y' for existing document types
+    // that belong to 'ARC' and 'APC' 
+
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      UpdateReversalDocumentTypesData.update(cp);
+
+    } catch (Exception e) {
+      handleError(e);
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UpdateReversalDocumentTypes_Data.xsql	Tue Mar 08 17:56:33 2011 +0100
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="UpdateReversalDocumentTypesData" package="org.openbravo.modulescript">
+   <SqlClassComment></SqlClassComment>
+   <SqlMethod name="dummy" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+      SELECT 1 AS dummy FROM DUAL
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="update" type="preparedStatement" return="rowCount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+      UPDATE c_doctype SET isreversal='Y' WHERE docbasetype in ('ARC', 'APC') and isreversal='N'
+      ]]>
+    </Sql>
+  </SqlMethod>
+</SqlClass>
\ No newline at end of file