src-db/database/model/triggers/A_ASSET_GROUP_TRG.xml
author Asier Lostalé <asier.lostale@openbravo.com>
Mon, 05 May 2008 06:59:24 +0000
changeset 799 fef2c5e2feb7
parent 785 8dba91261590
child 1605 8a0fe0193bef
permissions -rw-r--r--
Merged cleanup branch (r3931) with trunk
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER A_ASSET_GROUP_TRG">
adrian@94
     3
    <trigger name="A_ASSET_GROUP_TRG" table="A_ASSET_GROUP" fires="after" insert="true" update="false" delete="false" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
asier@799
     5
/*************************************************************************
asier@799
     6
* The contents of this file are subject to the Openbravo  Public  License
asier@799
     7
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
asier@799
     8
* Version 1.1  with a permitted attribution clause; you may not  use this
asier@799
     9
* file except in compliance with the License. You  may  obtain  a copy of
asier@799
    10
* the License at http://www.openbravo.com/legal/license.html
asier@799
    11
* Software distributed under the License  is  distributed  on  an "AS IS"
asier@799
    12
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@799
    13
* License for the specific  language  governing  rights  and  limitations
asier@799
    14
* under the License.
asier@799
    15
* The Original Code is Openbravo ERP.
asier@799
    16
* The Initial Developer of the Original Code is Openbravo SL
asier@799
    17
* All portions are Copyright (C) 2001-2008 Openbravo SL
asier@799
    18
* All Rights Reserved.
asier@799
    19
* Contributor(s):  ______________________________________.
asier@799
    20
************************************************************************/
adrian@94
    21
    TYPE RECORD IS REF CURSOR;
adrian@94
    22
  Cur_Defaults RECORD;
adrian@94
    23
BEGIN
adrian@94
    24
  FOR Cur_Defaults IN
adrian@94
    25
    (
adrian@94
    26
    SELECT *
adrian@94
    27
    FROM C_AcctSchema_Default d
adrian@94
    28
    WHERE EXISTS
adrian@94
    29
      (
adrian@94
    30
      SELECT 1
adrian@94
    31
      FROM AD_ClientInfo c
adrian@94
    32
      WHERE d.C_AcctSchema_ID IN(c.C_AcctSchema1_ID, c.C_AcctSchema2_ID, c.C_AcctSchema3_ID)
adrian@94
    33
        AND AD_Client_ID=:new.AD_Client_ID
adrian@94
    34
      )
adrian@94
    35
    )
adrian@94
    36
  LOOP
adrian@94
    37
    INSERT
adrian@94
    38
    INTO A_Asset_Group_Acct
adrian@94
    39
      (
adrian@94
    40
        A_ASSET_GROUP_ID, C_ACCTSCHEMA_ID, AD_CLIENT_ID,
adrian@94
    41
        AD_ORG_ID, ISACTIVE, CREATED,
adrian@94
    42
        CREATEDBY, UPDATED, UPDATEDBY,
adrian@94
    43
        A_DEPRECIATION_ACCT, A_ACCUMDEPRECIATION_ACCT, A_DISPOSAL_LOSS,
adrian@94
    44
        A_DISPOSAL_GAIN
adrian@94
    45
      )
adrian@94
    46
      VALUES
adrian@94
    47
      (
adrian@94
    48
        :new.A_Asset_Group_ID, Cur_Defaults.C_AcctSchema_ID, :new.AD_Client_ID,
adrian@94
    49
        :new.AD_Org_ID,  'Y', now(),
adrian@94
    50
        :new.CreatedBy, now(), :new.UpdatedBy,
adrian@94
    51
        Cur_Defaults.A_DEPRECIATION_ACCT, Cur_Defaults.A_ACCUMDEPRECIATION_ACCT, Cur_Defaults.A_DISPOSAL_LOSS,
adrian@94
    52
        Cur_Defaults.A_DISPOSAL_GAIN
adrian@94
    53
      )
adrian@94
    54
      ;
adrian@94
    55
  END LOOP;
antonio@735
    56
END A_ASSET_GROUP_TRG
gorkaion@239
    57
]]></body>
adrian@94
    58
    </trigger>
adrian@94
    59
  </database>