do some validation
This commit is contained in:
parent
855e831007
commit
33e72582d8
12
server.js
12
server.js
@ -197,19 +197,29 @@ server.get("/doc_add_gl_offset_single", bodyParser.json(), function (inReq, inRe
|
|||||||
{
|
{
|
||||||
var l = 0;
|
var l = 0;
|
||||||
var tot = 0.00;
|
var tot = 0.00;
|
||||||
|
var bomb = false;
|
||||||
console.log(inReq.body);
|
console.log(inReq.body);
|
||||||
x = inReq.body;
|
x = inReq.body;
|
||||||
|
//add GL array
|
||||||
x.GL = [];
|
x.GL = [];
|
||||||
for (var i in x.item){
|
for (var i in x.item){
|
||||||
var line = x.item[i];
|
var line = x.item[i];
|
||||||
|
if ((line.account != null) && (line.amount != null)) {
|
||||||
x.GL.push(line);
|
x.GL.push(line);
|
||||||
tot = tot + line.amount;
|
tot = tot + (line.amount || 0);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
bomb = true;
|
||||||
|
}
|
||||||
|
//add the whole line as-is
|
||||||
|
}
|
||||||
|
if (bomb = false) {
|
||||||
var ofs = JSON.parse(JSON.stringify(x.header));
|
var ofs = JSON.parse(JSON.stringify(x.header));
|
||||||
ofs.account = ofs.offset_account;
|
ofs.account = ofs.offset_account;
|
||||||
delete ofs.offset_account;
|
delete ofs.offset_account;
|
||||||
ofs.amount = -tot;
|
ofs.amount = -tot;
|
||||||
x.GL.push(ofs);
|
x.GL.push(ofs);
|
||||||
|
}
|
||||||
inRes.json(x);
|
inRes.json(x);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user