handle costs and major groups

This commit is contained in:
Trowbridge 2020-03-05 00:59:59 -05:00
parent 77fe829ece
commit 87d5dbceaf

View File

@ -99,7 +99,7 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
,repl AS (
SELECT
fspr
,plnt ---master data
,m.dplt plnt ---master data
,promo --history date mix
,terms
,bill_cust_descr --history cust mix
@ -116,22 +116,22 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
,m.item || ' - ' || m.descr partd
,substring(pl.replace,1,8) part_group
,m.branding branding
,m.majgd majg_descr
,m.mingd ming_descr
,m.majsd majs_descr
,m.minsd mins_descr
,m.majg||' - '||m.majgd majg_descr
,m.ming||' - '||m.mingd ming_descr
,m.majs||' - '||m.majsd majs_descr
,m.mins||' - '||m.minsd mins_descr
,seg.segm
,substance
,fs_line --master data
,r_currency --history cust mix
,r_rate --master data
,c_currency --master data
,c_rate --master data
,r.curr c_currency --master data
,x.rate c_rate --master data
,-units units
,-value_loc value_loc
,-value_usd value_usd
,-cost_loc cost_loc
,-cost_usd cost_usd
,-units * c.std cost_loc
,-units * c.std * x.rate cost_usd
,calc_status --0
,flag --0
,order_date --history date mix
@ -154,7 +154,17 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
INNER JOIN pl ON
pl.original = o.part
INNER JOIN rlarp.itemmv m ON
m.item = o.part
m.item = pl.replace
LEFT OUTER JOIN rlarp.icstx c ON
c.part = pl.replace
AND c.plnt = m.dplt
LEFT OUTER JOIN rlarp.plpr r ON
yaplnt = m.dplt
LEFT OUTER JOIN rlarp.ffcret x ON
x.fcur = r.curr
AND x.tcur = 'US'
AND x.rtyp = 'BG'
AND x.perd = '2101'
LEFT OUTER JOIN seg ON
seg.glec = m.glec
)