commit: 2024-12-13 09:46:50
This commit is contained in:
parent
b38cc02ef5
commit
3e530e2729
@ -14,7 +14,7 @@ lq AS MATERIALIZED (
|
|||||||
SELECT
|
SELECT
|
||||||
lq.*
|
lq.*
|
||||||
,pricing->'product'->>'mold' part_group
|
,pricing->'product'->>'mold' part_group
|
||||||
,substring(pricing->'customer'->>'chan',1,1) qchan
|
-- ,substring(pricing->'customer'->>'chan',1,1) qchan
|
||||||
,pricing->'customer'->>'cust' qcust
|
,pricing->'customer'->>'cust' qcust
|
||||||
,pricing->'product'->>'itemrel' item_fit
|
,pricing->'product'->>'itemrel' item_fit
|
||||||
,(pricing->'product'->>'pltq')::numeric pltq
|
,(pricing->'product'->>'pltq')::numeric pltq
|
||||||
|
@ -14,7 +14,19 @@ lq AS MATERIALIZED (
|
|||||||
SELECT
|
SELECT
|
||||||
lq.*
|
lq.*
|
||||||
,pricing->'product'->>'mold' part_group
|
,pricing->'product'->>'mold' part_group
|
||||||
,substring(pricing->'customer'->>'chan',1,1) qchan
|
CASE SUBSTR(bc.cclass,2,3)
|
||||||
|
--if the bill to class is ditsributor, then it's either warehouse or drop
|
||||||
|
WHEN 'DIS' THEN
|
||||||
|
--if the ship-to is a different name than the bill-to then it's drop, otherwise it's warehouse
|
||||||
|
CASE SUBSTR(sc.cclass,2,3)
|
||||||
|
WHEN 'DIS' THEN 'WHS'
|
||||||
|
ELSE 'DRP'
|
||||||
|
END
|
||||||
|
--CASE WHEN RTRIM(SUBSTR(LTRIM(SC.BVADR7)||SC.BVNAME,1,30)) = RTRIM(SUBSTR(LTRIM(BC.BVADR7)||BC.BVNAME,1,30)) THEN 'DIS' ELSE 'DRP' END
|
||||||
|
--everything else does not involve a distributor and is considered direct
|
||||||
|
ELSE 'DIR'
|
||||||
|
END qchan,
|
||||||
|
,CASE osm.chan WHEN 'DRP' THEN rtrim(osm.shipgrp) ELSE rtrim(osm.account) END customer
|
||||||
,pricing->'customer'->>'cust' qcust
|
,pricing->'customer'->>'cust' qcust
|
||||||
,pricing->'product'->>'itemrel' item_fit
|
,pricing->'product'->>'itemrel' item_fit
|
||||||
,(pricing->'product'->>'pltq')::numeric pltq
|
,(pricing->'product'->>'pltq')::numeric pltq
|
||||||
@ -28,6 +40,10 @@ lq AS MATERIALIZED (
|
|||||||
,jsonb_pretty(pricing) pricing
|
,jsonb_pretty(pricing) pricing
|
||||||
FROM
|
FROM
|
||||||
lq
|
lq
|
||||||
|
LEFT OUTER JOIN rlarp.cust bc ON
|
||||||
|
bc.cust = lq.billto
|
||||||
|
LEFT OUTER JOIN rlarp.cust sc ON
|
||||||
|
bc.cust = lq.shipto
|
||||||
LEFT JOIN LATERAL rlarp.guidance_r1(
|
LEFT JOIN LATERAL rlarp.guidance_r1(
|
||||||
rlarp.get_guidance_dseg(lq.billto,lq.shipto,substring(lq.part,1,8),lq.v1ds,lq.units_each,2025)
|
rlarp.get_guidance_dseg(lq.billto,lq.shipto,substring(lq.part,1,8),lq.v1ds,lq.units_each,2025)
|
||||||
) pricing ON TRUE
|
) pricing ON TRUE
|
||||||
|
Loading…
Reference in New Issue
Block a user