src-db/database/model/triggers/C_INVOICELINE_TRG2.xml
changeset 1605 8a0fe0193bef
parent 799 fef2c5e2feb7
child 2078 cf88ca44cdd2
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
    24 
    24 
    25 
    25 
    26    TYPE RECORD IS REF CURSOR;
    26    TYPE RECORD IS REF CURSOR;
    27    Cur_Offer RECORD;
    27    Cur_Offer RECORD;
    28 
    28 
    29   v_InvoiceLine_Offer_Id NUMBER;
    29   v_InvoiceLine_Offer_ID VARCHAR2(32);
    30   v_lineno NUMBER:=0;
    30   v_lineno NUMBER:=0;
    31   v_Price NUMBER;
    31   v_Price NUMBER;
    32   v_PriceNew NUMBER;
    32   v_PriceNew NUMBER;
    33   v_Amt NUMBER;
    33   v_Amt NUMBER;
    34   v_BPartner_ID NUMBER;
    34   v_BPartner_ID VARCHAR2(32);
    35   v_Order_ID NUMBER;
    35   v_Order_ID VARCHAR2(32);
    36   v_Insert BOOLEAN :=FALSE;
    36   v_Insert BOOLEAN :=FALSE;
    37   v_DateInvoiced DATE;
    37   v_DateInvoiced DATE;
    38   v_Precision NUMBER;
    38   v_Precision NUMBER;
    39   v_PriceList_ID NUMBER;
    39   v_PriceList_ID VARCHAR2(32);
    40 BEGIN
    40 BEGIN
    41 -- This trigger is used for calculate the applied offers f0r the invoice
    41 -- This trigger is used for calculate the applied offers f0r the invoice
    42 
    42 
    43 
    43 
    44 
    44 
    46    DELETE FROM C_INVOICELINE_OFFER
    46    DELETE FROM C_INVOICELINE_OFFER
    47    WHERE C_InvoiceLine_ID = :OLD.C_InvoiceLine_ID;
    47    WHERE C_InvoiceLine_ID = :OLD.C_InvoiceLine_ID;
    48  END IF;
    48  END IF;
    49 
    49 
    50  IF UPDATING THEN
    50  IF UPDATING THEN
    51   IF (    (COALESCE(:NEW.M_Product_ID,0) != COALESCE(:OLD.M_Product_ID,0))
    51   IF (    (COALESCE(:NEW.M_Product_ID,'0') != COALESCE(:OLD.M_Product_ID,'0'))
    52     OR (COALESCE(:NEW.PriceActual,0) != COALESCE(:OLD.PriceActual,0))
    52     OR (COALESCE(:NEW.PriceActual,0) != COALESCE(:OLD.PriceActual,0))
    53     OR (COALESCE(:NEW.QtyInvoiced,0) != COALESCE(:OLD.QtyInvoiced,0))) THEN
    53     OR (COALESCE(:NEW.QtyInvoiced,0) != COALESCE(:OLD.QtyInvoiced,0))) THEN
    54   DELETE FROM C_INVOICELINE_OFFER
    54   DELETE FROM C_INVOICELINE_OFFER
    55    WHERE C_InvoiceLine_ID = :NEW.C_InvoiceLine_ID;
    55    WHERE C_InvoiceLine_ID = :NEW.C_InvoiceLine_ID;
    56    v_Insert := TRUE;
    56    v_Insert := TRUE;