get rid of commented out stuff

This commit is contained in:
Paul Trowbridge 2021-05-10 16:06:55 -04:00
parent e376a9df2e
commit e0d32cf4cf

View File

@ -200,76 +200,6 @@ incr AS (
,chgrp
)
--SELECT * FROM baseline WHERE product = 'AMK06000.CBXX'
--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 = 2020) py_units
-- ,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
-- ,i.rate incr_rate
-- ,CASE p.chgrp
-- WHEN 'D' THEN .5
-- ELSE CASE p.majg
-- WHEN '610' THEN .02
-- ElSE CASE p.colgrp
-- WHEN 'B' THEN .15
-- WHEN 'C' THEN .20
-- 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'
--WHERE
-- p.account ~ 'AMERICAN HORT' and p.product = 'AZA06000.CBXX' and p.chgrp = 'W'
--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
----------calculate pricing as it sits in the forecast--------------
,poolprice AS (
SELECT
@ -410,72 +340,6 @@ GROUP BY
-- pivot p
--)
--SELECT * FROM test_unique where cnt > 1
--SELECT * FROM pivot LIMIT 1000
--------------join forecast price-------------------
--,fcp AS (
-- SELECT
-- pp.productt
-- ,pp.product
-- ,pp.majg
-- ,pp.quota_rep_descr
-- ,pp.order_season
-- ,pp.billto_group
-- ,pp.shipto_group
-- ,pp.chgrp
-- ,pp.fc_units
-- ,pp.fc_price
-- ,pp.iters
-- --,p.item
-- ,p.py_gasp
-- ,p.cy_units
-- ,p.py_asp
-- ,p.last_price
-- ,p.last_order
-- ,p.target
-- ,p.rate
-- ,p.jcprice
-- --need to link in targets pricing and price list for cap purposes---------
-- --also need to link regional price lists so we don't blow past those------
-- ,least(
-- least(
-- COALESCE(p.py_asp,p.last_price),
-- COALESCE(py_gasp,target)
-- ) * (1 + p.rate),
-- (jcprice->>0)::numeric
-- ) rev_price
-- ,greatest(
-- least(
-- least(
-- COALESCE(p.py_asp,p.last_price),
-- COALESCE(py_gasp,target)
-- ) * (1 + p.rate),
-- (jcprice->>0)::numeric
-- ) - fc_price
-- ,0
-- ) fc_adj
-- --last season price + % capped at list or py_gasp + %
-- --last price + % capped at list or pg_gasp + %
-- FROM
-- poolprice pp
-- LEFT OUTER JOIN pivot p ON
-- pp.productt = p.productt
-- AND pp.majg = p.majg
-- AND pp.chgrp = p.chgrp
-- AND pp.billto_group = p.account
-- AND pp.shipto_group = p.shipgrp
-- WHERE
-- greatest(
-- least(
-- least(
-- COALESCE(p.py_asp,p.last_price),
-- COALESCE(py_gasp,target)
-- ) * (1 + p.rate),
-- (jcprice->>0)::numeric
-- ) - fc_price
-- ,0
-- ) <> 0
--)
--SELECT * FROM fcp LIMIT 1000
----------------create a log entry--------------------
,log AS (
INSERT INTO
@ -712,20 +576,5 @@ WHERE
--SELECT order_season, order_month, sum(value_usd) from ins group by order_season, order_month;
INSERT INTO rlarp.osm_pool SELECT * FROM ins;
-----------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;