TWYN#52350 budgetten zijn weer aangepast!!
svn path=/Database/trunk/; revision=37181
This commit is contained in:
@@ -53,16 +53,18 @@ CREATE_TRIGGER(bgt_t_bgt_budgetmutatie_B_IU)
|
||||
BEFORE INSERT OR UPDATE ON bgt_budgetmutatie
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
-- Bij insert moet het nieuwe mutatiebedrag bij het budgetbedrag worden opgeteld.
|
||||
-- Bij update moet het VERSCHIL tussen het oude- en nieuwe mutatiebedrag bij het budgetbedrag worden opgeteld.
|
||||
IF (:new.bgt_budget_key_van IS NOT NULL) THEN
|
||||
UPDATE bgt_budget
|
||||
SET bgt_budget_bedrag = NVL(bgt_budget_bedrag, 0) + NVL(:new.bgt_budget_bedrag_van, 0)
|
||||
, bgt_budget_btwbedrag = NVL(bgt_budget_btwbedrag, 0) + NVL(:new.bgt_budget_btwbedrag_van, 0)
|
||||
SET bgt_budget_bedrag = NVL(bgt_budget_bedrag, 0) + (NVL(:new.bgt_budget_bedrag_van, 0) - NVL(:old.bgt_budget_bedrag_van, 0))
|
||||
, bgt_budget_btwbedrag = NVL(bgt_budget_btwbedrag, 0) + (NVL(:new.bgt_budget_btwbedrag_van, 0) - NVL(:old.bgt_budget_btwbedrag_van, 0))
|
||||
WHERE bgt_budget_key = :new.bgt_budget_key_van;
|
||||
END IF;
|
||||
IF (:new.bgt_budget_key_naar IS NOT NULL) THEN
|
||||
UPDATE bgt_budget
|
||||
SET bgt_budget_bedrag = NVL(bgt_budget_bedrag, 0) + NVL(:new.bgt_budget_bedrag_naar, 0)
|
||||
, bgt_budget_btwbedrag = NVL(bgt_budget_btwbedrag, 0) + NVL(:new.bgt_budget_btwbedrag_naar, 0)
|
||||
SET bgt_budget_bedrag = NVL(bgt_budget_bedrag, 0) + (NVL(:new.bgt_budget_bedrag_naar, 0) - NVL(:old.bgt_budget_bedrag_naar, 0))
|
||||
, bgt_budget_btwbedrag = NVL(bgt_budget_btwbedrag, 0) + (NVL(:new.bgt_budget_btwbedrag_naar, 0) - NVL(:old.bgt_budget_btwbedrag_naar, 0))
|
||||
WHERE bgt_budget_key = :new.bgt_budget_key_naar;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
Reference in New Issue
Block a user