link in cost and inventory currency
This commit is contained in:
parent
1443f339b7
commit
a3a5d3ad0d
@ -143,6 +143,26 @@ target AS (select '{"scenario":{"quota_rep_descr":"10032 - BRYAN HILL","part_gro
|
||||
,SI AS (
|
||||
SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') <> ''
|
||||
)
|
||||
,copr AS (
|
||||
SELECT
|
||||
LTRIM(RTRIM(A9)) AS COMP,
|
||||
A30 AS DESCR,
|
||||
SUBSTR(C.A249,242,2) CURR,
|
||||
SUBSTR(C.A249,32,4) AS GL,
|
||||
SUBSTR(C.A249,190,4) AS AR,
|
||||
SUBSTR(C.A249,182,4) AS AP,
|
||||
SUBSTR(C.A249,198,4) AS FA,
|
||||
SUBSTR(C.A249,238,4) AS IC ,
|
||||
SUBSTR(D.A249,9,5) CONS_FUNC
|
||||
FROM
|
||||
LGDAT.CODE
|
||||
LEFT OUTER JOIN LGDAT.NAME C ON
|
||||
'C0000'||LTRIM(RTRIM(A9)) = C.A7
|
||||
LEFT OUTER JOIN LGDAT.NAME D ON
|
||||
'D0000'||LTRIM(RTRIM(A9)) = D.A7
|
||||
WHERE
|
||||
A2 = 'AA' OR A2 IS NULL
|
||||
)
|
||||
,alldates AS (
|
||||
SELECT
|
||||
promo
|
||||
@ -599,16 +619,16 @@ SELECT
|
||||
,b.fs_line --master data
|
||||
,b.r_currency --history cust mix
|
||||
,b.r_rate --master data
|
||||
,b.c_currency --master data
|
||||
,b.c_rate --master data
|
||||
,copr.curr c_currency --master data
|
||||
,cx.rate c_rate --master data
|
||||
,b.ddqtoi
|
||||
,b.ddqtsi
|
||||
,b.fgqshp
|
||||
,b.diqtsh
|
||||
,b.fb_qty
|
||||
,b.fb_cst_loc
|
||||
,b.fb_cst_loc_cur
|
||||
,b.fb_cst_loc_fut
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.fb_qty fb_cst_loc
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.fb_qty fb_cst_loc_cur
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.fb_qty fb_cst_loc_fut
|
||||
,b.fb_val_loc
|
||||
,b.fb_val_loc_pl
|
||||
,b.calc_status
|
||||
@ -654,10 +674,10 @@ SELECT
|
||||
END mod_chansub
|
||||
,b.quota_rep_descr
|
||||
,b.director_descr
|
||||
,b.value_loc
|
||||
,b.value_usd
|
||||
,b.cost_loc
|
||||
,b.cost_usd
|
||||
,b.fb_val_loc value_loc
|
||||
,b.fb_val_loc *r_rate value_usd
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.fb_qty cost_loc
|
||||
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.fb_qty*cx.rate cost_usd
|
||||
,b.units
|
||||
FROM
|
||||
applyx b
|
||||
@ -697,3 +717,21 @@ FROM
|
||||
LEFT OUTER JOIN LGDAT.MMGP ON
|
||||
BRMGRP = COALESCE(m.avming,p.awming)
|
||||
AND BRGRP = COALESCE(m.avmajg,p.awmajg)
|
||||
LEFT OUTER JOIN lgdat.icstm im ON
|
||||
im.cgpart = b.part
|
||||
AND im.cgplnt = a.v6plnt
|
||||
LEFT OUTER JOIN lgdat.icstp ip ON
|
||||
ip.chpart = b.part
|
||||
AND ip.chplnt = a.v6plnt
|
||||
LEFT OUTER JOIN lgdat.icstr ir ON
|
||||
ir.y0part = b.part
|
||||
AND ir.y0plnt = a.v6plnt
|
||||
LEFT OUTER JOIN lgdat.plnt ON
|
||||
yaplnt = a.v6plnt
|
||||
LEFT OUTER JOIN copr ON
|
||||
copr.comp = yacomp::text
|
||||
LEFT OUTER JOIN rlarp.ffcret cx ON
|
||||
cx.perd = '1910'
|
||||
AND cx.rtyp = 'MA'
|
||||
AND cx.fcur = copr.curr
|
||||
AND cx.tcur = 'US'
|
Loading…
Reference in New Issue
Block a user