running the SQL was commented out in the router, also the columns were incorrect when swapping customer, and outer join was spelled wrong
This commit is contained in:
parent
f7f26b2804
commit
a328aaeaaf
4
index.js
4
index.js
@ -256,8 +256,8 @@ server.post('/cust_swap', bodyParser.json(), function(req, res) {
|
||||
sql = sql.replace(new RegExp("replace_iterdef", 'g'), JSON.stringify(req.body));
|
||||
//execute the sql and send the result
|
||||
console.log(sql);
|
||||
res.json(null);
|
||||
//Postgres.FirstRow(sql, [], res)
|
||||
//res.json(null);
|
||||
Postgres.FirstRow(sql, [], res)
|
||||
};
|
||||
})
|
||||
|
||||
|
@ -24,9 +24,9 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
|
||||
--other stuff doesn't matter becuase it's getting overridden anyways
|
||||
FROM
|
||||
swap
|
||||
LEFT out JOIN lgdat.cust bc ON
|
||||
LEFT OUTER JOIN lgdat.cust bc ON
|
||||
bc.bvcust = swap.bill_r
|
||||
LEFT out JOIN lgdat.cust sc ON
|
||||
LEFT OUTER JOIN lgdat.cust sc ON
|
||||
sc.bvcust = swap.ship_r
|
||||
)
|
||||
--put bill to and ship to back together and join in channel, terms, descriptions, etc
|
||||
@ -121,40 +121,40 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
|
||||
)
|
||||
,repl AS (
|
||||
SELECT
|
||||
o.fspr
|
||||
,o.dplt plnt ---master data
|
||||
o.fspr
|
||||
,o.plnt ---master data
|
||||
,o.promo --history date mix
|
||||
,terms
|
||||
,COALESCE(c.bill_r||' - '||c.bill_dba,bill_cust_descr) bill_cust_descr
|
||||
,COALESCE(c.ship_r||' - '||c.ship_dba,ship_cust_descr) ship_cust_descr
|
||||
,dsm
|
||||
,quota_rep_descr --master data
|
||||
,director
|
||||
,COALESCE(c.bill_dba,billto_group) billto_group
|
||||
,COALESCE(c.ship_dba,shipto_group) shipto_group
|
||||
,chan --master data
|
||||
,chansub
|
||||
,chan_retail
|
||||
,o.terms
|
||||
,COALESCE(c.bill_r||' - '||c.bill_dba,o.bill_cust_descr) bill_cust_descr
|
||||
,COALESCE(c.ship_r||' - '||c.ship_dba,o.ship_cust_descr) ship_cust_descr
|
||||
,o.dsm
|
||||
,o.quota_rep_descr --master data
|
||||
,o.director
|
||||
,COALESCE(c.bill_dba,o.billto_group) billto_group
|
||||
,COALESCE(c.ship_dba,o.shipto_group) shipto_group
|
||||
,o.chan --master data
|
||||
,o.chansub
|
||||
,o.chan_retail
|
||||
,o.part
|
||||
,o.partd
|
||||
,o.part_descr
|
||||
,o.part_group
|
||||
,o.branding
|
||||
,o.majg_descr
|
||||
,o.ming_descr
|
||||
,o.majs_descr
|
||||
,o.mins_descr
|
||||
,seg.segm
|
||||
,o.segm
|
||||
,o.substance
|
||||
,o.fs_line --master data
|
||||
,o.r_currency --history cust mix
|
||||
,o.r_rate --master data
|
||||
,o.r.curr c_currency --master data
|
||||
,o.x.rate c_rate --master data
|
||||
,o.c_currency --master data
|
||||
,o.c_rate --master data
|
||||
,-o.units units
|
||||
,-o.value_loc value_loc
|
||||
,-o.value_usd value_usd
|
||||
,-o.units * c.std cost_loc
|
||||
,-o.units * c.std * x.rate cost_usd
|
||||
,-o.cost_loc cost_loc
|
||||
,-o.cost_usd cost_usd
|
||||
,o.calc_status --0
|
||||
,o.flag --0
|
||||
,o.order_date --history date mix
|
||||
|
Loading…
Reference in New Issue
Block a user