From be5697d51fbfae9df7b7464d32c8c1b2790dd7a6 Mon Sep 17 00:00:00 2001 From: fleetside72 Date: Fri, 28 Sep 2018 14:16:40 -0400 Subject: [PATCH] add descriptions --- server.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index b55e985..f0936ee 100644 --- a/server.js +++ b/server.js @@ -224,18 +224,20 @@ server.get("/add_gl_multi_and_post", bodyParser.json(), function (inReq, inRes) x.gl.lines = []; x.gl.jpath = []; for (var i in x.item){ + //copy the current item to the gl array var line = x.item[i]; x.gl.lines.push(line); + //build references to 'item' array var ref = []; ref.push("{item,"+i+"}"); ref.push("{header}"); x.gl.jpath.push(ref); - //copy the existing line to the GL array + //copy the current item to the gl array again, but swap account with supplied 'account' in header var ofs = JSON.parse(JSON.stringify(line)); ofs.account = x.header.account; ofs.amount = -ofs.amount; - //add another line the GL array using the offset account x.gl.lines.push(ofs); + //add the same reference again for the offset account x.gl.jpath.push(ref); } var sql = "INSERT INTO evt.bpr (bpr) SELECT $1";