Compare commits

...

2 Commits

Author SHA1 Message Date
d46e71a170 shorten the note on last sale 2025-08-11 11:01:04 -04:00
d37aded2c9 history should be in an array 2025-08-11 11:00:40 -04:00
5 changed files with 44 additions and 22 deletions

View File

@ -6,6 +6,8 @@ EXEC pricing.single_price_call
@v1ds = 'v1:T..BDL..', @v1ds = 'v1:T..BDL..',
@vol = 50000; @vol = 50000;
SELECT * FROM pricing.lastpricedetail l WHERE customer = 'HYBELS' AND l.partgroup = 'HZP3E100'
EXEC pricing.single_price_call EXEC pricing.single_price_call
@bill = 'GRIF0001', @bill = 'GRIF0001',
@ship = 'GRIF0001', @ship = 'GRIF0001',

View File

@ -1,5 +1,5 @@
SELECT SELECT
* ui_json->'details'
FROM pricequote.single_price_call( FROM pricequote.single_price_call(
'FARM0001', 'FARM0001',
'KEYB0001', 'KEYB0001',
@ -8,3 +8,4 @@ FROM pricequote.single_price_call(
50000 50000
) f ) f
SELECT * FROM pricequote.lastpricedetail l WHERE customer = 'HYBELS' AND l.partgroup = 'HZP3E100'

View File

@ -440,23 +440,36 @@ BEGIN
JSON_QUERY(panel.details) AS details JSON_QUERY(panel.details) AS details
FROM ( FROM (
-- History Panel -- History Panel
SELECT SELECT
'History' AS label, 'History' AS label,
( (
SELECT SELECT
'Last Price' AS label, CASE
q.last_price AS value, WHEN q.last_price IS NOT NULL
'currency' AS type, THEN 'Last Sale: ' + ISNULL(CONVERT(varchar(10), q.last_date, 120), '')
CONCAT( ELSE 'No Recent'
'Source: ', ISNULL(q.last_source, 'N/A'), END AS label,
' | Date: ', ISNULL(CONVERT(varchar(10), q.last_date, 120), 'N/A'), ISNULL(q.last_price, 0) AS value,
' | Order: ', ISNULL(q.last_order, 'N/A'), 'currency' AS type,
' | Quote: ', ISNULL(q.last_quote, 'N/A'), CASE
' | Dataseg: ', ISNULL(q.last_dataseg, 'N/A'), WHEN q.last_price IS NOT NULL THEN
' | Qty: ', ISNULL(CAST(q.last_qty AS varchar(32)), 'N/A') CONCAT(
) AS note CASE ISNULL(q.last_source, '')
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER WHEN 'mrq' THEN 'Recent similar quote'
) AS details WHEN 'mra' THEN 'Recent similar sales'
WHEN 'dsq' THEN 'Last quote'
WHEN 'mrq' THEN 'Last sale'
ELSE ''
END,
CASE WHEN ISNULL(q.last_order, '0') = '0'
THEN ' Qt# ' + ISNULL(q.last_quote, '')
ELSE ' Ord# ' + ISNULL(q.last_order, '')
END
)
ELSE NULL
END AS note
FOR JSON PATH -- array with one object (no WITHOUT_ARRAY_WRAPPER)
) AS details
UNION ALL UNION ALL

View File

@ -35,7 +35,7 @@
==================================================================================== ====================================================================================
*/ */
DROP FUNCTION pricequote.single_price_call(text,text,text,text,numeric); --DROP FUNCTION pricequote.single_price_call(text,text,text,text,numeric);
CREATE OR REPLACE FUNCTION pricequote.single_price_call( CREATE OR REPLACE FUNCTION pricequote.single_price_call(
_bill TEXT, _bill TEXT,
@ -449,7 +449,14 @@ BEGIN
'label', CASE WHEN _last_price IS NOT NULL THEN 'Last Sale: ' || _last_date ELSE 'No Recent' END, 'label', CASE WHEN _last_price IS NOT NULL THEN 'Last Sale: ' || _last_date ELSE 'No Recent' END,
'value', COALESCE(_last_price,0), 'value', COALESCE(_last_price,0),
'type', 'currency', 'type', 'currency',
'note', CASE WHEN _last_price IS NOT NULL THEN _last_source || 'note', CASE WHEN _last_price IS NOT NULL THEN
CASE _last_source
WHEN 'mrq' THEN 'Recent similar quote'
WHEN 'mra' THEN 'Recent similar sales'
WHEN 'dsq' THEN 'Last quote'
WHEN 'mrq' THEN 'Last sale'
ELSE ''
END ||
CASE WHEN COALESCE(_last_order, '0') = '0' THEN ' Qt# ' || COALESCE(_last_quote, '') ELSE ' Ord# ' || COALESCE(_last_order, '') END CASE WHEN COALESCE(_last_order, '0') = '0' THEN ' Qt# ' || COALESCE(_last_quote, '') ELSE ' Ord# ' || COALESCE(_last_order, '') END
ELSE NULL END ELSE NULL END
) )

View File

@ -105,7 +105,7 @@ lq AS MATERIALIZED (
-- ,jsonb_pretty(pricing) pricing -- ,jsonb_pretty(pricing) pricing
,p.guidance_price ,p.guidance_price
,p.guidance_reason ,p.guidance_reason
,jsonb_pretty(p.expl) expl ,jsonb_pretty(p.ui_json->'details') expl
FROM FROM
lq lq
LEFT OUTER JOIN "CMS.CUSLG".itemm i ON LEFT OUTER JOIN "CMS.CUSLG".itemm i ON
@ -131,7 +131,6 @@ lq AS MATERIALIZED (
lq.billto lq.billto
,lq.shipto ,lq.shipto
,lq.part ,lq.part
,substring(lq.part,1,8)
,lq.v1ds ,lq.v1ds
,lq.units_each ,lq.units_each
) p ON TRUE ) p ON TRUE