functional but checks max for all bal every time
This commit is contained in:
parent
e29b3cea2e
commit
cd29ccefab
@ -205,12 +205,16 @@ CREATE OR REPLACE FUNCTION evt.gl_insert() RETURNS trigger
|
|||||||
,list AS (
|
,list AS (
|
||||||
SELECT
|
SELECT
|
||||||
acct
|
acct
|
||||||
,min(lower(dur)) minp
|
,least(min(lower(dur)),min(lower(g.dur))) minp
|
||||||
,max(lower(dur)) maxp
|
,greatest(max(lower(dur)),max(lower(g.dur))) maxp
|
||||||
FROM
|
FROM
|
||||||
ins b
|
ins b
|
||||||
INNER JOIN evt.fspr f ON
|
INNER JOIN evt.fspr f ON
|
||||||
f.id = b.fspr
|
f.id = b.fspr
|
||||||
|
LEFT OUTER JOIN evt.bal e ON
|
||||||
|
e.acct = b.acct
|
||||||
|
LEFT OUTER JOIN evt.fspr g ON
|
||||||
|
g.fspr = e.id
|
||||||
GROUP BY
|
GROUP BY
|
||||||
acct
|
acct
|
||||||
)
|
)
|
||||||
|
@ -29,15 +29,19 @@ CREATE OR REPLACE FUNCTION evt.gl_insert() RETURNS trigger
|
|||||||
)
|
)
|
||||||
,list AS (
|
,list AS (
|
||||||
SELECT
|
SELECT
|
||||||
acct
|
b.acct
|
||||||
,min(lower(dur)) minp
|
,least(min(lower(f.dur)),min(lower(g.dur))) minp
|
||||||
,max(lower(dur)) maxp
|
,greatest(max(lower(f.dur)),max(lower(g.dur))) maxp
|
||||||
FROM
|
FROM
|
||||||
ins b
|
ins b
|
||||||
INNER JOIN evt.fspr f ON
|
INNER JOIN evt.fspr f ON
|
||||||
f.id = b.fspr
|
f.id = b.fspr
|
||||||
|
LEFT OUTER JOIN evt.bal e ON
|
||||||
|
e.acct = b.acct
|
||||||
|
LEFT OUTER JOIN evt.fspr g ON
|
||||||
|
e.fspr = g.id
|
||||||
GROUP BY
|
GROUP BY
|
||||||
acct
|
b.acct
|
||||||
)
|
)
|
||||||
,seq AS (
|
,seq AS (
|
||||||
WITH RECURSIVE rf (acct, minp, maxp, id, dur, obal, debits, credits, cbal) AS
|
WITH RECURSIVE rf (acct, minp, maxp, id, dur, obal, debits, credits, cbal) AS
|
||||||
|
Loading…
Reference in New Issue
Block a user