change status so that only true open orders show as such
This commit is contained in:
parent
df8f63fcfb
commit
878ed265ca
@ -255,8 +255,8 @@ gld AS (
|
||||
,sum(o.fb_cst_loc_fut) fb_cst_loc_fut
|
||||
,sum(o.fb_val_loc) fb_val_loc
|
||||
,sum(o.fb_val_loc_pl) fb_val_loc_pl
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
,'CLOSED' calc_status
|
||||
,'SHIPMENT' flag
|
||||
,o.orderdate
|
||||
,o.requestdate
|
||||
,greatest(least(o.shipdate,gld.edat),gld.sdat) shipdate
|
||||
@ -336,8 +336,6 @@ gld AS (
|
||||
,o.ddqtsi
|
||||
,o.fgqshp
|
||||
,o.diqtsh
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
,o.orderdate
|
||||
,o.requestdate
|
||||
,greatest(least(o.shipdate,gld.edat),gld.sdat)
|
||||
|
@ -1,3 +1,5 @@
|
||||
BEGIN;
|
||||
|
||||
WITH
|
||||
mseq AS (
|
||||
SELECT * FROM
|
||||
@ -74,30 +76,21 @@ GROUP BY
|
||||
ORDER BY
|
||||
value_usd DESC
|
||||
)
|
||||
,rbld AS (
|
||||
SELECT
|
||||
o.shipgrp
|
||||
,o.orderdate
|
||||
,o.requestdate
|
||||
,o.shipdate
|
||||
,o.orderm
|
||||
,o.rmo
|
||||
,o.value_usd
|
||||
,lag.wav_lag
|
||||
,o.requestdate + lag.wav_lag + 15 rship
|
||||
,upd AS (
|
||||
UPDATE rlarp.osmfs o SET
|
||||
adj_shipdate = greatest(shipdate + lag.wav_lag + 5 ,shipdate)
|
||||
FROM
|
||||
opord o
|
||||
LEFT OUTER JOIN lag ON
|
||||
lag.shipgrp = o.shipgrp
|
||||
AND lag.orderm = o.orderm
|
||||
AND lag.rmo = o.rmo
|
||||
ORDER BY
|
||||
value_usd desc
|
||||
lag
|
||||
WHERE
|
||||
lag.shipgrp = o.shipgrp
|
||||
AND lag.orderm = to_char(o.orderdate,'Mon')
|
||||
AND lag.rmo = extract(month FROM age(o.requestdate,o.orderdate))
|
||||
AND o.calc_status in ('BACKORDER','OPEN')
|
||||
RETURNING *
|
||||
)
|
||||
select
|
||||
sum(value_usd) filter (where rship >= '2019-04-01')
|
||||
,sum(value_usd) filter (where rship < '2019-04-01')
|
||||
from
|
||||
rbld
|
||||
where
|
||||
shipdate < '2019-04-01'
|
||||
SELECT
|
||||
sum(fb_val_loc *r_rate) filter (where adj_shipdate < '2019-04-01')
|
||||
,sum(fb_val_loc *r_rate) filter (where adj_shipdate >= '2019-04-01')
|
||||
from upd;
|
||||
|
||||
COMMIT;
|
Loading…
Reference in New Issue
Block a user