From 73608b3e338b5bfaac7148fb36e335423ab300b8 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sun, 27 Jul 2025 14:38:04 -0400 Subject: [PATCH] link in new target prices to quote review --- sql/quote_review.pg.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sql/quote_review.pg.sql b/sql/quote_review.pg.sql index cedf56e..f3ae2a5 100644 --- a/sql/quote_review.pg.sql +++ b/sql/quote_review.pg.sql @@ -30,6 +30,7 @@ lq AS MATERIALIZED ( ,lq.shipto ,lq.qchan ,lq.qcustomer + ,CASE lq.qchan WHEN 'DIR' THEN bc.tier ELSE sc.tier END customer_tier ,lq.part ,lq.qoptions ,lq.partbuilt @@ -55,6 +56,7 @@ lq AS MATERIALIZED ( ,lq.lowerpricelimit ,lq.upperpricelimit ,(lq.upperpricelimit + lq.lowerpricelimit) / 2 midrange + ,nt.price qtarget_price ,i.partgroup part_group -- ,pricing->'product'->>'itemrel' item_fit ,i.mpck pltq @@ -116,6 +118,12 @@ lq AS MATERIALIZED ( lq.units_each >= pl.vb_f AND lq.units_each < pl.vb_t ) + LEFT OUTER JOIN pricequote.target_prices nt ON + nt.stlc = i.stlc + AND nt.ds = lq.v1ds + AND nt.chan = lq.qchan + AND nt.tier = CASE lq.qchan WHEN 'DIR' THEN bc.tier ELSE sc.tier END + AND floor(lq.units_each/i.mpck)::int <@ nt.vol WHERE lq.qstat ~ 'Submitted' )