add running collateral & loan balances
This commit is contained in:
parent
774540a83e
commit
2190f55acb
17
col_balance.pgsql
Normal file
17
col_balance.pgsql
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
SELECT
|
||||
id,
|
||||
rec->>'id',
|
||||
r.*,
|
||||
CASE "Schedule#"
|
||||
WHEN '02IN Raw Material' THEN 13097563.42
|
||||
WHEN '03IN Finished Goods' THEN 35790696.52
|
||||
ELSE 0
|
||||
END + SUM("Sales"+"Credits & Adjustments"-"Gross Collections") OVER (ORDER BY "PostDate" ASC, rec->>'id' ASC)
|
||||
FROM
|
||||
tps.trans
|
||||
LEFT JOIN LATERAL jsonb_populate_record(null::tps.pncl, rec) r ON TRUE
|
||||
WHERE
|
||||
rec @> '{"Schedule#":"01AR"}'
|
||||
ORDER BY
|
||||
r."PostDate" asc
|
12
loan_bal.pgsql
Normal file
12
loan_bal.pgsql
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
SELECT
|
||||
r.*,
|
||||
SUM(r."Advances"+r."Adjustments"-r."Payments") OVER (ORDER BY r."Post Date" asc ,r."Reference #" asc)
|
||||
FROM
|
||||
tps.trans
|
||||
LEFT JOIN LATERAL jsonb_populate_record(null::tps.pnco, rec) r ON TRUE
|
||||
WHERE
|
||||
rec @> '{"Loan#":"606780191"}'
|
||||
ORDER BY
|
||||
r."Post Date" asc
|
||||
,r."Reference #" asc
|
Loading…
Reference in New Issue
Block a user