Compare commits
73 Commits
cf82925eca
...
d541ee16cc
Author | SHA1 | Date | |
---|---|---|---|
d541ee16cc | |||
60b57263d0 | |||
5162839c5d | |||
6f0d8745d2 | |||
d13519c07c | |||
89e4983a03 | |||
3854bed603 | |||
cf6e3b6695 | |||
fee1b9202f | |||
ab7af8d2ed | |||
94ae5e192c | |||
7e4049d27d | |||
50da4dfa17 | |||
3b3b01bb90 | |||
9db81ace17 | |||
f156d599e5 | |||
409522677e | |||
ab1d8f8778 | |||
7dab34e949 | |||
4c43a79f15 | |||
9f208bc0b7 | |||
a50de52702 | |||
037070ed1e | |||
ce91851d48 | |||
3fae4d50cc | |||
c8cb809e18 | |||
|
6c6452014f | ||
19fc49420d | |||
a328aaeaaf | |||
f7f26b2804 | |||
b487430057 | |||
28ee5dfbb4 | |||
6e4e64b3a4 | |||
07f36612d5 | |||
e4604a16f5 | |||
a12fc36bad | |||
94f925f1d8 | |||
5dc43123c9 | |||
2013609c25 | |||
694d805aaf | |||
59c32d8619 | |||
4acee798d2 | |||
883840d565 | |||
551a4867d6 | |||
1b0f4b9f04 | |||
a0a6a94107 | |||
e4054326d0 | |||
8307b7c8ea | |||
fd855cda72 | |||
c4f3abd733 | |||
6984b039f2 | |||
b9ff9c1493 | |||
c6df2774cb | |||
c0c0a98e1f | |||
d53c7bec0a | |||
3b983140b6 | |||
652720ff32 | |||
|
834d52a2a2 | ||
|
3592120b54 | ||
|
ca996adac6 | ||
|
17dc465cdc | ||
|
e3205a94c1 | ||
|
37eb9d519f | ||
|
aca8fa7aeb | ||
|
ebc7d90dc5 | ||
|
3540c35629 | ||
|
f34b0d539d | ||
|
e201302953 | ||
|
3d5cd9b2ff | ||
|
87d5dbceaf | ||
|
77fe829ece | ||
|
28865863bd | ||
|
3492c802b9 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,3 +8,5 @@ stat.html
|
||||
changes.html
|
||||
*.pem
|
||||
*.log
|
||||
/.dbeaver
|
||||
.project
|
||||
|
BIN
Master Template 1.6.xlsm
Normal file
BIN
Master Template 1.6.xlsm
Normal file
Binary file not shown.
@ -54,7 +54,7 @@ gld AS (
|
||||
,null::numeric ditdis
|
||||
,null::jsonb discj
|
||||
,null::text dhincr
|
||||
,plnt
|
||||
,o.plnt
|
||||
,COALESCE(o.promo,'') promo
|
||||
,null::text return_reas
|
||||
,o.terms
|
||||
@ -65,10 +65,10 @@ gld AS (
|
||||
,null::text bill_rep
|
||||
,null::text bill_terr
|
||||
,null::text ship_class
|
||||
,ship_cust
|
||||
,o.ship_cust
|
||||
,null::text ship_rep
|
||||
,null::text ship_terr
|
||||
,null::text dsm
|
||||
,o.dsm
|
||||
,null::text account
|
||||
,null::text shipgrp
|
||||
,null::text geo
|
||||
@ -111,9 +111,9 @@ gld AS (
|
||||
,null::text plcd
|
||||
,o.fs_line
|
||||
,o.r_currency
|
||||
,null::numeric r_rate
|
||||
,o.r_rate
|
||||
,o.c_currency
|
||||
,null::numeric c_rate
|
||||
,o.c_rate
|
||||
,sum(o.fb_qty) fb_qty
|
||||
,sum(o.fb_val_loc) fb_val_loc
|
||||
,sum(o.fb_val_loc_dis) fb_val_loc_dis
|
||||
@ -145,26 +145,31 @@ gld AS (
|
||||
WHERE
|
||||
(
|
||||
--base period orders booked....
|
||||
o.odate BETWEEN '2019-06-01' AND '2020-02-29'
|
||||
o.odate BETWEEN '2020-06-01' AND '2021-04-11'
|
||||
--...or any open orders currently booked before cutoff....
|
||||
OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2020-03-01')
|
||||
OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2021-04-11')
|
||||
--...or anything that shipped in that period
|
||||
OR o.fspr BETWEEN '2001' AND '2009'
|
||||
OR o.fspr BETWEEN '2101' AND '2110'
|
||||
)
|
||||
AND fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||
---exclude integrated quotes----
|
||||
AND version = 'ACTUALS'
|
||||
GROUP BY
|
||||
o.fspr
|
||||
,plnt
|
||||
,o.plnt
|
||||
,COALESCE(o.promo,'')
|
||||
,o.terms
|
||||
,o.bill_cust
|
||||
,ship_cust
|
||||
,o.ship_cust
|
||||
,o.dsm
|
||||
,o.part
|
||||
,o.fs_line
|
||||
,o.r_currency
|
||||
,o.r_rate
|
||||
,o.c_currency
|
||||
,o.c_rate
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
,o.odate
|
||||
@ -216,7 +221,7 @@ gld AS (
|
||||
,ship_cust
|
||||
,null::text ship_rep
|
||||
,null::text ship_terr
|
||||
,null::text dsm
|
||||
,o.dsm
|
||||
,null::text account
|
||||
,null::text shipgrp
|
||||
,null::text geo
|
||||
@ -259,9 +264,9 @@ gld AS (
|
||||
,null::text plcd
|
||||
,o.fs_line
|
||||
,o.r_currency
|
||||
,null::numeric r_rate
|
||||
,o.r_rate
|
||||
,o.c_currency
|
||||
,null::numeric c_rate
|
||||
,o.c_rate
|
||||
,sum(o.fb_qty) fb_qty
|
||||
,sum(o.fb_val_loc) fb_val_loc
|
||||
,sum(o.fb_val_loc_dis) fb_val_loc_dis
|
||||
@ -289,22 +294,25 @@ gld AS (
|
||||
LEFT OUTER JOIN gld ss ON
|
||||
greatest(least(o.sdate,gld.edat),gld.sdat) + interval '1 year' BETWEEN ss.sdat AND ss.edat
|
||||
WHERE
|
||||
o.odate BETWEEN '2019-03-01' AND '2019-05-31'
|
||||
o.odate BETWEEN '2020-04-12' AND '2020-05-31'
|
||||
AND fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
------exclude actuals for now and use forecast to get the plug for the rest of the year
|
||||
AND false
|
||||
AND version = 'ACTUALS'
|
||||
GROUP BY
|
||||
o.fspr
|
||||
,plnt
|
||||
,COALESCE(o.promo,'')
|
||||
,o.terms
|
||||
,o.bill_cust
|
||||
,ship_cust
|
||||
,o.ship_cust
|
||||
,o.dsm
|
||||
,o.part
|
||||
,o.fs_line
|
||||
,o.r_currency
|
||||
,o.r_rate
|
||||
,o.c_currency
|
||||
,o.c_rate
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
,o.odate
|
||||
@ -429,9 +437,11 @@ gld AS (
|
||||
LEFT OUTER JOIN gld ss ON
|
||||
greatest(least(o.sdate,gld.edat),gld.sdat) BETWEEN ss.sdat AND ss.edat
|
||||
WHERE
|
||||
o.odate BETWEEN '2020-03-01' AND '2020-05-31'
|
||||
AND fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
false
|
||||
--o.odate BETWEEN '2020-03-01' AND '2020-05-31'
|
||||
--AND fs_line = '41010'
|
||||
--AND calc_status <> 'CANCELED'
|
||||
------dont pull forecast for a baseline this time around--
|
||||
GROUP BY
|
||||
o.fspr
|
||||
,plnt
|
||||
@ -555,14 +565,14 @@ SELECT
|
||||
,o.rseas + 1 --incremented
|
||||
,o.sdate + interval '1 year' --incremented
|
||||
,o.sseas + 1 --incremented
|
||||
,'b21' "version"
|
||||
,'b22' "version"
|
||||
,'copy' iter
|
||||
FROM
|
||||
baseline o
|
||||
LEFT OUTER JOIN gld ON
|
||||
o.sdate + interval '1 year' BETWEEN gld.sdat and gld.edat
|
||||
WHERE
|
||||
o.odate + interval '1 year' >= '2020-06-01'
|
||||
o.odate + interval '1 year' >= '2021-06-01'
|
||||
)
|
||||
INSERT INTO rlarp.osmf_dev
|
||||
SELECT * FROM incr
|
||||
|
@ -26,7 +26,8 @@ repc AS (
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1CU','Retail'),
|
||||
('1CU','Sustainable'),
|
||||
('1SU','Sustainable'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
@ -68,11 +69,43 @@ SELECT
|
||||
,chan
|
||||
,chansub
|
||||
,CASE seg.segm
|
||||
--for 1RE coded product
|
||||
WHEN 'Retail' THEN
|
||||
CASE o.bill_class
|
||||
WHEN 'RMAS' THEN 'MASS'
|
||||
WHEN 'RNAT' THEN 'NATIONAL'
|
||||
ELSE 'OTHER'
|
||||
WHEN 'RONL' THEN 'Online'
|
||||
WHEN 'RNAT' THEN 'National'
|
||||
WHEN 'RMAS' THEN 'National'
|
||||
ELSE
|
||||
------ ship-to class ---------------------
|
||||
CASE o.chan
|
||||
WHEN 'GDIS' THEN 'Distribution'
|
||||
WHEN 'NDIS' THEN 'Distribution'
|
||||
WHEN 'RDIS' THEN 'Distribution'
|
||||
WHEN 'GDRP' THEN 'Grower'
|
||||
WHEN 'NDRP' THEN 'Grower'
|
||||
WHEN 'RDRP' THEN 'Distribution'
|
||||
WHEN 'GDIR' THEN 'Grower'
|
||||
WHEN 'NDIR' THEN 'Grower'
|
||||
-------this will probably need reviewed--------
|
||||
WHEN 'RDIR' THEN 'Distribution'
|
||||
WHEN 'NDIR' THEN 'Grower'
|
||||
WHEN 'GDIR' THEN 'Grower'
|
||||
ELSE 'Distribution'
|
||||
END
|
||||
END
|
||||
--for 1SU 1CU coded product
|
||||
WHEN 'Sustainable' THEN
|
||||
CASE SUBSTRING(o.coltier,1,1)
|
||||
--anything with a bio color tier is bio on the channel
|
||||
WHEN 'R' THEN 'Bio'
|
||||
ELSE
|
||||
CASE o.glec
|
||||
--any 1SU that is not bio is fiber
|
||||
WHEN '1SU' THEN 'Fiber'
|
||||
--any 1CU that is not bio is commercial
|
||||
WHEN '1CU' THEN 'Commercial'
|
||||
ELSE o.chan
|
||||
END
|
||||
END
|
||||
ELSE o.chan
|
||||
END chan_retail
|
||||
|
@ -1,10 +1,10 @@
|
||||
SELECT
|
||||
order_season
|
||||
,sum(value_usd) value_usd
|
||||
,sum(coalesce(value_usd,0)) value_usd
|
||||
FROM
|
||||
rlarp.osm_pool
|
||||
WHERE
|
||||
order_season = 2021
|
||||
order_season = 2022
|
||||
--AND version = 'b21'
|
||||
GROUP BY
|
||||
order_season
|
||||
@ -15,8 +15,8 @@ SELECT
|
||||
FROM
|
||||
rlarp.osmf_dev
|
||||
WHERE
|
||||
oseas = 2021
|
||||
AND version = 'b21'
|
||||
oseas = 2022
|
||||
AND version = 'b22'
|
||||
GROUP BY
|
||||
oseas
|
||||
|
||||
|
@ -286,85 +286,88 @@ WHERE
|
||||
|
||||
---------------------------SET QUOTA REP---------------------------------------
|
||||
|
||||
|
||||
UPDATE
|
||||
RLARP.OSMFS_DEV S
|
||||
rlarp.osmfs_dev s
|
||||
SET
|
||||
DSM = CR.QUOTA_REP
|
||||
dsm = cr.quota_rep
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
VERSION,
|
||||
COALESCE(GLEC,'') GLEC,
|
||||
COALESCE(MING,'') MING,
|
||||
MING,
|
||||
BILL_CUST,
|
||||
SHIP_CUST,
|
||||
------------quota rep column--------------
|
||||
RTRIM(
|
||||
--retail items go to currep, or if null go to 90005
|
||||
CASE WHEN S.GLEC IN ('1RE','1CU') THEN
|
||||
CASE WHEN BVCTRY = 'CAN' THEN
|
||||
--Rachel Bowman
|
||||
'50300'
|
||||
CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE
|
||||
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
|
||||
CASE WHEN COALESCE(glec,'') = '1RE' AND COALESCE(cu.currep,'') <> '' THEN
|
||||
cu.currep
|
||||
--default logic
|
||||
ELSE
|
||||
--select customers go to select reps
|
||||
CASE ACCOUNT
|
||||
------Alecia Latini-------------------------------
|
||||
WHEN 'DO IT BEST' THEN '90006'
|
||||
WHEN 'ACE HARDWARE' THEN '90006'
|
||||
WHEN 'ALDI' THEN '90006'
|
||||
WHEN 'AMAZON.COM' THEN '90006'
|
||||
WHEN 'GARDEN RIDGE CORP' THEN '90006' --AKA "At Home"
|
||||
WHEN 'TRUE VALUE' THEN '90006'
|
||||
WHEN 'WAYFAIR' THEN '90006'
|
||||
WHEN 'GRIFFIN' THEN '90006'
|
||||
WHEN 'WAL-MART' THEN '90006'
|
||||
------Tony Landino--------------------------------
|
||||
WHEN 'THE HOME DEPOT' THEN '50802'
|
||||
WHEN 'FRED MEYER' THEN '50802'
|
||||
WHEN 'MENARDS' THEN '50802'
|
||||
WHEN 'KROGER' THEN '50802'
|
||||
WHEN 'OCEAN STATE JOBBERS' THEN '50802'
|
||||
WHEN 'AURORA WHOLESALE' THEN '50802'
|
||||
WHEN 'LEON KORRAL' THEN '50802'
|
||||
--all other retail goes to Doran Marable-----------
|
||||
ELSE '50200'
|
||||
END
|
||||
END
|
||||
--minor group b52 goes to dedicated rep
|
||||
CASE SUBSTR(bill_class,2,3)
|
||||
WHEN 'DIS' THEN
|
||||
ship_rep
|
||||
ELSE
|
||||
CASE WHEN MING = 'B52' THEN
|
||||
'PW'
|
||||
--gdir, ndir go to bill-to rep
|
||||
ELSE
|
||||
CASE WHEN BILL_CLASS IN ('GDIR','NDIR') THEN
|
||||
BILL_REP
|
||||
ELSE
|
||||
SHIP_REP
|
||||
bill_rep
|
||||
END
|
||||
END
|
||||
END
|
||||
) QUOTA_REP
|
||||
END QUOTA_REP
|
||||
FROM
|
||||
RLARP.OSMFS_DEV S
|
||||
LEFT OUTER JOIN LGDAT.CUST ON
|
||||
BVCUST = BILL_CUST
|
||||
rlarp.osmfs_dev s
|
||||
LEFT OUTER JOIN lgdat.cust ON
|
||||
bvcust = bill_cust
|
||||
LEFT OUTER JOIN lgpgm.usrcust cu ON
|
||||
cu.cucust = s.bill_cust
|
||||
WHERE
|
||||
COALESCE(GLEC,'') IS NOT NULL
|
||||
version = 'ACTUALS'
|
||||
) CR
|
||||
WHERE
|
||||
CR.VERSION = S.VERSION
|
||||
AND CR.GLEC = COALESCE(S.GLEC,'')
|
||||
AND CR.MING = COALESCE(S.MING,'')
|
||||
AND CR.MING = S.MING
|
||||
AND CR.BILL_CUST = S.BILL_CUST
|
||||
AND CR.SHIP_CUST = S.SHIP_CUST
|
||||
AND COALESCE(S.DSM,'') <> CR.QUOTA_REP;
|
||||
|
||||
|
||||
-------------------set fiscal period--------------------------------------
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfs_dev f
|
||||
SET
|
||||
fspr = gld.fspr
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
N1COMP COMP
|
||||
,N1CCYY FSYRq
|
||||
,KPMAXP PERDS
|
||||
,N1FSPP PERD
|
||||
,to_char(N1FSYP,'FM0000') FSPR
|
||||
,N1SD01 SDAT
|
||||
,N1ED01 EDAT
|
||||
,to_char(N1ED01,'yymm') CAPR
|
||||
,N1ED01 - N1SD01 +1 NDAYS
|
||||
,CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(YEAR FROM N1ED01) + 1 ELSE EXTRACT(YEAR FROM N1ED01) END SSYR
|
||||
,to_char(CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(MONTH FROM N1ED01) -5 ELSE EXTRACT(MONTH FROM N1ED01) +7 END,'00') SSPR
|
||||
FROM
|
||||
LGDAT.GLDATREF
|
||||
INNER JOIN LGDAT.GLDATE ON
|
||||
KPCOMP = N1COMP AND
|
||||
KPCCYY = N1CCYY
|
||||
WHERE
|
||||
N1COMP = 93
|
||||
--AND DIGITS(N1FSYP) = '1901'
|
||||
) gld
|
||||
WHERE
|
||||
f.sdate BETWEEN gld.sdat AND gld.edat
|
||||
AND coalesce(f.fspr,'') <> gld.fspr;
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfS_dev
|
||||
SET
|
||||
r_rate = .7518
|
||||
r_rate = .7900
|
||||
WHERE
|
||||
r_currency = 'CA';
|
||||
|
||||
@ -378,7 +381,7 @@ WHERE
|
||||
UPDATE
|
||||
rlarp.osmfS_dev
|
||||
SET
|
||||
c_rate = .7518
|
||||
c_rate = .7900
|
||||
WHERE
|
||||
c_currency = 'CA';
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
BEGIN;
|
||||
CREATE OR REPLACE PROCEDURE rlarp.convert_pool_all()
|
||||
LANGUAGE plpgsql AS
|
||||
$func$
|
||||
BEGIN
|
||||
|
||||
DELETE FROM rlarp.osmfs_dev;
|
||||
|
||||
@ -111,6 +114,7 @@ SELECT
|
||||
FROM
|
||||
rlarp.osm_pool;
|
||||
|
||||
-------need to set item master values before other things-----------
|
||||
UPDATE
|
||||
RLARP.OSMFS_DEV O
|
||||
SET
|
||||
@ -139,6 +143,7 @@ FROM
|
||||
WHERE
|
||||
M.ITEM = O.PART;
|
||||
|
||||
|
||||
WITH
|
||||
plist AS (
|
||||
SELECT DISTINCT
|
||||
@ -164,8 +169,6 @@ plist AS (
|
||||
ir.y0part = p.part
|
||||
AND ir.y0plnt = p.plnt
|
||||
)
|
||||
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfs_dev o
|
||||
SET
|
||||
@ -359,36 +362,74 @@ WHERE
|
||||
AND COALESCE(S.DSM,'') <> CR.QUOTA_REP;
|
||||
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfS_dev
|
||||
SET
|
||||
r_rate = .7518
|
||||
WHERE
|
||||
r_currency = 'CA';
|
||||
-------------------set fiscal period--------------------------------------
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfS_dev
|
||||
rlarp.osmfs_dev f
|
||||
SET
|
||||
r_rate = 1
|
||||
fspr = gld.fspr
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
N1COMP COMP
|
||||
,N1CCYY FSYRq
|
||||
,KPMAXP PERDS
|
||||
,N1FSPP PERD
|
||||
,to_char(N1FSYP,'FM0000') FSPR
|
||||
,N1SD01 SDAT
|
||||
,N1ED01 EDAT
|
||||
,to_char(N1ED01,'yymm') CAPR
|
||||
,N1ED01 - N1SD01 +1 NDAYS
|
||||
,CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(YEAR FROM N1ED01) + 1 ELSE EXTRACT(YEAR FROM N1ED01) END SSYR
|
||||
,to_char(CASE WHEN EXTRACT(MONTH FROM N1ED01) >= 6 THEN EXTRACT(MONTH FROM N1ED01) -5 ELSE EXTRACT(MONTH FROM N1ED01) +7 END,'00') SSPR
|
||||
FROM
|
||||
LGDAT.GLDATREF
|
||||
INNER JOIN LGDAT.GLDATE ON
|
||||
KPCOMP = N1COMP AND
|
||||
KPCCYY = N1CCYY
|
||||
WHERE
|
||||
N1COMP = 93
|
||||
--AND DIGITS(N1FSYP) = '1901'
|
||||
) gld
|
||||
WHERE
|
||||
r_currency = 'US';
|
||||
f.sdate BETWEEN gld.sdat AND gld.edat
|
||||
AND coalesce(f.fspr,'') <> gld.fspr;
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfS_dev
|
||||
SET
|
||||
c_rate = .7518
|
||||
WHERE
|
||||
c_currency = 'CA';
|
||||
|
||||
UPDATE
|
||||
rlarp.osmfS_dev
|
||||
SET
|
||||
c_rate = 1
|
||||
WHERE
|
||||
c_currency = 'US';
|
||||
--avoid setting fx as that should have been done up front to osmf
|
||||
--UPDATE
|
||||
-- rlarp.osmfS_dev
|
||||
--SET
|
||||
-- r_rate = .7900
|
||||
--WHERE
|
||||
-- r_currency = 'CA';
|
||||
--
|
||||
--UPDATE
|
||||
-- rlarp.osmfS_dev
|
||||
--SET
|
||||
-- r_rate = 1
|
||||
--WHERE
|
||||
-- r_currency = 'US';
|
||||
--
|
||||
--UPDATE
|
||||
-- rlarp.osmfS_dev
|
||||
--SET
|
||||
-- c_rate = .7900
|
||||
--WHERE
|
||||
-- c_currency = 'CA';
|
||||
--
|
||||
--UPDATE
|
||||
-- rlarp.osmfS_dev
|
||||
--SET
|
||||
-- c_rate = 1
|
||||
--WHERE
|
||||
-- c_currency = 'US';
|
||||
|
||||
--DELETE FROM rlarp.osmf_dev WHERE iter IN ('adj price','adj volume');
|
||||
|
||||
--INSERT INTO rlarp.osmf_dev SELECT * FROM rlarp.osmfs_dev;
|
||||
|
||||
COMMIT;
|
||||
END
|
||||
$func$;
|
||||
|
||||
GRANT ALL ON PROCEDURE rlarp.convert_pool_all() TO PUBLIC;
|
||||
|
@ -23,7 +23,8 @@ repc AS (
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1CU','Retail'),
|
||||
('1SU','Sustainable'),
|
||||
('1CU','Sustainable'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
|
8
build/move_sales/list_date.sql
Normal file
8
build/move_sales/list_date.sql
Normal file
@ -0,0 +1,8 @@
|
||||
SELECT
|
||||
ship_cust_descr, order_date, ship_date, sum(value_usd) sales
|
||||
from
|
||||
rlarp.osm_pool
|
||||
where
|
||||
ship_season = 2021
|
||||
group by
|
||||
ship_cust_descr, order_date, ship_date;
|
79
build/move_sales/remove_other.sql
Normal file
79
build/move_sales/remove_other.sql
Normal file
@ -0,0 +1,79 @@
|
||||
BEGIN;
|
||||
with
|
||||
logl AS (
|
||||
INSERT INTO
|
||||
rlarp.osm_log(doc)
|
||||
SELECT
|
||||
jsonb_build_object(
|
||||
'stamp',current_timestamp
|
||||
,'user','Trowbridge, Paul'
|
||||
,'source','script'
|
||||
,'tag','remove other'
|
||||
,'message','remove budget for quota reps rolling into director Other'
|
||||
,'type','remove other'
|
||||
,'version','b21'
|
||||
) doc RETURNING *
|
||||
)
|
||||
,targ as (
|
||||
select
|
||||
p.fspr
|
||||
,p.plnt
|
||||
,p.promo
|
||||
,p.terms
|
||||
,p.bill_cust_descr
|
||||
,p.ship_cust_descr
|
||||
,p.dsm
|
||||
,p.quota_rep_descr
|
||||
,p.director
|
||||
,p.billto_group
|
||||
,p.shipto_group
|
||||
,p.chan
|
||||
,p.chansub
|
||||
,p.chan_retail
|
||||
,p.part
|
||||
,p.part_descr
|
||||
,p.part_group
|
||||
,p.branding
|
||||
,p.majg_descr
|
||||
,p.ming_descr
|
||||
,p.majs_descr
|
||||
,p.mins_descr
|
||||
,p.segm
|
||||
,p.substance
|
||||
,p.fs_line
|
||||
,p.r_currency
|
||||
,p.r_rate
|
||||
,p.c_currency
|
||||
,p.c_rate
|
||||
,-p.units units
|
||||
,-p.value_loc value_loc
|
||||
,-p.value_usd value_usd
|
||||
,-p.cost_loc cost_loc
|
||||
,-p.cost_usd cost_usd
|
||||
,p.calc_status
|
||||
,p.flag
|
||||
,p.order_date
|
||||
,p.order_month
|
||||
,p.order_season
|
||||
,p.request_date
|
||||
,p.request_month
|
||||
,p.request_season
|
||||
,p.ship_date
|
||||
,p.ship_month
|
||||
,p.ship_season
|
||||
,'b21' AS version
|
||||
,'adj volume' iter
|
||||
,logl.id logid
|
||||
,logl.doc->>'tag' tag
|
||||
,logl.doc->>'message' "comment"
|
||||
,logl.doc->>'type' module
|
||||
from
|
||||
rlarp.osm_pool p
|
||||
CROSS JOIN logl
|
||||
where
|
||||
director = 'Other'
|
||||
and (order_season >= 2021 or ship_season >= 2021)
|
||||
)
|
||||
INSERT INTO rlarp.osm_pool SELECT * FROM targ;
|
||||
|
||||
COMMIT;
|
357
build/move_sales/sales_months.sql
Normal file
357
build/move_sales/sales_months.sql
Normal file
@ -0,0 +1,357 @@
|
||||
BEGIN;
|
||||
|
||||
WITH
|
||||
move AS (
|
||||
SELECT * FROM (VALUES
|
||||
('HOME0004 - ALLIANCE INTERNATIONAL LLC',CAST('10/7/2019' AS DATE),CAST('6/1/2020' AS DATE),11322.85,CAST('7/2/2020' AS DATE)),
|
||||
('CORS0004 - CORSOS PERENNIALS',CAST('10/23/2019' AS DATE),CAST('6/1/2020' AS DATE),30916.44,CAST('7/2/2020' AS DATE)),
|
||||
('MONR0007 - MONROVIA - VISALIA CA',CAST('2/3/2020' AS DATE),CAST('6/1/2020' AS DATE),8409.6,CAST('7/2/2020' AS DATE)),
|
||||
('BATT0001 - BATTLEFIELD FARMS',CAST('2/5/2020' AS DATE),CAST('6/1/2020' AS DATE),2285,CAST('7/2/2020' AS DATE)),
|
||||
('BABI0001 - BABIKOW GREENHOUSES',CAST('2/7/2020' AS DATE),CAST('6/1/2020' AS DATE),9640.8,CAST('7/2/2020' AS DATE)),
|
||||
('KALA0002 - KALAMAZOO FLOWER GROUP LLC',CAST('2/10/2020' AS DATE),CAST('6/1/2020' AS DATE),1005.4,CAST('7/2/2020' AS DATE)),
|
||||
('HATR0001 - H.A. TREICHLER SONS',CAST('2/11/2020' AS DATE),CAST('6/1/2020' AS DATE),13425.44,CAST('7/2/2020' AS DATE)),
|
||||
('KALA0002 - KALAMAZOO FLOWER GROUP LLC',CAST('3/13/2020' AS DATE),CAST('6/1/2020' AS DATE),2464,CAST('7/2/2020' AS DATE)),
|
||||
('METR0002 - METROLINA GREENHOUSES',CAST('3/17/2020' AS DATE),CAST('6/1/2020' AS DATE),17619.12,CAST('7/2/2020' AS DATE)),
|
||||
('JOHN0020 - JOHN BARONEDBA BARONE FARM',CAST('3/23/2020' AS DATE),CAST('6/1/2020' AS DATE),5571.85,CAST('7/2/2020' AS DATE)),
|
||||
('JENS0002 - JENSEN DISTRIBUTION SERVICES',CAST('3/24/2020' AS DATE),CAST('6/1/2020' AS DATE),487.15,CAST('7/2/2020' AS DATE)),
|
||||
('DIST0007 - TERIS SERVICES-PICK UP ONLY U',CAST('3/31/2020' AS DATE),CAST('6/1/2020' AS DATE),5318.78,CAST('7/2/2020' AS DATE)),
|
||||
('DIST0007 - TERIS SERVICES-PICK UP ONLY U',CAST('4/7/2020' AS DATE),CAST('6/1/2020' AS DATE),400.28,CAST('7/2/2020' AS DATE)),
|
||||
('BELA0001 - BELA FLOR NURSERIES',CAST('4/15/2020' AS DATE),CAST('6/1/2020' AS DATE),1219.71,CAST('7/2/2020' AS DATE)),
|
||||
('JENS0002 - JENSEN DISTRIBUTION SERVICES',CAST('4/15/2020' AS DATE),CAST('6/1/2020' AS DATE),395.01,CAST('7/2/2020' AS DATE)),
|
||||
('LLNU0003 - LL NURSERY SUPPLY INC WA',CAST('4/16/2020' AS DATE),CAST('6/1/2020' AS DATE),656.7,CAST('7/2/2020' AS DATE)),
|
||||
('INTE0003 - GREENHOUSE MEGASTORE',CAST('4/23/2020' AS DATE),CAST('6/1/2020' AS DATE),283.06,CAST('7/2/2020' AS DATE)),
|
||||
('CALC0004 - CAL COLOR GROWERS LLC',CAST('4/28/2020' AS DATE),CAST('6/1/2020' AS DATE),8273.25,CAST('7/2/2020' AS DATE)),
|
||||
('BATT0001 - BATTLEFIELD FARMS',CAST('5/1/2020' AS DATE),CAST('6/1/2020' AS DATE),18919.26,CAST('7/2/2020' AS DATE)),
|
||||
('LOWE3110 - LOWES OF MILTON CANADA # 3110',CAST('5/4/2020' AS DATE),CAST('6/1/2020' AS DATE),8901.3,CAST('7/2/2020' AS DATE)),
|
||||
('SILV0007 - SILVERLEAF GHSE',CAST('5/6/2020' AS DATE),CAST('6/1/2020' AS DATE),19368.3,CAST('7/2/2020' AS DATE)),
|
||||
('HOME0004 - ALLIANCE INTERNATIONAL LLC',CAST('5/11/2020' AS DATE),CAST('6/1/2020' AS DATE),6312.37,CAST('7/2/2020' AS DATE)),
|
||||
('SHAD0009 - SHADY CREEK GREENHOUSES',CAST('5/12/2020' AS DATE),CAST('6/1/2020' AS DATE),1395.9,CAST('7/2/2020' AS DATE)),
|
||||
('ISLA0008 - ISLAND GROWER SUPPLIES LLC',CAST('5/13/2020' AS DATE),CAST('6/1/2020' AS DATE),2160,CAST('7/2/2020' AS DATE)),
|
||||
('LYSH0001 - LYS HYDRO GARDEN FRESNO',CAST('5/13/2020' AS DATE),CAST('6/1/2020' AS DATE),5383.08,CAST('7/2/2020' AS DATE)),
|
||||
('LLNU0003 - LL NURSERY SUPPLY INC WA',CAST('5/13/2020' AS DATE),CAST('6/1/2020' AS DATE),667.89,CAST('7/2/2020' AS DATE)),
|
||||
('STAN0009 - STANDEX ELECTRONICS',CAST('5/15/2020' AS DATE),CAST('6/1/2020' AS DATE),47.25,CAST('7/2/2020' AS DATE)),
|
||||
('BRAD0020 - BRADFORD CO-OP STORAGE LTD (U)',CAST('5/15/2020' AS DATE),CAST('6/1/2020' AS DATE),460.8,CAST('7/2/2020' AS DATE)),
|
||||
('CANA0034 - CANADIAN TIRE RETAIL DC 9004',CAST('5/16/2020' AS DATE),CAST('6/1/2020' AS DATE),4908.09,CAST('7/2/2020' AS DATE)),
|
||||
('AJBI0001 - AJ BILLES DC CANADIAN TIRE',CAST('5/16/2020' AS DATE),CAST('6/1/2020' AS DATE),29620.77,CAST('7/2/2020' AS DATE)),
|
||||
('LOWE3110 - LOWES OF MILTON CANADA # 3110',CAST('5/18/2020' AS DATE),CAST('6/1/2020' AS DATE),1595.47,CAST('7/2/2020' AS DATE)),
|
||||
('BATT0001 - BATTLEFIELD FARMS',CAST('5/19/2020' AS DATE),CAST('6/1/2020' AS DATE),2088,CAST('7/2/2020' AS DATE)),
|
||||
('HYDR0010 - HYDROFARM INC',CAST('5/20/2020' AS DATE),CAST('6/1/2020' AS DATE),22368.8,CAST('7/2/2020' AS DATE)),
|
||||
('WILD0012 - WILDWOODS-PACIFIC NURSERY POTS',CAST('5/20/2020' AS DATE),CAST('6/1/2020' AS DATE),4180,CAST('7/2/2020' AS DATE)),
|
||||
('GULF0002 - SUNBLEST GARDENS',CAST('5/20/2020' AS DATE),CAST('6/1/2020' AS DATE),21501.89,CAST('7/2/2020' AS DATE)),
|
||||
('LOUI0001 - LOUIS DAVINO SR LLC',CAST('5/20/2020' AS DATE),CAST('6/1/2020' AS DATE),38150.76,CAST('7/2/2020' AS DATE)),
|
||||
('DIST0007 - TERIS SERVICES-PICK UP ONLY U',CAST('5/21/2020' AS DATE),CAST('6/1/2020' AS DATE),3626.73,CAST('7/2/2020' AS DATE)),
|
||||
('FRED0038 - FRED MEYER STORES',CAST('5/21/2020' AS DATE),CAST('6/1/2020' AS DATE),38706.76,CAST('7/2/2020' AS DATE)),
|
||||
('LLNU0003 - LL NURSERY SUPPLY INC WA',CAST('5/21/2020' AS DATE),CAST('6/1/2020' AS DATE),3205.89,CAST('7/2/2020' AS DATE)),
|
||||
('DOIT0008 - DO IT BEST CORP',CAST('5/21/2020' AS DATE),CAST('6/1/2020' AS DATE),551.34,CAST('7/2/2020' AS DATE)),
|
||||
('BATT0001 - BATTLEFIELD FARMS',CAST('5/21/2020' AS DATE),CAST('6/1/2020' AS DATE),25150,CAST('7/2/2020' AS DATE)),
|
||||
('AJBI0001 - AJ BILLES DC CANADIAN TIRE',CAST('5/23/2020' AS DATE),CAST('6/1/2020' AS DATE),339.94,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0033 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),998.94,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0134 - AMAZON LGB6',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),1058.85,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0115 - AMAZON.COM LGB4 LLC',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),743.79,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0093 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),3087.16,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0055 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),772.44,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0008 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),1735.38,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0123 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),720.9,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0156 - AMAZON - MEM1',CAST('5/25/2020' AS DATE),CAST('6/1/2020' AS DATE),750.12,CAST('7/2/2020' AS DATE)),
|
||||
('FRED0038 - FRED MEYER STORES',CAST('5/26/2020' AS DATE),CAST('6/1/2020' AS DATE),4972.75,CAST('7/2/2020' AS DATE)),
|
||||
('INTE0003 - GREENHOUSE MEGASTORE',CAST('5/26/2020' AS DATE),CAST('6/1/2020' AS DATE),16602.93,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0156 - AMAZON - MEM1',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),14.46,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0159 - AMAZON - SCK1',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0045 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('STON0028 - STONINGTON GARDENS',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),1370.99,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0083 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),130.14,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0073 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0012 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),28.92,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0127 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0093 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),14.46,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0043 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0140 - AMAZON - CLT3',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0114 - AMAZON.COM SERVICES,INC.',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),81.81,CAST('7/2/2020' AS DATE)),
|
||||
('COPP0002 - COPPERSTATE FARMS MGMT LLC',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),16156.8,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0148 - AMAZON - IND9 9912622',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),14.46,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0144 - AMAZON - CMH3',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),27.27,CAST('7/2/2020' AS DATE)),
|
||||
('INTE0003 - GREENHOUSE MEGASTORE',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),16810.8,CAST('7/2/2020' AS DATE)),
|
||||
('DCME0009 - 9 DIS ASM DC 7103 MERCH WM',CAST('5/27/2020' AS DATE),CAST('6/1/2020' AS DATE),26970.81,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0019 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0155 - AMAZON - XIX7',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0107 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),65.4,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0099 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0108 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('7/2/2020' AS DATE)),
|
||||
('AMAZ0090 - AMAZON.COM FULFILLMENT CTRCHH2',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('7/2/2020' AS DATE)),
|
||||
('GOLD0038 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('7/2/2020' AS DATE)),
|
||||
('GASK0001 - GASKO GREENHOUSES',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),39166.05,CAST('7/2/2020' AS DATE)),
|
||||
('EAGL0001 - EAGLE CREEK WHOLESALE',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),489.5,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0123 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0127 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0029 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('DIST0007 - TERIS SERVICES-PICK UP ONLY U',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),19122.39,CAST('8/2/2020' AS DATE)),
|
||||
('BEAU0002 - BEAUTIFUL LAND PRODUCTS',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),282.85,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0068 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0045 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0121 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0058 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0051 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('DEWA0001 - DEWAR NURSERIES',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),24181.3,CAST('8/2/2020' AS DATE)),
|
||||
('AMAZ0091 - AMAZON.COM SERVICES,INC.',CAST('5/28/2020' AS DATE),CAST('6/1/2020' AS DATE),46.32,CAST('8/2/2020' AS DATE)),
|
||||
('LUPI0001 - LUPINE LADY PORCUPINE GNHSE',CAST('5/29/2020' AS DATE),CAST('6/1/2020' AS DATE),112.42,CAST('8/2/2020' AS DATE)),
|
||||
('YODE0010 - YODERS PRODUCE INC',CAST('5/29/2020' AS DATE),CAST('6/1/2020' AS DATE),228.75,CAST('8/2/2020' AS DATE)),
|
||||
('JACK0020 - JACKSON COUNTY ARC INC',CAST('5/29/2020' AS DATE),CAST('6/1/2020' AS DATE),63.2,CAST('8/2/2020' AS DATE)),
|
||||
('RAND0011 - RANDY WESTRATE GREENHOUSE',CAST('5/29/2020' AS DATE),CAST('6/1/2020' AS DATE),420.75,CAST('8/2/2020' AS DATE)),
|
||||
('JOSE0006 - JOSE OCHOA',CAST('5/29/2020' AS DATE),CAST('6/1/2020' AS DATE),520.86,CAST('8/2/2020' AS DATE)),
|
||||
('WERA0001 - WE RADTKE INC',CAST('5/30/2020' AS DATE),CAST('6/1/2020' AS DATE),1747.05,CAST('8/2/2020' AS DATE)),
|
||||
('ERNS0003 - ERNST NURSERY',CAST('9/9/2019' AS DATE),CAST('6/2/2020' AS DATE),23493.6,CAST('8/2/2020' AS DATE)),
|
||||
('SANM0002 - SAN MARCOS-AMER HORT SUPPLY',CAST('10/7/2019' AS DATE),CAST('6/2/2020' AS DATE),23118.67,CAST('8/2/2020' AS DATE)),
|
||||
('CORS0004 - CORSOS PERENNIALS',CAST('10/23/2019' AS DATE),CAST('6/2/2020' AS DATE),18034.59,CAST('8/2/2020' AS DATE)),
|
||||
('ALTM0034 - ALTMAN PLANTS - SALINAS',CAST('11/15/2019' AS DATE),CAST('6/2/2020' AS DATE),6092.7,CAST('8/2/2020' AS DATE)),
|
||||
('ALTM0021 - ALTMANS SPECIALTY PLANTS PERRI',CAST('11/15/2019' AS DATE),CAST('6/2/2020' AS DATE),36831.64,CAST('8/2/2020' AS DATE)),
|
||||
('WILL0064 - WILLOWBROOK NURSERIES INC',CAST('11/25/2019' AS DATE),CAST('6/2/2020' AS DATE),3474,CAST('8/2/2020' AS DATE)),
|
||||
('CAVI0001 - CAVICCHIO GREENHOUSES INC',CAST('12/10/2019' AS DATE),CAST('6/2/2020' AS DATE),12716.82,CAST('8/2/2020' AS DATE)),
|
||||
('ENVI0008 - EVL NURSERY',CAST('12/16/2019' AS DATE),CAST('6/2/2020' AS DATE),3551.31,CAST('8/2/2020' AS DATE)),
|
||||
('MONR0018 - MONROVIA - DAYTON OR',CAST('1/6/2020' AS DATE),CAST('6/2/2020' AS DATE),29433.6,CAST('8/2/2020' AS DATE)),
|
||||
('WALD0003 - WALDO ASSOCIATES',CAST('1/30/2020' AS DATE),CAST('6/2/2020' AS DATE),924.93,CAST('8/2/2020' AS DATE)),
|
||||
('METR0002 - METROLINA GREENHOUSES',CAST('2/11/2020' AS DATE),CAST('6/2/2020' AS DATE),13200,CAST('8/2/2020' AS DATE)),
|
||||
('HEAR0011 - HEARTLAND-SUN WAREHOUSE24HR N',CAST('2/28/2020' AS DATE),CAST('6/2/2020' AS DATE),4442.04,CAST('8/2/2020' AS DATE)),
|
||||
('FORE0005 - FOREST GLEN GREENHOUSES (C)',CAST('3/4/2020' AS DATE),CAST('6/2/2020' AS DATE),1747.44,CAST('8/2/2020' AS DATE)),
|
||||
('VPNU0002 - VP NURSERY',CAST('3/6/2020' AS DATE),CAST('6/2/2020' AS DATE),19356.48,CAST('8/2/2020' AS DATE)),
|
||||
('ACOS0002 - ACOSTA FARMS NURSERY INC',CAST('3/9/2020' AS DATE),CAST('6/2/2020' AS DATE),4391.78,CAST('8/2/2020' AS DATE)),
|
||||
('ACOS0002 - ACOSTA FARMS NURSERY INC',CAST('3/10/2020' AS DATE),CAST('6/2/2020' AS DATE),8700,CAST('8/2/2020' AS DATE)),
|
||||
('PLEA0026 - PLEASANT VALLEY FARM INC',CAST('3/11/2020' AS DATE),CAST('6/2/2020' AS DATE),731.2,CAST('8/2/2020' AS DATE)),
|
||||
('ROCK0026 - ROCKWELL FARMS',CAST('3/16/2020' AS DATE),CAST('6/2/2020' AS DATE),15949.44,CAST('8/2/2020' AS DATE)),
|
||||
('CLEA0015 - CLEARVIEW GREENHOUSES',CAST('3/16/2020' AS DATE),CAST('6/2/2020' AS DATE),6698.45,CAST('8/2/2020' AS DATE)),
|
||||
('OLDN0001 - OLD NORTH GROWERS',CAST('3/16/2020' AS DATE),CAST('6/2/2020' AS DATE),7484.51,CAST('8/2/2020' AS DATE)),
|
||||
('METR0002 - METROLINA GREENHOUSES',CAST('3/17/2020' AS DATE),CAST('6/2/2020' AS DATE),6767.1,CAST('8/2/2020' AS DATE)),
|
||||
('BAMA0001 - BAMA GREEN',CAST('3/17/2020' AS DATE),CAST('6/2/2020' AS DATE),13264.85,CAST('8/2/2020' AS DATE)),
|
||||
('WALD0003 - WALDO ASSOCIATES',CAST('3/18/2020' AS DATE),CAST('6/2/2020' AS DATE),1234.9,CAST('8/2/2020' AS DATE)),
|
||||
('TREE0044 - TREESAP FARMS-FOREST GROVE OR',CAST('3/24/2020' AS DATE),CAST('6/2/2020' AS DATE),3047.22,CAST('8/2/2020' AS DATE)),
|
||||
('HEAR0011 - HEARTLAND-SUN WAREHOUSE24HR N',CAST('3/24/2020' AS DATE),CAST('6/2/2020' AS DATE),271,CAST('8/2/2020' AS DATE)),
|
||||
('YOUN0005 - YOUNGS PLANT FARM INC - FARM 2',CAST('3/25/2020' AS DATE),CAST('6/2/2020' AS DATE),44807.6,CAST('8/2/2020' AS DATE)),
|
||||
('YOUN0004 - YOUNGS PLANT FARM INC - FARM 1',CAST('3/25/2020' AS DATE),CAST('6/2/2020' AS DATE),27216.51,CAST('8/2/2020' AS DATE)),
|
||||
('DIXI0001 - DIXIE GREEN INC.',CAST('3/26/2020' AS DATE),CAST('6/2/2020' AS DATE),8568,CAST('8/2/2020' AS DATE)),
|
||||
('WILL0028 - WILLIAMS PLANT FARM',CAST('3/31/2020' AS DATE),CAST('6/2/2020' AS DATE),2812.5,CAST('8/2/2020' AS DATE)),
|
||||
('PLEA0026 - PLEASANT VALLEY FARM INC',CAST('4/2/2020' AS DATE),CAST('6/2/2020' AS DATE),468.18,CAST('8/2/2020' AS DATE)),
|
||||
('SPAR0001 - SPARETIME SUPPLY',CAST('4/2/2020' AS DATE),CAST('6/2/2020' AS DATE),17690.4,CAST('8/2/2020' AS DATE)),
|
||||
('HYDR0010 - HYDROFARM INC',CAST('4/3/2020' AS DATE),CAST('6/2/2020' AS DATE),19445.93,CAST('8/2/2020' AS DATE)),
|
||||
('CARL0001 - CARL BREHOB SON',CAST('4/10/2020' AS DATE),CAST('6/2/2020' AS DATE),450.6,CAST('8/2/2020' AS DATE)),
|
||||
('ALPH0003 - ALPHA FOLIAGE',CAST('4/13/2020' AS DATE),CAST('6/2/2020' AS DATE),16207.16,CAST('8/2/2020' AS DATE)),
|
||||
('FISH0009 - FISHER NURSERY INC - CA',CAST('4/13/2020' AS DATE),CAST('6/2/2020' AS DATE),2211.86,CAST('8/2/2020' AS DATE)),
|
||||
('WALD0003 - WALDO ASSOCIATES',CAST('4/14/2020' AS DATE),CAST('6/2/2020' AS DATE),2769.33,CAST('8/2/2020' AS DATE)),
|
||||
('ROCK0026 - ROCKWELL FARMS',CAST('4/15/2020' AS DATE),CAST('6/2/2020' AS DATE),5061.84,CAST('8/2/2020' AS DATE)),
|
||||
('SCOT0019 - SCOTTS NURSERY LTD (C)',CAST('4/17/2020' AS DATE),CAST('6/2/2020' AS DATE),18909.45,CAST('8/2/2020' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('4/17/2020' AS DATE),CAST('6/2/2020' AS DATE),172.4,CAST('8/2/2020' AS DATE)),
|
||||
('WALD0003 - WALDO ASSOCIATES',CAST('4/22/2020' AS DATE),CAST('6/2/2020' AS DATE),607.81,CAST('8/2/2020' AS DATE)),
|
||||
('KMNU0003 - KM NURSERY',CAST('4/22/2020' AS DATE),CAST('6/2/2020' AS DATE),30531.6,CAST('8/2/2020' AS DATE)),
|
||||
('SPAR0001 - SPARETIME SUPPLY',CAST('4/27/2020' AS DATE),CAST('6/2/2020' AS DATE),6633.9,CAST('2/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('4/28/2020' AS DATE),CAST('6/2/2020' AS DATE),8518.61,CAST('2/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('4/29/2020' AS DATE),CAST('6/2/2020' AS DATE),926.2,CAST('2/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('4/30/2020' AS DATE),CAST('6/2/2020' AS DATE),6024.27,CAST('2/2/2021' AS DATE)),
|
||||
('AJBI0001 - AJ BILLES DC CANADIAN TIRE',CAST('5/2/2020' AS DATE),CAST('6/2/2020' AS DATE),752.43,CAST('2/2/2021' AS DATE)),
|
||||
('CARL0001 - CARL BREHOB SON',CAST('5/6/2020' AS DATE),CAST('6/2/2020' AS DATE),627.25,CAST('2/2/2021' AS DATE)),
|
||||
('ENVI0008 - EVL NURSERY',CAST('5/6/2020' AS DATE),CAST('6/2/2020' AS DATE),1587.84,CAST('2/2/2021' AS DATE)),
|
||||
('WALD0003 - WALDO ASSOCIATES',CAST('5/7/2020' AS DATE),CAST('6/2/2020' AS DATE),1734.3,CAST('2/2/2021' AS DATE)),
|
||||
('LOWE3110 - LOWES OF MILTON CANADA # 3110',CAST('5/11/2020' AS DATE),CAST('6/2/2020' AS DATE),3066.42,CAST('2/2/2021' AS DATE)),
|
||||
('BUCK0006 - BUCKHORN NURSERY',CAST('5/11/2020' AS DATE),CAST('6/2/2020' AS DATE),1804,CAST('2/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('5/12/2020' AS DATE),CAST('6/2/2020' AS DATE),73.8,CAST('2/2/2021' AS DATE)),
|
||||
('WALD0003 - WALDO ASSOCIATES',CAST('5/13/2020' AS DATE),CAST('6/2/2020' AS DATE),5142.12,CAST('2/2/2021' AS DATE)),
|
||||
('WHIT0003 - WHITES NURSERY',CAST('5/14/2020' AS DATE),CAST('6/2/2020' AS DATE),1859.68,CAST('2/2/2021' AS DATE)),
|
||||
('MENA3339 - MENARDS INC',CAST('5/18/2020' AS DATE),CAST('6/2/2020' AS DATE),1974.54,CAST('2/2/2021' AS DATE)),
|
||||
('WEST0646 - NUTRIEN AG SOL. - WATSONVILLE',CAST('5/18/2020' AS DATE),CAST('6/2/2020' AS DATE),9660.19,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5089 - THE HOME DEPOT #5089 PICK UP',CAST('5/19/2020' AS DATE),CAST('6/2/2020' AS DATE),4166.76,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5642 - THE HOME DEPOT #5642 PICK UP',CAST('5/19/2020' AS DATE),CAST('6/2/2020' AS DATE),7687.15,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5030 - THE HOME DEPOT #5030 PICK UP',CAST('5/19/2020' AS DATE),CAST('6/2/2020' AS DATE),4395.64,CAST('2/2/2021' AS DATE)),
|
||||
('HYDR0010 - HYDROFARM INC',CAST('5/20/2020' AS DATE),CAST('6/2/2020' AS DATE),12492.62,CAST('2/2/2021' AS DATE)),
|
||||
('CARL0001 - CARL BREHOB SON',CAST('5/20/2020' AS DATE),CAST('6/2/2020' AS DATE),1747.28,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5034 - THE HOME DEPOT #5034 PICK UP',CAST('5/21/2020' AS DATE),CAST('6/2/2020' AS DATE),18292.72,CAST('2/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('5/21/2020' AS DATE),CAST('6/2/2020' AS DATE),1104.45,CAST('2/2/2021' AS DATE)),
|
||||
('WOOD0001 - WOODBURN NURSERY',CAST('5/21/2020' AS DATE),CAST('6/2/2020' AS DATE),6138,CAST('2/2/2021' AS DATE)),
|
||||
('ROBE0014 - ROBERTAS YOUNG PLANTS',CAST('5/21/2020' AS DATE),CAST('6/2/2020' AS DATE),9819.29,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5084 - THE HOME DEPOT #5084 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),6897.97,CAST('2/2/2021' AS DATE)),
|
||||
('CASS0002 - CASSCO',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),20617.7,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5085 - THE HOME DEPOT #5085 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),17337.57,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5089 - THE HOME DEPOT #5089 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),9208.18,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5643 - THE HOME DEPOT #5643 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),963.84,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5642 - THE HOME DEPOT #5642 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),576.04,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5520 - THE HOME DEPOT #5520 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),7713.04,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5030 - THE HOME DEPOT #5030 PICK UP',CAST('5/22/2020' AS DATE),CAST('6/2/2020' AS DATE),5072.52,CAST('2/2/2021' AS DATE)),
|
||||
('AMAZ0058 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/2/2020' AS DATE),578.27,CAST('2/2/2021' AS DATE)),
|
||||
('LOWE3110 - LOWES OF MILTON CANADA # 3110',CAST('5/25/2020' AS DATE),CAST('6/2/2020' AS DATE),1637.71,CAST('2/2/2021' AS DATE)),
|
||||
('AMAZ0006 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/2/2020' AS DATE),2438.8,CAST('2/2/2021' AS DATE)),
|
||||
('AMAZ0085 - AMAZON.COM SERVICES,INC.',CAST('5/25/2020' AS DATE),CAST('6/2/2020' AS DATE),2800.81,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5851 - THE HOME DEPOT #5851 PICK UP',CAST('5/26/2020' AS DATE),CAST('6/2/2020' AS DATE),19600.94,CAST('2/2/2021' AS DATE)),
|
||||
('HOMU5520 - THE HOME DEPOT #5520 PICK UP',CAST('5/26/2020' AS DATE),CAST('6/2/2020' AS DATE),10885.09,CAST('5/2/2021' AS DATE)),
|
||||
('HOMU5084 - THE HOME DEPOT #5084 PICK UP',CAST('5/26/2020' AS DATE),CAST('6/2/2020' AS DATE),3289.09,CAST('4/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('5/26/2020' AS DATE),CAST('6/2/2020' AS DATE),1422.36,CAST('4/2/2021' AS DATE)),
|
||||
('BRAN0014 - BRANTLEY NURSERIES-BUSHNELL',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),9762.48,CAST('5/2/2021' AS DATE)),
|
||||
('BWIC000G - BWI - SPRINGFIELD MO',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),12315.24,CAST('3/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),408,CAST('3/2/2021' AS DATE)),
|
||||
('DIST0004 - TERIS SVSC DAPPROVISIONNEMNTC',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),1942.22,CAST('3/2/2021' AS DATE)),
|
||||
('WALM602A - WALMART DC 6002A-ASM DIS',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),30551,CAST('3/2/2021' AS DATE)),
|
||||
('CASS0002 - CASSCO',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),6635.15,CAST('3/2/2021' AS DATE)),
|
||||
('HOMU5087 - THE HOME DEPOT #5087 PICK UP',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),12138.15,CAST('3/2/2021' AS DATE)),
|
||||
('TJSG0001 - TJS GREENHOUSE LANDSCAPE',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),1085.19,CAST('3/2/2021' AS DATE)),
|
||||
('HOMU5642 - THE HOME DEPOT #5642 PICK UP',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),4149.17,CAST('3/2/2021' AS DATE)),
|
||||
('SCMD0001 - SCM DC 6063A-ASM DIS WM PICKUP',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),18407.75,CAST('3/2/2021' AS DATE)),
|
||||
('HOMU5639 - THE HOME DEPOT #5639 PICK UP',CAST('5/27/2020' AS DATE),CAST('6/2/2020' AS DATE),4594.91,CAST('3/2/2021' AS DATE)),
|
||||
('GRIF0001 - GRIFFIN GREENHOUSE - TEWKSBURY',CAST('5/28/2020' AS DATE),CAST('6/2/2020' AS DATE),660.9,CAST('3/2/2021' AS DATE)),
|
||||
('CWKI0001 - CW KITCHENS INC',CAST('5/28/2020' AS DATE),CAST('6/2/2020' AS DATE),780.23,CAST('3/2/2021' AS DATE)),
|
||||
('LLNU0001 - LL NURSERY SUPPLY INC CA',CAST('5/28/2020' AS DATE),CAST('6/2/2020' AS DATE),40536.37,CAST('3/2/2021' AS DATE)),
|
||||
('ROSE0026 - ROSEVILLE FARMS',CAST('5/29/2020' AS DATE),CAST('6/2/2020' AS DATE),10254.6,CAST('3/2/2021' AS DATE)),
|
||||
('PLEA0026 - PLEASANT VALLEY FARM INC',CAST('5/29/2020' AS DATE),CAST('6/2/2020' AS DATE),12979.2,CAST('3/2/2021' AS DATE)),
|
||||
('BRAD0020 - BRADFORD CO-OP STORAGE LTD (U)',CAST('5/29/2020' AS DATE),CAST('6/2/2020' AS DATE),5908.07,CAST('3/2/2021' AS DATE)),
|
||||
('GLOB0004 - GLOBAL HORTICULTURAL INC (C)',CAST('5/31/2019' AS DATE),CAST('6/3/2020' AS DATE),4159.13,CAST('3/2/2021' AS DATE)),
|
||||
('GREE0092 - GREENSCAPE',CAST('8/13/2019' AS DATE),CAST('6/3/2020' AS DATE),565.45,CAST('3/2/2021' AS DATE)),
|
||||
('QUAL0021 - QUALITY GHSE SITE 2',CAST('8/15/2019' AS DATE),CAST('6/3/2020' AS DATE),28746.9,CAST('3/2/2021' AS DATE)),
|
||||
('MARK0020 - MARKET BASKET OF ST PETERS #6',CAST('9/5/2019' AS DATE),CAST('6/3/2020' AS DATE),89.16,CAST('3/2/2021' AS DATE)),
|
||||
('TWIN0007 - TWIN OAKS GROWERS',CAST('9/9/2019' AS DATE),CAST('6/3/2020' AS DATE),2310,CAST('3/2/2021' AS DATE)),
|
||||
('UCGM0001 - UGC - MARKET BASKET',CAST('9/17/2019' AS DATE),CAST('6/3/2020' AS DATE),133.77,CAST('3/2/2021' AS DATE)),
|
||||
('DREA0005 - DREAMS WITH COLORS INC',CAST('10/3/2019' AS DATE),CAST('6/3/2020' AS DATE),11549.2,CAST('4/2/2021' AS DATE)),
|
||||
('RSGR0004 - RS GROWERS SUPPLY INC',CAST('10/14/2019' AS DATE),CAST('6/3/2020' AS DATE),4339.84,CAST('4/2/2021' AS DATE)),
|
||||
('WEAV0003 - WEAVERLAND VALLEY GREENHOUSE',CAST('10/18/2019' AS DATE),CAST('6/3/2020' AS DATE),1039.92,CAST('4/2/2021' AS DATE)),
|
||||
('FOST0001 - FOSTERS INC RETAIL',CAST('10/22/2019' AS DATE),CAST('6/3/2020' AS DATE),1162.1,CAST('4/2/2021' AS DATE)),
|
||||
('WETS0003 - BFG SUPPLY - HARRISONBURG(W13)',CAST('10/22/2019' AS DATE),CAST('6/3/2020' AS DATE),1788.07,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0011 - BFG SUPPLY - ST PAUL',CAST('10/22/2019' AS DATE),CAST('6/3/2020' AS DATE),1448.7,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0004 - BFG SUPPLY - GRAND RAPIDS(W04)',CAST('10/22/2019' AS DATE),CAST('6/3/2020' AS DATE),973.07,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0015 - BFG SUPPLY - CHESWICK (W08)',CAST('10/23/2019' AS DATE),CAST('6/3/2020' AS DATE),2197.89,CAST('4/2/2021' AS DATE)),
|
||||
('FOST0001 - FOSTERS INC RETAIL',CAST('10/25/2019' AS DATE),CAST('6/3/2020' AS DATE),1575.99,CAST('4/2/2021' AS DATE)),
|
||||
('ARTK0002 - ART KNAPP - HESTIA PRODUCTIONS',CAST('10/28/2019' AS DATE),CAST('6/3/2020' AS DATE),610.56,CAST('4/2/2021' AS DATE)),
|
||||
('EARL0012 - EARL MAY SEED NURSERY',CAST('10/28/2019' AS DATE),CAST('6/3/2020' AS DATE),174.23,CAST('4/2/2021' AS DATE)),
|
||||
('DEGR0004 - DEGROOTS NURSERIES',CAST('10/31/2019' AS DATE),CAST('6/3/2020' AS DATE),205.12,CAST('4/2/2021' AS DATE)),
|
||||
('PLAN0009 - PLANTERS SEED SPICE RET',CAST('11/1/2019' AS DATE),CAST('6/3/2020' AS DATE),234.61,CAST('4/2/2021' AS DATE)),
|
||||
('CYGR0003 - CY GROWERS SUPPLIES LTD U',CAST('11/4/2019' AS DATE),CAST('6/3/2020' AS DATE),1566,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0004 - BFG SUPPLY - GRAND RAPIDS(W04)',CAST('11/4/2019' AS DATE),CAST('6/3/2020' AS DATE),187.77,CAST('4/2/2021' AS DATE)),
|
||||
('CISC0001 - CISCO COMPANIES (THE)',CAST('11/11/2019' AS DATE),CAST('6/3/2020' AS DATE),533.92,CAST('4/2/2021' AS DATE)),
|
||||
('BERG0012 - BERGENS GREENHOUSE',CAST('11/12/2019' AS DATE),CAST('6/3/2020' AS DATE),84.46,CAST('4/2/2021' AS DATE)),
|
||||
('BERG0029 - BERGEN NURSERY',CAST('11/12/2019' AS DATE),CAST('6/3/2020' AS DATE),759.73,CAST('4/2/2021' AS DATE)),
|
||||
('GREE0223 - EDDIS WHOLESALE GDN SUPPLIES',CAST('11/13/2019' AS DATE),CAST('6/3/2020' AS DATE),87.58,CAST('4/2/2021' AS DATE)),
|
||||
('KOLL0002 - KOLLMANS GREENHOUSE',CAST('11/15/2019' AS DATE),CAST('6/3/2020' AS DATE),174.67,CAST('4/2/2021' AS DATE)),
|
||||
('ALTM0032 - ALTMAN PLANTS - TROUP',CAST('11/15/2019' AS DATE),CAST('6/3/2020' AS DATE),933,CAST('4/2/2021' AS DATE)),
|
||||
('MISC0001 - MISC ACCT - (US )',CAST('11/18/2019' AS DATE),CAST('6/3/2020' AS DATE),0,CAST('4/2/2021' AS DATE)),
|
||||
('DOIT0030 - DIB-ROLLIERS INC #4447',CAST('11/19/2019' AS DATE),CAST('6/3/2020' AS DATE),23.04,CAST('4/2/2021' AS DATE)),
|
||||
('BWIC000T - BWI - TEXARKANA TX',CAST('11/20/2019' AS DATE),CAST('6/3/2020' AS DATE),21.77,CAST('4/2/2021' AS DATE)),
|
||||
('GREE0005 - GREEN ISLAND DISTRIBUTORS INC.',CAST('11/20/2019' AS DATE),CAST('6/3/2020' AS DATE),156.56,CAST('4/2/2021' AS DATE)),
|
||||
('MAPL0025 - MAPLE LEAF GARDEN',CAST('11/20/2019' AS DATE),CAST('6/3/2020' AS DATE),87.58,CAST('4/2/2021' AS DATE)),
|
||||
('WYAT0007 - WYATT QUARLES SEED CO',CAST('11/21/2019' AS DATE),CAST('6/3/2020' AS DATE),506.32,CAST('4/2/2021' AS DATE)),
|
||||
('BWIC000E - BWI - GREENVILLE-SPARTANBURG',CAST('11/22/2019' AS DATE),CAST('6/3/2020' AS DATE),662.73,CAST('4/2/2021' AS DATE)),
|
||||
('HALI0002 - HALIFAX SEED DIST CENTER (C)',CAST('11/22/2019' AS DATE),CAST('6/3/2020' AS DATE),555.71,CAST('4/2/2021' AS DATE)),
|
||||
('EDDI0001 - EDDIS WHOLESALE GDN SUPPLIES',CAST('12/2/2019' AS DATE),CAST('6/3/2020' AS DATE),86.01,CAST('4/2/2021' AS DATE)),
|
||||
('MARI0030 - MARIA GARDENS',CAST('12/3/2019' AS DATE),CAST('6/3/2020' AS DATE),790.55,CAST('4/2/2021' AS DATE)),
|
||||
('MARI0007 - MARIA GARDENS - N. ROYALTON',CAST('12/4/2019' AS DATE),CAST('6/3/2020' AS DATE),675.25,CAST('4/2/2021' AS DATE)),
|
||||
('LLNU0003 - LL NURSERY SUPPLY INC WA',CAST('12/5/2019' AS DATE),CAST('6/3/2020' AS DATE),445.85,CAST('4/2/2021' AS DATE)),
|
||||
('LLNU0001 - LL NURSERY SUPPLY INC CA',CAST('12/5/2019' AS DATE),CAST('6/3/2020' AS DATE),358.1,CAST('4/2/2021' AS DATE)),
|
||||
('CAVI0001 - CAVICCHIO GREENHOUSES INC',CAST('12/6/2019' AS DATE),CAST('6/3/2020' AS DATE),2316.1,CAST('4/2/2021' AS DATE)),
|
||||
('GRIF0010 - GRIFFIN GREENHOUSE - STAFFORD',CAST('12/6/2019' AS DATE),CAST('6/3/2020' AS DATE),527.51,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0015 - BFG SUPPLY - CHESWICK (W08)',CAST('12/6/2019' AS DATE),CAST('6/3/2020' AS DATE),1640.54,CAST('4/2/2021' AS DATE)),
|
||||
('COST0015 - COSTA FARMS-FOLIAGE DIV (CNF)',CAST('12/6/2019' AS DATE),CAST('6/3/2020' AS DATE),18673.2,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0015 - BFG SUPPLY - CHESWICK (W08)',CAST('12/9/2019' AS DATE),CAST('6/3/2020' AS DATE),716.74,CAST('4/2/2021' AS DATE)),
|
||||
('BFGS0004 - BFG SUPPLY - GRAND RAPIDS(W04)',CAST('12/9/2019' AS DATE),CAST('6/3/2020' AS DATE),521.93,CAST('4/2/2021' AS DATE)),
|
||||
('HORI0005 - HORIZON DISTRIBUTION INC',CAST('12/10/2019' AS DATE),CAST('6/3/2020' AS DATE),133.47,CAST('4/2/2021' AS DATE)),
|
||||
('CARL0002 - CARLIN HORTICULTURAL SUPP U',CAST('12/10/2019' AS DATE),CAST('6/3/2020' AS DATE),155.55,CAST('4/2/2021' AS DATE)),
|
||||
('CAVI0001 - CAVICCHIO GREENHOUSES INC',CAST('12/10/2019' AS DATE),CAST('6/3/2020' AS DATE),1695.58,CAST('4/2/2021' AS DATE)),
|
||||
('CARL0001 - CARL BREHOB SON',CAST('12/12/2019' AS DATE),CAST('6/3/2020' AS DATE),478.87,CAST('4/2/2021' AS DATE)),
|
||||
('BWIC000G - BWI - SPRINGFIELD MO',CAST('12/12/2019' AS DATE),CAST('6/3/2020' AS DATE),68.23,CAST('4/2/2021' AS DATE)),
|
||||
('GARD0095 - GARD N WISE SALT LAKE',CAST('12/12/2019' AS DATE),CAST('6/3/2020' AS DATE),214.58,CAST('4/2/2021' AS DATE)),
|
||||
('GARD0122 - GARD N WISE DENVER',CAST('12/12/2019' AS DATE),CAST('6/3/2020' AS DATE),632.41,CAST('4/2/2021' AS DATE)),
|
||||
('STRA0022 - STRADERS GARDEN SUPPLY',CAST('12/13/2019' AS DATE),CAST('6/3/2020' AS DATE),186.94,CAST('4/2/2021' AS DATE)),
|
||||
('STRA0020 - STRADERS GARDEN CENTER #1',CAST('12/13/2019' AS DATE),CAST('6/3/2020' AS DATE),290.19,CAST('4/2/2021' AS DATE)),
|
||||
('PLRO0001 - PL ROHRER BRO INC RET',CAST('12/13/2019' AS DATE),CAST('6/3/2020' AS DATE),21.77,CAST('4/2/2021' AS DATE)),
|
||||
('STRA0001 - STRADERS GREENHOUSE-POWELL',CAST('12/13/2019' AS DATE),CAST('6/3/2020' AS DATE),119.62,CAST('4/2/2021' AS DATE)),
|
||||
('STRA0023 - STRADERS GARDEN SUPPLY',CAST('12/13/2019' AS DATE),CAST('6/3/2020' AS DATE),186.94,CAST('4/2/2021' AS DATE)),
|
||||
('STRA0002 - STRADERS GREENHOUSE-GROVE CITY',CAST('12/13/2019' AS DATE),CAST('6/3/2020' AS DATE),186.94,CAST('4/2/2021' AS DATE)),
|
||||
('LUCA0001 - LUCAS GREENHOUSE',CAST('12/16/2019' AS DATE),CAST('6/3/2020' AS DATE),101062.73,CAST('4/2/2021' AS DATE)),
|
||||
('ENVI0008 - EVL NURSERY',CAST('12/16/2019' AS DATE),CAST('6/3/2020' AS DATE),22023.66,CAST('4/2/2021' AS DATE)),
|
||||
('WILD0012 - WILDWOODS-PACIFIC NURSERY POTS',CAST('12/16/2019' AS DATE),CAST('6/3/2020' AS DATE),14853.15,CAST('4/2/2021' AS DATE)),
|
||||
('APAC0001 - APACHE SEEDS LTD',CAST('12/17/2019' AS DATE),CAST('6/3/2020' AS DATE),663.82,CAST('4/2/2021' AS DATE)),
|
||||
('GALE0003 - GALES GARDEN CENTER',CAST('12/18/2019' AS DATE),CAST('6/3/2020' AS DATE),622.16,CAST('4/2/2021' AS DATE)),
|
||||
('OTTO0004 - OTTEN BROS NRSY LANDSCPG INC',CAST('12/19/2019' AS DATE),CAST('6/3/2020' AS DATE),211.66,CAST('4/2/2021' AS DATE)),
|
||||
('INTE0014 - INTERMOUNTAIN FARMERS ASSN',CAST('12/20/2019' AS DATE),CAST('6/3/2020' AS DATE),87.46,CAST('4/2/2021' AS DATE)),
|
||||
('GARD0095 - GARD N WISE SALT LAKE',CAST('12/20/2019' AS DATE),CAST('6/3/2020' AS DATE),71.63,CAST('4/2/2021' AS DATE)),
|
||||
('GRIF0002 - GRIFFIN GREENHOUSE - SCHENECTA',CAST('12/26/2019' AS DATE),CAST('6/3/2020' AS DATE),1849.79,CAST('4/2/2021' AS DATE)),
|
||||
('COST0007 - COSTA COLOR-MIAMI FL',CAST('1/8/2020' AS DATE),CAST('6/3/2020' AS DATE),15629.4,CAST('4/2/2021' AS DATE)),
|
||||
('COST0015 - COSTA FARMS-FOLIAGE DIV (CNF)',CAST('1/9/2020' AS DATE),CAST('6/3/2020' AS DATE),6652.8,CAST('4/2/2021' AS DATE)),
|
||||
('COST0015 - COSTA FARMS-FOLIAGE DIV (CNF)',CAST('1/10/2020' AS DATE),CAST('6/3/2020' AS DATE),944,CAST('4/2/2021' AS DATE)),
|
||||
('FOST0001 - FOSTERS INC RETAIL',CAST('1/13/2020' AS DATE),CAST('6/3/2020' AS DATE),888.04,CAST('4/2/2021' AS DATE)),
|
||||
('INTE0003 - GREENHOUSE MEGASTORE',CAST('1/13/2020' AS DATE),CAST('6/3/2020' AS DATE),368.52,CAST('4/2/2021' AS DATE)),
|
||||
('JOSE0009 - JOSEPH GEREMIA FARM',CAST('1/13/2020' AS DATE),CAST('6/3/2020' AS DATE),1739.3,CAST('4/2/2021' AS DATE)),
|
||||
('COST0015 - COSTA FARMS-FOLIAGE DIV (CNF)',CAST('1/14/2020' AS DATE),CAST('6/3/2020' AS DATE),5026.94,CAST('4/2/2021' AS DATE)),
|
||||
('RITC0001 - RITCHIE FEED SEED C',CAST('1/15/2020' AS DATE),CAST('6/3/2020' AS DATE),1.1,CAST('4/2/2021' AS DATE)),
|
||||
('KUBE0001 - KUBE PAK CORPORATION',CAST('1/16/2020' AS DATE),CAST('6/3/2020' AS DATE),874.5,CAST('4/2/2021' AS DATE)),
|
||||
('FRYS0001 - FRYSVILLE FARMS (MILES FRY)',CAST('1/17/2020' AS DATE),CAST('6/3/2020' AS DATE),1857.6,CAST('4/2/2021' AS DATE)),
|
||||
('PRIN0001 - PRINCE CORPORATION',CAST('1/20/2020' AS DATE),CAST('6/3/2020' AS DATE),211.16,CAST('4/2/2021' AS DATE)),
|
||||
('GALE0006 - GALES GARDEN CENTER',CAST('1/20/2020' AS DATE),CAST('6/3/2020' AS DATE),19.47,CAST('4/2/2021' AS DATE)),
|
||||
('CKGR0004 - CK GREENHOUSES',CAST('1/20/2020' AS DATE),CAST('6/3/2020' AS DATE),4442.04,CAST('4/2/2021' AS DATE)),
|
||||
('MATS0002 - MATSUDAS OF SACRAMENTO',CAST('1/20/2020' AS DATE),CAST('6/3/2020' AS DATE),57056.64,CAST('5/2/2021' AS DATE)),
|
||||
('GRIF0005 - GRIFFIN GREENHOUSE - AUBURN',CAST('1/21/2020' AS DATE),CAST('6/3/2020' AS DATE),7399.49,CAST('5/2/2021' AS DATE)),
|
||||
('GRIF0014 - GRIFFIN GREENHOUSE - MORGANTWN',CAST('1/21/2020' AS DATE),CAST('6/3/2020' AS DATE),16031.53,CAST('5/2/2021' AS DATE)),
|
||||
('GRIF0004 - GRIFFIN GREENHOUSE - CHESHIRE',CAST('1/21/2020' AS DATE),CAST('6/3/2020' AS DATE),6166.24,CAST('5/2/2021' AS DATE)),
|
||||
('GROW0001 - GROWER DIRECT FARMS INC',CAST('1/24/2020' AS DATE),CAST('6/3/2020' AS DATE),1199.44,CAST('5/2/2021' AS DATE)),
|
||||
('CHAR0009 - CHARLES SPITZNER',CAST('1/24/2020' AS DATE),CAST('6/3/2020' AS DATE),7350,CAST('5/2/2021' AS DATE)),
|
||||
('KURT0018 - KURTZ FARMS',CAST('1/27/2020' AS DATE),CAST('6/3/2020' AS DATE),3689.69,CAST('5/2/2021' AS DATE)),
|
||||
('PARK0004 - PARKS BROTHERS FARMS',CAST('1/27/2020' AS DATE),CAST('6/3/2020' AS DATE),2250,CAST('5/2/2021' AS DATE)),
|
||||
('JAYW0001 - JAY W GUILD',CAST('1/28/2020' AS DATE),CAST('6/3/2020' AS DATE),8388.9,CAST('5/2/2021' AS DATE)),
|
||||
('VAND0001 - VANDENBERG BULB CO INC',CAST('1/29/2020' AS DATE),CAST('6/3/2020' AS DATE),70.35,CAST('5/2/2021' AS DATE)),
|
||||
('LITT0001 - LITTLE MOUNTAIN GREENHOUSES U',CAST('2/3/2020' AS DATE),CAST('6/3/2020' AS DATE),61.92,CAST('5/2/2021' AS DATE)),
|
||||
('JIFF0006 - JIFFY PRODUCTS OF AMERICA',CAST('2/4/2020' AS DATE),CAST('6/3/2020' AS DATE),16652.25,CAST('5/2/2021' AS DATE)),
|
||||
('RSGR0004 - RS GROWERS SUPPLY INC',CAST('2/6/2020' AS DATE),CAST('6/3/2020' AS DATE),0.02,CAST('5/2/2021' AS DATE)),
|
||||
('SCHL0001 - SCHLEGEL GRHSE',CAST('2/6/2020' AS DATE),CAST('6/3/2020' AS DATE),3646.58,CAST('5/2/2021' AS DATE)),
|
||||
('VANW0013 - VAN WINGERDEN GREENHOUSE LLC',CAST('2/7/2020' AS DATE),CAST('6/3/2020' AS DATE),537.3,CAST('5/2/2021' AS DATE)),
|
||||
('RITC0001 - RITCHIE FEED SEED C',CAST('2/7/2020' AS DATE),CAST('6/3/2020' AS DATE),179.46,CAST('5/2/2021' AS DATE)),
|
||||
('LONG0002 - LONGFELLOWS GREENHOUSE',CAST('2/7/2020' AS DATE),CAST('6/3/2020' AS DATE),5536.48,CAST('5/2/2021' AS DATE)),
|
||||
('AAPL0001 - AA PLANTS INC',CAST('2/7/2020' AS DATE),CAST('6/3/2020' AS DATE),3843,CAST('5/2/2021' AS DATE)),
|
||||
('BFGS0004 - BFG SUPPLY - GRAND RAPIDS(W04)',CAST('2/10/2020' AS DATE),CAST('6/3/2020' AS DATE),553.3,CAST('5/2/2021' AS DATE)),
|
||||
('KALA0002 - KALAMAZOO FLOWER GROUP LLC',CAST('2/10/2020' AS DATE),CAST('6/3/2020' AS DATE),502.7,CAST('5/2/2021' AS DATE)),
|
||||
('DOIT0079 - DO IT BEST CORP',CAST('2/10/2020' AS DATE),CAST('6/3/2020' AS DATE),494.4,CAST('5/2/2021' AS DATE)),
|
||||
('DOIT0004 - DO IT BEST CORP',CAST('2/11/2020' AS DATE),CAST('6/3/2020' AS DATE),82.4,CAST('5/2/2021' AS DATE)),
|
||||
('GRIF0002 - GRIFFIN GREENHOUSE - SCHENECTA',CAST('2/12/2020' AS DATE),CAST('6/3/2020' AS DATE),376.6,CAST('5/2/2021' AS DATE)),
|
||||
('NATU0027 - NATURALLY BEAUTIFUL PLANT PROD',CAST('2/12/2020' AS DATE),CAST('6/3/2020' AS DATE),31636.8,CAST('5/2/2021' AS DATE)),
|
||||
('FARM0012 - FARMETTE GARDENS',CAST('2/13/2020' AS DATE),CAST('6/3/2020' AS DATE),6028.37,CAST('5/2/2021' AS DATE)),
|
||||
('SPOR0002 - SPORTEL GREENHOUSE',CAST('2/13/2020' AS DATE),CAST('6/3/2020' AS DATE),3728.54,CAST('5/2/2021' AS DATE)),
|
||||
('ARET0001 - ARETT SALES - BRISTOL',CAST('2/14/2020' AS DATE),CAST('6/3/2020' AS DATE),266.62,CAST('5/2/2021' AS DATE)),
|
||||
('GREE0005 - GREEN ISLAND DISTRIBUTORS INC.',CAST('2/14/2020' AS DATE),CAST('6/3/2020' AS DATE),21.21,CAST('5/2/2021' AS DATE)),
|
||||
('FARM0001 - FARMERS COOPERATIVE ELEVATOR',CAST('2/17/2020' AS DATE),CAST('6/3/2020' AS DATE),495,CAST('5/2/2021' AS DATE)),
|
||||
('VANW0009 - VAN WINGERDEN INTERNATIONAL',CAST('2/17/2020' AS DATE),CAST('6/3/2020' AS DATE),908.6,CAST('5/2/2021' AS DATE)),
|
||||
('CIVA0001 - CIVANO NURSERY',CAST('2/18/2020' AS DATE),CAST('6/3/2020' AS DATE),50700,CAST('5/2/2021' AS DATE))
|
||||
) x(ship_cust_descr,order_date,ship_date,sales,revised)
|
||||
)
|
||||
,upd AS (
|
||||
UPDATE
|
||||
rlarp.osm_pool p
|
||||
SET
|
||||
ship_date = revised
|
||||
FROM
|
||||
move
|
||||
WHERE
|
||||
move.ship_cust_descr = p.ship_cust_descr
|
||||
AND move.order_date = p.order_date
|
||||
AND move.ship_date = p.ship_date
|
||||
AND p.ship_season = 2021
|
||||
RETURNING *
|
||||
)
|
||||
SELECT ship_month ,sum(value_usd) FROM upd group by ship_month;
|
||||
|
||||
UPDATE
|
||||
rlarp.osm_pool
|
||||
SET
|
||||
ship_month = gld.sspr || ' - ' || to_char(ship_date,'FMMon')
|
||||
,ship_season = gld.ssyr
|
||||
,fspr = gld.fspr
|
||||
FROM
|
||||
rlarp.gld gld
|
||||
WHERE
|
||||
ship_date BETWEEN gld.sdat AND gld.edat
|
||||
RETURNING *;
|
||||
--ROLLBACK;
|
||||
|
||||
|
||||
--SELECT
|
||||
-- move.revised
|
||||
-- ,sum(sales)
|
||||
-- ,sum(value_usd)
|
||||
--FROM
|
||||
-- rlarp.osm_pool p
|
||||
-- INNER JOIN move ON
|
||||
-- move.ship_cust_descr = p.ship_cust_descr
|
||||
-- AND move.order_date = p.order_date
|
||||
-- AND move.ship_date = p.ship_date
|
||||
--WHERE
|
||||
-- ship_season = 2021
|
||||
--GROUP BY
|
||||
-- move.revised
|
13
build/readme.md
Normal file
13
build/readme.md
Normal file
@ -0,0 +1,13 @@
|
||||
Build A New Forecast
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
* overwrite osmf: review dates and execute build_forecase.sql
|
||||
* the product and customer attributes are wiped, they will need to be snapped (itemm must come first)
|
||||
1. snap_itemm.sql
|
||||
2. snap_customer.sql
|
||||
3. snap_cost_current.sql
|
||||
4. snap_fx.sql (if necessary)
|
||||
5. offline/last_price.sql (if necessary)
|
||||
* build the pool for the more limited UI data set: build_pool.sql
|
||||
* copy the pool to osmfs_dev from inclusion in the osm_stack and reporting: convert_pool_all.sql
|
||||
* refresh osm_stack_refresh() to integrate into reporting
|
@ -1,6 +1,8 @@
|
||||
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/build_forecast.sql
|
||||
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_cost_current.sql
|
||||
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/fx.sql
|
||||
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/customer.sql
|
||||
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/snap_itemm.sql
|
||||
psql -U ptrowbridge -d ubm -p 5030 -h usmidlnx01 -f build/build_pool.sql
|
||||
$PG -f build_forecast.sql
|
||||
$PG -f snap_itemm.sql
|
||||
$PG -f snap_cost_current.sql
|
||||
$PG -f snap_customer.sql
|
||||
$PG -f snap_fx.sql
|
||||
$PG -f build_pool.sql
|
||||
$PG -f convert_pool_all.sql
|
||||
$PG -c "CALL rlarp.osm_stack_refresh();"
|
||||
|
33
build/rec_act.sql
Normal file
33
build/rec_act.sql
Normal file
@ -0,0 +1,33 @@
|
||||
SELECT
|
||||
oseas
|
||||
,go.drange
|
||||
,go.sspr
|
||||
,sum(fb_val_loc * r_rate)
|
||||
FROM
|
||||
rlarp.osm_dev o
|
||||
--snap the ship dates of the historic fiscal period
|
||||
--LEFT OUTER JOIN rlarp.gld ON
|
||||
-- gld.fspr = o.fspr
|
||||
LEFT OUTER JOIN rlarp.gld go ON
|
||||
odate between go.sdat and go.edat
|
||||
--get the shipping season for open orders based on the snapped date
|
||||
--LEFT OUTER JOIN rlarp.gld ss ON
|
||||
-- greatest(least(o.sdate,gld.edat),gld.sdat) BETWEEN ss.sdat AND ss.edat
|
||||
WHERE
|
||||
(
|
||||
--base period orders booked....
|
||||
o.odate BETWEEN '2020-06-01' AND '2021-04-04'
|
||||
----...or any open orders currently booked before cutoff....
|
||||
--OR (o.calc_status IN ('OPEN','BACKORDER') and o.odate < '2021-04-04')
|
||||
----...or anything that shipped in that period
|
||||
--OR o.fspr BETWEEN '2101' AND '2110'
|
||||
)
|
||||
AND fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
--AND NOT (calc_status = 'CLOSED' AND flag = 'REMAINDER')
|
||||
---exclude integrated quotes----
|
||||
AND version = 'ACTUALS'
|
||||
GROUP BY
|
||||
oseas
|
||||
,go.drange
|
||||
,go.sspr
|
44
build/snap_cust_osmfs.sql
Normal file
44
build/snap_cust_osmfs.sql
Normal file
@ -0,0 +1,44 @@
|
||||
UPDATE
|
||||
RLARP.OSMFS_DEV S
|
||||
SET
|
||||
DSM = CR.QUOTA_REP
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
VERSION,
|
||||
COALESCE(GLEC,'') GLEC,
|
||||
COALESCE(MING,'') MING,
|
||||
BILL_CUST,
|
||||
SHIP_CUST,
|
||||
------------quota rep column--------------
|
||||
CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE
|
||||
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
|
||||
CASE WHEN COALESCE(glec,'') = '1RE' AND COALESCE(cu.currep,'') <> '' THEN
|
||||
cu.currep
|
||||
--default logic
|
||||
ELSE
|
||||
CASE SUBSTR(bill_class,2,3)
|
||||
WHEN 'DIS' THEN
|
||||
ship_rep
|
||||
ELSE
|
||||
bill_rep
|
||||
END
|
||||
END
|
||||
END QUOTA_REP
|
||||
FROM
|
||||
RLARP.OSMFS_DEV S
|
||||
LEFT OUTER JOIN LGDAT.CUST ON
|
||||
BVCUST = BILL_CUST
|
||||
LEFT OUTER JOIN lgpgm.usrcust cu ON
|
||||
cu.cucust = s.bill_cust
|
||||
--WHERE
|
||||
-- COALESCE(GLEC,'') IS NOT NULL
|
||||
) CR
|
||||
WHERE
|
||||
CR.VERSION = S.VERSION
|
||||
AND CR.GLEC = COALESCE(S.GLEC,'')
|
||||
AND CR.MING = COALESCE(S.MING,'')
|
||||
AND CR.BILL_CUST = S.BILL_CUST
|
||||
AND CR.SHIP_CUST = S.SHIP_CUST
|
||||
AND COALESCE(S.DSM,'') <> CR.QUOTA_REP;
|
||||
|
@ -32,15 +32,14 @@ SET
|
||||
------------quota rep column--------------
|
||||
CASE WHEN COALESCE(substring(ming_descr,1,3),'') = 'B52' THEN 'PW' ELSE
|
||||
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
|
||||
CASE WHEN COALESCE(o.segm,'') = 'Retail' AND COALESCE(cu.currep,'') <> '' THEN
|
||||
cu.currep
|
||||
CASE WHEN COALESCE(o.segm,'') = 'Retail' AND COALESCE((SELECT currep FROM lgpgm.usrcust where cucust = b.bvcust),'') <> ''
|
||||
THEN
|
||||
(SELECT currep FROM lgpgm.usrcust where cucust = b.bvcust)
|
||||
--default logic
|
||||
ELSE
|
||||
CASE SUBSTR(b.bvclas,2,3)
|
||||
WHEN 'DIS' THEN
|
||||
s.bvsalm
|
||||
ELSE
|
||||
b.bvsalm
|
||||
WHEN 'DIS' THEN s.bvsalm
|
||||
ELSE b.bvsalm
|
||||
END
|
||||
END
|
||||
END,
|
||||
@ -48,12 +47,10 @@ SET
|
||||
shipto_group = CASE s.bvadr6 WHEN '' THEN s.bvname ELSE s.bvadr6 END
|
||||
FROM
|
||||
lgdat.cust b,
|
||||
lgdat.cust s,
|
||||
lgpgm.usrcust cu
|
||||
lgdat.cust s
|
||||
WHERE
|
||||
b.bvcust = rtrim(substring(o.bill_cust_descr,1,8))
|
||||
AND s.bvcust = rtrim(substring(o.ship_cust_descr,1,8))
|
||||
AND cu.cucust = b.bvcust;
|
||||
AND s.bvcust = rtrim(substring(o.ship_cust_descr,1,8));
|
||||
--BEGIN;
|
||||
|
||||
UPDATE
|
||||
|
@ -144,66 +144,37 @@ FROM
|
||||
SELECT DISTINCT
|
||||
VERSION,
|
||||
COALESCE(GLEC,'') GLEC,
|
||||
COALESCE(MING,'') MING,
|
||||
MING,
|
||||
BILL_CUST,
|
||||
SHIP_CUST,
|
||||
------------quota rep column--------------
|
||||
RTRIM(
|
||||
--retail items go to currep, or if null go to 90005
|
||||
CASE WHEN S.GLEC IN ('1RE','1CU') THEN
|
||||
CASE WHEN BVCTRY = 'CAN' THEN
|
||||
--Rachel Bowman
|
||||
'50300'
|
||||
CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE
|
||||
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
|
||||
CASE WHEN COALESCE(glec,'') = '1RE' AND COALESCE(cu.currep,'') <> '' THEN
|
||||
cu.currep
|
||||
--default logic
|
||||
ELSE
|
||||
--select customers go to select reps
|
||||
CASE ACCOUNT
|
||||
------Alecia Latini-------------------------------
|
||||
WHEN 'DO IT BEST' THEN '90006'
|
||||
WHEN 'ACE HARDWARE' THEN '90006'
|
||||
WHEN 'ALDI' THEN '90006'
|
||||
WHEN 'AMAZON.COM' THEN '90006'
|
||||
WHEN 'GARDEN RIDGE CORP' THEN '90006' --AKA "At Home"
|
||||
WHEN 'TRUE VALUE' THEN '90006'
|
||||
WHEN 'WAYFAIR' THEN '90006'
|
||||
WHEN 'GRIFFIN' THEN '90006'
|
||||
WHEN 'WAL-MART' THEN '90006'
|
||||
------Tony Landino--------------------------------
|
||||
WHEN 'THE HOME DEPOT' THEN '50802'
|
||||
WHEN 'FRED MEYER' THEN '50802'
|
||||
WHEN 'MENARDS' THEN '50802'
|
||||
WHEN 'KROGER' THEN '50802'
|
||||
WHEN 'OCEAN STATE JOBBERS' THEN '50802'
|
||||
WHEN 'AURORA WHOLESALE' THEN '50802'
|
||||
WHEN 'LEON KORRAL' THEN '50802'
|
||||
--all other retail goes to Doran Marable-----------
|
||||
ELSE '50200'
|
||||
END
|
||||
END
|
||||
--minor group b52 goes to dedicated rep
|
||||
CASE SUBSTR(bill_class,2,3)
|
||||
WHEN 'DIS' THEN
|
||||
ship_rep
|
||||
ELSE
|
||||
CASE WHEN MING = 'B52' THEN
|
||||
'PW'
|
||||
--gdir, ndir go to bill-to rep
|
||||
ELSE
|
||||
CASE WHEN BILL_CLASS IN ('GDIR','NDIR') THEN
|
||||
BILL_REP
|
||||
ELSE
|
||||
SHIP_REP
|
||||
bill_rep
|
||||
END
|
||||
END
|
||||
END
|
||||
) QUOTA_REP
|
||||
END QUOTA_REP
|
||||
FROM
|
||||
RLARP.OSMF_DEV S
|
||||
LEFT OUTER JOIN LGDAT.CUST ON
|
||||
BVCUST = BILL_CUST
|
||||
LEFT OUTER JOIN lgpgm.usrcust cu ON
|
||||
cu.cucust = s.bill_cust
|
||||
WHERE
|
||||
COALESCE(GLEC,'') IS NOT NULL
|
||||
version = 'ACTUALS'
|
||||
) CR
|
||||
WHERE
|
||||
CR.VERSION = S.VERSION
|
||||
AND CR.GLEC = COALESCE(S.GLEC,'')
|
||||
AND CR.MING = COALESCE(S.MING,'')
|
||||
AND CR.MING = S.MING
|
||||
AND CR.BILL_CUST = S.BILL_CUST
|
||||
AND CR.SHIP_CUST = S.SHIP_CUST
|
||||
AND COALESCE(S.DSM,'') <> CR.QUOTA_REP;
|
@ -1,9 +1,10 @@
|
||||
------------update fx rates-----------------------------------------------------------------
|
||||
UPDATE rlarp.osmf_dev SET r_rate = .7518 WHERE r_currency = 'CA' AND version = 'b21';
|
||||
UPDATE rlarp.osmf_dev SET r_rate = 1.0000 WHERE r_currency = 'US' AND version = 'b21';
|
||||
UPDATE rlarp.osmf_dev SET c_rate = .7518 WHERE c_currency = 'CA' AND version = 'b21';
|
||||
UPDATE rlarp.osmf_dev SET c_rate = 1.0000 WHERE c_currency = 'US' AND version = 'b21';
|
||||
UPDATE rlarp.osm_pool SET r_rate = .7518 WHERE r_currency = 'CA' AND version = 'b21';
|
||||
UPDATE rlarp.osm_pool SET value_usd = value_loc * r_rate WHERE r_currency = 'CA' AND version = 'b21';
|
||||
UPDATE rlarp.osm_pool SET c_rate = .7518 WHERE c_currency = 'CA' AND version = 'b21';
|
||||
UPDATE rlarp.osm_pool SET cost_usd = cost_loc * c_rate WHERE c_currency = 'CA' AND version = 'b21';
|
||||
---only apply fx to forecast orders----
|
||||
UPDATE rlarp.osmf_dev SET r_rate = .7900 WHERE r_currency = 'CA' AND odate >= '2021-04-08';
|
||||
UPDATE rlarp.osmf_dev SET r_rate = 1.0000 WHERE r_currency = 'US' AND odate >= '2021-04-08';
|
||||
UPDATE rlarp.osmf_dev SET c_rate = .7900 WHERE c_currency = 'CA' AND odate >= '2021-04-08';
|
||||
UPDATE rlarp.osmf_dev SET c_rate = 1.0000 WHERE c_currency = 'US' AND odate >= '2021-04-08';
|
||||
--UPDATE rlarp.osm_pool SET r_rate = .7900 WHERE r_currency = 'CA' AND version = 'b22';
|
||||
--UPDATE rlarp.osm_pool SET value_usd = value_loc * r_rate WHERE r_currency = 'CA' AND version = 'b22';
|
||||
--UPDATE rlarp.osm_pool SET c_rate = .7900 WHERE c_currency = 'CA' AND version = 'b22';
|
||||
--UPDATE rlarp.osm_pool SET cost_usd = cost_loc * c_rate WHERE c_currency = 'CA' AND version = 'b22';
|
||||
|
@ -1,7 +1,8 @@
|
||||
UPDATE
|
||||
RLARP.OSMF_DEV O
|
||||
SET
|
||||
COLC = M.COLC
|
||||
STYC = M.STLC
|
||||
,COLC = M.COLC
|
||||
,COLGRP = M.COLGRP
|
||||
,COLTIER = M.COLTIER
|
||||
,COLSTAT = M.COLSTAT
|
||||
|
64
build/snap_itemm_pool.sql
Normal file
64
build/snap_itemm_pool.sql
Normal file
@ -0,0 +1,64 @@
|
||||
BEGIN;
|
||||
|
||||
WITH
|
||||
SEG AS (
|
||||
SELECT
|
||||
GLEC
|
||||
,SEGM
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1SU','Sustainable'),
|
||||
('1CU','Sustainable'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
('2WI','Greenhouse'),
|
||||
('3BM','Other'),
|
||||
('3CO','Other'),
|
||||
('3PE','Other'),
|
||||
('3PP','Other'),
|
||||
('4CO','Other'),
|
||||
('4RA','Other'),
|
||||
('9MI','Other'),
|
||||
('9SA','Other'),
|
||||
('9TO','Other')
|
||||
) X(GLEC, SEGM)
|
||||
)
|
||||
,fin AS (
|
||||
SELECT DISTINCT
|
||||
o.part
|
||||
,i.item||coalesce(' - '||i.descr,'') part_descr
|
||||
,i.stlc part_group
|
||||
,i.branding
|
||||
,i.majg||' - '||i.majgd majg_descr
|
||||
,i.ming||' - '||i.mingd ming_descr
|
||||
,i.majs||' - '||i.majsd majs_descr
|
||||
,i.mins||' - '||i.minsd mins_descr
|
||||
,seg.segm
|
||||
,CASE WHEN i.majg = '610' THEN 'Fiber' ELSE 'Plastic' END substance
|
||||
FROM
|
||||
rlarp.osm_pool o
|
||||
LEFT OUTER JOIN rlarp.itemm i ON
|
||||
i.item = o.part
|
||||
LEFT OUTER JOIN seg ON
|
||||
seg.glec = i.glec
|
||||
)
|
||||
UPDATE
|
||||
rlarp.osm_pool o
|
||||
SET
|
||||
part_descr = fin.part_descr
|
||||
,part_group = fin.part_group
|
||||
,branding = fin.branding
|
||||
,majg_descr = fin.majg_descr
|
||||
,ming_descr = fin.ming_descr
|
||||
,majs_descr = fin.majs_descr
|
||||
,mins_descr = fin.mins_descr
|
||||
,segm = fin.segm
|
||||
,substance = fin.substance
|
||||
FROM
|
||||
fin
|
||||
WHERE
|
||||
fin.part = o.part;
|
||||
|
||||
COMMIT;
|
@ -1,29 +1,413 @@
|
||||
with
|
||||
fp as (
|
||||
SEG AS (
|
||||
SELECT
|
||||
GLEC
|
||||
,SEGM
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1CU','Retail'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
('2WI','Greenhouse'),
|
||||
('3BM','Other'),
|
||||
('3CO','Other'),
|
||||
('3PE','Other'),
|
||||
('3PP','Other'),
|
||||
('4CO','Other'),
|
||||
('4RA','Other'),
|
||||
('9MI','Other'),
|
||||
('9SA','Other'),
|
||||
('9TO','Other')
|
||||
) X(GLEC, SEGM)
|
||||
)
|
||||
,fp as (
|
||||
SELECT
|
||||
od.part,
|
||||
sum(fb_val_loc * r_rate) sales,
|
||||
sum(fb_cst_loc * c_rate) scost
|
||||
sum(value_usd) sales,
|
||||
sum(cost_usd) scost
|
||||
FROM
|
||||
rlarp.osmf_dev od
|
||||
rlarp.osm_pool od
|
||||
LEFT OUTER JOIN rlarp.itemmv m ON
|
||||
m.item = od.part
|
||||
WHERE
|
||||
m.item is null
|
||||
AND coalesce(od.part,'') <> ''
|
||||
GROUP BY
|
||||
od.part
|
||||
)
|
||||
,repl AS (
|
||||
SELECT * FROM (VALUES
|
||||
('ANP00001A39','ANP00001A39C003LRDBP','New 2020'),
|
||||
('ANP12000A39','ANP12000A39C001LRCOM','New 2020'),
|
||||
('ANP15000A39','ANP15000A39C001LRCON','New 2020'),
|
||||
('ANP17500A39','ANP17500A39C001LRCOO','New 2020'),
|
||||
('ARP06000DE3','ARP06000DE3C012LRDBQ','New 2020'),
|
||||
('ARP06000P26','ARP06000P26C012LRDBR','New 2020'),
|
||||
('ARP06000P80','ARP06000P80C012LRDBS','New 2020'),
|
||||
('ARP06000P81','ARP06000P81C012LRDBT','New 2020'),
|
||||
('ARP08000DE3','ARP08000DE3C012LRDBU','New 2020'),
|
||||
('ARP08000P26','ARP08000P26C012LRDBV','New 2020'),
|
||||
('ARP08000P80','ARP08000P80C012LRDBW','New 2020'),
|
||||
('ARP08000P81','ARP08000P81C012LRDBX','New 2020'),
|
||||
('ARP10000DE3','ARP10000DE3C010LRDBY','New 2020'),
|
||||
('ARP10000P26','ARP10000P26C010LRDBZ','New 2020'),
|
||||
('ARP10000P80','ARP10000P80C010LRDCA','New 2020'),
|
||||
('ARP10000P81','ARP10000P81C010LRDCB','New 2020'),
|
||||
('ARP12000DE3','ARP12000DE3C010LRDCC','New 2020'),
|
||||
('ARP12000P26','ARP12000P26C010LRDCD','New 2020'),
|
||||
('ARP12000P80','ARP12000P80C010LRDCE','New 2020'),
|
||||
('ARP12000P81','ARP12000P81C010LRDCF','New 2020'),
|
||||
('ARP16000DE3','ARP16000DE3C008LRDCG','New 2020'),
|
||||
('ARP16000P26','ARP16000P26C008LRDCH','New 2020'),
|
||||
('ARP16000P80','ARP16000P80C008LRDCI','New 2020'),
|
||||
('ARP16000P81','ARP16000P81C008LRDCJ','New 2020'),
|
||||
('ASP06000DE3','ASP06000DE3C012LRDCK','New 2020'),
|
||||
('ASP06000P26','ASP06000P26C012LRDCL','New 2020'),
|
||||
('ASP06000P80','ASP06000P80C012LRDCM','New 2020'),
|
||||
('ASP06000P81','ASP06000P81C012LRDCN','New 2020'),
|
||||
('ASP08000DE3','ASP08000DE3C012LRDCO','New 2020'),
|
||||
('ASP08000P26','ASP08000P26C012LRDCP','New 2020'),
|
||||
('ASP08000P80','ASP08000P80C012LRDCQ','New 2020'),
|
||||
('ASP08000P81','ASP08000P81C012LRDCR','New 2020'),
|
||||
('ASP10000DE3','ASP10000DE3C010LRDCS','New 2020'),
|
||||
('ASP10000P26','ASP10000P26C010LRDCT','New 2020'),
|
||||
('ASP10000P80','ASP10000P80C010LRDCU','New 2020'),
|
||||
('ASP10000P81','ASP10000P81C010LRDCV','New 2020'),
|
||||
('ASP12000DE3','ASP12000DE3C010LRDCW','New 2020'),
|
||||
('ASP12000P26','ASP12000P26C010LRDCX','New 2020'),
|
||||
('ASP12000P80','ASP12000P80C010LRDCY','New 2020'),
|
||||
('ASP12000P81','ASP12000P81C010LRDCZ','New 2020'),
|
||||
('ASP16000DE3','ASP16000DE3C008LRDDB','New 2020'),
|
||||
('ASP16000P26','ASP16000P26C008LRDDC','New 2020'),
|
||||
('ASP16000P80','ASP16000P80C008LRDDE','New 2020'),
|
||||
('ASP16000P81','ASP16000P81C008LRDDF','New 2020'),
|
||||
('CAR12000P26','CAR13000P261004LRDBE','New 2020'),
|
||||
('CAR12000P80','CAR13000P801004LRDBF','New 2020'),
|
||||
('CAR15000P26','CAR16000P261004LRDBG','New 2020'),
|
||||
('CAR15000P80','CAR16000P801004LRDBH','New 2020'),
|
||||
('CAS12000P26','CAS12000P261004LRDBI','New 2020'),
|
||||
('CAS12000P80','CAS12000P801004LRDBJ','New 2020'),
|
||||
('CAS15000P26','CAS15000P261004LRDBK','New 2020'),
|
||||
('CAS15000P80','CAS15000P801004LRDBL','New 2020'),
|
||||
('CNA06000A10','CNA06000A10C024LRCJJ','New 2020'),
|
||||
('CNA06000A42','CNA06000A42C024LRCDC','New 2020'),
|
||||
('CNA06000BG3','CNA06000BG3C024LRCJK','New 2020'),
|
||||
('CNA06000F89','CNA06000F89C024LRCJL','New 2020'),
|
||||
('CNA08000A10','CNA08000A10C024LRCJM','New 2020'),
|
||||
('CNA08000A42','CNA08000A42C024LRBXH','New 2020'),
|
||||
('CNA08000BG3','CNA08000BG3C024LRCJN','New 2020'),
|
||||
('CNA08000F89','CNA08000F89C024LRCJO','New 2020'),
|
||||
('CNA10000A10','CNA10000A10C012LRCJP','New 2020'),
|
||||
('CNA10000BG3','CNA10000BG3C012LRCJQ','New 2020'),
|
||||
('CNA10000F89','CNA10000F89C012LRCJR','New 2020'),
|
||||
('CNA12000A10','CNA12000A10C012LRCJS','New 2020'),
|
||||
('CNA12000BG3','CNA12000BG3C012LRCJT','New 2020'),
|
||||
('CNA12000F89','CNA12000F89C012LRCJU','New 2020'),
|
||||
('ECA06000B78','ECA06000B781028LRCJV','New 2020'),
|
||||
('ECA06000DE2','ECA06000DE21028LRCJW','New 2020'),
|
||||
('ECA08000B78','ECA08000B781024LRCJX','New 2020'),
|
||||
('ECA08000DE2','ECA08000DE21024LRCJY','New 2020'),
|
||||
('ECA10000B78','ECA10000B781020LRCJZ','New 2020'),
|
||||
('ECA10000DE2','ECA10000DE21020LRCKA','New 2020'),
|
||||
('ECA12000B78','ECA12000B781016LRCKB','New 2020'),
|
||||
('ECA12000DE2','ECA12000DE21016LRCKC','New 2020'),
|
||||
('ECA16000B78','ECA16000B781010LRCKD','New 2020'),
|
||||
('ECA16000DE2','ECA16000DE21010LRCKE','New 2020'),
|
||||
('ECA20000B78','ECA20000B781006LRCKF','New 2020'),
|
||||
('ECA20000DE2','ECA20000DE21006LRCKG','New 2020'),
|
||||
('GAB12000BG3','GAB12000BG3C012LRCKH','New 2020'),
|
||||
('GAB12000DE2','GAB12000DE2C012LRCKI','New 2020'),
|
||||
('GAB14000BG3','GAB14000BG3C012LRCKJ','New 2020'),
|
||||
('GAB14000DE2','GAB14000DE2C012LRCKK','New 2020'),
|
||||
('GAB18000BG3','GAB18000BG3C006LRCKL','New 2020'),
|
||||
('GAB18000DE2','GAB18000DE2C006LRCKM','New 2020'),
|
||||
('GAB22000BG3','GAB22000BG3C006LRCKN','New 2020'),
|
||||
('GAB22000DE2','GAB22000DE2C006LRCKO','New 2020'),
|
||||
('GDP08000BG3','GDP08000BG3C012LRCOJ','New 2020'),
|
||||
('GDP08000DE2','GDP08000DE2C012LRCOK','New 2020'),
|
||||
('LIA06000B78','LIA06000B78C024LRCKP','New 2020'),
|
||||
('LIA06000DE2','LIA06000DE2C024LRCKQ','New 2020'),
|
||||
('LIA08000B78','LIA08000B78C024LRCKR','New 2020'),
|
||||
('LIA08000DE2','LIA08000DE2C024LRCKS','New 2020'),
|
||||
('LIA10000B78','LIA10000B78C012LRCKT','New 2020'),
|
||||
('LIA10000DE2','LIA10000DE2C012LRCKU','New 2020'),
|
||||
('LIA12000B78','LIA12000B78C012LRCKV','New 2020'),
|
||||
('LIA12000DE2','LIA12000DE2C012LRCKW','New 2020'),
|
||||
('LIA14000B78','LIA14000B78C012LRCKX','New 2020'),
|
||||
('LIA14000DE2','LIA14000DE2C012LRCKY','New 2020'),
|
||||
('LIA16000B78','LIA16000B78C012LRCKZ','New 2020'),
|
||||
('LIA16000DE2','LIA16000DE2C012LRCLA','New 2020'),
|
||||
('LIA20000B78','LIA20000B78C006LRCLB','New 2020'),
|
||||
('LIA20000DE2','LIA20000DE2C006LRCLC','New 2020'),
|
||||
('LIA24000B78','LIA24000B78C006LRCLD','New 2020'),
|
||||
('LIA24000DE2','LIA24000DE2C006LRCLE','New 2020'),
|
||||
('MSA12001A42','MSA12001A421008LRCLF','New 2020'),
|
||||
('MSA12001B78','MSA12001B781008LRCLG','New 2020'),
|
||||
('MSA12001DE2','MSA12001DE21008LRCLH','New 2020'),
|
||||
('MSA16001A42','MSA16001A42C004LRCLI','New 2020'),
|
||||
('MSA16001B78','MSA16001B78C004LRCLJ','New 2020'),
|
||||
('MSA16001DE2','MSA16001DE2C004LRCLK','New 2020'),
|
||||
('MSA20001A42','MSA20001A42C004LRCLL','New 2020'),
|
||||
('MSA20001B78','MSA20001B78C004LRCLM','New 2020'),
|
||||
('MSA20001DE2','MSA20001DE2C004LRCLN','New 2020'),
|
||||
('SEA07001A42','SEA07001A421008LRCLP','New 2020'),
|
||||
('SEA07001B78','SEA07001B781008LRCLQ','New 2020'),
|
||||
('SEA07001DE2','SEA07001DE21008LRCLR','New 2020'),
|
||||
('SEA09001A42','SEA09001A421008LRCLT','New 2020'),
|
||||
('SEA09001B78','SEA09001B781008LRCLU','New 2020'),
|
||||
('SEA09001DE2','SEA09001DE21008LRCLV','New 2020'),
|
||||
('SEA12001A42','SEA12001A421006LRCLX','New 2020'),
|
||||
('SEA12001B78','SEA12001B781006LRCLY','New 2020'),
|
||||
('SEA12001DE2','SEA12001DE21006LRCLZ','New 2020'),
|
||||
('SEA14001A42','SEA14001A421006LRCMB','New 2020'),
|
||||
('SEA14001B78','SEA14001B781006LRCMC','New 2020'),
|
||||
('SEA14001DE2','SEA14001DE21006LRCMD','New 2020'),
|
||||
('SEA16000A42','SEA16001A421006LRCMF','New 2020'),
|
||||
('SEA16000B78','SEA16001B781006LRCMG','New 2020'),
|
||||
('SEA16000DE2','SEA16001DE21006LRCMH','New 2020'),
|
||||
('SKR12000A56','SKR12000A56C010LRDDI','New 2020'),
|
||||
('SKR12000E66','SKR12000E66C010LRDDJ','New 2020'),
|
||||
('SKR12000G27','SKR12000G27C010LRDDK','New 2020'),
|
||||
('SKR16000A56','SKR16000A56C008LRDDL','New 2020'),
|
||||
('SKR16000E66','SKR16000E66C008LRDDM','New 2020'),
|
||||
('SKR16000G27','SKR16000G27C008LRDDN','New 2020'),
|
||||
('SKS12000A56','SKS12000A56C010LRDDO','New 2020'),
|
||||
('SKS12000E66','SKS12000E66C010LRDDP','New 2020'),
|
||||
('SKS12000G27','SKS12000G27C010LRDDQ','New 2020'),
|
||||
('SKS16000A56','SKS16000A56C008LRDDR','New 2020'),
|
||||
('SKS16000E66','SKS16000E66C008LRDDS','New 2020'),
|
||||
('SKS16000G27','SKS16000G27C008LRDDT','New 2020'),
|
||||
('SLI06000B78','SLI06000B78C024LRCMI','New 2020'),
|
||||
('SLI06000DE2','SLI06000DE2C024LRCMJ','New 2020'),
|
||||
('SLI08000B78','SLI08000B78C024LRCMK','New 2020'),
|
||||
('SLI08000DE2','SLI08000DE2C024LRCML','New 2020'),
|
||||
('SLI10000B78','SLI10000B78C012LRCMM','New 2020'),
|
||||
('SLI10000DE2','SLI10000DE2C012LRCMN','New 2020'),
|
||||
('SLI12000B78','SLI12000B78C012LRCMO','New 2020'),
|
||||
('SLI12000DE2','SLI12000DE2C012LRCMP','New 2020'),
|
||||
('SLI14000B78','SLI14000B78C012LRCMQ','New 2020'),
|
||||
('SLI14000DE2','SLI14000DE2C012LRCMR','New 2020'),
|
||||
('SLI16000B78','SLI17000B78C012LRCMS','New 2020'),
|
||||
('SLI17000DE2','SLI17000DE2C012LRCMT','New 2020'),
|
||||
('SLI20000B78','SLI20000B78C006LRCMU','New 2020'),
|
||||
('SLI20000DE2','SLI20000DE2C006LRCMV','New 2020'),
|
||||
('SLI24000B78','SLI24000B78C006LRCMW','New 2020'),
|
||||
('SLI24000DE2','SLI24000DE2C006LRCMX','New 2020'),
|
||||
('SVN18000A10','SVN18000A10C006LRCMY','New 2020'),
|
||||
('SVN18000A42','SVN18000A42C006LRCMZ','New 2020'),
|
||||
('SVN24000A10','SVN24000A10C006LRCNA','New 2020'),
|
||||
('SVN24000A42','SVN24000A42C006LRCNB','New 2020'),
|
||||
('SVN30000A10','SVN30000A10C006LRCNC','New 2020'),
|
||||
('SVN30000A42','SVN30000A42C006LRCND','New 2020'),
|
||||
('VNP18000A10','VNP18000A10C006LRCNE','New 2020'),
|
||||
('VNP18000A42','VNP18000A42C006LRCNF','New 2020'),
|
||||
('VNP24000A10','VNP24000A10C006LRCNG','New 2020'),
|
||||
('VNP24000A42','VNP24000A42C006LRCNH','New 2020'),
|
||||
('VNP30000A10','VNP30000A10C006LRCNI','New 2020'),
|
||||
('VNP30000A42','VNP30000A42C006LRCNJ','New 2020'),
|
||||
('WBP16000P82','WBP16000P82C008LRDDG','New 2020'),
|
||||
('ROS15500A42','ROS15500A42C012LRDFA','New 2021'),
|
||||
('SRO15500A42','SRO15500A42C012LRDFB','New 2021'),
|
||||
('CSB06000A58','CSB06000A58C020LRDHO','New 2021'),
|
||||
('CSB06000E67','CSB06000E67C020LRDHM','New 2021'),
|
||||
('CSB06000G28','CSB06000G28C020LRDHN','New 2021'),
|
||||
('CSB08000A58','CSB08000A58C020LRDHU','New 2021'),
|
||||
('CSB08000E67','CSB08000E67C020LRDHS','New 2021'),
|
||||
('CSB08000G28','CSB08000G28C020LRDHT','New 2021'),
|
||||
('CNA06000A02','CNA06000A02C024LRDGU','New 2021'),
|
||||
('CNA06000CXX','CNA06000CXXC024LRDGV','New 2021'),
|
||||
('CNA06000DE1','CNA06000DE1C024LRDGW','New 2021'),
|
||||
('CNA08000A02','CNA08000A02C024LRDGX','New 2021'),
|
||||
('CNA08000CXX','CNA08000CXXC024LRDGY','New 2021'),
|
||||
('CNA08000DE1','CNA08000DE1C024LRDGZ','New 2021'),
|
||||
('CNA10000A02','CNA10000A02C012LRDHA','New 2021'),
|
||||
('CNA10000CXX','CNA10000CXXC012LRDHB','New 2021'),
|
||||
('CNA10000DE1','CNA10000DE1C012LRDHC','New 2021'),
|
||||
('CNA12000A02','CNA12000A02C012LRDHD','New 2021'),
|
||||
('CNA12000CXX','CNA12000CXXC012LRDHE','New 2021'),
|
||||
('CNA12000DE1','CNA12000DE1C012LRDHF','New 2021'),
|
||||
('DFB06000A58','DFB06000A58C024LRDHR','New 2021'),
|
||||
('DFB06000E67','DFB06000E67C024LRDHP','New 2021'),
|
||||
('DFB06000G28','DFB06000G28C024LRDHQ','New 2021'),
|
||||
('DFB08000A58','DFB08000A58C024LRDHX','New 2021'),
|
||||
('DFB08000E67','DFB08000E67C024LRDHV','New 2021'),
|
||||
('DFB08000G28','DFB08000G28C024LRDHW','New 2021'),
|
||||
('ECH12000A42','ECH12000A421010LRDFM','New 2021'),
|
||||
('ECH12000E21','ECH12000E211010LRDFK','New 2021'),
|
||||
('ECH12000G18','ECH12000G181010LRDFL','New 2021'),
|
||||
('ECA06000A02','ECA06000A021028LRDEJ','New 2021'),
|
||||
('ECA06000A42','ECA06000A421028LRDEI','New 2021'),
|
||||
('ECA08000A02','ECA08000A021024LRDEL','New 2021'),
|
||||
('ECA08000A42','ECA08000A421024LRDEK','New 2021'),
|
||||
('ECA10000A02','ECA10000A021020LRDEM','New 2021'),
|
||||
('ECA10000A42','ECA10000A421020LRDEN','New 2021'),
|
||||
('ECA12000A02','ECA12000A021016LRDEO','New 2021'),
|
||||
('ECA12000A42','ECA12000A421016LRDEP','New 2021'),
|
||||
('ECA16000A02','ECA16000A021010LRDES','New 2021'),
|
||||
('ECA16000A42','ECA16000A421010LRDET','New 2021'),
|
||||
('ECA20000A02','ECA20000A021006LRDEW','New 2021'),
|
||||
('ECA20000A42','ECA20000A421006LRDEX','New 2021'),
|
||||
('ECI12000A42','ECI12000A421010LRDFP','New 2021'),
|
||||
('ECI12000E21','ECI12000E211010LRDFN','New 2021'),
|
||||
('ECI12000G18','ECI12000G181010LRDFO','New 2021'),
|
||||
('ECP06000A02','ECP06000A021028LRDGK','New 2021'),
|
||||
('ECP06000A42','ECP06000A421028LRDGM','New 2021'),
|
||||
('ECP06000DE2','ECP06000DE21028LRDGL','New 2021'),
|
||||
('ECP06000E35','ECP06000E351028LRDGJ','New 2021'),
|
||||
('ECP06000G18','ECP06000G181028LRDGI','New 2021'),
|
||||
('ECP08000A02','ECP08000A021024LRDGP','New 2021'),
|
||||
('ECP08000A42','ECP08000A421024LRDGR','New 2021'),
|
||||
('ECP08000DE2','ECP08000DE21024LRDGQ','New 2021'),
|
||||
('ECP08000E35','ECP08000E351024LRDGO','New 2021'),
|
||||
('ECP08000G18','ECP08000G181024LRDGN','New 2021'),
|
||||
('ECP10000A02','ECP10000A021020LRDGA','New 2021'),
|
||||
('ECP10000A42','ECP10000A421020LRDGC','New 2021'),
|
||||
('ECP10000DE2','ECP10000DE21020LRDGB','New 2021'),
|
||||
('ECP10000E35','ECP10000E351020LRDFZ','New 2021'),
|
||||
('ECP10000G18','ECP10000G181020LRDFY','New 2021'),
|
||||
('ECP12000A02','ECP12000A021016LRDGF','New 2021'),
|
||||
('ECP12000A42','ECP12000A421016LRDGH','New 2021'),
|
||||
('ECP12000DE2','ECP12000DE21016LRDGG','New 2021'),
|
||||
('ECP12000E35','ECP12000E351016LRDGE','New 2021'),
|
||||
('ECP12000G18','ECP12000G181016LRDGD','New 2021'),
|
||||
('ECW24000A10','ECW24000A101006LRDFQ','New 2021'),
|
||||
('ECW24000A42','ECW24000A421006LRDFT','New 2021'),
|
||||
('ECW24000E35','ECW24000E351006LRDFS','New 2021'),
|
||||
('ECW24000G18','ECW24000G181006LRDFR','New 2021'),
|
||||
('ECW30000A10','ECW30000A101006LRDFU','New 2021'),
|
||||
('ECW30000A42','ECW30000A421006LRDFX','New 2021'),
|
||||
('ECW30000E35','ECW30000E351006LRDFW','New 2021'),
|
||||
('ECW30000G18','ECW30000G181006LRDFV','New 2021'),
|
||||
('GAB12000A42','GAB12000A42C012LRDFC','New 2021'),
|
||||
('GAB14000A42','GAB14000A42C012LRDFD','New 2021'),
|
||||
('GAB22000A42','GAB22000A42C006LRDFE','New 2021'),
|
||||
('GDP08000A10','GDP08000A10C012LRDFF','New 2021'),
|
||||
('HBM12000H13','HBM12000H136010LRDIB','New 2021'),
|
||||
('HBM12000H26','HBM12000H226010LRDIC','New 2021'),
|
||||
('HBM12000H22','HBM12000H266010LRDIA','New 2021'),
|
||||
('PA.08005B71',CAST(NULL AS VARCHAR(255)),'New 2021'),
|
||||
('PA.08005E22','PA.08005E22C250LYHQO','New 2021'),
|
||||
('SPP08000A58','SPP08000A581004LRDHZ','New 2021'),
|
||||
('SPP08000E67','SPP08000E671004LRDHY','New 2021'),
|
||||
('PZA09000YB5','PZA09000YB5C012LRDFG','New 2021'),
|
||||
('PZA12000YB5','PZA12000YB5C012LRDFH','New 2021'),
|
||||
('PZA16000YB5','PZA16000YB5C006LRDFI','New 2021'),
|
||||
('PZA20000YB5','PZA20000YB5C006LRDFJ','New 2021'),
|
||||
('SSP02500A58','SSP02500A58C020LRDHI','New 2021'),
|
||||
('SSP02500E67','SSP02500E67C020LRDHG','New 2021'),
|
||||
('SSP02500G28','SSP02500G28C020LRDHH','New 2021'),
|
||||
('SSP03000A58','SSP03000A58C020LRDHL','New 2021'),
|
||||
('SSP03000E67','SSP03000E67C020LRDHJ','New 2021'),
|
||||
('SSP03000G28','SSP03000G28C020LRDHK','New 2021'),
|
||||
('RZ.MT160G18',CAST(NULL AS VARCHAR(255)),'New 2021'),
|
||||
('RZ.MT160A42',CAST(NULL AS VARCHAR(255)),'New 2021'),
|
||||
('RZ.MT160XXX',CAST(NULL AS VARCHAR(255)),'New 2021'),
|
||||
('RZ.WC2G3B66','RZ.WC2G3B66C020LRCOT','New 2021')
|
||||
) x(f11,fp,note)
|
||||
)
|
||||
, fin AS (
|
||||
SELECT
|
||||
fp.part,
|
||||
fp.sales,
|
||||
min(item) item
|
||||
min(item) item,
|
||||
repl.fp,
|
||||
COALESCE(repl.fp,min(item)) pick
|
||||
FROM
|
||||
fp
|
||||
LEFT OUTER JOIN rlarp.itemmv m ON
|
||||
substring(m.item,1,11) = fp.part
|
||||
substring(m.item,1,11) = substring(fp.part,1,11)
|
||||
LEFT OUTER JOIN repl ON
|
||||
repl.f11 = substring(fp.part,1,11)
|
||||
GROUP BY
|
||||
fp.part,
|
||||
fp.sales
|
||||
fp.sales,
|
||||
repl.fp
|
||||
ORDER BY
|
||||
fp.sales desc,`
|
||||
fp.sales desc,
|
||||
fp.part
|
||||
)
|
||||
--SELECT * FROM fin;
|
||||
/*
|
||||
,upd AS (
|
||||
UPDATE
|
||||
rlarp.osm_pool o
|
||||
SET
|
||||
part = fin.pick
|
||||
FROM
|
||||
fin
|
||||
WHERE
|
||||
fin.part = o.part
|
||||
RETURNING *
|
||||
)
|
||||
SELECT * from upd;
|
||||
*/
|
||||
--SELECT * FROM rlarp.osm_pool o inner join fin on fin.part = o.part ;
|
||||
select * from fin;
|
||||
|
||||
|
||||
ROLLBACK;
|
||||
/*
|
||||
,ins AS (
|
||||
SELECT
|
||||
p.fspr
|
||||
,p.plnt
|
||||
,p.promo
|
||||
,p.terms
|
||||
,p.bill_cust_descr
|
||||
,p.ship_cust_descr
|
||||
,p.dsm
|
||||
,p.quota_rep_descr
|
||||
,p.director
|
||||
,p.billto_group
|
||||
,p.shipto_group
|
||||
,p.chan
|
||||
,p.chansub
|
||||
,p.chan_retail
|
||||
,fin.pick
|
||||
,i.item||coalesce(' - '||i.descr,'') part_descr
|
||||
,i.stlc part_group
|
||||
,i.branding
|
||||
,i.majg||' - '||i.majgd majg_descr
|
||||
,i.ming||' - '||i.mingd ming_descr
|
||||
,i.majs||' - '||i.majsd majs_descr
|
||||
,i.mins||' - '||i.minsd mins_descr
|
||||
,seg.segm
|
||||
,CASE WHEN i.majg = '610' THEN 'Fiber' ELSE 'Plastic' END substance
|
||||
,p.fs_line
|
||||
,p.r_currency
|
||||
,p.r_rate
|
||||
,p.c_currency
|
||||
,p.c_rate
|
||||
,p.units
|
||||
,p.value_loc
|
||||
,p.value_usd
|
||||
,p.cost_loc
|
||||
,p.cost_usd
|
||||
,p.calc_status
|
||||
,p.flag
|
||||
,p.order_date
|
||||
,p.order_month
|
||||
,p.order_season
|
||||
,p.request_date
|
||||
,p.request_month
|
||||
,p.request_season
|
||||
,p.ship_date + INTERVAL '1 year'
|
||||
,ship_month
|
||||
,ship_season
|
||||
,'b21' AS version
|
||||
,'fake parts' iter
|
||||
,logl.id logid
|
||||
,logl.doc->>'tag' tag
|
||||
,logl.doc->>'message' "comment"
|
||||
,logl.doc->>'type' module
|
||||
FROM
|
||||
rlarp.osm_pool p
|
||||
INNER JOIN fin ON
|
||||
fin.part = p.part
|
||||
LEFT OUTER JOIN rlarp.itemm i ON
|
||||
i.item = fin.pick
|
||||
LEFT OUTER JOIN seg ON
|
||||
seg.glec = i.glec;
|
||||
*/
|
||||
|
14
change_log.sql
Normal file
14
change_log.sql
Normal file
@ -0,0 +1,14 @@
|
||||
WITH l AS (
|
||||
SELECT DISTINCT logid FROM rlarp.osm_pool
|
||||
)
|
||||
SELECT
|
||||
doc->>'user' as user,
|
||||
(doc->>'stamp')::timestamptz stamp,
|
||||
doc->>'type' as type,
|
||||
CASE WHEN logid IS NULL THEN 'undone' ELSE '' END flag,
|
||||
doc->>'tag', doc->>'message',
|
||||
doc->'scenario'->>'quota_rep_descr' dsm
|
||||
FROM
|
||||
rlarp.osm_log
|
||||
LEFT OUTER JOIN l ON logid = id
|
||||
LIMIT 1000;
|
@ -7,7 +7,7 @@ ExecStart=/usr/bin/node //opt/forecast_api/index.js
|
||||
Restart=always
|
||||
User=fc_api
|
||||
Environemnt=NODE_ENV=production
|
||||
WorkingDirectory=//opt/forecast_api
|
||||
WorkingDirectory=//opt/forecast_api/
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
46
index.js
46
index.js
@ -217,6 +217,50 @@ server.post('/swap', bodyParser.json(), function(req, res) {
|
||||
};
|
||||
})
|
||||
|
||||
server.post('/cust_swap', bodyParser.json(), function(req, res) {
|
||||
|
||||
var sql = "";
|
||||
var w = "";
|
||||
var c = 1;
|
||||
var d = 1;
|
||||
var args = [];
|
||||
var path = './route_sql/swap_cust.sql';
|
||||
|
||||
fs.readFile(path, 'utf8', function(err, data) {
|
||||
if (!err) {
|
||||
callback(data);
|
||||
} else {
|
||||
console.log("fatal error pulling sql file")
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
|
||||
var callback = function(arg) {
|
||||
sql = arg;
|
||||
|
||||
//parse request body into a where clause
|
||||
({ c, w, d } = build_where(req, c, w, d, args));
|
||||
|
||||
//if there was no body sent, return with nothing
|
||||
if (c == 1) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-------------------------get swap fit:------------------------------")
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("where_clause", 'g'), w);
|
||||
sql = sql.replace(new RegExp("swap_doc", 'g'), JSON.stringify(req.body.swap));
|
||||
sql = sql.replace(new RegExp("replace_version", 'g'), req.body.scenario.version);
|
||||
sql = sql.replace(new RegExp("replace_source", 'g'), req.body.source);
|
||||
sql = sql.replace(new RegExp("replace_iterdef", 'g'), JSON.stringify(req.body));
|
||||
//execute the sql and send the result
|
||||
console.log(sql);
|
||||
//res.json(null);
|
||||
Postgres.FirstRow(sql, [], res)
|
||||
};
|
||||
})
|
||||
|
||||
server.get('/list_changes', bodyParser.json(), function(req, res) {
|
||||
|
||||
var sql = "";
|
||||
@ -241,7 +285,7 @@ server.get('/list_changes', bodyParser.json(), function(req, res) {
|
||||
console.log(new Date().toISOString() + "-------------------------list changes:------------------------------")
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("replace_user", 'g'), req.body.quota_rep_descr)
|
||||
sql = sql.replace(new RegExp("replace_user", 'g'), req.body.scenario.quota_rep_descr)
|
||||
//execute the sql and send the result
|
||||
console.log(sql);
|
||||
Postgres.FirstRow(sql, [], res)
|
||||
|
@ -1,120 +1,406 @@
|
||||
BEGIN;
|
||||
--BEGIN;
|
||||
|
||||
with p AS (
|
||||
WITH
|
||||
------------------goal price increases---------------------
|
||||
incr AS (
|
||||
SELECT * FROM (VALUES
|
||||
('110','PP','B',0.25),
|
||||
('110','PP','T',0.25),
|
||||
('110','PP','L',0.4),
|
||||
('110','PP','M',0.4),
|
||||
('110','PP','P',0.4),
|
||||
('110','PP','C',0.4),
|
||||
('210','PE','B',0.25),
|
||||
('210','PE','T',0.25),
|
||||
('210','PE','L',0.25),
|
||||
('210','PE','M',0.25),
|
||||
('210','PE','P',0.25),
|
||||
('210','PE','C',0.25),
|
||||
('310','PE','B',0.15),
|
||||
('310','PE','T',0.25),
|
||||
('310','PE','L',0.25),
|
||||
('310','PE','M',0.25),
|
||||
('310','PE','P',0.25),
|
||||
('310','PE','C',0.25),
|
||||
('310','PP','B',0.13),
|
||||
('310','PP','T',0.16),
|
||||
('310','PP','L',0.16),
|
||||
('310','PP','M',0.16),
|
||||
('310','PP','P',0.16),
|
||||
('310','PP','C',0.16),
|
||||
('310','PS','B',0.13),
|
||||
('310','PS','T',0.16),
|
||||
('310','PS','L',0.16),
|
||||
('310','PS','M',0.16),
|
||||
('310','PS','P',0.16),
|
||||
('310','PS','C',0.16),
|
||||
('320','PE','B',0.25),
|
||||
('320','PE','T',0.25),
|
||||
('320','PE','L',0.25),
|
||||
('320','PE','M',0.25),
|
||||
('320','PE','P',0.25),
|
||||
('320','PE','C',0.25),
|
||||
('320','PP','B',0.25),
|
||||
('320','PP','T',0.25),
|
||||
('320','PP','L',0.25),
|
||||
('320','PP','M',0.25),
|
||||
('320','PP','P',0.25),
|
||||
('320','PP','C',0.25),
|
||||
('910','PE','B',0.15),
|
||||
('910','PE','D',0.25),
|
||||
('910','PE','F',0.25),
|
||||
('910','PP','B',0.15),
|
||||
('910','PP','D',0.25),
|
||||
('910','PP','F',0.25),
|
||||
('910','PS','B',0.15),
|
||||
('910','','B',0.15),
|
||||
('910','','D',0.25),
|
||||
('910','','F',0.25),
|
||||
('910','','T',0.25),
|
||||
('910','','L',0.25),
|
||||
('910','','M',0.25),
|
||||
('910','','P',0.25),
|
||||
('910','','C',0.25),
|
||||
('910','PS','D',0.25),
|
||||
('910','PS','F',0.25),
|
||||
('610','','B',0.02),
|
||||
('610','','S',0.02),
|
||||
('610','','W',0.02)
|
||||
) x(MAJG,ASSC,COLTIER,RATE)
|
||||
)
|
||||
------------carve out pricing baseline data--------------------
|
||||
,p AS (
|
||||
SELECT
|
||||
part
|
||||
,bill_cust
|
||||
,ship_cust
|
||||
,round(fb_val_loc/fb_qty,10) AS price
|
||||
,orderdate
|
||||
,row_number() OVER (PARTITION BY part,bill_cust, ship_cust ORDER BY orderdate DESC) rn
|
||||
o.part
|
||||
,o.styc||'.'||o.colgrp||substring(o.sizc,1,3) product
|
||||
,o.glec
|
||||
,o.styc
|
||||
,o.majg
|
||||
,i.assc
|
||||
,o.coltier
|
||||
,o.colgrp
|
||||
,o.sizc
|
||||
,i.suffix
|
||||
,substring(o.chan,1,1) chgrp
|
||||
,o.account
|
||||
,o.shipgrp
|
||||
,o.fb_qty units
|
||||
,o.fb_val_loc*r_rate val_usd
|
||||
,round(o.fb_val_loc/o.fb_qty,10) AS price
|
||||
,o.odate
|
||||
,o.oseas
|
||||
,row_number() OVER (PARTITION BY o.styc||'.'||o.colgrp||substring(o.sizc,1,3),o.account, o.shipgrp ORDER BY o.odate DESC) rn
|
||||
FROM
|
||||
rlarp.osm
|
||||
rlarp.osm_dev o
|
||||
INNER JOIN rlarp.itemmv i ON
|
||||
i.item = o.part
|
||||
WHERE
|
||||
fs_line = '41010'
|
||||
AND calc_status <> 'CANCELED'
|
||||
AND COALESCE(part,'') <> ''
|
||||
AND fb_qty <> 0
|
||||
AND orderdate IS NOT NULL
|
||||
---exclude R&A's
|
||||
o.fs_line = '41010'
|
||||
---exclude canceled orders
|
||||
AND o.calc_status <> 'CANCELED'
|
||||
---exclude quotes
|
||||
AND o.version = 'ACTUALS'
|
||||
---only finished goods
|
||||
AND substring(o.glec,1,1) <= '2'
|
||||
---exclude blank parts
|
||||
AND COALESCE(o.part,'') <> ''
|
||||
---must have a quantity
|
||||
AND o.fb_qty <> 0
|
||||
---must have a price
|
||||
AND o.fb_val_loc <> 0
|
||||
---must come from and order
|
||||
AND o.odate IS NOT NULL
|
||||
---exclude samples
|
||||
AND o.bill_class <> 'SALE'
|
||||
---only use recent history
|
||||
AND o.oseas >= 2020
|
||||
---only for direct and drop
|
||||
--AND o.chan IN ('DIR','DRP')
|
||||
ORDER BY
|
||||
part
|
||||
,bill_cust
|
||||
,ship_cust
|
||||
,orderdate
|
||||
o.part
|
||||
,o.styc
|
||||
,o.coltier
|
||||
,o.sizc
|
||||
,i.suffix
|
||||
,o.account
|
||||
,o.shipgrp
|
||||
,o.odate DESC
|
||||
)
|
||||
--SELECT * FROM p WHERE rn = 1
|
||||
,incr AS (
|
||||
--SELECT * FROM p WHERE account ~ 'ACOSTA'
|
||||
------------build global py asp------------------
|
||||
,baseline AS (
|
||||
SELECT
|
||||
b.plnt
|
||||
,b."ddord#"
|
||||
,b."dditm#"
|
||||
,b."fgbol#"
|
||||
,b."fgent#"
|
||||
,b."diinv#"
|
||||
,b."dilin#"
|
||||
,b.promo
|
||||
,b.return_reas
|
||||
,b.terms
|
||||
,b.custpo
|
||||
,b.dhincr
|
||||
,b.diext
|
||||
,b.ditdis
|
||||
,b.dcodat
|
||||
,b.ddqdat
|
||||
,b.dcmdat
|
||||
,b.dhidat
|
||||
,b.fspr
|
||||
,b.remit_to
|
||||
,b.bill_class
|
||||
,b.bill_cust
|
||||
,b.bill_rep
|
||||
,b.bill_terr
|
||||
,b.ship_class
|
||||
,b.ship_cust
|
||||
,b.ship_rep
|
||||
,b.ship_terr
|
||||
,b.quota_rep
|
||||
,b.account
|
||||
,b.shipgrp
|
||||
,b.geo
|
||||
,b.chan
|
||||
,b.orig_ctry
|
||||
,b.orig_prov
|
||||
,b.orig_post
|
||||
,b.dest_ctry
|
||||
,b.dest_prov
|
||||
,b.dest_post
|
||||
,b.part
|
||||
,b.ord_gldc
|
||||
,b.majg
|
||||
,b.ming
|
||||
,b.majs
|
||||
,b.mins
|
||||
,b.gldc
|
||||
,b.glec
|
||||
,b.harm
|
||||
,b.clss
|
||||
,b.brand
|
||||
,b.assc
|
||||
,b.fs_line
|
||||
,b.r_currency
|
||||
,b.r_rate
|
||||
,b.c_currency
|
||||
,b.c_rate
|
||||
,b.ddqtoi
|
||||
,b.ddqtsi
|
||||
,b.fgqshp
|
||||
,b.diqtsh
|
||||
,0 fb_qty
|
||||
,0 fb_cst_loc
|
||||
,0 fb_cst_loc_cur
|
||||
,0 fb_cst_loc_fut
|
||||
,b.fb_qty * p.price - b.fb_val_loc fb_val_loc
|
||||
,0 fb_val_loc_pl
|
||||
,b.calc_status
|
||||
,b.flag
|
||||
,b.orderdate
|
||||
,b.requestdate
|
||||
,b.shipdate
|
||||
,b.adj_orderdate
|
||||
,b.adj_requestdate
|
||||
,b.adj_shipdate
|
||||
,b."version"
|
||||
,'last price paid' iter
|
||||
product
|
||||
,majg
|
||||
,assc
|
||||
,chgrp
|
||||
,round(sum(val_usd) FILTER (WHERE oseas = 2020)/sum(units) FILTER (WHERE oseas = 2020),5) py_gasp
|
||||
FROM
|
||||
rlarp.osmfs b
|
||||
INNER JOIN p ON
|
||||
p.part = b.part
|
||||
AND p.bill_cust = b.bill_cust
|
||||
AND p.ship_cust = b.ship_cust
|
||||
AND p.rn = 1
|
||||
WHERE
|
||||
b.orderdate BETWEEN '2019-03-25' AND '2019-05-31'
|
||||
OR b.orderdate BETWEEN '2020-03-25' AND '2020-05-31'
|
||||
p
|
||||
GROUP BY
|
||||
product
|
||||
,majg
|
||||
,assc
|
||||
,chgrp
|
||||
)
|
||||
, ins AS (
|
||||
INSERT INTO rlarp.osmfs SELECT * FROM incr RETURNING *
|
||||
)
|
||||
SELECT fspr, sum(fb_val_loc *r_rate) FROM ins GROUP BY fspr;
|
||||
----------pivot the pricing out into columns per customer/product--------
|
||||
,pivot AS (
|
||||
SELECT
|
||||
p.product
|
||||
,p.styc
|
||||
,p.glec
|
||||
,p.majg
|
||||
,p.assc
|
||||
,p.colgrp
|
||||
,p.coltier
|
||||
,p.sizc
|
||||
,p.suffix
|
||||
,p.chgrp
|
||||
,p.account
|
||||
,p.shipgrp
|
||||
,bl.py_gasp
|
||||
,sum(units) FILTER (WHERE oseas = 2021) cy_units
|
||||
,round(sum(val_usd) FILTER (WHERE oseas = 2020)/sum(units) FILTER (WHERE oseas = 2020),5) py_asp
|
||||
,round(avg(price) FILTER (WHERE rn = 1),5) last_price
|
||||
,max(odate) FILTER (WHERE rn = 1) last_order
|
||||
,CASE p.chgrp
|
||||
WHEN 'D' THEN i.rate
|
||||
ELSE CASE p.majg
|
||||
WHEN '610' THEN .02
|
||||
ElSE CASE p.colgrp
|
||||
WHEN 'B' THEN .1
|
||||
WHEN 'C' THEN .15
|
||||
ELSE 1
|
||||
END
|
||||
END
|
||||
END rate
|
||||
,CASE WHEN sum(val_usd) FILTER (WHERE oseas = 2020) IS NULL
|
||||
THEN CASE WHEN sum(units) FILTER (WHERE oseas = 2021) IS NULL
|
||||
THEN 'unknown'
|
||||
ELSE 'new'
|
||||
END
|
||||
ELSE CASE WHEN sum(units) FILTER (WHERE oseas = 2021) IS NULL
|
||||
THEN 'lost'
|
||||
ELSE 'repeat'
|
||||
END
|
||||
END flag
|
||||
FROM
|
||||
p
|
||||
LEFT OUTER JOIN baseline bl ON
|
||||
bl.product = p.product
|
||||
AND bl.majg = p.majg
|
||||
AND bl.assc = p.assc
|
||||
AND bl.chgrp = p.chgrp
|
||||
LEFT OUTER JOIN incr i ON
|
||||
i.majg = p.majg
|
||||
AND i.assc = p.assc
|
||||
AND i.coltier = p.coltier
|
||||
AND p.glec <> '1RE'
|
||||
|
||||
COMMIT;
|
||||
GROUP BY
|
||||
p.product
|
||||
,p.styc
|
||||
,p.glec
|
||||
,p.majg
|
||||
,p.assc
|
||||
,p.coltier
|
||||
,p.colgrp
|
||||
,p.sizc
|
||||
,p.suffix
|
||||
,p.chgrp
|
||||
,p.account
|
||||
,p.shipgrp
|
||||
,bl.py_gasp
|
||||
,i.rate
|
||||
)
|
||||
----------------create the new price-----------------
|
||||
,adj AS (
|
||||
SELECT
|
||||
p.product
|
||||
,p.styc
|
||||
,p.glec
|
||||
,p.majg
|
||||
,p.assc
|
||||
,p.coltier
|
||||
,p.sizc
|
||||
,p.suffix
|
||||
,p.account
|
||||
,p.shipgrp
|
||||
,p.py_gasp
|
||||
,p.cy_units
|
||||
,p.py_asp
|
||||
,p.last_price
|
||||
,p.last_order
|
||||
,p.rate
|
||||
,p.flag
|
||||
,CASE p.flag
|
||||
----------------------if repeat business then get to prior year + target %--------------------------------------------------------------
|
||||
WHEN 'repeat' THEN greatest(py_asp * COALESCE(1+rate,1) - last_price,0)
|
||||
WHEN 'lost' THEN greatest(py_asp * COALESCE(1+rate,1) - last_price,0)
|
||||
----------------------if new business, move towards py_gasp + target % : lesser of py gloabl + target or last + target------------------
|
||||
WHEN 'new' THEN least(last_price * COALESCE(1+rate,1) - last_price,greatest(py_gasp * COALESCE(1+rate,1) - last_price,0))
|
||||
END price_increment
|
||||
FROM
|
||||
pivot p
|
||||
)
|
||||
--SELECT * FROM adj LIMIT 10000
|
||||
--------------create a log entry--------------------
|
||||
,log AS (
|
||||
INSERT INTO
|
||||
rlarp.osm_log(doc)
|
||||
SELECT
|
||||
$${
|
||||
"message":"application of last price and target increases to all forecast orders",
|
||||
"tag":"last price",
|
||||
"type":"build"
|
||||
}$$::jsonb doc
|
||||
RETURNING *
|
||||
)
|
||||
,poolprice AS (
|
||||
SELECT
|
||||
i.stlc||'.'||i.colgrp||substring(i.sizc,1,3) product
|
||||
,o.quota_rep_descr
|
||||
,o.billto_group
|
||||
,o.shipto_group
|
||||
,order_season
|
||||
,sum(units) units
|
||||
,sum(value_loc) valloc
|
||||
,sum(value_usd) valusd
|
||||
,sum(o.value_loc)/sum(o.units) price
|
||||
,jsonb_agg(DISTINCT iter) iters
|
||||
FROM
|
||||
rlarp.osm_pool o
|
||||
,rlarp.itemmv i
|
||||
WHERE
|
||||
i.item = o.part
|
||||
--AND o.units <> 0
|
||||
---only apply to 2022 orders----
|
||||
AND o.order_date >= '2021-06-01'
|
||||
--only include baseline stuff---
|
||||
AND segm <> 'Retail'
|
||||
GROUP BY
|
||||
i.stlc||'.'||i.colgrp||substring(i.sizc,1,3)
|
||||
,o.quota_rep_descr
|
||||
,o.billto_group
|
||||
,o.shipto_group
|
||||
,order_season
|
||||
--AND iter <> 'upload price'
|
||||
)
|
||||
, pooladj AS (
|
||||
SELECT
|
||||
p.product
|
||||
,p.quota_rep_descr
|
||||
,p.billto_group
|
||||
,p.shipto_group
|
||||
,p.price
|
||||
,a.py_gasp
|
||||
,a.rate
|
||||
,a.last_price
|
||||
,a.price_increment
|
||||
FROM
|
||||
poolprice p
|
||||
,adj a
|
||||
WHERE
|
||||
a.product = p.product
|
||||
AND a.account = p.billto_group
|
||||
AND a.shipgrp = p.shipto_group
|
||||
)
|
||||
SELECT * FROM pooladj WHERE product ~ 'STG06000' AND shipto_group = 'BWI' limit 100
|
||||
--SELECT * FROM poolprice WHERE product ~ 'TCA06600' AND shipto_group = 'BWI' AND quota_rep_descr = 'BRYAN HILL' LIMIT 1000
|
||||
-------------build the iteration rows----------------
|
||||
--,ins AS (
|
||||
--SELECT
|
||||
-- o.fspr
|
||||
-- ,o.plnt ---master data
|
||||
-- ,o.promo --history date mix
|
||||
-- ,o.terms
|
||||
-- ,o.bill_cust_descr --history cust mix
|
||||
-- ,o.ship_cust_descr --history cust mix
|
||||
-- ,o.dsm
|
||||
-- ,o.quota_rep_descr --master data
|
||||
-- ,o.director
|
||||
-- ,o.billto_group --master data
|
||||
-- ,o.shipto_group
|
||||
-- ,o.chan --master data
|
||||
-- ,o.chansub
|
||||
-- ,o.chan_retail
|
||||
-- ,o.part
|
||||
-- ,o.part_descr
|
||||
-- ,o.part_group
|
||||
-- ,o.branding
|
||||
-- ,o.majg_descr
|
||||
-- ,o.ming_descr
|
||||
-- ,o.majs_descr
|
||||
-- ,o.mins_descr
|
||||
-- ,o.segm
|
||||
-- ,o.substance
|
||||
-- ,o.fs_line --master data
|
||||
-- ,o.r_currency --history cust mix
|
||||
-- ,o.r_rate --master data
|
||||
-- ,o.c_currency --master data
|
||||
-- ,o.c_rate --master data
|
||||
-- ,0::numeric units
|
||||
-- ,ROUND(o.units * (a.price_increment/o.r_rate),2) value_loc
|
||||
-- ,ROUND(o.units * a.price_increment,2) value_usd
|
||||
-- ,0::numeric cost_loc
|
||||
-- ,0::numeric cost_usd
|
||||
-- ,o.calc_status --0
|
||||
-- ,o.flag --0
|
||||
-- ,o.order_date --history date mix
|
||||
-- ,o.order_month
|
||||
-- ,o.order_season
|
||||
-- ,o.request_date --history date mix
|
||||
-- ,o.request_month
|
||||
-- ,o.request_season
|
||||
-- ,o.ship_date --history date mix
|
||||
-- ,o.ship_month
|
||||
-- ,o.ship_season
|
||||
-- ,o.version
|
||||
-- ---this iteration has to be listed in the master template file in order to be effectively included---
|
||||
-- ,'upload price' iter
|
||||
-- ,log.id
|
||||
-- ,COALESCE(log.doc->>'tag','') "tag"
|
||||
-- ,log.doc->>'message' "comment"
|
||||
-- ,log.doc->>'type' module
|
||||
-- -----------debug columns---------
|
||||
-- --,value_usd/units price
|
||||
-- --,a.py_gasp
|
||||
-- --,a.rate
|
||||
-- --,a.last_price
|
||||
-- --,a.price_increment
|
||||
--FROM
|
||||
-- rlarp.osm_pool o
|
||||
-- ,rlarp.itemmv i
|
||||
-- ,adj a
|
||||
-- ,log
|
||||
--WHERE
|
||||
-- i.item = o.part
|
||||
-- AND a.product = i.stlc||'.'||i.colgrp||substring(i.sizc,1,3)
|
||||
-- AND a.account = o.billto_group
|
||||
-- AND a.shipgrp = o.shipto_group
|
||||
-- AND a.price_increment <> 0
|
||||
-- AND o.units <> 0
|
||||
-- ---only apply to 2022 orders----
|
||||
-- AND o.order_date >= '2021-06-01'
|
||||
-- --only include baseline stuff---
|
||||
-- AND iter <> 'upload price'
|
||||
--)
|
||||
-------------aggregate the impact------------
|
||||
----SELECT * FROM ins limit 10000
|
||||
----SELECT
|
||||
---- order_season
|
||||
---- ,sum(value_loc) val_loc
|
||||
---- ,sum(value_usd) val_usd
|
||||
----FROM
|
||||
---- ins
|
||||
----GROUP BY
|
||||
---- order_season;
|
||||
--,del AS (
|
||||
-- DELETE FROM rlarp.osm_pool WHERE iter = 'upload price' RETURNING *
|
||||
--)
|
||||
--INSERT INTO
|
||||
-- rlarp.osm_pool
|
||||
--SELECT * FROM ins;
|
||||
--
|
||||
--COMMIT;
|
||||
|
25
over_under_ship.sql
Normal file
25
over_under_ship.sql
Normal file
@ -0,0 +1,25 @@
|
||||
SELECT
|
||||
calc_status
|
||||
,flag
|
||||
,sum(fb_val_loc * r_rate) filter (WHERE version = 'ACTUALS' AND calc_status = 'CLOSED' AND flag = 'REMAINDER' AND fb_qty < 0) overship
|
||||
,sum(fb_val_loc * r_rate) filter (WHERE version = 'ACTUALS' AND calc_status = 'CLOSED' AND flag = 'REMAINDER' AND fb_qty > 0) undership
|
||||
,sum(fb_val_loc * r_rate) filter (WHERE version = 'ACTUALS' AND fb_qty = 0) no_units
|
||||
,sum(fb_val_loc * r_rate) filter (WHERE version = 'ACTUALS' AND dhincr = 'C') credits
|
||||
,sum(fb_val_loc * r_rate) filter (WHERE version = 'ACTUALS' AND "ddord#" = 0 ) no_units
|
||||
FROM
|
||||
rlarp.osmf_dev
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
oseas = 2021
|
||||
AND odate <@ daterange('2020-06-01','2021-04-11')
|
||||
)
|
||||
OR sseas = 2021
|
||||
)
|
||||
AND fs_line = '41010'
|
||||
--AND version = 'ACTUALS'
|
||||
--AND calc_status = 'CLOSED'
|
||||
--AND flag = 'REMAINDER'
|
||||
GROUP BY
|
||||
calc_status,
|
||||
flag;
|
@ -323,14 +323,14 @@ SELECT
|
||||
,b.cost_usd*s.factor*m.momix cost_usd
|
||||
,b.calc_status
|
||||
,b.flag
|
||||
,make_date(mseq.yr + 2021,mseq.cal,m.odom) order_date
|
||||
,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom),'Mon') order_month
|
||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date
|
||||
,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom),'Mon') order_month
|
||||
,od.ssyr order_season
|
||||
,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag request_date
|
||||
,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag request_date
|
||||
,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag,'Mon') request_month
|
||||
,rd.ssyr request_season
|
||||
,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag ship_date
|
||||
,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag ship_date
|
||||
,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
|
||||
,sd.ssyr ship_season
|
||||
,'replace_version' "version"
|
||||
,'replace_source'||' volume' iter
|
||||
@ -347,11 +347,11 @@ FROM
|
||||
LEFT OUTER JOIN mseq ON
|
||||
mseq.m = closest.m
|
||||
LEFT OUTER JOIN gld od ON
|
||||
make_date(mseq.yr + 2021,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
|
||||
make_date(mseq.yr + 2022,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
|
||||
LEFT OUTER JOIN gld rd ON
|
||||
make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
||||
make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = (SELECT _month FROM closest)
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ FROM
|
||||
LEFT OUTER JOIN rlarp.osm_log ON
|
||||
id = logid
|
||||
WHERE
|
||||
order_season = 2021
|
||||
order_season = 2022
|
||||
GROUP BY
|
||||
director
|
||||
,quota_rep_descr
|
||||
|
@ -15,7 +15,7 @@ from
|
||||
id = logid
|
||||
WHERE
|
||||
quota_rep_descr = 'replace_user'
|
||||
AND tag <> 'Initial Build'
|
||||
AND tag NOT IN ('Initial Build','last price')
|
||||
group BY
|
||||
ol.doc->>'user'
|
||||
,quota_rep_descr
|
||||
|
@ -53,7 +53,8 @@ target AS (select $$replace_request$$::json def)
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1CU','Retail'),
|
||||
('1SU','Sustainable'),
|
||||
('1CU','Sustainable'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
@ -245,18 +246,18 @@ SELECT
|
||||
,mxm.r_currency
|
||||
,jr.bill_cust_descr
|
||||
,jr.ship_cust_descr
|
||||
,(regexp_match(jr.part_descr,'(.*?)(?= - |$)'))[1] part
|
||||
,rtrim((regexp_match(jr.part_descr,'(.*?)(?= - |$)'))[1]) part
|
||||
,jr.part_descr
|
||||
,substring(jr.part_descr,1,8) part_group
|
||||
,mxm.qty*mxm.momix*jr.mix units
|
||||
,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD
|
||||
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) order_date
|
||||
,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) order_date
|
||||
,od.sortmo order_month
|
||||
,od.ssyr order_season
|
||||
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag request_date
|
||||
,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag request_date
|
||||
,rd.sortmo request_month
|
||||
,rd.ssyr request_season
|
||||
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag ship_date
|
||||
,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag ship_date
|
||||
,sd.sortmo ship_month
|
||||
,sd.ssyr ship_season
|
||||
,jr.mix
|
||||
@ -266,11 +267,11 @@ SELECT
|
||||
JOIN LATERAL json_to_record(ae.e) as jr(part_descr text, bill_cust_descr text, ship_cust_descr text, mix numeric) ON true
|
||||
CROSS JOIN mxm
|
||||
LEFT OUTER JOIN gld od ON
|
||||
od.drange @> make_date(mxm.yr + 2021,mxm.cal,mxm.odom)
|
||||
od.drange @> make_date(mxm.yr + 2022,mxm.cal,mxm.odom)
|
||||
LEFT OUTER JOIN gld rd ON
|
||||
rd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag)
|
||||
rd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag)
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
sd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag)
|
||||
sd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag)
|
||||
)
|
||||
--SELECT * FROM basemix
|
||||
,log AS (
|
||||
|
@ -88,7 +88,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
WHERE
|
||||
-----------------scenario----------------------------
|
||||
where_clause
|
||||
AND ship_season = 2021
|
||||
AND ship_season = 2022
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
WHEN 'scale all' THEN true
|
||||
|
@ -36,7 +36,7 @@ FROM
|
||||
rlarp.osm_pool
|
||||
WHERE
|
||||
where_clause
|
||||
AND order_season IN (2020,2021)
|
||||
AND order_season IN (2021,2022)
|
||||
GROUP BY
|
||||
order_season
|
||||
,order_month
|
||||
@ -94,14 +94,14 @@ GROUP BY
|
||||
SELECT
|
||||
order_month
|
||||
,seq
|
||||
,SUM(units) FILTER (WHERE order_season = 2020) "2020 qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021 AND iter IN ('copy','short ship','bad_ship')) "2021 base qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021 AND iter NOT IN ('copy','short ship','bad_ship')) "2021 adj qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021) "2021 tot qty"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2020) "2020 value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter IN ('copy','short ship','bad_ship')) "2021 base value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter NOT IN ('copy','short ship','bad_ship')) "2021 adj value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 tot value_usd"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021) "2021 qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship')) "2022 base qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship')) "2022 adj qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2022) "2022 tot qty"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship')) "2022 base value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship')) "2022 adj value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd"
|
||||
FROM
|
||||
months
|
||||
GROUP BY
|
||||
@ -113,14 +113,14 @@ GROUP BY
|
||||
,mlist AS (
|
||||
SELECT
|
||||
mseq.m order_month
|
||||
,"2020 qty"
|
||||
,"2021 base qty"
|
||||
,"2021 adj qty"
|
||||
,"2021 tot qty"
|
||||
,"2020 value_usd"
|
||||
,"2021 base value_usd"
|
||||
,"2021 adj value_usd"
|
||||
,"2021 tot value_usd"
|
||||
,"2021 qty"
|
||||
,"2022 base qty"
|
||||
,"2022 adj qty"
|
||||
,"2022 tot qty"
|
||||
,"2021 value_usd"
|
||||
,"2022 base value_usd"
|
||||
,"2022 adj value_usd"
|
||||
,"2022 tot value_usd"
|
||||
FROM
|
||||
mseq
|
||||
LEFT OUTER JOIN mpvt ON
|
||||
|
311
route_sql/swap_cust.sql
Normal file
311
route_sql/swap_cust.sql
Normal file
@ -0,0 +1,311 @@
|
||||
WITH
|
||||
target AS (SELECT $$swap_doc$$::jsonb swap)
|
||||
,swap AS (
|
||||
SELECT
|
||||
rtrim(substring(bill,1,8)) billto
|
||||
,rtrim(substring(bill_r,1,8)) bill_r
|
||||
,rtrim(substring(ship,1,8)) shipto
|
||||
,rtrim(substring(ship_r,1,8)) ship_r
|
||||
FROM
|
||||
TARGET
|
||||
LEFT JOIN LATERAL jsonb_to_recordset(target.swap->'rows') AS x(bill text, bill_r text, ship text, ship_r text)ON TRUE
|
||||
WHERE
|
||||
rtrim(substring(bill_r,1,8)) IS NOT null
|
||||
OR rtrim(substring(ship_r,1,8)) IS NOT null
|
||||
)
|
||||
,cust AS (
|
||||
----------only return dba if being replaced-------------------------------------------------
|
||||
----------class and rep must always bew returned for both to determine new quota rep--------
|
||||
SELECT
|
||||
billto
|
||||
,bill_r
|
||||
,CASE WHEN bill_r IS NULL THEN NULL::text ELSE bc.bvadr6 END bill_dba
|
||||
,bc.bvclas bill_class
|
||||
,bc.bvsalm bill_rep
|
||||
,shipto
|
||||
,ship_r
|
||||
,CASE WHEN ship_r IS NULL THEN NULL::text ELSE sc.bvadr6 END ship_dba
|
||||
,sc.bvclas ship_class
|
||||
,sc.bvsalm ship_rep
|
||||
FROM
|
||||
swap
|
||||
----default to the replacement customer but join to original otherwise since still neeed
|
||||
----customer info for revised quote rep
|
||||
LEFT OUTER JOIN lgdat.cust bc ON
|
||||
bc.bvcust = COALESCE(swap.bill_r,billto)
|
||||
LEFT OUTER JOIN lgdat.cust sc ON
|
||||
sc.bvcust = COALESCE(swap.ship_r,shipto)
|
||||
)
|
||||
--put bill to and ship to back together and join in channel, terms, descriptions, etc
|
||||
,seg AS (
|
||||
SELECT
|
||||
x.glec
|
||||
,x.segm
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1SU','Sustainable'),
|
||||
('1CU','Sustainable'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
('2WI','Greenhouse'),
|
||||
('3BM','Other'),
|
||||
('3CO','Other'),
|
||||
('3PE','Other'),
|
||||
('3PP','Other'),
|
||||
('4CO','Other'),
|
||||
('4RA','Other'),
|
||||
('9MI','Other'),
|
||||
('9SA','Other'),
|
||||
('9TO','Other')
|
||||
) x(glec, segm)
|
||||
)
|
||||
,log AS (
|
||||
INSERT INTO rlarp.osm_log(doc) SELECT $$replace_iterdef$$::jsonb doc RETURNING *
|
||||
)
|
||||
,remove AS (
|
||||
SELECT
|
||||
fspr
|
||||
,plnt ---master data
|
||||
,promo --history date mix
|
||||
,terms
|
||||
,bill_cust_descr --history cust mix
|
||||
,ship_cust_descr --history cust mix
|
||||
,dsm
|
||||
,quota_rep_descr --master data
|
||||
,director
|
||||
,billto_group --master data
|
||||
,shipto_group
|
||||
,chan --master data
|
||||
,chansub
|
||||
,chan_retail
|
||||
,part
|
||||
,part_descr
|
||||
,part_group
|
||||
,branding
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
,segm
|
||||
,substance
|
||||
,fs_line --master data
|
||||
,r_currency --history cust mix
|
||||
,r_rate --master data
|
||||
,c_currency --master data
|
||||
,c_rate --master data
|
||||
,-units units
|
||||
,-value_loc value_loc
|
||||
,-value_usd value_usd
|
||||
,-cost_loc cost_loc
|
||||
,-cost_usd cost_usd
|
||||
,calc_status --0
|
||||
,flag --0
|
||||
,order_date --history date mix
|
||||
,order_month
|
||||
,order_season
|
||||
,request_date --history date mix
|
||||
,request_month
|
||||
,request_season
|
||||
,ship_date --history date mix
|
||||
,ship_month
|
||||
,ship_season
|
||||
,'replace_version' "version"
|
||||
,'replace_source'||' volume' iter
|
||||
,log.id
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
FROM
|
||||
rlarp.osm_pool o
|
||||
CROSS JOIN log
|
||||
INNER JOIN cust c ON
|
||||
c.billto = SUBSTRING(o.bill_cust_descr,1,8)
|
||||
AND c.shipto = SUBSTRING(o.ship_cust_descr,1,8)
|
||||
WHERE
|
||||
-----------------scenario----------------------------
|
||||
where_clause
|
||||
)
|
||||
,repl AS (
|
||||
SELECT
|
||||
o.fspr
|
||||
,o.plnt ---master data
|
||||
,o.promo --history date mix
|
||||
,o.terms
|
||||
,COALESCE(c.bill_r||' - '||c.bill_dba,o.bill_cust_descr) bill_cust_descr
|
||||
,COALESCE(c.ship_r||' - '||c.ship_dba,o.ship_cust_descr) ship_cust_descr
|
||||
,o.dsm
|
||||
,(regexp_match(r.repp,'.* - (.*)$'))[1] quota_rep_descr
|
||||
,r.director
|
||||
,COALESCE(c.bill_dba,o.billto_group) billto_group
|
||||
,COALESCE(c.ship_dba,o.shipto_group) shipto_group
|
||||
,CASE SUBSTRING(c.bill_class,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 SUBSTRING(c.ship_class,2,3)
|
||||
WHEN 'DIS' THEN 'WHS'
|
||||
ELSE 'DRP'
|
||||
END
|
||||
--CASE WHEN RTRIM(SUBSTRING(LTRIM(SC.BVADR7)||SC.BVNAME,1,30)) = RTRIM(SUBSTRING(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 chan
|
||||
,CASE SUBSTRING(c.bill_class,2,3)
|
||||
WHEN 'DIS' THEN
|
||||
--if the ship-to is a different name than the bill-to then it's drop, otherwise it's warehouse
|
||||
CASE SUBSTRING(c.ship_class,2,3)
|
||||
WHEN 'DIS' THEN 'WHS'
|
||||
ELSE CASE SUBSTRING(c.ship_class,1,1) WHEN 'R' THEN 'RDP' ELSE 'DRP' END
|
||||
END
|
||||
WHEN 'MAS' THEN 'RMN'
|
||||
WHEN 'NAT' THEN 'RMN'
|
||||
ELSE CASE SUBSTRING(c.ship_class,1,1) WHEN 'R' THEN 'RDI' ELSE 'DIR' END
|
||||
END chansub
|
||||
,o.chan_retail
|
||||
,o.part
|
||||
,o.part_descr
|
||||
,o.part_group
|
||||
,o.branding
|
||||
,o.majg_descr
|
||||
,o.ming_descr
|
||||
,o.majs_descr
|
||||
,o.mins_descr
|
||||
,o.segm
|
||||
,o.substance
|
||||
,o.fs_line --master data
|
||||
,o.r_currency --history cust mix
|
||||
,o.r_rate --master data
|
||||
,o.c_currency --master data
|
||||
,o.c_rate --master data
|
||||
,-o.units units
|
||||
,-o.value_loc value_loc
|
||||
,-o.value_usd value_usd
|
||||
,-o.cost_loc cost_loc
|
||||
,-o.cost_usd cost_usd
|
||||
,o.calc_status --0
|
||||
,o.flag --0
|
||||
,o.order_date --history date mix
|
||||
,o.order_month
|
||||
,o.order_season
|
||||
,o.request_date --history date mix
|
||||
,o.request_month
|
||||
,o.request_season
|
||||
,o.ship_date --history date mix
|
||||
,o.ship_month
|
||||
,o.ship_season
|
||||
,o."version"
|
||||
,o.iter
|
||||
,o.id
|
||||
,o."tag"
|
||||
,o."comment"
|
||||
,o.module
|
||||
FROM
|
||||
remove o
|
||||
INNER JOIN cust c ON
|
||||
c.billto = SUBSTRING(o.bill_cust_descr,1,8)
|
||||
AND c.shipto = SUBSTRING(o.ship_cust_descr,1,8)
|
||||
LEFT OUTER JOIN rlarp.repc r ON
|
||||
r.rcode = CASE WHEN COALESCE(substring(ming_descr,1,3),'') = 'B52' THEN 'PW' ELSE
|
||||
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
|
||||
CASE WHEN COALESCE(o.segm,'') = 'Retail' AND COALESCE((SELECT currep FROM lgpgm.usrcust where cucust = c.bill_r),'') <> ''
|
||||
THEN
|
||||
(SELECT currep FROM lgpgm.usrcust where cucust = c.bill_r)
|
||||
--default logic
|
||||
ELSE
|
||||
CASE SUBSTR(c.bill_class,2,3)
|
||||
WHEN 'DIS' THEN c.ship_rep
|
||||
ELSE c.bill_rep
|
||||
END
|
||||
END
|
||||
END
|
||||
)
|
||||
--select bill_cust_descr, ship_cust_descr, sum(value_usd) from (SELECT * FROM remove UNION ALL SELECT * FROM repl) x group by bill_cust_descr, ship_cust_descr
|
||||
,ins AS (
|
||||
INSERT INTO rlarp.osm_pool SELECT * FROM remove UNION ALL SELECT * FROM repl RETURNING *
|
||||
)
|
||||
,insagg AS (
|
||||
SELECT
|
||||
---------customer info-----------------
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director
|
||||
,segm
|
||||
,substance
|
||||
,chan
|
||||
,chansub
|
||||
---------product info------------------
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
--,brand
|
||||
--,part_family
|
||||
,part_group
|
||||
,branding
|
||||
--,color
|
||||
,part_descr
|
||||
---------dates-------------------------
|
||||
,order_season
|
||||
,order_month
|
||||
,ship_season
|
||||
,ship_month
|
||||
,request_season
|
||||
,request_month
|
||||
,promo
|
||||
,version
|
||||
,iter
|
||||
,logid
|
||||
,tag
|
||||
,comment
|
||||
--------values-------------------------
|
||||
,sum(value_loc) value_loc
|
||||
,sum(value_usd) value_usd
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
FROM
|
||||
ins
|
||||
GROUP BY
|
||||
---------customer info-----------------
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director
|
||||
,segm
|
||||
,substance
|
||||
,chan
|
||||
,chansub
|
||||
---------product info------------------
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
--,brand
|
||||
--,part_family
|
||||
,part_group
|
||||
,branding
|
||||
--,color
|
||||
,part_descr
|
||||
---------dates-------------------------
|
||||
,order_season
|
||||
,order_month
|
||||
,ship_season
|
||||
,ship_month
|
||||
,request_season
|
||||
,request_month
|
||||
,promo
|
||||
,version
|
||||
,iter
|
||||
,logid
|
||||
,tag
|
||||
,comment
|
||||
)
|
||||
SELECT json_agg(row_to_json(insagg)) x from insagg
|
||||
|
@ -2,7 +2,11 @@ WITH
|
||||
target AS (SELECT $$swap_doc$$::jsonb swap)
|
||||
,pl AS (
|
||||
SELECT
|
||||
x.*
|
||||
-----trim white space on CMS part numbers coming from spreadsheet master data----
|
||||
rtrim(x.original) AS original
|
||||
,sales
|
||||
,rtrim(x."replace") AS replace
|
||||
,rtrim(x.fit) fit
|
||||
FROM
|
||||
TARGET
|
||||
LEFT JOIN LATERAL jsonb_to_recordset(target.swap->'rows') AS x(original text, sales numeric, replace text, fit text)ON TRUE
|
||||
@ -17,7 +21,8 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
|
||||
FROM
|
||||
(
|
||||
VALUES
|
||||
('1CU','Retail'),
|
||||
('1CU','Sustainable'),
|
||||
('1SU','Sustainable'),
|
||||
('1GR','Greenhouse'),
|
||||
('1NU','Nursery'),
|
||||
('1RE','Retail'),
|
||||
|
Loading…
Reference in New Issue
Block a user