Compare commits

..

No commits in common. "a4d34ec83abbc0edd9fb9f83ab392abd6bde56e0" and "fb7fdc7959382be0109474a98d97737554380c40" have entirely different histories.

2 changed files with 77 additions and 82 deletions

View File

@ -178,10 +178,10 @@ target AS (select incr_qty qincr)
,c_currency --master data ,c_currency --master data
,c_rate --master data ,c_rate --master data
,units*s.factor ,units*s.factor
,value_loc*s.factor value_loc ,value_loc*s.factor
,value_usd*s.factor value_usd ,value_usd*s.factor
,cost_loc*s.factor cost_loc ,cost_loc*s.factor
,cost_usd*s.factor cost_usd ,cost_usd*s.factor
,calc_status --0 ,calc_status --0
,flag --0 ,flag --0
,order_date --history date mix ,order_date --history date mix

View File

@ -12,7 +12,7 @@ target AS (select target_vol vincr, target_prc pincr)
where_clause where_clause
-----------------additional params------------------- -----------------additional params-------------------
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
AND order_date <= ship_date AND adj_orderdate <= adj_shipdate
) )
,flagv AS ( ,flagv AS (
@ -176,11 +176,11 @@ target AS (select target_vol vincr, target_prc pincr)
,r_rate --master data ,r_rate --master data
,c_currency --master data ,c_currency --master data
,c_rate --master data ,c_rate --master data
,units*s.factor units ,units*s.factor
,value_loc*s.factor value_loc ,value_loc*s.factor
,value_usd*s.factor value_usd ,value_usd*s.factor
,cost_loc*s.factor cost_loc ,cost_loc*s.factor
,cost_usd*s.factor cost_usd ,cost_usd*s.factor
,calc_status --0 ,calc_status --0
,flag --0 ,flag --0
,order_date --history date mix ,order_date --history date mix
@ -225,6 +225,8 @@ FROM
END mod_price END mod_price
) )
--select * from pscale --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 ( ,pricing AS (
SELECT SELECT
fspr fspr
@ -288,77 +290,70 @@ FROM
INSERT INTO rlarp.osm_pool (SELECT * FROM pricing UNION ALL SELECT * FROM volume) RETURNING * INSERT INTO rlarp.osm_pool (SELECT * FROM pricing UNION ALL SELECT * FROM volume) RETURNING *
) )
,insagg AS ( ,insagg AS (
SELECT SELECT
---------customer info----------------- bill_cust_descr
bill_cust_descr ,billto_group
,billto_group ,ship_cust_descr
,ship_cust_descr ,shipto_group
,shipto_group ,quota_rep_descr
,quota_rep_descr ,director_descr
,director ,segm
,segm ,mod_chan
,chan ,mod_chansub
,chansub ,majg_descr
---------product info------------------ ,ming_descr
,majg_descr ,majs_descr
,ming_descr ,mins_descr
,majs_descr ,brand
,mins_descr ,part_family
--,brand ,part_group
--,part_family ,branding
,part_group ,color
,branding ,part_descr
--,color ,order_season
,part_descr ,order_month
---------dates------------------------- ,ship_season
,order_season ,ship_month
,order_month ,request_season
,ship_season ,request_month
,ship_month ,promo
,request_season ,version
,request_month ,iter
,promo ,sum(value_loc) value_loc
,version ,sum(value_usd) value_usd
,iter ,sum(cost_loc) cost_loc
--------values------------------------- ,sum(cost_usd) cost_usd
,sum(value_loc) value_loc ,sum(units) units
,sum(value_usd) value_usd FROM
,sum(cost_loc) cost_loc ins
,sum(cost_usd) cost_usd GROUP BY
,sum(units) units bill_cust_descr
FROM ,billto_group
ins ,ship_cust_descr
GROUP BY ,shipto_group
---------customer info----------------- ,quota_rep_descr
bill_cust_descr ,director_descr
,billto_group ,segm
,ship_cust_descr ,mod_chan
,shipto_group ,mod_chansub
,quota_rep_descr ,majg_descr
,director ,ming_descr
,segm ,majs_descr
,chan ,mins_descr
,chansub ,brand
---------product info------------------ ,part_family
,majg_descr ,part_group
,ming_descr ,branding
,majs_descr ,color
,mins_descr ,part_descr
--,brand ,order_season
--,part_family ,order_month
,part_group ,ship_season
,branding ,ship_month
--,color ,request_season
,part_descr ,request_month
---------dates------------------------- ,promo
,order_season ,version
,order_month ,iter
,ship_season
,ship_month
,request_season
,request_month
,promo
,version
,iter
) )
SELECT json_agg(row_to_json(insagg)) x from insagg SELECT json_agg(row_to_json(insagg)) x from insagg