[doubtful Debt] Triggers and js function
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Fri, 21 Dec 2012 16:24:55 +0100
changeset 19561 724e0684566c
parent 19560 e8bbe1ed64da
child 19562 538f78321be2
[doubtful Debt] Triggers and js function
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js
src-db/database/model/triggers/FIN_DOUBTFUL_DEBT_CHK_TRG.xml
src-db/database/model/triggers/FIN_DOUBTFUL_DEBT_RUN_CHK_TRG.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_TAB.xml
src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js	Thu Dec 20 20:23:07 2012 +0100
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js	Fri Dec 21 16:24:55 2012 +0100
@@ -204,4 +204,14 @@
   }
 
   return true;
+};
+
+OB.APRM.selectDoubtfulDebtPickAndEdit = function (grid, record, state) {
+	var percentage = grid.view.parentWindow.views[0].getParentRecord().percentage;
+	if(state){
+	  record.doubtfulDebtAmount = String(new BigDecimal(String(record.outstandingamt)).multiply(new BigDecimal(String(percentage))).divide(new BigDecimal('100')));
+	}else{
+	  record.doubtfulDebtAmount = '0.00';
+	}
+  return true;
 };
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/FIN_DOUBTFUL_DEBT_CHK_TRG.xml	Fri Dec 21 16:24:55 2012 +0100
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER FIN_DOUBTFUL_DEBT_CHK_TRG">
+    <trigger name="FIN_DOUBTFUL_DEBT_CHK_TRG" table="FIN_DOUBTFUL_DEBT" fires="before" insert="true" update="true" delete="true" foreach="row">
+      <body><![CDATA[    /*************************************************************************
+    * 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) 2012 Openbravo SLU
+    * All Rights Reserved.
+    * Contributor(s):  ______________________________________.
+    ************************************************************************/
+
+  v_DateNull DATE := TO_DATE('01-01-1900', 'DD-MM-YYYY');
+
+     
+BEGIN
+    
+    IF AD_isTriggerEnabled()='N' THEN RETURN;
+    END IF;
+
+
+  IF UPDATING THEN
+    IF(:old.Processed='Y'
+    AND ((COALESCE(:old.C_BPartner_ID, '0') <> COALESCE(:new.C_BPartner_ID, '0'))
+    OR(COALESCE(:old.DOCUMENTNO, '.') <> COALESCE(:new.DOCUMENTNO, '.'))
+    OR(COALESCE(:old.C_DOCTYPE_ID, '0') <> COALESCE(:new.C_DOCTYPE_ID, '0'))
+    OR(COALESCE(:old.C_CURRENCY_ID, '0') <> COALESCE(:new.C_CURRENCY_ID, '0'))
+    OR(COALESCE(:old.FIN_PAYMENT_SCHEDULE_ID, '0') <> COALESCE(:new.FIN_PAYMENT_SCHEDULE_ID, '0'))
+    OR(COALESCE(:old.FIN_DOUBTFUL_DEBT_RUN_ID, '0') <> COALESCE(:new.FIN_DOUBTFUL_DEBT_RUN_ID, '0'))
+    OR(COALESCE(:old.AMOUNT, 0) <> COALESCE(:new.AMOUNT, 0))
+    OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0'))
+    OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0')))) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+    IF(:old.Posted='Y' AND ((COALESCE(:old.DATEACCT, v_DateNull) <> COALESCE(:new.DATEACCT, v_DateNull))
+      OR(COALESCE(:old.C_CAMPAIGN_ID, '0') <> COALESCE(:new.C_CAMPAIGN_ID, '0'))
+      OR(COALESCE(:old.C_PROJECT_ID, '0') <> COALESCE(:new.C_PROJECT_ID, '0'))
+      OR(COALESCE(:old.C_ACTIVITY_ID, '0') <> COALESCE(:new.C_ACTIVITY_ID, '0'))
+      OR(COALESCE(:old.C_COSTCENTER_ID, '0') <> COALESCE(:new.C_COSTCENTER_ID, '0'))
+      OR(COALESCE(:old.A_ASSET_ID, '0') <> COALESCE(:new.A_ASSET_ID, '0'))
+      OR(COALESCE(:old.USER1_ID, '0') <> COALESCE(:new.USER1_ID, '0'))
+      OR(COALESCE(:old.USER2_ID, '0') <> COALESCE(:new.USER2_ID, '0')))) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+  END IF;
+  IF(DELETING) THEN
+    IF(:old.Processed='Y') THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+  END IF;
+  IF(INSERTING) THEN
+    IF(:NEW.Processed='Y') THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+  END IF;
+END FIN_DOUBTFUL_DEBT_CHK_TRG
+]]></body>
+    </trigger>
+  </database>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/FIN_DOUBTFUL_DEBT_RUN_CHK_TRG.xml	Fri Dec 21 16:24:55 2012 +0100
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER FIN_DOUBTFUL_DEBT_RUN_CHK_TRG">
+    <trigger name="FIN_DOUBTFUL_DEBT_RUN_CHK_TRG" table="FIN_DOUBTFUL_DEBT_RUN" fires="before" insert="true" update="true" delete="true" foreach="row">
+      <body><![CDATA[    /*************************************************************************
+    * 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) 2012 Openbravo SLU
+    * All Rights Reserved.
+    * Contributor(s):  ______________________________________.
+    ************************************************************************/
+
+  v_DateNull DATE := TO_DATE('01-01-1900', 'DD-MM-YYYY');
+
+     
+BEGIN
+    
+    IF AD_isTriggerEnabled()='N' THEN RETURN;
+    END IF;
+
+
+  IF UPDATING THEN
+    IF(:old.Processed='Y'
+    AND ((COALESCE(:old.C_BPartner_ID, '0') <> COALESCE(:new.C_BPartner_ID, '0'))
+    OR(COALESCE(:old.C_BP_GROUP_ID, '0') <> COALESCE(:new.C_BP_GROUP_ID, '0'))
+    OR(COALESCE(:old.PERCENTAGE, 0) <> COALESCE(:new.PERCENTAGE, 0))
+    OR(COALESCE(:old.DAYSOVERDUE, 0) <> COALESCE(:new.DAYSOVERDUE, 0))
+    OR(COALESCE(:old.RUNDATE, v_DateNull) <> COALESCE(:new.RUNDATE, v_DateNull))
+    OR(COALESCE(:old.AD_ORG_ID, '0') <> COALESCE(:new.AD_ORG_ID, '0'))
+    OR(COALESCE(:old.AD_CLIENT_ID, '0') <> COALESCE(:new.AD_CLIENT_ID, '0')))) THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+  END IF;
+  IF(DELETING) THEN
+    IF(:old.Processed='Y') THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+  END IF;
+  IF(INSERTING) THEN
+    IF(:NEW.Processed='Y') THEN
+      RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+    END IF;
+  END IF;
+END FIN_DOUBTFUL_DEBT_RUN_CHK_TRG
+]]></body>
+    </trigger>
+  </database>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Thu Dec 20 20:23:07 2012 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Fri Dec 21 16:24:55 2012 +0100
@@ -220291,7 +220291,7 @@
 <!--026810E03C274CD9A01DC0C688C78EF2-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--026810E03C274CD9A01DC0C688C78EF2-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
 <!--026810E03C274CD9A01DC0C688C78EF2-->  <AD_ELEMENT_ID><![CDATA[1047]]></AD_ELEMENT_ID>
-<!--026810E03C274CD9A01DC0C688C78EF2-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--026810E03C274CD9A01DC0C688C78EF2-->  <ISSESSIONATTR><![CDATA[Y]]></ISSESSIONATTR>
 <!--026810E03C274CD9A01DC0C688C78EF2-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--026810E03C274CD9A01DC0C688C78EF2-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--026810E03C274CD9A01DC0C688C78EF2-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Thu Dec 20 20:23:07 2012 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Fri Dec 21 16:24:55 2012 +0100
@@ -180561,33 +180561,6 @@
 <!--1D534D626BB1488DBEBDB4B6E0C70A8B-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--1D534D626BB1488DBEBDB4B6E0C70A8B--></AD_FIELD>
 
-<!--1D5A5FA90B6342C18EE5D61D3260F490--><AD_FIELD>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <AD_FIELD_ID><![CDATA[1D5A5FA90B6342C18EE5D61D3260F490]]></AD_FIELD_ID>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <NAME><![CDATA[Percentage]]></NAME>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <AD_TAB_ID><![CDATA[9D859A2A50F44562AFA21AAF2DF91B8A]]></AD_TAB_ID>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <AD_COLUMN_ID><![CDATA[44639EB55C5F4D899889466C9B6A3463]]></AD_COLUMN_ID>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <PROPERTY><![CDATA[fINDoubtfulDebtRun.percentage]]></PROPERTY>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <IGNOREINWAD><![CDATA[Y]]></IGNOREINWAD>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <DISPLAYLENGTH><![CDATA[2]]></DISPLAYLENGTH>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <SEQNO><![CDATA[90]]></SEQNO>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
-<!--1D5A5FA90B6342C18EE5D61D3260F490-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
-<!--1D5A5FA90B6342C18EE5D61D3260F490--></AD_FIELD>
-
 <!--1D5E40824DA04DC1AED695552A1A3038--><AD_FIELD>
 <!--1D5E40824DA04DC1AED695552A1A3038-->  <AD_FIELD_ID><![CDATA[1D5E40824DA04DC1AED695552A1A3038]]></AD_FIELD_ID>
 <!--1D5E40824DA04DC1AED695552A1A3038-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -190315,6 +190288,7 @@
 <!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <AD_COLUMN_ID><![CDATA[16EB0A80B42A4A8D9E3BA93BFA8F5FBD]]></AD_COLUMN_ID>
 <!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y']]></DISPLAYLOGIC>
 <!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
 <!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--4AF93B6DD1084C15804DDB6C5EF991F0-->  <SEQNO><![CDATA[300]]></SEQNO>
@@ -190955,7 +190929,7 @@
 <!--4F2BB401D62F4725A1227482524046FE-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--4F2BB401D62F4725A1227482524046FE-->  <DISPLAYLENGTH><![CDATA[19]]></DISPLAYLENGTH>
 <!--4F2BB401D62F4725A1227482524046FE-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--4F2BB401D62F4725A1227482524046FE-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--4F2BB401D62F4725A1227482524046FE-->  <SEQNO><![CDATA[80]]></SEQNO>
 <!--4F2BB401D62F4725A1227482524046FE-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--4F2BB401D62F4725A1227482524046FE-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--4F2BB401D62F4725A1227482524046FE-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -215168,7 +215142,7 @@
 <!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
 <!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <SEQNO><![CDATA[80]]></SEQNO>
+<!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <SEQNO><![CDATA[130]]></SEQNO>
 <!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7FBC1C8777BD48C6BA70893CAC89C7BA-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -226301,7 +226275,7 @@
 <!--94F989AE1DE3404481A7BEC41F0E2288-->  <AD_TAB_ID><![CDATA[9D859A2A50F44562AFA21AAF2DF91B8A]]></AD_TAB_ID>
 <!--94F989AE1DE3404481A7BEC41F0E2288-->  <AD_COLUMN_ID><![CDATA[FD333E7EC43041978F2A939475C920A2]]></AD_COLUMN_ID>
 <!--94F989AE1DE3404481A7BEC41F0E2288-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--94F989AE1DE3404481A7BEC41F0E2288-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--94F989AE1DE3404481A7BEC41F0E2288-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
 <!--94F989AE1DE3404481A7BEC41F0E2288-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--94F989AE1DE3404481A7BEC41F0E2288-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
 <!--94F989AE1DE3404481A7BEC41F0E2288-->  <SEQNO><![CDATA[110]]></SEQNO>
@@ -229008,7 +228982,7 @@
 <!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <DISPLAYLENGTH><![CDATA[2]]></DISPLAYLENGTH>
 <!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <SEQNO><![CDATA[130]]></SEQNO>
+<!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <SEQNO><![CDATA[90]]></SEQNO>
 <!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--A1983BE1F9C44E8E85BE572D7CFE224B-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -230809,7 +230783,7 @@
 <!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <DISPLAYLOGIC><![CDATA[@ACCT_DIMENSION_DISPLAY@]]></DISPLAYLOGIC>
 <!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
-<!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
 <!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <SEQNO><![CDATA[2000]]></SEQNO>
 <!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--A92FF6B8EFB842ECA29A01ADD3EB72BA-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -252319,14 +252293,14 @@
 <!--D4230A89F60249BEB961386264E90CA1-->  <AD_TAB_ID><![CDATA[3FD616A223E44621806A8573068B6C62]]></AD_TAB_ID>
 <!--D4230A89F60249BEB961386264E90CA1-->  <AD_COLUMN_ID><![CDATA[B1241FEF34514E86A9AF38230B57E174]]></AD_COLUMN_ID>
 <!--D4230A89F60249BEB961386264E90CA1-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
-<!--D4230A89F60249BEB961386264E90CA1-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--D4230A89F60249BEB961386264E90CA1-->  <ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
 <!--D4230A89F60249BEB961386264E90CA1-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
 <!--D4230A89F60249BEB961386264E90CA1-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
 <!--D4230A89F60249BEB961386264E90CA1-->  <SEQNO><![CDATA[70]]></SEQNO>
 <!--D4230A89F60249BEB961386264E90CA1-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--D4230A89F60249BEB961386264E90CA1-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--D4230A89F60249BEB961386264E90CA1-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--D4230A89F60249BEB961386264E90CA1-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--D4230A89F60249BEB961386264E90CA1-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
 <!--D4230A89F60249BEB961386264E90CA1-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
 <!--D4230A89F60249BEB961386264E90CA1-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--D4230A89F60249BEB961386264E90CA1-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
@@ -253652,33 +253626,6 @@
 <!--D9A9CA880316499E83F26F4DDEE28626-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--D9A9CA880316499E83F26F4DDEE28626--></AD_FIELD>
 
-<!--D9BE09F890A14195A35EC39017CC06CF--><AD_FIELD>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <AD_FIELD_ID><![CDATA[D9BE09F890A14195A35EC39017CC06CF]]></AD_FIELD_ID>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <NAME><![CDATA[Days Overdue]]></NAME>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <AD_TAB_ID><![CDATA[9D859A2A50F44562AFA21AAF2DF91B8A]]></AD_TAB_ID>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <AD_COLUMN_ID><![CDATA[28F414D20A1D412CB0D9B1FD040CE670]]></AD_COLUMN_ID>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <PROPERTY><![CDATA[fINDoubtfulDebtRun.daysOverdue]]></PROPERTY>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <IGNOREINWAD><![CDATA[Y]]></IGNOREINWAD>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <DISPLAYLENGTH><![CDATA[2]]></DISPLAYLENGTH>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <SEQNO><![CDATA[80]]></SEQNO>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
-<!--D9BE09F890A14195A35EC39017CC06CF-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
-<!--D9BE09F890A14195A35EC39017CC06CF--></AD_FIELD>
-
 <!--D9DBA0ABF5F14C138EFF53A62F28A80F--><AD_FIELD>
 <!--D9DBA0ABF5F14C138EFF53A62F28A80F-->  <AD_FIELD_ID><![CDATA[D9DBA0ABF5F14C138EFF53A62F28A80F]]></AD_FIELD_ID>
 <!--D9DBA0ABF5F14C138EFF53A62F28A80F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -257235,6 +257182,7 @@
 <!--EC4A97FF9A1C41D997A1546340F83F55-->  <AD_COLUMN_ID><![CDATA[16EB0A80B42A4A8D9E3BA93BFA8F5FBD]]></AD_COLUMN_ID>
 <!--EC4A97FF9A1C41D997A1546340F83F55-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--EC4A97FF9A1C41D997A1546340F83F55-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--EC4A97FF9A1C41D997A1546340F83F55-->  <DISPLAYLOGIC><![CDATA[@Processed@ = 'Y']]></DISPLAYLOGIC>
 <!--EC4A97FF9A1C41D997A1546340F83F55-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
 <!--EC4A97FF9A1C41D997A1546340F83F55-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--EC4A97FF9A1C41D997A1546340F83F55-->  <SEQNO><![CDATA[80]]></SEQNO>
--- a/src-db/database/sourcedata/AD_TAB.xml	Thu Dec 20 20:23:07 2012 +0100
+++ b/src-db/database/sourcedata/AD_TAB.xml	Fri Dec 21 16:24:55 2012 +0100
@@ -12723,6 +12723,7 @@
 AND ((@FIN_DoubtFul_Debt_Run.businessPartner@ is null OR @FIN_DoubtFul_Debt_Run.businessPartner@ = '') OR (@FIN_DoubtFul_Debt_Run.businessPartner@ is not null and e.businessPartner.id = @FIN_DoubtFul_Debt_Run.businessPartner@))
 AND ((@FIN_DoubtFul_Debt_Run.businessPartnerCategory@ is null OR @FIN_DoubtFul_Debt_Run.businessPartnerCategory@ = '') OR (@FIN_DoubtFul_Debt_Run.businessPartnerCategory@ is not null and e.businessPartnerCategory.id = @FIN_DoubtFul_Debt_Run.businessPartnerCategory@)))]]></HQLFILTERCLAUSE>
 <!--3FD616A223E44621806A8573068B6C62-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
+<!--3FD616A223E44621806A8573068B6C62-->  <EM_OBUIAPP_SELECTION><![CDATA[OB.APRM.selectDoubtfulDebtPickAndEdit]]></EM_OBUIAPP_SELECTION>
 <!--3FD616A223E44621806A8573068B6C62-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--3FD616A223E44621806A8573068B6C62-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
 <!--3FD616A223E44621806A8573068B6C62-->  <EM_OBUIAPP_SHOW_SELECT><![CDATA[Y]]></EM_OBUIAPP_SHOW_SELECT>
@@ -15336,7 +15337,7 @@
 <!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <UIPATTERN><![CDATA[RO]]></UIPATTERN>
+<!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <UIPATTERN><![CDATA[SR]]></UIPATTERN>
 <!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--E4DC11F751F34F0DAE11A4D856CD99EB-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
--- a/src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java	Thu Dec 20 20:23:07 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java	Fri Dec 21 16:24:55 2012 +0100
@@ -163,7 +163,7 @@
       fact.createLine(null, getAccountBPartnerBadDebt(C_BPartner_ID, true, as, conn),
           this.C_Currency_ID, bpAmountConverted.toString(), "", Fact_Acct_Group_ID,
           nextSeqNo(SeqNo), DocumentType, conn);
-      fact.createLine(null, getAccountBPartnerBadDebt(C_BPartner_ID, false, as, conn),
+      fact.createLine(null, getAccountBPartnerAllowanceForDoubtfulDebt(C_BPartner_ID, as, conn),
           this.C_Currency_ID, "", bpAmountConverted.toString(), Fact_Acct_Group_ID,
           nextSeqNo(SeqNo), DocumentType, conn);
     } finally {