diff --git a/sql/quote_review.pg.sql b/sql/quote_review.pg.sql index fbaf3e3..b638ac3 100644 --- a/sql/quote_review.pg.sql +++ b/sql/quote_review.pg.sql @@ -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