From fff9073f9d02c9a338333f7610f37e13206bae4c Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 12 Oct 2021 16:54:28 -0700 Subject: [PATCH] IO-256 Add vendor credits. --- server/accounting/qbo/qbo-payables.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/accounting/qbo/qbo-payables.js b/server/accounting/qbo/qbo-payables.js index ffe60b373..c68531b49 100644 --- a/server/accounting/qbo/qbo-payables.js +++ b/server/accounting/qbo/qbo-payables.js @@ -72,6 +72,7 @@ exports.default = async (req, res) => { bill, vendorRecord ); + ret.push({ billid: bill.id, success: true }); } catch (error) { ret.push({ @@ -112,7 +113,7 @@ async function QueryVendorRecord(oauthClient, req, bill) { ); } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { - error, + error: JSON.stringify(error), method: "QueryVendorRecord", }); throw error; @@ -135,7 +136,7 @@ async function InsertVendorRecord(oauthClient, req, bill) { return result && result.Vendor; } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { - error, + error: JSON.stringify(error), method: "InsertVendorRecord", }); throw error; @@ -150,7 +151,7 @@ async function InsertBill(oauthClient, req, bill, vendor) { value: vendor.Id, }, TxnDate: moment(bill.date).format("YYYY-MM-DD"), - DueDate: bill.due_date && moment(bill.due_date).format("YYYY-MM-DD"), + //DueDate: bill.due_date && moment(bill.due_date).format("YYYY-MM-DD"), DocNumber: bill.invoice_number, ...(bill.job.class ? { ClassRef: { Id: classes[bill.job.class] } } : {}), @@ -170,7 +171,10 @@ async function InsertBill(oauthClient, req, bill, vendor) { }; try { const result = await oauthClient.makeApiCall({ - url: urlBuilder(req.cookies.qbo_realmId, "bill"), + url: urlBuilder( + req.cookies.qbo_realmId, + bill.is_credit_memo ? "vendorcredit" : "bill" + ), method: "POST", headers: { "Content-Type": "application/json", @@ -181,7 +185,7 @@ async function InsertBill(oauthClient, req, bill, vendor) { return result && result.Bill; } catch (error) { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { - error, + error: JSON.stringify(error), method: "InsertBill", }); throw error; @@ -231,6 +235,7 @@ const generateBillLine = ( .toFormat(DineroQbFormat), }; }; + async function QueryMetaData(oauthClient, req) { const accounts = await oauthClient.makeApiCall({ url: urlBuilder(