diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index b5da1f0..721f5f4 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -281,7 +281,7 @@ SELECT b.fspr ,i.dplt plnt ,b.promo - ,b.terms + ,COALESCE(b.terms,bc.bvterm) terms ,b.bill_cust_descr ,b.ship_cust_descr ,(SELECT max(rcode) FROM repc WHERE rname = log.doc->'scenario'->>'quota_rep_descr') dsm @@ -324,7 +324,7 @@ SELECT ,seg.segm ,CASE WHEN i.majg = '610' THEN 'Fiber' ELSE 'Plastic' END substance ,'41010' fs_line --master data - ,mxm.r_currency --history cust mix + ,b.r_currency --history cust mix ,rx.rate r_rate --master data ,copr.curr c_currency --master data ,cx.rate c_rate --master data @@ -422,14 +422,14 @@ FROM LEFT OUTER JOIN copr ON copr.comp = yacomp::text LEFT OUTER JOIN rlarp.ffcret cx ON - cx.perd = '2008' - AND cx.rtyp = 'MA' + cx.perd = '2101' + AND cx.rtyp = 'BG' AND cx.fcur = copr.curr AND cx.tcur = 'US' LEFT OUTER JOIN rlarp.ffcret rx ON - rx.perd = '2008' - AND rx.rtyp = 'MA' - AND rx.fcur = COALESCE(bc.bvcurr,mxm.r_currency) + rx.perd = '2101' + AND rx.rtyp = 'BG' + AND rx.fcur = COALESCE(bc.bvcurr,b.r_currency) AND rx.tcur = 'US' ) , ins AS (