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));
|
sql = sql.replace(new RegExp("replace_iterdef", 'g'), JSON.stringify(req.body));
|
||||||
//execute the sql and send the result
|
//execute the sql and send the result
|
||||||
console.log(sql);
|
console.log(sql);
|
||||||
res.json(null);
|
//res.json(null);
|
||||||
//Postgres.FirstRow(sql, [], res)
|
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
|
--other stuff doesn't matter becuase it's getting overridden anyways
|
||||||
FROM
|
FROM
|
||||||
swap
|
swap
|
||||||
LEFT out JOIN lgdat.cust bc ON
|
LEFT OUTER JOIN lgdat.cust bc ON
|
||||||
bc.bvcust = swap.bill_r
|
bc.bvcust = swap.bill_r
|
||||||
LEFT out JOIN lgdat.cust sc ON
|
LEFT OUTER JOIN lgdat.cust sc ON
|
||||||
sc.bvcust = swap.ship_r
|
sc.bvcust = swap.ship_r
|
||||||
)
|
)
|
||||||
--put bill to and ship to back together and join in channel, terms, descriptions, etc
|
--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 (
|
,repl AS (
|
||||||
SELECT
|
SELECT
|
||||||
o.fspr
|
o.fspr
|
||||||
,o.dplt plnt ---master data
|
,o.plnt ---master data
|
||||||
,o.promo --history date mix
|
,o.promo --history date mix
|
||||||
,terms
|
,o.terms
|
||||||
,COALESCE(c.bill_r||' - '||c.bill_dba,bill_cust_descr) bill_cust_descr
|
,COALESCE(c.bill_r||' - '||c.bill_dba,o.bill_cust_descr) bill_cust_descr
|
||||||
,COALESCE(c.ship_r||' - '||c.ship_dba,ship_cust_descr) ship_cust_descr
|
,COALESCE(c.ship_r||' - '||c.ship_dba,o.ship_cust_descr) ship_cust_descr
|
||||||
,dsm
|
,o.dsm
|
||||||
,quota_rep_descr --master data
|
,o.quota_rep_descr --master data
|
||||||
,director
|
,o.director
|
||||||
,COALESCE(c.bill_dba,billto_group) billto_group
|
,COALESCE(c.bill_dba,o.billto_group) billto_group
|
||||||
,COALESCE(c.ship_dba,shipto_group) shipto_group
|
,COALESCE(c.ship_dba,o.shipto_group) shipto_group
|
||||||
,chan --master data
|
,o.chan --master data
|
||||||
,chansub
|
,o.chansub
|
||||||
,chan_retail
|
,o.chan_retail
|
||||||
,o.part
|
,o.part
|
||||||
,o.partd
|
,o.part_descr
|
||||||
,o.part_group
|
,o.part_group
|
||||||
,o.branding
|
,o.branding
|
||||||
,o.majg_descr
|
,o.majg_descr
|
||||||
,o.ming_descr
|
,o.ming_descr
|
||||||
,o.majs_descr
|
,o.majs_descr
|
||||||
,o.mins_descr
|
,o.mins_descr
|
||||||
,seg.segm
|
,o.segm
|
||||||
,o.substance
|
,o.substance
|
||||||
,o.fs_line --master data
|
,o.fs_line --master data
|
||||||
,o.r_currency --history cust mix
|
,o.r_currency --history cust mix
|
||||||
,o.r_rate --master data
|
,o.r_rate --master data
|
||||||
,o.r.curr c_currency --master data
|
,o.c_currency --master data
|
||||||
,o.x.rate c_rate --master data
|
,o.c_rate --master data
|
||||||
,-o.units units
|
,-o.units units
|
||||||
,-o.value_loc value_loc
|
,-o.value_loc value_loc
|
||||||
,-o.value_usd value_usd
|
,-o.value_usd value_usd
|
||||||
,-o.units * c.std cost_loc
|
,-o.cost_loc cost_loc
|
||||||
,-o.units * c.std * x.rate cost_usd
|
,-o.cost_usd cost_usd
|
||||||
,o.calc_status --0
|
,o.calc_status --0
|
||||||
,o.flag --0
|
,o.flag --0
|
||||||
,o.order_date --history date mix
|
,o.order_date --history date mix
|
||||||
|
Loading…
Reference in New Issue
Block a user