src-db/database/model/triggers/C_BANKACCOUNT_TRG.xml
author Eduardo Argal <eduardo.argal@openbravo.com>
Thu, 29 May 2008 10:00:05 +0000
changeset 1067 4a05c922c488
parent 785 8dba91261590
child 1605 8a0fe0193bef
permissions -rw-r--r--
Fixed bug 0000104 Review all the triggers for Accounting
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER C_BANKACCOUNT_TRG">
eduardo@1067
     3
    <trigger name="C_BANKACCOUNT_TRG" table="C_BANKACCOUNT" fires="after" insert="true" update="true" delete="false" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
juanpablo@771
     5
    /*************************************************************************
juanpablo@771
     6
    * The contents of this file are subject to the Compiere Public
juanpablo@771
     7
    * License 1.1 ("License"); You may not use this file except in
juanpablo@771
     8
    * compliance with the License. You may obtain a copy of the License in
juanpablo@771
     9
    * the legal folder of your Openbravo installation.
adrian@94
    10
    * Software distributed under the License is distributed on an
adrian@94
    11
    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
adrian@94
    12
    * implied. See the License for the specific language governing rights
adrian@94
    13
    * and limitations under the License.
juanpablo@778
    14
    * The Original Code is  Compiere  ERP &  Business Solution
juanpablo@771
    15
    * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
adrian@94
    16
    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
adrian@94
    17
    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
adrian@94
    18
    * All Rights Reserved.
adrian@94
    19
    * Contributor(s): Openbravo SL
juanpablo@785
    20
    * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
juanpablo@771
    21
    *
juanpablo@771
    22
    * Specifically, this derivative work is based upon the following Compiere
juanpablo@771
    23
    * file and version.
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
eduardo@1067
    33
  IF(INSERTING) THEN
eduardo@1067
    34
    FOR Cur_Defaults IN
adrian@94
    35
      (
adrian@94
    36
      SELECT *
eduardo@1067
    37
      FROM C_AcctSchema_Default d
eduardo@1067
    38
      WHERE EXISTS
eduardo@1067
    39
        (
eduardo@1067
    40
        SELECT *
eduardo@1067
    41
        FROM AD_ClientInfo c
eduardo@1067
    42
        WHERE d.C_AcctSchema_ID IN(c.C_AcctSchema1_ID, c.C_AcctSchema2_ID, c.C_AcctSchema3_ID)
eduardo@1067
    43
          AND AD_Client_ID=:new.AD_Client_ID
eduardo@1067
    44
        )
adrian@94
    45
      )
eduardo@1067
    46
    LOOP
eduardo@1067
    47
      INSERT
eduardo@1067
    48
      INTO C_BankAccount_Acct
eduardo@1067
    49
        (
eduardo@1067
    50
          C_BankAccount_ID, C_AcctSchema_ID, AD_Client_ID,
eduardo@1067
    51
          AD_Org_ID, IsActive, Created,
eduardo@1067
    52
          CreatedBy, Updated, UpdatedBy,
eduardo@1067
    53
          B_InTransit_Acct, B_Asset_Acct, B_Expense_Acct,
eduardo@1067
    54
          B_InterestRev_Acct, B_InterestExp_Acct, B_UnIdentified_Acct,
eduardo@1067
    55
          B_SettlementGain_Acct, B_SettlementLoss_Acct, B_RevaluationGain_Acct,
eduardo@1067
    56
          B_RevaluationLoss_Acct, B_PaymentSelect_Acct, B_UnallocatedCash_Acct
eduardo@1067
    57
        )
eduardo@1067
    58
        VALUES
eduardo@1067
    59
        (
eduardo@1067
    60
          :new.C_BankAccount_ID, Cur_Defaults.C_AcctSchema_ID, :new.AD_Client_ID,
eduardo@1067
    61
          :new.AD_ORG_ID,  'Y', now(),
eduardo@1067
    62
          :new.CreatedBy, now(), :new.UpdatedBy,
eduardo@1067
    63
          Cur_Defaults.B_InTransit_Acct, Cur_Defaults.B_Asset_Acct, Cur_Defaults.B_Expense_Acct,
eduardo@1067
    64
          Cur_Defaults.B_InterestRev_Acct, Cur_Defaults.B_InterestExp_Acct, Cur_Defaults.B_UnIdentified_Acct,
eduardo@1067
    65
          Cur_Defaults.B_SettlementGain_Acct, Cur_Defaults.B_SettlementLoss_Acct, Cur_Defaults.B_RevaluationGain_Acct,
eduardo@1067
    66
          Cur_Defaults.B_RevaluationLoss_Acct, Cur_Defaults.B_PaymentSelect_Acct, Cur_Defaults.B_UnallocatedCash_Acct
eduardo@1067
    67
        )
eduardo@1067
    68
        ;
eduardo@1067
    69
    END LOOP;
eduardo@1067
    70
  ELSIF (UPDATING) THEN
eduardo@1067
    71
    UPDATE C_BANKACCOUNT_ACCT SET AD_ORG_ID = :new.AD_ORG_ID
eduardo@1067
    72
    WHERE C_BANKACCOUNT_ID = :new.C_BANKACCOUNT_ID;
eduardo@1067
    73
  END IF;
antonio@735
    74
END C_BANKACCOUNT_TRG
gorkaion@239
    75
]]></body>
adrian@94
    76
    </trigger>
adrian@94
    77
  </database>