align rate column
This commit is contained in:
parent
f548780d9f
commit
b32d897b1d
@ -10,42 +10,42 @@ incr AS (
|
||||
('110','PP','M',0.45),
|
||||
('110','PP','P',0.45),
|
||||
('110','PP','C',0.45),
|
||||
('210','PE','B',0.4),
|
||||
('210','PE','T',0.4),
|
||||
('210','PE','L',0.4),
|
||||
('210','PE','M',0.4),
|
||||
('210','PE','P',0.4),
|
||||
('210','PE','C',0.4),
|
||||
('310','PE','B',0.3),
|
||||
('210','PE','B',0.40),
|
||||
('210','PE','T',0.40),
|
||||
('210','PE','L',0.40),
|
||||
('210','PE','M',0.40),
|
||||
('210','PE','P',0.40),
|
||||
('210','PE','C',0.40),
|
||||
('310','PE','B',0.30),
|
||||
('310','PE','T',0.35),
|
||||
('310','PE','L',0.35),
|
||||
('310','PE','M',0.35),
|
||||
('310','PE','P',0.35),
|
||||
('310','PE','C',0.35),
|
||||
('310','PP','B',0.3),
|
||||
('310','PP','T',0.3),
|
||||
('310','PP','L',0.3),
|
||||
('310','PP','M',0.3),
|
||||
('310','PP','P',0.3),
|
||||
('310','PP','C',0.3),
|
||||
('310','PS','B',0.3),
|
||||
('310','PS','T',0.3),
|
||||
('310','PS','L',0.3),
|
||||
('310','PS','M',0.3),
|
||||
('310','PS','P',0.3),
|
||||
('310','PS','C',0.3),
|
||||
('320','PE','B',0.3),
|
||||
('320','PE','T',0.3),
|
||||
('320','PE','L',0.3),
|
||||
('320','PE','M',0.3),
|
||||
('320','PE','P',0.3),
|
||||
('320','PE','C',0.3),
|
||||
('320','PP','B',0.3),
|
||||
('320','PP','T',0.3),
|
||||
('320','PP','L',0.3),
|
||||
('320','PP','M',0.3),
|
||||
('320','PP','P',0.3),
|
||||
('320','PP','C',0.3),
|
||||
('310','PP','B',0.30),
|
||||
('310','PP','T',0.30),
|
||||
('310','PP','L',0.30),
|
||||
('310','PP','M',0.30),
|
||||
('310','PP','P',0.30),
|
||||
('310','PP','C',0.30),
|
||||
('310','PS','B',0.30),
|
||||
('310','PS','T',0.30),
|
||||
('310','PS','L',0.30),
|
||||
('310','PS','M',0.30),
|
||||
('310','PS','P',0.30),
|
||||
('310','PS','C',0.30),
|
||||
('320','PE','B',0.30),
|
||||
('320','PE','T',0.30),
|
||||
('320','PE','L',0.30),
|
||||
('320','PE','M',0.30),
|
||||
('320','PE','P',0.30),
|
||||
('320','PE','C',0.30),
|
||||
('320','PP','B',0.30),
|
||||
('320','PP','T',0.30),
|
||||
('320','PP','L',0.30),
|
||||
('320','PP','M',0.30),
|
||||
('320','PP','P',0.30),
|
||||
('320','PP','C',0.30),
|
||||
('910','PE','B',0.25),
|
||||
('910','PE','D',0.25),
|
||||
('910','PE','F',0.25),
|
||||
@ -55,17 +55,17 @@ incr AS (
|
||||
('910','PS','B',0.25),
|
||||
('910','PS','D',0.25),
|
||||
('910','PS','F',0.25),
|
||||
('910','','B',0.25),
|
||||
('910','','T',0.25),
|
||||
('910','','L',0.25),
|
||||
('910','','M',0.25),
|
||||
('910','','P',0.25),
|
||||
('910','','D',0.25),
|
||||
('910','','F',0.25),
|
||||
('910','','C',0.25),
|
||||
('610','','B',0.02),
|
||||
('610','','S',0.02),
|
||||
('610','','W',0.02)
|
||||
('910', '','B',0.25),
|
||||
('910', '','T',0.25),
|
||||
('910', '','L',0.25),
|
||||
('910', '','M',0.25),
|
||||
('910', '','P',0.25),
|
||||
('910', '','D',0.25),
|
||||
('910', '','F',0.25),
|
||||
('910', '','C',0.25),
|
||||
('610', '','B',0.02),
|
||||
('610', '','S',0.02),
|
||||
('610', '','W',0.02)
|
||||
) x(MAJG,ASSC,COLTIER,RATE)
|
||||
)
|
||||
,chx AS (
|
||||
@ -350,17 +350,17 @@ GROUP BY
|
||||
--)
|
||||
--SELECT * FROM test_unique where cnt > 1
|
||||
----------------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 r1",
|
||||
"type":"build"
|
||||
}$$::jsonb doc
|
||||
RETURNING *
|
||||
)
|
||||
--,log AS (
|
||||
-- INSERT INTO
|
||||
-- rlarp.osm_log(doc)
|
||||
-- SELECT
|
||||
-- $${
|
||||
-- "message":"application of last price and target increases to all forecast orders",
|
||||
-- "tag":"last price r1",
|
||||
-- "type":"build"
|
||||
-- }$$::jsonb doc
|
||||
-- RETURNING *
|
||||
--)
|
||||
---------collapse iterations-----------------------
|
||||
,collapse AS (
|
||||
SELECT
|
||||
@ -518,23 +518,23 @@ SELECT
|
||||
)*o.units - o.value_loc) * r_rate,2)
|
||||
,0) AS value_usd
|
||||
----debug---
|
||||
--,least(
|
||||
-- least(
|
||||
-- COALESCE(a.py_asp,o.price_loc),
|
||||
-- COALESCE(a.py_gasp,a.target)
|
||||
-- ) * (1 + a.rate),
|
||||
-- (a.jcprice->>0)::numeric
|
||||
--) AS rev_price
|
||||
--,o.units
|
||||
--,o.value_loc
|
||||
--,o.value_usd
|
||||
--,o.price_loc
|
||||
--,a.last_price
|
||||
--,a.target
|
||||
--,a.jcprice
|
||||
--,a.rate
|
||||
--,a.py_asp
|
||||
--,a.py_gasp
|
||||
,a.py_asp
|
||||
,a.py_gasp
|
||||
,a.last_price
|
||||
,o.price_loc
|
||||
,a.target
|
||||
,a.jcprice
|
||||
,a.rate
|
||||
,least(
|
||||
least(
|
||||
COALESCE(a.py_asp,o.price_loc),
|
||||
COALESCE(a.py_gasp,a.target)
|
||||
) * (1 + a.rate),
|
||||
(a.jcprice->>0)::numeric
|
||||
) AS rev_price
|
||||
,o.units qorig
|
||||
,o.value_loc vl_orig
|
||||
,o.value_usd vu_orig
|
||||
-----------
|
||||
,0::numeric cost_loc
|
||||
,0::numeric cost_usd
|
||||
@ -553,16 +553,16 @@ SELECT
|
||||
---this iteration has to be listed in the master template file in order to be effectively included---
|
||||
,'b22' AS version
|
||||
,'upload price' iter
|
||||
,log.id
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
--,log.id
|
||||
--,COALESCE(log.doc->>'tag','') "tag"
|
||||
--,log.doc->>'message' "comment"
|
||||
--,log.doc->>'type' module
|
||||
FROM
|
||||
collapse o
|
||||
--need to join to itemm to get the product from osm_pool
|
||||
--,fcp a
|
||||
,pivot a
|
||||
,log
|
||||
--,log
|
||||
WHERE
|
||||
-- a.productt = o.productt
|
||||
--AND a.quota_rep_descr = o.quota_rep_descr
|
||||
@ -579,10 +579,11 @@ WHERE
|
||||
AND a.shipgrp = o.shipto_group
|
||||
AND o.order_date >= '2021-06-01'
|
||||
AND o.segm <> 'Retail'
|
||||
AND o.dsm = 'PW'
|
||||
)
|
||||
--SELECT order_season, order_month, sum(value_usd) from ins group by order_season, order_month;
|
||||
INSERT INTO rlarp.osm_pool SELECT * FROM ins;
|
||||
--SELECT * FROM ins WHERE shipto_group = 'A&W ANNUALS' and part = 'TWA10200G18B027';
|
||||
--INSERT INTO rlarp.osm_pool SELECT * FROM ins;
|
||||
SELECT * FROM ins WHERE shipto_group = 'BATTLEFIELD FARMS' and part = 'XNT0TQT3X56B220PYDKP';
|
||||
-----------aggregate the impact------------
|
||||
|
||||
--COMMIT;
|
||||
|
Loading…
Reference in New Issue
Block a user