database/model/triggers/C_BANKACCOUNT_TRG.xml
author Adrián Romero <adrian.romero@openbravo.com>
Tue, 20 Nov 2007 16:27:14 +0000
changeset 94 4e7ba7b8a4ad
parent 59 85aab40b7d24
child 132 33c5ca45fcff
permissions -rw-r--r--
fix: Changed check constraint names and foreign key names to fit in to
30 characteres.
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER C_BANKACCOUNT_TRG">
adrian@94
     3
    <trigger name="C_BANKACCOUNT_TRG" table="C_BANKACCOUNT" fires="after" insert="true" update="false" delete="false" foreach="row">
adrian@94
     4
      <body>
adrian@94
     5
adrian@94
     6
adrian@94
     7
    /*************************************************************************
adrian@94
     8
    * The contents of this file are subject to the Compiere License
adrian@94
     9
    * Version 2.5.0 ("License"); You may not use this file except in
adrian@94
    10
    * compliance with the License. You may obtain a copy of the License at
adrian@94
    11
    * http://www.compiere.org/license.html
adrian@94
    12
    * Software distributed under the License is distributed on an
adrian@94
    13
    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
adrian@94
    14
    * implied. See the License for the specific language governing rights
adrian@94
    15
    * and limitations under the License.
adrian@94
    16
    * The Original Code is  Compiere  ERP &amp;  Business Solution
adrian@94
    17
    * The Initial Developer of the Original Code is Jorg Janke  and ComPiere,
adrian@94
    18
    Inc.
adrian@94
    19
    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
adrian@94
    20
    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
adrian@94
    21
    * All Rights Reserved.
adrian@94
    22
    * Contributor(s): Openbravo SL
adrian@94
    23
    * Contributions are Copyright (C) 1999-2005 Openbravo, S.L
adrian@94
    24
    *************************************************************************
adrian@94
    25
    * $Id: C_BankAccount_Trg.sql,v 1.2 2002/01/04 04:29:54 jjanke Exp $
adrian@94
    26
    ***
adrian@94
    27
    * Title: New Accounting Defaults
adrian@94
    28
    * Description:
adrian@94
    29
    ************************************************************************/
adrian@94
    30
    TYPE RECORD IS REF CURSOR;
adrian@94
    31
  Cur_Defaults RECORD;
adrian@94
    32
BEGIN
adrian@94
    33
  FOR Cur_Defaults IN
adrian@94
    34
    (
adrian@94
    35
    SELECT *
adrian@94
    36
    FROM C_AcctSchema_Default d
adrian@94
    37
    WHERE EXISTS
adrian@94
    38
      (
adrian@94
    39
      SELECT *
adrian@94
    40
      FROM AD_ClientInfo c
adrian@94
    41
      WHERE d.C_AcctSchema_ID IN(c.C_AcctSchema1_ID, c.C_AcctSchema2_ID, c.C_AcctSchema3_ID)
adrian@94
    42
        AND AD_Client_ID=:new.AD_Client_ID
adrian@94
    43
      )
adrian@94
    44
    )
adrian@94
    45
  LOOP
adrian@94
    46
    INSERT
adrian@94
    47
    INTO C_BankAccount_Acct
adrian@94
    48
      (
adrian@94
    49
        C_BankAccount_ID, C_AcctSchema_ID, AD_Client_ID,
adrian@94
    50
        AD_Org_ID, IsActive, Created,
adrian@94
    51
        CreatedBy, Updated, UpdatedBy,
adrian@94
    52
        B_InTransit_Acct, B_Asset_Acct, B_Expense_Acct,
adrian@94
    53
        B_InterestRev_Acct, B_InterestExp_Acct, B_UnIdentified_Acct,
adrian@94
    54
        B_SettlementGain_Acct, B_SettlementLoss_Acct, B_RevaluationGain_Acct,
adrian@94
    55
        B_RevaluationLoss_Acct, B_PaymentSelect_Acct, B_UnallocatedCash_Acct
adrian@94
    56
      )
adrian@94
    57
      VALUES
adrian@94
    58
      (
adrian@94
    59
        :new.C_BankAccount_ID, Cur_Defaults.C_AcctSchema_ID, :new.AD_Client_ID,
adrian@94
    60
        :new.AD_ORG_ID,  'Y', SysDate,
adrian@94
    61
        :new.CreatedBy, SysDate, :new.UpdatedBy,
adrian@94
    62
        Cur_Defaults.B_InTransit_Acct, Cur_Defaults.B_Asset_Acct, Cur_Defaults.B_Expense_Acct,
adrian@94
    63
        Cur_Defaults.B_InterestRev_Acct, Cur_Defaults.B_InterestExp_Acct, Cur_Defaults.B_UnIdentified_Acct,
adrian@94
    64
        Cur_Defaults.B_SettlementGain_Acct, Cur_Defaults.B_SettlementLoss_Acct, Cur_Defaults.B_RevaluationGain_Acct,
adrian@94
    65
        Cur_Defaults.B_RevaluationLoss_Acct, Cur_Defaults.B_PaymentSelect_Acct, Cur_Defaults.B_UnallocatedCash_Acct
adrian@94
    66
      )
adrian@94
    67
      ;
adrian@94
    68
  END LOOP;
adrian@94
    69
END C_BankAccount_Trg 
adrian@94
    70
</body>
adrian@94
    71
    </trigger>
adrian@94
    72
  </database>