tps/reports/colateral_balalance.sql

19 lines
744 B
MySQL
Raw Normal View History

2018-05-30 13:27:01 -04:00
SELECT
r.*
,CASE "Schedule#"
WHEN '02IN Raw Material' THEN 13097563.42
WHEN '03IN Finished Goods' THEN 35790696.52
ELSE 0
2018-05-30 13:38:27 -04:00
END + SUM("Sales"+"Credits & Adjustments"-"Gross Collections") OVER (PARTITION BY "Schedule#" ORDER BY "Schedule#" ASC, "PostDate" ASC) running_bal
2018-05-30 13:27:01 -04:00
,(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
"Schedule#" = '01AR'
--"Schedule#" = '02IN Raw Material'
--"Schedule#" = '03IN Finished Goods'
2018-05-30 13:27:01 -04:00
ORDER BY
"Schedule#" asc
,r."PostDate" asc
,id