pull target based on modified channel

This commit is contained in:
Paul Trowbridge 2023-12-08 11:37:07 -05:00
parent 885a2982ee
commit e1406f70ab
2 changed files with 14 additions and 2 deletions

View File

@ -5,6 +5,7 @@ LANGUAGE plpgsql AS
$func$
DECLARE
_chan text;
_chantp text;
_bill_class text;
_ship_class text;
_bill_dba text;
@ -47,6 +48,14 @@ BEGIN
INTO
_chan;
SELECT
CASE WHEN SUBSTRING(_bill_class,2,3) = 'DIS'
THEN CASE WHEN SUBSTRING(_ship_class,2,3) = 'DIS' THEN 'DISTRIBUTOR' ELSE 'DISTRIB DROP SHIP' END
ELSE 'DIRECT'
END
INTO
_chantp;
SELECT
CASE WHEN _chan = 'DRP' THEN _ship_dba ELSE _bill_dba END
INTO
@ -56,6 +65,7 @@ BEGIN
jsonb_build_object(
'cust',_cust,
'chan',_chan,
'chantp',_chantp,
'curr',_bill_curr,
'fxrate',_bill_rate,
'bill_dba',_bill_dba,

View File

@ -181,7 +181,8 @@ BEGIN
mold = _stlc
AND season = _seas
AND data_segment = _v0ds
AND region = 'ALL';
AND region = 'ALL'
AND chan = _customer->'customer'->>'chantp';
----------------target pricing------------------------------
SELECT
jsonb_build_object(
@ -198,7 +199,8 @@ BEGIN
mold = _stlc
AND season = _seas
AND data_segment = _dseg
AND region = 'ALL';
AND region = 'ALL'
AND chan = _customer->'customer'->>'chantp';
--RAISE NOTICE 'target: %', jsonb_pretty(_targ);
_pricing := (COALESCE(_v0tp,'{}'::jsonb)||COALESCE(_v1tp,'{}'::jsonb));