Compare commits
No commits in common. "8bdcd5cc3ed972c5a30c8fad20ec54c56cefed73" and "d129e5d0f6dc083434e6f2d5af449f175c5d7c6c" have entirely different histories.
8bdcd5cc3e
...
d129e5d0f6
@ -1,51 +1,51 @@
|
|||||||
--BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
WITH
|
WITH
|
||||||
------------------goal price increases---------------------
|
------------------goal price increases---------------------
|
||||||
incr AS (
|
incr AS (
|
||||||
SELECT * FROM (VALUES
|
SELECT * FROM (VALUES
|
||||||
('110','PP','B',0.35),
|
('110','PP','B',0.3),
|
||||||
('110','PP','T',0.35),
|
('110','PP','T',0.3),
|
||||||
('110','PP','L',0.45),
|
('110','PP','L',0.4),
|
||||||
('110','PP','M',0.45),
|
('110','PP','M',0.4),
|
||||||
('110','PP','P',0.45),
|
('110','PP','P',0.4),
|
||||||
('110','PP','C',0.45),
|
('110','PP','C',0.4),
|
||||||
('210','PE','B',0.4),
|
('210','PE','B',0.3),
|
||||||
('210','PE','T',0.4),
|
('210','PE','T',0.3),
|
||||||
('210','PE','L',0.4),
|
('210','PE','L',0.3),
|
||||||
('210','PE','M',0.4),
|
('210','PE','M',0.3),
|
||||||
('210','PE','P',0.4),
|
('210','PE','P',0.3),
|
||||||
('210','PE','C',0.4),
|
('210','PE','C',0.3),
|
||||||
('310','PE','B',0.3),
|
('310','PE','B',0.25),
|
||||||
('310','PE','T',0.35),
|
('310','PE','T',0.3),
|
||||||
('310','PE','L',0.35),
|
('310','PE','L',0.3),
|
||||||
('310','PE','M',0.35),
|
('310','PE','M',0.3),
|
||||||
('310','PE','P',0.35),
|
('310','PE','P',0.3),
|
||||||
('310','PE','C',0.35),
|
('310','PE','C',0.3),
|
||||||
('310','PP','B',0.3),
|
('310','PP','B',0.25),
|
||||||
('310','PP','T',0.3),
|
('310','PP','T',0.25),
|
||||||
('310','PP','L',0.3),
|
('310','PP','L',0.25),
|
||||||
('310','PP','M',0.3),
|
('310','PP','M',0.25),
|
||||||
('310','PP','P',0.3),
|
('310','PP','P',0.25),
|
||||||
('310','PP','C',0.3),
|
('310','PP','C',0.25),
|
||||||
('310','PS','B',0.3),
|
('310','PS','B',0.25),
|
||||||
('310','PS','T',0.3),
|
('310','PS','T',0.25),
|
||||||
('310','PS','L',0.3),
|
('310','PS','L',0.25),
|
||||||
('310','PS','M',0.3),
|
('310','PS','M',0.25),
|
||||||
('310','PS','P',0.3),
|
('310','PS','P',0.25),
|
||||||
('310','PS','C',0.3),
|
('310','PS','C',0.25),
|
||||||
('320','PE','B',0.3),
|
('320','PE','B',0.25),
|
||||||
('320','PE','T',0.3),
|
('320','PE','T',0.25),
|
||||||
('320','PE','L',0.3),
|
('320','PE','L',0.25),
|
||||||
('320','PE','M',0.3),
|
('320','PE','M',0.25),
|
||||||
('320','PE','P',0.3),
|
('320','PE','P',0.25),
|
||||||
('320','PE','C',0.3),
|
('320','PE','C',0.25),
|
||||||
('320','PP','B',0.3),
|
('320','PP','B',0.25),
|
||||||
('320','PP','T',0.3),
|
('320','PP','T',0.25),
|
||||||
('320','PP','L',0.3),
|
('320','PP','L',0.25),
|
||||||
('320','PP','M',0.3),
|
('320','PP','M',0.25),
|
||||||
('320','PP','P',0.3),
|
('320','PP','P',0.25),
|
||||||
('320','PP','C',0.3),
|
('320','PP','C',0.25),
|
||||||
('910','PE','B',0.25),
|
('910','PE','B',0.25),
|
||||||
('910','PE','D',0.25),
|
('910','PE','D',0.25),
|
||||||
('910','PE','F',0.25),
|
('910','PE','F',0.25),
|
||||||
@ -55,14 +55,6 @@ incr AS (
|
|||||||
('910','PS','B',0.25),
|
('910','PS','B',0.25),
|
||||||
('910','PS','D',0.25),
|
('910','PS','D',0.25),
|
||||||
('910','PS','F',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','','B',0.02),
|
||||||
('610','','S',0.02),
|
('610','','S',0.02),
|
||||||
('610','','W',0.02)
|
('610','','W',0.02)
|
||||||
@ -276,15 +268,14 @@ SELECT
|
|||||||
ELSE CASE p.majg
|
ELSE CASE p.majg
|
||||||
WHEN '610' THEN .02
|
WHEN '610' THEN .02
|
||||||
ElSE CASE p.colgrp
|
ElSE CASE p.colgrp
|
||||||
WHEN 'B' THEN .20
|
WHEN 'B' THEN .15
|
||||||
WHEN 'C' THEN .25
|
WHEN 'C' THEN .20
|
||||||
ELSE 1
|
ELSE 1
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
END rate
|
END rate
|
||||||
,ms.avg_price target
|
,ms.avg_price target
|
||||||
----------------potential price list increase of 5% across board-----
|
,JSONB_AGG(DISTINCT plist.jcpric/1000) jcprice
|
||||||
,JSONB_AGG(DISTINCT (plist.jcpric*1.05)/1000) jcprice
|
|
||||||
--,CASE WHEN sum(val_usd) FILTER (WHERE oseas = 2020) IS NULL
|
--,CASE WHEN sum(val_usd) FILTER (WHERE oseas = 2020) IS NULL
|
||||||
-- THEN CASE WHEN sum(units) FILTER (WHERE oseas = 2021) IS NULL
|
-- THEN CASE WHEN sum(units) FILTER (WHERE oseas = 2021) IS NULL
|
||||||
-- THEN 'unknown'
|
-- THEN 'unknown'
|
||||||
@ -356,7 +347,7 @@ GROUP BY
|
|||||||
SELECT
|
SELECT
|
||||||
$${
|
$${
|
||||||
"message":"application of last price and target increases to all forecast orders",
|
"message":"application of last price and target increases to all forecast orders",
|
||||||
"tag":"last price r1",
|
"tag":"last price",
|
||||||
"type":"build"
|
"type":"build"
|
||||||
}$$::jsonb doc
|
}$$::jsonb doc
|
||||||
RETURNING *
|
RETURNING *
|
||||||
@ -397,8 +388,7 @@ GROUP BY
|
|||||||
,SUM(o.units) units
|
,SUM(o.units) units
|
||||||
,SUM(o.value_loc) value_loc
|
,SUM(o.value_loc) value_loc
|
||||||
,SUM(o.value_usd) value_usd
|
,SUM(o.value_usd) value_usd
|
||||||
-----exclude any prior pricing adjustments from the "current" price in the forecast------
|
,SUM(o.value_loc)/SUM(o.units) price_loc
|
||||||
,SUM(o.value_loc) FILTER (WHERE iter <> 'upload price')/SUM(o.units) FILTER (WHERE iter <> 'upload price') price_loc
|
|
||||||
,SUM(o.cost_loc) cost_loc
|
,SUM(o.cost_loc) cost_loc
|
||||||
,SUM(o.cost_usd) cost_usd
|
,SUM(o.cost_usd) cost_usd
|
||||||
,o.calc_status --0
|
,o.calc_status --0
|
||||||
@ -499,7 +489,6 @@ SELECT
|
|||||||
,0::numeric units
|
,0::numeric units
|
||||||
,greatest(
|
,greatest(
|
||||||
round(least(
|
round(least(
|
||||||
----cap pricing at global ASP or target---
|
|
||||||
least(
|
least(
|
||||||
COALESCE(a.py_asp,o.price_loc),
|
COALESCE(a.py_asp,o.price_loc),
|
||||||
COALESCE(a.py_gasp,a.target)
|
COALESCE(a.py_gasp,a.target)
|
||||||
@ -510,7 +499,6 @@ SELECT
|
|||||||
,greatest(
|
,greatest(
|
||||||
round((least(
|
round((least(
|
||||||
least(
|
least(
|
||||||
-----price loc needs to be prior to any other pricing adjustments-----
|
|
||||||
COALESCE(a.py_asp,o.price_loc),
|
COALESCE(a.py_asp,o.price_loc),
|
||||||
COALESCE(a.py_gasp,a.target)
|
COALESCE(a.py_gasp,a.target)
|
||||||
) * (1 + a.rate),
|
) * (1 + a.rate),
|
||||||
@ -557,6 +545,12 @@ SELECT
|
|||||||
,COALESCE(log.doc->>'tag','') "tag"
|
,COALESCE(log.doc->>'tag','') "tag"
|
||||||
,log.doc->>'message' "comment"
|
,log.doc->>'message' "comment"
|
||||||
,log.doc->>'type' module
|
,log.doc->>'type' module
|
||||||
|
-----------debug columns---------
|
||||||
|
--,value_usd/units price
|
||||||
|
--,a.py_gasp
|
||||||
|
--,a.rate
|
||||||
|
--,a.last_price
|
||||||
|
--,a.price_increment
|
||||||
FROM
|
FROM
|
||||||
collapse o
|
collapse o
|
||||||
--need to join to itemm to get the product from osm_pool
|
--need to join to itemm to get the product from osm_pool
|
||||||
@ -582,7 +576,6 @@ WHERE
|
|||||||
)
|
)
|
||||||
--SELECT order_season, order_month, sum(value_usd) from ins group by order_season, order_month;
|
--SELECT order_season, order_month, sum(value_usd) from ins group by order_season, order_month;
|
||||||
INSERT INTO rlarp.osm_pool SELECT * FROM ins;
|
INSERT INTO rlarp.osm_pool SELECT * FROM ins;
|
||||||
--SELECT * FROM ins WHERE shipto_group = 'A&W ANNUALS' and part = 'TWA10200G18B027';
|
|
||||||
-----------aggregate the impact------------
|
-----------aggregate the impact------------
|
||||||
|
|
||||||
--COMMIT;
|
COMMIT;
|
||||||
|
Loading…
Reference in New Issue
Block a user