src-db/database/model/triggers/GL_JOURNALLINE2_TRG.xml
changeset 25470 7c00db2d6532
parent 21737 fcb87e990fcd
equal deleted inserted replaced
25469:777541c9e414 25470:7c00db2d6532
    27   v_StdPrecision      NUMBER(10) ;
    27   v_StdPrecision      NUMBER(10) ;
    28   v_rate              NUMBER;
    28   v_rate              NUMBER;
    29   v_CurrencyRate      NUMBER;
    29   v_CurrencyRate      NUMBER;
    30   v_CurrencyRateType  VARCHAR(60) ;
    30   v_CurrencyRateType  VARCHAR(60) ;
    31   v_DateAcct          DATE;
    31   v_DateAcct          DATE;
       
    32   v_IsMultiGL     CHAR(1);
    32     
    33     
    33 BEGIN
    34 BEGIN
    34     
    35     
    35     IF AD_isTriggerEnabled()='N' THEN RETURN;
    36     IF AD_isTriggerEnabled()='N' THEN RETURN;
    36     END IF;
    37     END IF;
    41     END IF;
    42     END IF;
    42   END IF;
    43   END IF;
    43   SELECT C_AcctSchema_ID,
    44   SELECT C_AcctSchema_ID,
    44     CurrencyRate,
    45     CurrencyRate,
    45     COALESCE(CurrencyRateType, 'S'),
    46     COALESCE(CurrencyRateType, 'S'),
    46     dateacct
    47     dateacct, multi_gl
    47   INTO v_AcctSchema_ID,
    48   INTO v_AcctSchema_ID,
    48     v_CurrencyRate,
    49     v_CurrencyRate,
    49     v_CurrencyRateType,
    50     v_CurrencyRateType,
    50     v_DateAcct
    51     v_DateAcct, v_IsMultiGL
    51   FROM GL_Journal
    52   FROM GL_Journal
    52   WHERE GL_Journal_ID=:NEW.GL_Journal_ID;
    53   WHERE GL_Journal_ID=:NEW.GL_Journal_ID;
    53   SELECT COALESCE(MAX(c.C_Currency_ID), '0'),
    54   SELECT COALESCE(MAX(c.C_Currency_ID), '0'),
    54     COALESCE(MAX(c.StdPrecision), 2)
    55     COALESCE(MAX(c.StdPrecision), 2)
    55   INTO v_TargetCurrency_ID,
    56   INTO v_TargetCurrency_ID,
    60     AND a.C_AcctSchema_ID=v_AcctSchema_ID;
    61     AND a.C_AcctSchema_ID=v_AcctSchema_ID;
    61   v_rate:=v_CurrencyRate;
    62   v_rate:=v_CurrencyRate;
    62   IF(v_rate IS NULL OR v_rate = 0) THEN
    63   IF(v_rate IS NULL OR v_rate = 0) THEN
    63     v_rate:=C_CURRENCY_RATE(:NEW.C_Currency_ID, v_TargetCurrency_ID, v_DateAcct, v_CurrencyRateType, :NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID) ;
    64     v_rate:=C_CURRENCY_RATE(:NEW.C_Currency_ID, v_TargetCurrency_ID, v_DateAcct, v_CurrencyRateType, :NEW.AD_CLIENT_ID, :NEW.AD_ORG_ID) ;
    64   END IF;
    65   END IF;
       
    66   IF(v_IsMultiGL = 'Y') THEN
       
    67     v_rate:= 1;
       
    68   END IF;
    65   :NEW.AMTACCTDR:=ROUND(COALESCE(:NEW.AMTSOURCEDR, 0) *v_rate, v_StdPrecision) ;
    69   :NEW.AMTACCTDR:=ROUND(COALESCE(:NEW.AMTSOURCEDR, 0) *v_rate, v_StdPrecision) ;
    66   :NEW.AMTACCTCR:=ROUND(COALESCE(:NEW.AMTSOURCECR, 0) *v_rate, v_StdPrecision) ;
    70   :NEW.AMTACCTCR:=ROUND(COALESCE(:NEW.AMTSOURCECR, 0) *v_rate, v_StdPrecision) ;
    67   :NEW.CURRENCYRATE:=v_rate;
    71   :NEW.CURRENCYRATE:=v_rate;
    68   :NEW.CURRENCYRATETYPE:=v_CurrencyRateType;
    72   :NEW.CURRENCYRATETYPE:=v_CurrencyRateType;
    69 END GL_JOURNALLINE2_TRG
    73 END GL_JOURNALLINE2_TRG