retain dsm and fx rates, couple date fixes
This commit is contained in:
parent
fd855cda72
commit
8307b7c8ea
@ -54,7 +54,7 @@ gld AS (
|
|||||||
,null::numeric ditdis
|
,null::numeric ditdis
|
||||||
,null::jsonb discj
|
,null::jsonb discj
|
||||||
,null::text dhincr
|
,null::text dhincr
|
||||||
,plnt
|
,o.plnt
|
||||||
,COALESCE(o.promo,'') promo
|
,COALESCE(o.promo,'') promo
|
||||||
,null::text return_reas
|
,null::text return_reas
|
||||||
,o.terms
|
,o.terms
|
||||||
@ -65,10 +65,10 @@ gld AS (
|
|||||||
,null::text bill_rep
|
,null::text bill_rep
|
||||||
,null::text bill_terr
|
,null::text bill_terr
|
||||||
,null::text ship_class
|
,null::text ship_class
|
||||||
,ship_cust
|
,o.ship_cust
|
||||||
,null::text ship_rep
|
,null::text ship_rep
|
||||||
,null::text ship_terr
|
,null::text ship_terr
|
||||||
,null::text dsm
|
,o.dsm
|
||||||
,null::text account
|
,null::text account
|
||||||
,null::text shipgrp
|
,null::text shipgrp
|
||||||
,null::text geo
|
,null::text geo
|
||||||
@ -111,9 +111,9 @@ gld AS (
|
|||||||
,null::text plcd
|
,null::text plcd
|
||||||
,o.fs_line
|
,o.fs_line
|
||||||
,o.r_currency
|
,o.r_currency
|
||||||
,null::numeric r_rate
|
,o.r_rate
|
||||||
,o.c_currency
|
,o.c_currency
|
||||||
,null::numeric c_rate
|
,o.c_rate
|
||||||
,sum(o.fb_qty) fb_qty
|
,sum(o.fb_qty) fb_qty
|
||||||
,sum(o.fb_val_loc) fb_val_loc
|
,sum(o.fb_val_loc) fb_val_loc
|
||||||
,sum(o.fb_val_loc_dis) fb_val_loc_dis
|
,sum(o.fb_val_loc_dis) fb_val_loc_dis
|
||||||
@ -145,26 +145,31 @@ gld AS (
|
|||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
--base period orders booked....
|
--base period orders booked....
|
||||||
o.odate BETWEEN '2020-06-01' AND '2021-04-11'
|
o.odate BETWEEN '2020-06-01' AND '2021-04-04'
|
||||||
--...or any open orders currently booked before cutoff....
|
--...or any open orders currently booked before cutoff....
|
||||||
OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2021-04-11')
|
OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2021-04-04')
|
||||||
--...or anything that shipped in that period
|
--...or anything that shipped in that period
|
||||||
OR o.fspr BETWEEN '2101' AND '2011'
|
OR o.fspr BETWEEN '2101' AND '2110'
|
||||||
)
|
)
|
||||||
AND fs_line = '41010'
|
AND fs_line = '41010'
|
||||||
AND calc_status <> 'CANCELED'
|
AND calc_status <> 'CANCELED'
|
||||||
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||||
|
---exclude integrated quotes----
|
||||||
|
AND version = 'ACTUALS'
|
||||||
GROUP BY
|
GROUP BY
|
||||||
o.fspr
|
o.fspr
|
||||||
,plnt
|
,o.plnt
|
||||||
,COALESCE(o.promo,'')
|
,COALESCE(o.promo,'')
|
||||||
,o.terms
|
,o.terms
|
||||||
,o.bill_cust
|
,o.bill_cust
|
||||||
,ship_cust
|
,o.ship_cust
|
||||||
|
,o.dsm
|
||||||
,o.part
|
,o.part
|
||||||
,o.fs_line
|
,o.fs_line
|
||||||
,o.r_currency
|
,o.r_currency
|
||||||
|
,o.r_rate
|
||||||
,o.c_currency
|
,o.c_currency
|
||||||
|
,o.c_rate
|
||||||
,o.calc_status
|
,o.calc_status
|
||||||
,o.flag
|
,o.flag
|
||||||
,o.odate
|
,o.odate
|
||||||
@ -216,7 +221,7 @@ gld AS (
|
|||||||
,ship_cust
|
,ship_cust
|
||||||
,null::text ship_rep
|
,null::text ship_rep
|
||||||
,null::text ship_terr
|
,null::text ship_terr
|
||||||
,null::text dsm
|
,o.dsm
|
||||||
,null::text account
|
,null::text account
|
||||||
,null::text shipgrp
|
,null::text shipgrp
|
||||||
,null::text geo
|
,null::text geo
|
||||||
@ -259,9 +264,9 @@ gld AS (
|
|||||||
,null::text plcd
|
,null::text plcd
|
||||||
,o.fs_line
|
,o.fs_line
|
||||||
,o.r_currency
|
,o.r_currency
|
||||||
,null::numeric r_rate
|
,o.r_rate
|
||||||
,o.c_currency
|
,o.c_currency
|
||||||
,null::numeric c_rate
|
,o.c_rate
|
||||||
,sum(o.fb_qty) fb_qty
|
,sum(o.fb_qty) fb_qty
|
||||||
,sum(o.fb_val_loc) fb_val_loc
|
,sum(o.fb_val_loc) fb_val_loc
|
||||||
,sum(o.fb_val_loc_dis) fb_val_loc_dis
|
,sum(o.fb_val_loc_dis) fb_val_loc_dis
|
||||||
@ -289,22 +294,25 @@ gld AS (
|
|||||||
LEFT OUTER JOIN gld ss ON
|
LEFT OUTER JOIN gld ss ON
|
||||||
greatest(least(o.sdate,gld.edat),gld.sdat) + interval '1 year' BETWEEN ss.sdat AND ss.edat
|
greatest(least(o.sdate,gld.edat),gld.sdat) + interval '1 year' BETWEEN ss.sdat AND ss.edat
|
||||||
WHERE
|
WHERE
|
||||||
o.odate BETWEEN '2020-04-12' AND '2020-05-31'
|
o.odate BETWEEN '2020-04-05' AND '2020-05-31'
|
||||||
AND fs_line = '41010'
|
AND fs_line = '41010'
|
||||||
AND calc_status <> 'CANCELED'
|
AND calc_status <> 'CANCELED'
|
||||||
------exclude actuals for now and use forecast to get the plug for the rest of the year
|
------exclude actuals for now and use forecast to get the plug for the rest of the year
|
||||||
--AND false
|
AND version = 'ACTUALS'
|
||||||
GROUP BY
|
GROUP BY
|
||||||
o.fspr
|
o.fspr
|
||||||
,plnt
|
,plnt
|
||||||
,COALESCE(o.promo,'')
|
,COALESCE(o.promo,'')
|
||||||
,o.terms
|
,o.terms
|
||||||
,o.bill_cust
|
,o.bill_cust
|
||||||
,ship_cust
|
,o.ship_cust
|
||||||
|
,o.dsm
|
||||||
,o.part
|
,o.part
|
||||||
,o.fs_line
|
,o.fs_line
|
||||||
,o.r_currency
|
,o.r_currency
|
||||||
|
,o.r_rate
|
||||||
,o.c_currency
|
,o.c_currency
|
||||||
|
,o.c_rate
|
||||||
,o.calc_status
|
,o.calc_status
|
||||||
,o.flag
|
,o.flag
|
||||||
,o.odate
|
,o.odate
|
||||||
@ -429,11 +437,11 @@ gld AS (
|
|||||||
LEFT OUTER JOIN gld ss ON
|
LEFT OUTER JOIN gld ss ON
|
||||||
greatest(least(o.sdate,gld.edat),gld.sdat) BETWEEN ss.sdat AND ss.edat
|
greatest(least(o.sdate,gld.edat),gld.sdat) BETWEEN ss.sdat AND ss.edat
|
||||||
WHERE
|
WHERE
|
||||||
o.odate BETWEEN '2020-03-01' AND '2020-05-31'
|
false
|
||||||
AND fs_line = '41010'
|
--o.odate BETWEEN '2020-03-01' AND '2020-05-31'
|
||||||
AND calc_status <> 'CANCELED'
|
--AND fs_line = '41010'
|
||||||
|
--AND calc_status <> 'CANCELED'
|
||||||
------dont pull forecast for a baseline this time around--
|
------dont pull forecast for a baseline this time around--
|
||||||
AND false
|
|
||||||
GROUP BY
|
GROUP BY
|
||||||
o.fspr
|
o.fspr
|
||||||
,plnt
|
,plnt
|
||||||
|
Loading…
Reference in New Issue
Block a user