commit: 2025-08-08 17:36:58

This commit is contained in:
Paul Trowbridge 2025-08-08 17:36:58 -04:00
parent 68921d9a7f
commit 10ca238010
4 changed files with 30 additions and 16 deletions

View File

@ -1,10 +1,10 @@
EXEC pricing.single_price_call
@bill = 'GRIF0001',
@ship = 'GRIF0001',
@part = 'XNS0T1G3G18B096',
@v1ds = 'v1:B.L.PLT..',
@vol = 9600;
@bill = 'FARM0001',
@ship = 'KEYB0001',
@part = 'HZP3E100E21D050',
@v1ds = 'v1:T..PLT..',
@vol = 50000;
SELECT
@ -50,7 +50,7 @@ WHERE
SELECT
*
FROM pricing.single_price_call(
FROM pricequote.single_price_call(
'GRIF0001',
'GRIF0001',
'XNS0T1G3G18B096',

View File

@ -1,9 +1,12 @@
SELECT
*
FROM pricequote.single_price_call(
'GRIF0001',
'GRIF0001',
'XNS0T1G3G18B096',
'v1:B..PLT..',
9600
'FARM0001',
'KEYB0001',
'HZP3E100E21D050',
'v1:L..BDL..',
50000
) f
SELECT * FROM pricequote.target_prices tp WHERE tp.stlc = 'HZP3E100' AND ds = 'v1:T..PLT..' and chan = 'DRP' and tier = '1' and vol @> 1;

View File

@ -466,7 +466,7 @@ BEGIN
RTRIM(SUBSTRING(value,1,18)) AS label,
TRY_CAST(SUBSTRING(value,23,7) AS NUMERIC(20,5))
+ CASE SUBSTRING(value,19,1) WHEN '+' THEN 0 ELSE -1 END AS value,
CASE SUBSTRING(value,19,1) WHEN '+' THEN 'currency' ELSE 'Percentage' END AS type,
CASE SUBSTRING(value,19,1) WHEN '+' THEN 'currency' ELSE 'Percent' END AS type,
CASE SUBSTRING(value,19,1) WHEN '+' THEN 'Price' ELSE 'Premium' END AS note
FROM OPENJSON(q.expl, '$.target_math')
WITH (value NVARCHAR(MAX) '$')
@ -497,5 +497,5 @@ BEGIN
--------------------------------------------------------------------------------
-- Final: Return all calculated fields and JSON payloads.
--------------------------------------------------------------------------------
SELECT * FROM @queue;
SELECT guidance_price, ui_json FROM @queue;
END;

View File

@ -93,6 +93,8 @@ RETURNS TABLE (
) AS $$
DECLARE
_pltq NUMERIC;
_calculated_pallets INT;
_exact_pallets NUMERIC;
_chan TEXT;
_tier TEXT;
_cust TEXT;
@ -173,8 +175,11 @@ BEGIN
i.v1ds,
CASE substring(_v1ds,4,1) WHEN 'B' THEN 'B' ELSE 'C' END || CASE substring(_v1ds,6,1) WHEN 'L' THEN 'L' WHEN 'P' THEN 'P' ELSE '' END,
i.curstdus,
i.futstdus
INTO _pltq, _chan, _tier, _cust, _plevel, _partgroup, _stlc, _part_v1ds, _v0ds, _curstd_orig, _futstd_orig
i.futstdus,
FLOOR(_vol / NULLIF(_pltq, 0)),
ROUND(_vol / NULLIF(_pltq, 0), 5)
INTO
_pltq, _chan, _tier, _cust, _plevel, _partgroup, _stlc, _part_v1ds, _v0ds, _curstd_orig, _futstd_orig, _calculated_pallets, _exact_pallets
FROM rlarp.cust bc
LEFT JOIN rlarp.cust sc ON sc.code = _ship
LEFT JOIN "CMS.CUSLG".itemm i ON i.item = _part
@ -185,6 +190,9 @@ BEGIN
_customized := 'Customized';
END IF;
RAISE NOTICE 'Debug Inputs => stlc: "%", v1ds: "%", chan: "%", tier: "%", pallets: "%" , pltq: "%"',
_stlc, _v1ds, _chan, _tier, _calculated_pallets, _pltq;
------------------------------------------------------------------
-- Step 2: Target price logic (current and for last_dataseg)
------------------------------------------------------------------
@ -195,7 +203,10 @@ BEGIN
AND tp.ds = _v1ds
AND tp.chan = _chan
AND tp.tier = _tier
AND FLOOR(_vol / NULLIF(_pltq, 0))::int <@ tp.vol;
AND tp.vol @> _calculated_pallets;
RAISE NOTICE 'Debug: tprice=%, tmath=%, volume_range=%',
_tprice, _tmath, _volume_range;
------------------------------------------------------------------
-- Step 3: Last sale/quote/volume/segment data