pull target based on modified channel
This commit is contained in:
parent
885a2982ee
commit
e1406f70ab
@ -5,6 +5,7 @@ LANGUAGE plpgsql AS
|
|||||||
$func$
|
$func$
|
||||||
DECLARE
|
DECLARE
|
||||||
_chan text;
|
_chan text;
|
||||||
|
_chantp text;
|
||||||
_bill_class text;
|
_bill_class text;
|
||||||
_ship_class text;
|
_ship_class text;
|
||||||
_bill_dba text;
|
_bill_dba text;
|
||||||
@ -47,6 +48,14 @@ BEGIN
|
|||||||
INTO
|
INTO
|
||||||
_chan;
|
_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
|
SELECT
|
||||||
CASE WHEN _chan = 'DRP' THEN _ship_dba ELSE _bill_dba END
|
CASE WHEN _chan = 'DRP' THEN _ship_dba ELSE _bill_dba END
|
||||||
INTO
|
INTO
|
||||||
@ -56,6 +65,7 @@ BEGIN
|
|||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'cust',_cust,
|
'cust',_cust,
|
||||||
'chan',_chan,
|
'chan',_chan,
|
||||||
|
'chantp',_chantp,
|
||||||
'curr',_bill_curr,
|
'curr',_bill_curr,
|
||||||
'fxrate',_bill_rate,
|
'fxrate',_bill_rate,
|
||||||
'bill_dba',_bill_dba,
|
'bill_dba',_bill_dba,
|
||||||
|
@ -181,7 +181,8 @@ BEGIN
|
|||||||
mold = _stlc
|
mold = _stlc
|
||||||
AND season = _seas
|
AND season = _seas
|
||||||
AND data_segment = _v0ds
|
AND data_segment = _v0ds
|
||||||
AND region = 'ALL';
|
AND region = 'ALL'
|
||||||
|
AND chan = _customer->'customer'->>'chantp';
|
||||||
----------------target pricing------------------------------
|
----------------target pricing------------------------------
|
||||||
SELECT
|
SELECT
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
@ -198,7 +199,8 @@ BEGIN
|
|||||||
mold = _stlc
|
mold = _stlc
|
||||||
AND season = _seas
|
AND season = _seas
|
||||||
AND data_segment = _dseg
|
AND data_segment = _dseg
|
||||||
AND region = 'ALL';
|
AND region = 'ALL'
|
||||||
|
AND chan = _customer->'customer'->>'chantp';
|
||||||
--RAISE NOTICE 'target: %', jsonb_pretty(_targ);
|
--RAISE NOTICE 'target: %', jsonb_pretty(_targ);
|
||||||
_pricing := (COALESCE(_v0tp,'{}'::jsonb)||COALESCE(_v1tp,'{}'::jsonb));
|
_pricing := (COALESCE(_v0tp,'{}'::jsonb)||COALESCE(_v1tp,'{}'::jsonb));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user