commit: 2024-12-13 13:41:15

This commit is contained in:
Paul Trowbridge 2024-12-13 13:41:15 -05:00
parent 31e474ca26
commit 454c6e379a

View File

@ -65,20 +65,20 @@ lq AS MATERIALIZED (
-- if more than a pallet use the target price
ELSE CASE WHEN units_each >= 8*mpck THEN (lq.upperpricelimit + lq.lowerpricelimit) / 2
-- if more than a pallet use the target price
ELSE CASE WHEN units_each < 8*mpck THEN lq.upperpricelimit
ELSE CASE WHEN units_each >= 4*mpck THEN lq.upperpricelimit
-- if more than a pallet use the target price
ELSE CASE WHEN units_each < mpck THEN lq.upperpricelimit * 1.15
END END END END
ELSE lq.upperpricelimit * 1.15
END END END
ELSE
--if more than 8/24 pallets, use floor
--at least 8 pallets is lower limit
CASE WHEN units_each >= 08*mpck THEN lq.lowerpricelimit
-- if more than a pallet use the target price
--at least 2 pallets is mid range
ELSE CASE WHEN units_each >= 2*mpck THEN (lq.upperpricelimit + lq.lowerpricelimit) / 2
-- if more than a pallet use the target price
ELSE CASE WHEN units_each < 2*mpck THEN lq.upperpricelimit
-- if more than a pallet use the target price
ELSE CASE WHEN units_each < mpck THEN lq.upperpricelimit * 1.15
END END END END
--at least 1 pallet is upper range
ELSE CASE WHEN units_each >= 1*mpck THEN lq.upperpricelimit
--less than a pallet is upper + 15%
ELSE lq.upperpricelimit * 1.15
END END END
END guidance
-- ,(pricing->'guidance'->>'ltp')::numeric ltp
-- ,(pricing->'guidance'->>'optimization')::numeric optimization