DELETE FROM pricing.price_queue;

INSERT INTO pricing.price_queue (bill, ship, part, stlc, v1ds, vol) SELECT 'GRIF0001','GRIF0001','XNS0T1G3G18B096','XNS0T1G3','v1:L..PLT..',9600;

SELECT * FROM pricing.price_queue

EXEC pricing.process_queue


EXEC pricing.single_price_call
    @bill = 'GRIF0001',
    @ship = 'JRSG0001',
    @part = 'XNS0T1G3G18B096',
    @stlc = 'XNS0T1G3',
    @v1ds = 'v1:T..PLT..',
    @vol = 0;

EXEC pricing.single_price_call_nowrite
    @bill = 'GRIF0001',
    @ship = 'JRSG0001',
    @part = 'XNS0T1G3G18B096',
    @stlc = 'XNS0T1G3',
    @v1ds = 'v1:T..PLT..',
    @vol = 19200;

SELECT 
	price, expl
FROM pricing.fn_single_price_call(
    'GRIF0001',
    'JRSG0001',
    'XNS0T1G3G18B096',
    'XNS0T1G3',
    'v1:T..PLT..',
    12500
) f

SELECT 
	price
	,expl
	,JSON_VALUE(expl, '$."tier"') AS tier
	,JSON_VALUE(expl, '$."customer"') AS cust
    ,JSON_QUERY(expl, '$."target math"') AS math
FROM pricing.fn_single_price_call(
    'GRIF0001',
    'JRSG0001',
    'XNS0T1G3G18B096',
    'XNS0T1G3',
    'v1:T..PLT..',
    12500
);

SELECT * INTO #result FROM pricing.price_queue WHERE 0=1

INSERT INTO #result
EXEC pricing.single_price_call_nowrite
    @bill = 'GRIF0001',
    @ship = 'JRSG0001',
    @part = 'XNS0T1G3G18B096',
    @stlc = 'XNS0T1G3',
    @v1ds = 'v1:T..PLT..',
    @vol = 19200;

SELECT * FROM #RESULT
