reverse out
This commit is contained in:
parent
b372f70f12
commit
e93ea9b64a
@ -1,6 +1,6 @@
|
|||||||
---------------------------handle new gl lines----------------------------------------
|
---------------------------handle deleted gl lines----------------------------------------
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION evt.gl_insert() RETURNS trigger
|
CREATE OR REPLACE FUNCTION evt.gl_delete() RETURNS trigger
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS
|
AS
|
||||||
$func$
|
$func$
|
||||||
@ -27,8 +27,9 @@ BEGIN
|
|||||||
acct
|
acct
|
||||||
,fspr
|
,fspr
|
||||||
,dur
|
,dur
|
||||||
,coalesce(sum(amount) FILTER (WHERE amount > 0),0) debits
|
--negate initial debits credits
|
||||||
,coalesce(sum(amount) FILTER (WHERE amount < 0),0) credits
|
,coalesce(-sum(amount) FILTER (WHERE amount > 0),0) debits
|
||||||
|
,coalesce(-sum(amount) FILTER (WHERE amount < 0),0) credits
|
||||||
FROM
|
FROM
|
||||||
ins
|
ins
|
||||||
INNER JOIN evt.fspr f ON
|
INNER JOIN evt.fspr f ON
|
||||||
@ -133,10 +134,10 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$func$;
|
$func$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION evt.gl_insert IS 'update evt.bal with new ledger rows';
|
COMMENT ON FUNCTION evt.gl_delete IS 'reduce evt.bal for deleted ledger rows';
|
||||||
|
|
||||||
CREATE TRIGGER gl_insert
|
CREATE TRIGGER gl_delete
|
||||||
AFTER INSERT ON evt.gl
|
AFTER INSERT ON evt.gl
|
||||||
REFERENCING NEW TABLE AS ins
|
REFERENCING OLD TABLE AS ins
|
||||||
FOR EACH STATEMENT
|
FOR EACH STATEMENT
|
||||||
EXECUTE PROCEDURE evt.gl_insert();
|
EXECUTE PROCEDURE evt.gl_delete();
|
Loading…
Reference in New Issue
Block a user