loan pncl
This commit is contained in:
parent
9d5a69c891
commit
02e6b761b4
@ -7,19 +7,20 @@ SELECT
|
|||||||
,to_char(r."PostDate",'mm/dd/yyyy') "Post Date"
|
,to_char(r."PostDate",'mm/dd/yyyy') "Post Date"
|
||||||
,r."Assn#"
|
,r."Assn#"
|
||||||
,r."Coll#"
|
,r."Coll#"
|
||||||
,r."AdvanceRate"
|
,COALESCE(r."AdvanceRate",0) "AdvanceRate"
|
||||||
,r."Sales"
|
,COALESCE(r."Sales",0) "Sales"
|
||||||
,r."Credits & Adjustments"
|
,COALESCE(r."Credits & Adjustments",0) "Credits & Adjustments"
|
||||||
,r."Gross Collections"
|
,COALESCE(r."Gross Collections",0) "Gross Collections"
|
||||||
,r."CollateralBalance"
|
,COALESCE(r."CollateralBalance",0) "CollateralBalance"
|
||||||
,r."MaxEligible"
|
,COALESCE(r."MaxEligible",0) "MaxEligible"
|
||||||
,r."Ineligible Amount"
|
,COALESCE(r."Ineligible Amount",0) "Ineligible Amount"
|
||||||
,r."Reserve Amount"
|
,COALESCE(r."Reserve Amount",0) "Reserve Amount"
|
||||||
FROM
|
FROM
|
||||||
tps.trans
|
tps.trans
|
||||||
JOIN LATERAL jsonb_populate_record(NULL::tps.pncl, rec) r ON TRUE
|
JOIN LATERAL jsonb_populate_record(NULL::tps.pncl, rec) r ON TRUE
|
||||||
WHERE
|
WHERE
|
||||||
srce = 'PNCL'
|
srce = 'PNCL'
|
||||||
|
--and case when rec->>'Credits & Adjustments' is null then 'null' else '' end <> 'null'
|
||||||
)
|
)
|
||||||
TO 'C:\users\ptrowbridge\downloads\pncl.csv' WITH (format csv, header TRUE)
|
TO 'C:\users\ptrowbridge\downloads\pncl.csv' WITH (format csv, header TRUE)
|
||||||
|
|
||||||
|
19
reports/colateral_balalance.sql
Normal file
19
reports/colateral_balalance.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
SELECT
|
||||||
|
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 (PARTITION BY "Schedule#" ORDER BY "Schedule#" ASC, "Post Date" 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
|
||||||
|
tpsv.pncl_default r
|
||||||
|
WHERE
|
||||||
|
--AND rec @> '{"Schedule#":"01AR"}'
|
||||||
|
--AND rec @> '{"Schedule#":"02IN Raw Material"}'
|
||||||
|
"Schedule#" = '03IN Finished Goods'
|
||||||
|
|
||||||
|
ORDER BY
|
||||||
|
"Schedule#" asc
|
||||||
|
,r."Post Date" asc
|
Loading…
Reference in New Issue
Block a user