From 2506701a85f626d7024e16db846614956438f1b9 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 5 May 2021 09:11:36 -0700 Subject: [PATCH] IO-991 QBXML Receivable Export changes [ci skip] --- server/accounting/qbxml/qbxml-receivables.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/accounting/qbxml/qbxml-receivables.js b/server/accounting/qbxml/qbxml-receivables.js index 14831f925..5bef85ec9 100644 --- a/server/accounting/qbxml/qbxml-receivables.js +++ b/server/accounting/qbxml/qbxml-receivables.js @@ -13,7 +13,7 @@ require("dotenv").config({ ), }); -Dinero.globalRoundingMode = 'HALF_EVEN' +Dinero.globalRoundingMode = "HALF_EVEN"; const { generateJobTier, generateOwnerTier, generateSourceTier } = QbXmlUtils; exports.default = async (req, res) => { @@ -196,7 +196,7 @@ const generateInvoiceQbxml = ( //Create the invoice lines mapping. jobs_by_pk.joblines.map((jobline) => { //Parts Lines - console.log("Jobline desc", jobline.line_desc); + if (jobline.profitcenter_part && jobline.act_price) { const DineroAmount = Dinero({ amount: Math.round(jobline.act_price * 100), @@ -227,7 +227,7 @@ const generateInvoiceQbxml = ( ].Amount.add(DineroAmount); } } - console.log("Parts Done"); + // Labor Lines if ( jobline.profitcenter_labor && @@ -270,7 +270,6 @@ const generateInvoiceQbxml = ( //Convert the hash to an array. Object.keys(invoiceLineHash).forEach((key) => { - console.log(key, invoiceLineHash[key]); InvoiceLineAdd.push({ ...invoiceLineHash[key], Amount: invoiceLineHash[key].Amount.toFormat(DineroQbFormat), @@ -353,9 +352,12 @@ const generateInvoiceQbxml = ( TxnDate: moment(jobs_by_pk.date_invoiced).format("YYYY-MM-DD"), RefNumber: jobs_by_pk.ro_number, - BillAddress: { - Addr1: jobs_by_pk.ownr_addr1, - Addr2: jobs_by_pk.ownr_addr2, + ShipAddress: { + Addr1: `${jobs_by_pk.ownr_fn || ""} ${jobs_by_pk.ownr_ln || ""} ${ + jobs_by_pk.ownr_co_nm || "" + }`, + Addr2: jobs_by_pk.ownr_addr1, + Addr3: jobs_by_pk.ownr_addr2, City: jobs_by_pk.ownr_city, State: jobs_by_pk.ownr_st, PostalCode: jobs_by_pk.ownrzip, @@ -367,6 +369,8 @@ const generateInvoiceQbxml = ( }, }, }; + + console.log(JSON.stringify(invoiceQbxmlObj, null, 2)); var invoiceQbxml_partial = builder .create(invoiceQbxmlObj, { version: "1.30",