add calc columns to collateral
This commit is contained in:
parent
e68b3e0349
commit
f203c7010a
@ -1,17 +1,21 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id
|
||||||
rec->>'id',
|
,rec->>'id'
|
||||||
r.*,
|
,r.*
|
||||||
CASE "Schedule#"
|
,CASE "Schedule#"
|
||||||
WHEN '02IN Raw Material' THEN 13097563.42
|
WHEN '02IN Raw Material' THEN 13097563.42
|
||||||
WHEN '03IN Finished Goods' THEN 35790696.52
|
WHEN '03IN Finished Goods' THEN 35790696.52
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END + SUM("Sales"+"Credits & Adjustments"-"Gross Collections") OVER (ORDER BY "PostDate" ASC, rec->>'id' ASC)
|
END + SUM("Sales"+"Credits & Adjustments"-"Gross Collections") OVER (ORDER BY "PostDate" ASC, rec->>'id' ASC) running_bal
|
||||||
|
,(LEAST("CollateralBalance" - "Ineligible Amount","MaxEligible")*("AdvanceRate"/100))::NUMERIC(20,2) qualified_collateral
|
||||||
|
,(("CollateralBalance" - "Ineligible Amount")*("AdvanceRate"/100))::NUMERIC(20,2) qualified_collateral_nl
|
||||||
FROM
|
FROM
|
||||||
tps.trans
|
tps.trans
|
||||||
LEFT JOIN LATERAL jsonb_populate_record(null::tps.pncl, rec) r ON TRUE
|
LEFT JOIN LATERAL jsonb_populate_record(null::tps.pncl, rec) r ON TRUE
|
||||||
WHERE
|
WHERE
|
||||||
rec @> '{"Schedule#":"01AR"}'
|
srce = 'PNCL'
|
||||||
|
AND "PostDate" >= '2017-10-12'
|
||||||
|
--rec @> '{"Schedule#":"03IN Finished Goods"}'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
r."PostDate" asc
|
r."PostDate" asc
|
Loading…
Reference in New Issue
Block a user