From 0e9d2f5cb27cbfee725c5e79bf8031bd3d1741b3 Mon Sep 17 00:00:00 2001 From: fleetside72 Date: Fri, 5 Oct 2018 16:28:35 -0400 Subject: [PATCH] setup manual journal entry --- server.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/server.js b/server.js index 7a2da36..5bb2e14 100644 --- a/server.js +++ b/server.js @@ -234,24 +234,19 @@ server.get("/gl_mje_build", bodyParser.json(), function (inReq, inRes) x.gl = {}; x.gl.lines = []; x.gl.jpath = []; - for (var i in x.item){ + for (var i in x.items){ //copy the current item to the gl array - var line = x.item[i]; + var line = x.items[i]; x.gl.lines.push(line); //build references to 'item' array var ref = []; - ref.push("{item,"+i+"}"); + ref.push("{items,"+i+"}"); ref.push("{header}"); x.gl.jpath.push(ref); - //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; - x.gl.lines.push(ofs); - //add the same reference again for the offset account - x.gl.jpath.push(ref); } - inRes.json(x); + var sql = "INSERT INTO evt.bpr (bpr) SELECT $1"; + console.log(JSON.stringify(x)); + Postgres.FirstRow(sql,[JSON.stringify(x)], inRes); }); //add ledger array and create offset account for total of all lines