link in some more offline meta

This commit is contained in:
Trowbridge 2019-03-22 04:16:07 -04:00
parent 46a299c1a3
commit 7d1adcf779

View File

@ -309,7 +309,7 @@ SELECT
,null::date ddqdat
,null::date dcmdat
,null::date dhidat
,null::text fspr
,sd.fspr
,null::text remit_to
,null::text bill_class
,(regexp_match(jr.bill_cust_descr,'(.*?)(?= - |$)'))[1] bill_cust
@ -542,23 +542,23 @@ SELECT
,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(b.part,9,3) ELSE '' END color
,COALESCE(SEG.SEGM,'Other') segm
,b.bill_cust_descr
,b.billto_group
,coalesce(cg.cgrp,bc.bvname) billto_group
,b.ship_cust_descr
,b.shipto_group
,coalesce(sg.cgrp,sc.bvname) shipto_group
,COALESCE(m.avmajg,p.awmajg)||COALESCE(' - '||BQDES,'') majg_descr
,COALESCE(m.avming,p.awming)||COALESCE(' - '||BRDES,'') ming_descr
,COALESCE(m.avmajs,p.awmajs)||COALESCE(' - '||SJ.BSDES1,'') majs_descr
,COALESCE(m.avmins,p.awmins)||COALESCE(' - '||SI.BSDES1,'') mins_descr
,CASE COALESCE(SEG.SEGM,'Other')
WHEN 'Retail' THEN c.RETAIL
ELSE b.CHAN
ELSE coalesce(c.chan,'UNDEFINED')
END mod_chan
,CASE COALESCE(SEG.SEGM,'Other')
WHEN 'Retail' THEN c.RETAILSUB
ELSE ''
END mod_chansub
,b.quota_rep_descr
,b.director_descr
,repc.repp quota_rep_descr
,repc.director director_descr
,b.fb_val_loc value_loc
,b.fb_val_loc *r_rate value_usd
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs)*b.fb_qty cost_loc
@ -598,7 +598,41 @@ FROM
LEFT OUTER JOIN RLARP.FFCUST SG ON
SG.CUSTN = SC.BVCUST
LEFT OUTER JOIN REPC ON
REPC.RCODE = b.QUOTA_REP
REPC.RCODE = RTRIM(
COALESCE(
--retail items go to currep, or if null go to 90005
CASE WHEN COALESCE(avgled,awgled) IN ('1RE','1CU') THEN
CASE WHEN bc.bvctry = 'CAN' THEN
--Rachel Bowman
'50300'
ELSE
--retail chain got to Mark Wilkinson
CASE COALESCE(cg.cgrp,bc.bvname)
WHEN 'THE HOME DEPOT' THEN '90005'
WHEN 'DO IT BEST' THEN '90005'
WHEN 'ACE HARDWARE' THEN '90005'
WHEN 'ALDI' THEN '90005'
WHEN 'AMAZON.COM' THEN '90005'
WHEN 'GARDEN RIDGE CORP' THEN '90005'
--all other retail goes to Doran Marable
ELSE '50200'
END
END
ELSE
CASE WHEN COALESCE(avming,awming) = 'B52' THEN
'PW'
--gdir, ndir go to bill-to rep
ELSE
CASE WHEN bc.bvclas IN ('GDIR','NDIR') THEN
bc.bvsalm
ELSE
sc.bvsalm
END
END
END
,''
)
)
LEFT OUTER JOIN SI ON
SI.BSMJCD = COALESCE(m.avmajs,p.awmajs)
AND SI.BSMNCD = COALESCE(m.avmins,p.awmins)