diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index a57c206..4adc460 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -316,11 +316,11 @@ SELECT ,b.r_rate ,b.c_currency ,b.c_rate - ,b.units*s.factor*m.momix units - ,b.value_loc*s.factor*m.momix value_loc - ,b.value_usd*s.factor*m.momix value_usd - ,b.cost_loc*s.factor*m.momix cost_loc - ,b.cost_usd*s.factor*m.momix cost_usd + ,round(b.units*s.factor*m.momix ,2) units + ,round(b.value_loc*s.factor*m.momix,2) value_loc + ,round(b.value_usd*s.factor*m.momix,2) value_usd + ,round(b.cost_loc*s.factor*m.momix ,2) cost_loc + ,round(b.cost_usd*s.factor*m.momix ,2) cost_usd ,b.calc_status ,b.flag ,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date @@ -407,8 +407,8 @@ SELECT ,b.c_currency ,b.c_rate ,0::numeric units - ,(CASE WHEN p.factor = 0 THEN b.units * p.mod_price/b.r_rate ELSE b.value_loc*p.factor END)::numeric value_loc - ,(CASE WHEN p.factor = 0 THEN b.units * p.mod_price ELSE b.value_usd*p.factor END)::numeric value_usd + ,round((CASE WHEN p.factor = 0 THEN b.units * p.mod_price/b.r_rate ELSE b.value_loc*p.factor END)::numeric,2) value_loc + ,round((CASE WHEN p.factor = 0 THEN b.units * p.mod_price ELSE b.value_usd*p.factor END)::numeric ,2) value_usd ,0::numeric cost_loc ,0::numeric cost_usd ,b.calc_status diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index a29819f..d16005c 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -329,11 +329,11 @@ SELECT ,rx.rate r_rate --master data ,copr.curr c_currency --master data ,cx.rate c_rate --master data - ,b.units - ,b.value_usd / COALESCE(rx.rate,1) --b.value is denominated in USD, need to apply currency to get to local, assume 1 if using a fake customer - ,b.value_usd value_usd --b.value is already denominated in usd - ,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units cost_loc - ,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate cost_usd + ,round(b.units ,2) units + ,round(b.value_usd / COALESCE(rx.rate,1) ,2) value_loc --b.value is denominated in USD, need to apply currency to get to local, assume 1 if using a fake customer + ,round(b.value_usd ,2) value_usd --b.value is already denominated in usd + ,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units ,2) cost_loc + ,round(COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.units*cx.rate,2) cost_usd ,'CLOSED' calc_status ,'SHIPMENT' flag ,b.order_date diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index 4b29f15..811ccaf 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -152,8 +152,8 @@ target AS (select target_increment incr) ,c_currency --master data ,c_rate --master data ,0::numeric units - ,(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 ELSE b.value_usd*s.factor END)::numeric value_usd + ,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric,2) value_loc + ,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric ,2) value_usd ,0::numeric cost_loc ,0::numeric cost_usd ,calc_status --0 diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index 03029bc..75b5a57 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -180,11 +180,11 @@ target AS (select incr_qty qincr) ,r_rate --master data ,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 + ,round(units*s.factor ,2) units + ,round(value_loc*s.factor,2) value_loc + ,round(value_usd*s.factor,2) value_usd + ,round(cost_loc*s.factor ,2) cost_loc + ,round(cost_usd*s.factor ,2) cost_usd ,calc_status --0 ,flag --0 ,order_date --history date mix @@ -293,4 +293,4 @@ FROM ,tag ,comment ) -SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file +SELECT json_agg(row_to_json(insagg)) x from insagg diff --git a/route_sql/scale_vupd.sql b/route_sql/scale_vupd.sql index b25755f..a21f43e 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -179,11 +179,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 + ,round(units*s.factor ,2) units + ,round(value_loc*s.factor,2) value_loc + ,round(value_usd*s.factor,2) value_usd + ,round(cost_loc*s.factor ,2) cost_loc + ,round(cost_usd*s.factor ,2) cost_usd ,calc_status --0 ,flag --0 ,order_date --history date mix @@ -261,8 +261,8 @@ FROM ,c_currency --master data ,c_rate --master data ,0::numeric units - ,(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 ELSE b.value_usd*s.factor END)::numeric value_usd + ,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric,2) value_loc + ,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric ,2) value_usd ,0::numeric cost_loc ,0::numeric cost_usd ,calc_status --0 diff --git a/route_sql/scale_vupd_sales.sql b/route_sql/scale_vupd_sales.sql index 1ad0b7d..aa7b1f0 100644 --- a/route_sql/scale_vupd_sales.sql +++ b/route_sql/scale_vupd_sales.sql @@ -180,11 +180,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 + ,round(units*s.factor ,2) units + ,round(value_loc*s.factor,2) value_loc + ,round(value_usd*s.factor,2) value_usd + ,round(cost_loc*s.factor ,2) cost_loc + ,round(cost_usd*s.factor ,2) cost_usd ,calc_status --0 ,flag --0 ,order_date --history date mix @@ -262,8 +262,8 @@ FROM ,c_currency --master data ,c_rate --master data ,0::numeric units - ,(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 ELSE b.value_usd*s.factor END)::numeric value_usd + ,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price/b.r_rate ELSE b.value_loc*s.factor END)::numeric,2) value_loc + ,round((CASE WHEN s.factor = 0 THEN b.units * s.mod_price ELSE b.value_usd*s.factor END)::numeric ,2) value_usd ,0::numeric cost_loc ,0::numeric cost_usd ,calc_status --0