From f936b9d31d5bbc8ce1b90f06270343010bc866d6 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 11 Aug 2025 21:18:22 -0400 Subject: [PATCH] show bridge to normalize last price --- procs/single_price_call.pg.sql | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/procs/single_price_call.pg.sql b/procs/single_price_call.pg.sql index 4ad7d76..c1ef653 100644 --- a/procs/single_price_call.pg.sql +++ b/procs/single_price_call.pg.sql @@ -464,6 +464,26 @@ BEGIN ELSE NULL END ) ) + -- ||CASE WHEN _last_premium IS NOT NULL THEN + ||COALESCE(jsonb_build_array(jsonb_build_object( + 'label','Price Difference', + 'value', _last_premium, + 'type','percent', + 'note', _last_premium_method + )),'[]'::jsonb) + -- ELSE + -- '[]'::jsonb + -- END + -- ||CASE WHEN _last_premium IS NOT NULL THEN + ||COALESCE(jsonb_build_array(jsonb_build_object( + 'label','Adjusted Price', + 'value', _last_price_norm, + 'type','currency', + 'note','normalized to ' || _v1ds + )),'[]'::jsonb) + -- ELSE + -- '[]'::jsonb + -- END ), ------------------------------------------ -- price list @@ -515,9 +535,9 @@ BEGIN ELSE '' END ) ) - FROM jsonb_array_elements_text(COALESCE(_tmath,'{}'::jsonb)) ae + FROM jsonb_array_elements_text(COALESCE(_tmath,'[""]'::jsonb)) ae ) - ||jsonb_build_object('label','Price','value',_tprice,'type','currency','note','Total') + ||CASE WHEN _tprice IS NULL THEN '[]'::jsonb ELSE jsonb_build_object('label','Price','value',COALESCE(_tprice,0),'type','currency','note','Total') END -- ) ), ------------------------------------------ @@ -528,9 +548,9 @@ BEGIN 'details', jsonb_build_array( jsonb_build_object( 'label', 'Price', - 'value', _guidance_price, + 'value', COALESCE(_guidance_price,0), 'type', 'currency', - 'note', _guidance_reason + 'note', COALESCE(_guidance_reason,'') ) ) )