diff --git a/offline/last_price.sql b/offline/last_price.sql index b16f0b0..88582b9 100644 --- a/offline/last_price.sql +++ b/offline/last_price.sql @@ -397,7 +397,8 @@ GROUP BY ,SUM(o.units) units ,SUM(o.value_loc) value_loc ,SUM(o.value_usd) value_usd - ,SUM(o.value_loc)/SUM(o.units) price_loc + -----exclude any prior pricing adjustments from the "current" price in the forecast------ + ,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_usd) cost_usd ,o.calc_status --0 @@ -498,6 +499,7 @@ SELECT ,0::numeric units ,greatest( round(least( + ----cap pricing at global ASP or target--- least( COALESCE(a.py_asp,o.price_loc), COALESCE(a.py_gasp,a.target) @@ -508,6 +510,7 @@ SELECT ,greatest( round((least( least( + -----price loc needs to be prior to any other pricing adjustments----- COALESCE(a.py_asp,o.price_loc), COALESCE(a.py_gasp,a.target) ) * (1 + a.rate), @@ -554,12 +557,6 @@ SELECT ,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 collapse o --need to join to itemm to get the product from osm_pool @@ -585,6 +582,7 @@ 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; +--SELECT * FROM ins WHERE shipto_group = 'A&W ANNUALS' and part = 'TWA10200G18B027'; -----------aggregate the impact------------ -COMMIT; +--COMMIT;