details:   http://code.openbravo.com/erp/devel/pi/rev/529add09ba87
changeset: 4615:529add09ba87
user:      Rajagopal Baskaran <rajagopal.baskaran <at> openbravo.com>
date:      Mon Aug 17 20:23:04 2009 +0530
summary:   Core-enhancement for Booking Control Feature.

diffstat:

 src-db/database/model/tables/C_ACCTSCHEMA_PROCESS.xml       |    6 +-
 src-db/database/model/triggers/C_ACCTSCHEMA_PROCESS_TRG.xml |  107 
+++++++++++++++++
 src-db/database/sourcedata/AD_COLUMN.xml                    |   29 ++++
 src-db/database/sourcedata/AD_FIELD.xml                     |   20 +++
 4 files changed, 161 insertions(+), 1 deletions(-)

diffs (201 lines):

diff -r 61c5bf24998b -r 529add09ba87 
src-db/database/model/tables/C_ACCTSCHEMA_PROCESS.xml
--- a/src-db/database/model/tables/C_ACCTSCHEMA_PROCESS.xml     Mon Aug 17 
16:13:31 2009 +0200
+++ b/src-db/database/model/tables/C_ACCTSCHEMA_PROCESS.xml     Mon Aug 17 
20:23:04 2009 +0530
@@ -5,7 +5,7 @@
         <default/>
         <onCreateDefault/>
       </column>
-      <column name="C_ACCTSCHEMA_ID" primaryKey="false" required="true" 
type="VARCHAR" size="32" autoIncrement="false">
+      <column name="C_ACCTSCHEMA_ID" primaryKey="false" required="false" 
type="VARCHAR" size="32" autoIncrement="false">
         <default/>
         <onCreateDefault/>
       </column>
@@ -45,6 +45,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="ISDATASET" primaryKey="false" required="true" type="CHAR" 
size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" 
name="AD_CLIENT_CACCTSCHEMAPROCESS">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
diff -r 61c5bf24998b -r 529add09ba87 
src-db/database/model/triggers/C_ACCTSCHEMA_PROCESS_TRG.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/C_ACCTSCHEMA_PROCESS_TRG.xml       Mon Aug 
17 20:23:04 2009 +0530
@@ -0,0 +1,107 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER C_ACCTSCHEMA_PROCESS_TRG">
+    <trigger name="C_ACCTSCHEMA_PROCESS_TRG" table="C_ACCTSCHEMA_PROCESS" 
fires="before" insert="true" update="false" delete="false" foreach="row">
+      <body><![CDATA[
+
+/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.0  (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 SL
+* All portions are Copyright (C) 2009 Openbravo SL
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+
+  v_Count NUMBER;
+  v_Count2 NUMBER;
+  TYPE RECORD IS REF CURSOR;
+  cur_AcctSchemas RECORD;
+  v_c_ACCTSCHEMA_ID c_acctschema.c_acctschema_id%type;
+  
+BEGIN
+ 
+IF (:NEW.ISDATASET='Y') THEN
+  -- Present trigger manages the issue of inserting a row in 
c_acctschema_process
+  --table with no value for the c_acctschema_id column. In that case, one row 
will
+  --be inserted for each accounting schema of the client or organization.
+  -- Main scenario for this situation is that a dataset of a module tries to 
+  --insert a process for the accounting schema that is being created during an
+  --initial client/organization setup.
+
+  IF (:NEW.C_ACCTSCHEMA_ID IS NULL) THEN
+    SELECT COUNT(1)
+    INTO v_Count
+    FROM AD_ORG_ACCTSCHEMA
+    WHERE AD_CLIENT_ID = :NEW.AD_CLIENT_ID AND AD_ORG_ID = :NEW.AD_ORG_ID;
+    -- If there exists just one accounting schema for the organization, means 
trigger
+    --is launched due to a initial organization setup, or entity module 
management
+    IF (v_Count=1) THEN
+      SELECT C_ACCTSCHEMA_ID
+      INTO v_c_ACCTSCHEMA_ID
+      FROM AD_ORG_ACCTSCHEMA
+      WHERE AD_CLIENT_ID = :NEW.AD_CLIENT_ID AND AD_ORG_ID = :NEW.AD_ORG_ID;
+    ELSIF (v_Count=0) THEN
+      SELECT COUNT(1)
+      INTO v_Count2
+      FROM AD_ORG_ACCTSCHEMA
+      WHERE AD_CLIENT_ID=:NEW.AD_CLIENT_ID AND AD_ORG_ID='0';
+      -- If there exists just one schema for the client, means trigger was 
launched
+      --due to an initial client setup.
+      IF (v_Count2=1) THEN
+        SELECT C_ACCTSCHEMA_ID
+        INTO v_c_ACCTSCHEMA_ID
+        FROM AD_ORG_ACCTSCHEMA
+        WHERE AD_CLIENT_ID = :NEW.AD_CLIENT_ID AND AD_ORG_ID = :NEW.AD_ORG_ID;
+      ELSE
+        -- No accounting schema was found!
+        RAISE_APPLICATION_ERROR(-1, 'WHATEVER EXCEPTION') ;
+      END IF;
+    ELSIF (v_Count>1) THEN
+      -- If there exists more than one accounting schema for the organization 
then
+      --one row is inserted in c_acctschema_process for each schema of the 
organization
+      --in except of one, which c_acctschema_id is assigned to the 
:new.c_acctschema_id
+      SELECT MAX(C_ACCTSCHEMA_ID)
+      INTO v_c_ACCTSCHEMA_ID
+      FROM AD_ORG_ACCTSCHEMA
+      WHERE AD_CLIENT_ID=:NEW.AD_CLIENT_ID AND AD_ORG_ID=:NEW.AD_ORG_ID;
+      FOR cur_AcctSchemas IN
+      (
+      SELECT C_ACCTSCHEMA_ID
+      FROM AD_ORG_ACCTSCHEMA
+      WHERE AD_CLIENT_ID=:NEW.AD_CLIENT_ID AND AD_ORG_ID=:NEW.AD_ORG_ID
+      )
+      LOOP
+        IF (cur_AcctSchemas.C_ACCTSCHEMA_ID <> v_c_ACCTSCHEMA_ID) THEN
+          INSERT INTO C_ACCTSCHEMA_PROCESS (C_ACCTSCHEMA_PROCESS_ID, 
+                                            C_ACCTSCHEMA_ID, 
+                                            AD_CLIENT_ID, 
+                                            AD_ORG_ID,
+                                            ISACTIVE,
+                                            AD_ACCTPROCESS_ID,
+                                            SEQNO)
+          VALUES (GET_UUID(),
+                  cur_AcctSchemas.C_ACCTSCHEMA_ID,
+                  :NEW.AD_CLIENT_ID,
+                  :NEW.AD_ORG_ID,
+                  :NEW.ISACTIVE,
+                  :NEW.AD_ACCTPROCESS_ID,
+                  :NEW.SEQNO);
+        END IF;
+      END LOOP;
+    END IF;
+    :new.C_ACCTSCHEMA_ID=v_c_ACCTSCHEMA_ID;
+  END IF;
+END IF;
+  
+END C_ACCTSCHEMA_PROCESS_TRG
+]]></body>
+    </trigger>
+  </database>
diff -r 61c5bf24998b -r 529add09ba87 src-db/database/sourcedata/AD_COLUMN.xml
--- a/src-db/database/sourcedata/AD_COLUMN.xml  Mon Aug 17 16:13:31 2009 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml  Mon Aug 17 20:23:04 2009 +0530
@@ -268386,4 +268386,33 @@
 <!--FC9DC467563648F380F7B8C49E1DE99F-->  
<ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--FC9DC467563648F380F7B8C49E1DE99F--></AD_COLUMN>
 
+<!--FE966CACD6FE4744BFF79F6C70D99D36--><AD_COLUMN>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<AD_COLUMN_ID><![CDATA[FE966CACD6FE4744BFF79F6C70D99D36]]></AD_COLUMN_ID>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <NAME><![CDATA[Isdataset]]></NAME>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<COLUMNNAME><![CDATA[Isdataset]]></COLUMNNAME>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<AD_TABLE_ID><![CDATA[443DD9B88BF2443982C61C8EFB07C64D]]></AD_TABLE_ID>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <SEQNO><![CDATA[110]]></SEQNO>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  <POSITION><![CDATA[12]]></POSITION>
+<!--FE966CACD6FE4744BFF79F6C70D99D36-->  
<ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--FE966CACD6FE4744BFF79F6C70D99D36--></AD_COLUMN>
+
 </data>
diff -r 61c5bf24998b -r 529add09ba87 src-db/database/sourcedata/AD_FIELD.xml
--- a/src-db/database/sourcedata/AD_FIELD.xml   Mon Aug 17 16:13:31 2009 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml   Mon Aug 17 20:23:04 2009 +0530
@@ -181859,6 +181859,26 @@
 <!--189519309B5211DDA6AF00014A62838F-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--189519309B5211DDA6AF00014A62838F--></AD_FIELD>
 
+<!--18DA0F94F716487DB3B71E4466231D94--><AD_FIELD>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<AD_FIELD_ID><![CDATA[18DA0F94F716487DB3B71E4466231D94]]></AD_FIELD_ID>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--18DA0F94F716487DB3B71E4466231D94-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--18DA0F94F716487DB3B71E4466231D94-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--18DA0F94F716487DB3B71E4466231D94-->  <NAME><![CDATA[Isdataset]]></NAME>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<AD_TAB_ID><![CDATA[4F9E1C27F7F040C58C5CA2E6FD5B26CB]]></AD_TAB_ID>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<AD_COLUMN_ID><![CDATA[FE966CACD6FE4744BFF79F6C70D99D36]]></AD_COLUMN_ID>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<ISDISPLAYED><![CDATA[N]]></ISDISPLAYED>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--18DA0F94F716487DB3B71E4466231D94-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--18DA0F94F716487DB3B71E4466231D94-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--18DA0F94F716487DB3B71E4466231D94-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--18DA0F94F716487DB3B71E4466231D94--></AD_FIELD>
+
 <!--1C70789D0D4F4C36AEB334055B995C6F--><AD_FIELD>
 <!--1C70789D0D4F4C36AEB334055B995C6F-->  
<AD_FIELD_ID><![CDATA[1C70789D0D4F4C36AEB334055B995C6F]]></AD_FIELD_ID>
 <!--1C70789D0D4F4C36AEB334055B995C6F-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to