From 36c7a30c1deef2f154fdbc3e95b2e8ee7cb32fda Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 5 Aug 2025 14:30:44 -0400 Subject: [PATCH] link in new guidance logic --- sql/quote_review.pg.sql | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sql/quote_review.pg.sql b/sql/quote_review.pg.sql index f3ae2a5..e6351c4 100644 --- a/sql/quote_review.pg.sql +++ b/sql/quote_review.pg.sql @@ -103,6 +103,9 @@ lq AS MATERIALIZED ( -- ,(pricing->'guidance'->>'optimization')::numeric optimization -- ,(pricing->'guidance'->>'inflationFactor')::numeric inflation -- ,jsonb_pretty(pricing) pricing + ,p.guidance_price + ,p.guidance_reason + ,p.expl FROM lq LEFT OUTER JOIN "CMS.CUSLG".itemm i ON @@ -123,7 +126,15 @@ lq AS MATERIALIZED ( 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 + AND CASE WHEN coalesce(i.mpck,0) = 0 THEN FALSE ELSE floor(lq.units_each/i.mpck)::int <@ nt.vol END + LEFT JOIN LATERAL pricequote.single_price_call( + lq.billto + ,lq.shipto + ,lq.part + ,substring(lq.part,1,8) + ,lq.v1ds + ,lq.units_each + ) p ON TRUE WHERE lq.qstat ~ 'Submitted' )