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
FROM (
-- History Panel
SELECT
'History' AS label,
(
SELECT
'Last Price' AS label,
q.last_price AS value,
'currency' AS type,
CONCAT(
'Source: ', ISNULL(q.last_source, 'N/A'),
' | Date: ', ISNULL(CONVERT(varchar(10), q.last_date, 120), 'N/A'),
' | Order: ', ISNULL(q.last_order, 'N/A'),
' | Quote: ', ISNULL(q.last_quote, 'N/A'),
' | Dataseg: ', ISNULL(q.last_dataseg, 'N/A'),
' | Qty: ', ISNULL(CAST(q.last_qty AS varchar(32)), 'N/A')
) AS note
FOR JSON PATH
) AS details
SELECT
'History' AS label,
(
SELECT
CASE
WHEN q.last_price IS NOT NULL
THEN 'Last Sale: ' + ISNULL(CONVERT(varchar(10), q.last_date, 120), '')
ELSE 'No Recent'
END AS label,
ISNULL(q.last_price, 0) AS value,
'currency' AS type,
CASE
WHEN q.last_price IS NOT NULL THEN
CONCAT(
CASE ISNULL(q.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 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

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(
_bill TEXT,
@ -449,7 +449,14 @@ BEGIN
'label', CASE WHEN _last_price IS NOT NULL THEN 'Last Sale: ' || _last_date ELSE 'No Recent' END,
'value', COALESCE(_last_price,0),
'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
ELSE NULL END
)