From cd53505d59debef6b97e93c609bf6fca2d37db55 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 16 Apr 2019 18:50:01 -0400 Subject: [PATCH] use replacement part in all cases, and apply currency --- route_sql/build/set_part_master.sql | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/route_sql/build/set_part_master.sql b/route_sql/build/set_part_master.sql index fab9be4..4b9c07f 100644 --- a/route_sql/build/set_part_master.sql +++ b/route_sql/build/set_part_master.sql @@ -5,7 +5,7 @@ repl AS ( SELECT * FROM ( VALUES - ('IFA06000G181012LRCIR ','IFA06000G181012LRCIR') + ('MOW24000A47E880','MOW24000A47E880') ) as x(orig,fix) ) ,SEG AS ( @@ -146,10 +146,10 @@ SELECT ,COALESCE(cm.cgstcs, cp.chstcs, cr.y0stcs) stdcost ,copr.curr c_currency ,cx.rate c_rate - ,SUBSTR(o.part,1,3)||coalesce(' - '||F.DESCR,'') part_family - ,SUBSTRING(o.part,1,8)||coalesce(' - '||MD.DESCR,'') part_group + ,SUBSTR(repl.fix,1,3)||coalesce(' - '||F.DESCR,'') part_family + ,SUBSTRING(repl.fix,1,8)||coalesce(' - '||MD.DESCR,'') part_group ,COALESCE(MG.GRP,'Unbranded') branding - ,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(o.part,9,3) ELSE '' END color + ,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(repl.fix,9,3) ELSE '' END color ,COALESCE(SEG.SEGM,'Other') segm ,COALESCE(m.avmajg,p.awmajg)||COALESCE(' - '||BQDES,'') majg_descr ,COALESCE(m.avming,p.awming)||COALESCE(' - '||BRDES,'') ming_descr @@ -217,12 +217,12 @@ FROM SEG.GLEC = COALESCE(m.avgled,p.awgled) --AND SEG.SEGM <> 'Other' LEFT OUTER JOIN MG ON - MG.F1 = SUBSTR(o.part,16,1) + MG.F1 = SUBSTR(repl.fix,16,1) AND MG.MING = COALESCE(m.avming,p.awming) LEFT OUTER JOIN rlarp.family F ON - F.F3 = SUBSTR(o.part,1,3) + F.F3 = SUBSTR(repl.fix,1,3) LEFT OUTER JOIN MD ON - MD.MOLD = SUBSTR(o.part,1,8) + MD.MOLD = SUBSTR(repl.fix,1,8) LEFT OUTER JOIN SI ON SI.BSMJCD = COALESCE(m.avmajs,p.awmajs) AND SI.BSMNCD = COALESCE(m.avmins,p.awmins) @@ -308,6 +308,10 @@ SET ,fb_cst_loc = o.fb_qty * x.stdcost ,fb_cst_loc_cur = o.fb_qty * x.stdcost ,fb_cst_loc_fut = o.fb_qty * x.stdcost + ,cost_loc = o.fb_qty * x.stdcost + ,cost_usd = o.fb_qty * x.stdcost * x.c_rate + ,c_currency = x.c_currency + ,c_rate = x.c_rate ,part_family = x.part_family ,part_group = x.part_group ,branding = x.branding @@ -329,4 +333,4 @@ RETURNING o.* SELECT * FROM u; --ROLLBACK; -COMMIT; \ No newline at end of file +--COMMIT; \ No newline at end of file