From 97beed28fdd4febade18200ba29495c485d00ea4 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 9 Jan 2025 16:57:36 -0500 Subject: [PATCH] treat dishes and hangers differently --- sql/quote_review.pg.sql | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sql/quote_review.pg.sql b/sql/quote_review.pg.sql index a9c07db..976dcad 100644 --- a/sql/quote_review.pg.sql +++ b/sql/quote_review.pg.sql @@ -72,15 +72,25 @@ lq AS MATERIALIZED ( ELSE lq.upperpricelimit * 1.15 END END END ELSE - --at least 8 pallets is lower limit - CASE WHEN units_each >= 08*mpck THEN lq.lowerpricelimit - --at least 2 pallets is mid range - ELSE CASE WHEN units_each >= 2*mpck THEN (lq.upperpricelimit + lq.lowerpricelimit) / 2 - --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 + CASE WHEN i.pricegroup ~ '(Hanger|Dish)' THEN + --at least 1 pallets is lower limit + CASE WHEN units_each >= 01*mpck THEN lq.lowerpricelimit + --at least 2 pallets is mid range + ELSE CASE WHEN units_each >= 0.5*mpck THEN (lq.upperpricelimit + lq.lowerpricelimit) / 2 + --less than a pallet is upper + 15% + ELSE lq.upperpricelimit + END END + ELSE + --at least 8 pallets is lower limit + CASE WHEN units_each >= 08*mpck THEN lq.lowerpricelimit + --at least 2 pallets is mid range + ELSE CASE WHEN units_each >= 2*mpck THEN (lq.upperpricelimit + lq.lowerpricelimit) / 2 + --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 END guidance -- ,(pricing->'guidance'->>'ltp')::numeric ltp -- ,(pricing->'guidance'->>'optimization')::numeric optimization