shorten the note on last sale

This commit is contained in:
Paul Trowbridge 2025-08-11 11:01:04 -04:00
parent d37aded2c9
commit d46e71a170
2 changed files with 39 additions and 19 deletions

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 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
) )