diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index 14020ef..2b16515 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -198,7 +198,7 @@ SELECT ,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM basemix) = 0 THEN 0 ELSE - ((SELECT incr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM basemix))/(SELECT sum(fb_val_loc * r_rate) FROM basemix) + (SELECT incr::numeric FROM target)/(SELECT sum(fb_val_loc * r_rate) FROM basemix) END factor ,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM basemix) = 0 THEN CASE WHEN ((SELECT incr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM basemix)) <> 0 THEN @@ -277,8 +277,10 @@ SELECT ,0 fb_cst_loc ,0 fb_cst_loc_cur ,0 fb_cst_loc_fut - ,b.fb_val_loc*s.factor fb_val_loc - ,b.fb_val_loc_pl*s.factor fb_val_loc_pl + --,b.fb_val_loc*s.factor fb_val_loc + ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric fb_val_loc + ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc_pl*s.factor END)::numeric fb_val_loc_pl + --,b.fb_val_loc_pl*s.factor fb_val_loc_pl ,b.calc_status --0 ,b.flag --0 ,b.orderdate @@ -317,7 +319,7 @@ SELECT ,b.quota_rep_descr ,b.director_descr ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric value_loc - ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor END)::numeric value_usd + ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor*r_rate END)::numeric value_usd ,0 cost_loc ,0 cost_usd ,0 units @@ -398,4 +400,4 @@ GROUP BY ,version ,iter ) -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 ea96d75..59ade9d 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -360,7 +360,7 @@ target AS (select target_vol vincr, target_prc pincr) ,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM volume) = 0 THEN 0 ELSE - ((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume))/(SELECT sum(fb_val_loc * r_rate) FROM volume) + (SELECT pincr::numeric FROM target)/(SELECT sum(fb_val_loc * r_rate) FROM volume) END factor ,CASE WHEN (SELECT sum(fb_val_loc * r_rate) FROM volume) = 0 THEN CASE WHEN ((SELECT pincr::numeric FROM target) - (SELECT sum(fb_val_loc * r_rate) FROM volume)) <> 0 THEN @@ -440,8 +440,10 @@ target AS (select target_vol vincr, target_prc pincr) ,0 fb_cst_loc ,0 fb_cst_loc_cur ,0 fb_cst_loc_fut - ,b.fb_val_loc*s.factor fb_val_loc - ,b.fb_val_loc_pl*s.factor fb_val_loc_pl + --,b.fb_val_loc*s.factor fb_val_loc + ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric fb_val_loc + ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc_pl*s.factor END)::numeric fb_val_loc_pl + --,b.fb_val_loc_pl*s.factor fb_val_loc_pl ,b.calc_status --0 ,b.flag --0 ,b.orderdate @@ -480,7 +482,7 @@ target AS (select target_vol vincr, target_prc pincr) ,b.quota_rep_descr ,b.director_descr ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price/b.r_rate ELSE b.fb_val_loc*s.factor END)::numeric value_loc - ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor END)::numeric value_usd + ,(CASE WHEN s.factor = 0 THEN b.fb_qty * s.mod_price ELSE b.fb_val_loc*s.factor*b.r_rate END)::numeric value_usd ,0 cost_loc ,0 cost_usd ,0 units @@ -561,4 +563,4 @@ GROUP BY ,version ,iter ) -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