Compare commits
No commits in common. "a4d34ec83abbc0edd9fb9f83ab392abd6bde56e0" and "fb7fdc7959382be0109474a98d97737554380c40" have entirely different histories.
a4d34ec83a
...
fb7fdc7959
@ -178,10 +178,10 @@ target AS (select incr_qty qincr)
|
||||
,c_currency --master data
|
||||
,c_rate --master data
|
||||
,units*s.factor
|
||||
,value_loc*s.factor value_loc
|
||||
,value_usd*s.factor value_usd
|
||||
,cost_loc*s.factor cost_loc
|
||||
,cost_usd*s.factor cost_usd
|
||||
,value_loc*s.factor
|
||||
,value_usd*s.factor
|
||||
,cost_loc*s.factor
|
||||
,cost_usd*s.factor
|
||||
,calc_status --0
|
||||
,flag --0
|
||||
,order_date --history date mix
|
||||
|
@ -12,7 +12,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
where_clause
|
||||
-----------------additional params-------------------
|
||||
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
|
||||
AND order_date <= ship_date
|
||||
AND adj_orderdate <= adj_shipdate
|
||||
|
||||
)
|
||||
,flagv AS (
|
||||
@ -176,11 +176,11 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
,r_rate --master data
|
||||
,c_currency --master data
|
||||
,c_rate --master data
|
||||
,units*s.factor units
|
||||
,value_loc*s.factor value_loc
|
||||
,value_usd*s.factor value_usd
|
||||
,cost_loc*s.factor cost_loc
|
||||
,cost_usd*s.factor cost_usd
|
||||
,units*s.factor
|
||||
,value_loc*s.factor
|
||||
,value_usd*s.factor
|
||||
,cost_loc*s.factor
|
||||
,cost_usd*s.factor
|
||||
,calc_status --0
|
||||
,flag --0
|
||||
,order_date --history date mix
|
||||
@ -225,6 +225,8 @@ FROM
|
||||
END mod_price
|
||||
)
|
||||
--select * from pscale
|
||||
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric value_loc
|
||||
,(CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc_pl*s.factor END)::numeric value_loc_pl
|
||||
,pricing AS (
|
||||
SELECT
|
||||
fspr
|
||||
@ -288,77 +290,70 @@ FROM
|
||||
INSERT INTO rlarp.osm_pool (SELECT * FROM pricing UNION ALL SELECT * FROM volume) RETURNING *
|
||||
)
|
||||
,insagg AS (
|
||||
SELECT
|
||||
---------customer info-----------------
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director
|
||||
,segm
|
||||
,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
|
||||
--------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
|
||||
,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
|
||||
SELECT
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director_descr
|
||||
,segm
|
||||
,mod_chan
|
||||
,mod_chansub
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
,brand
|
||||
,part_family
|
||||
,part_group
|
||||
,branding
|
||||
,color
|
||||
,part_descr
|
||||
,order_season
|
||||
,order_month
|
||||
,ship_season
|
||||
,ship_month
|
||||
,request_season
|
||||
,request_month
|
||||
,promo
|
||||
,version
|
||||
,iter
|
||||
,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
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director_descr
|
||||
,segm
|
||||
,mod_chan
|
||||
,mod_chansub
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
,brand
|
||||
,part_family
|
||||
,part_group
|
||||
,branding
|
||||
,color
|
||||
,part_descr
|
||||
,order_season
|
||||
,order_month
|
||||
,ship_season
|
||||
,ship_month
|
||||
,request_season
|
||||
,request_month
|
||||
,promo
|
||||
,version
|
||||
,iter
|
||||
)
|
||||
SELECT json_agg(row_to_json(insagg)) x from insagg
|
||||
|
Loading…
Reference in New Issue
Block a user