Merge branch 'feature/qbo' into test

# Conflicts:
#	server/accounting/qbo/qbo-payables.js
#	server/accounting/qbo/qbo-payments.js
#	server/accounting/qbo/qbo-receivables.js
This commit is contained in:
Patrick Fic
2021-10-13 15:25:02 -07:00
3 changed files with 29 additions and 7 deletions

View File

@@ -79,7 +79,8 @@ exports.default = async (req, res) => {
billid: bill.id, billid: bill.id,
success: false, success: false,
errorMessage: errorMessage:
(error && error.authResponse.body) || JSON.stringify(error), (error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
}); });
} }
} }
@@ -114,7 +115,9 @@ async function QueryVendorRecord(oauthClient, req, bill) {
); );
} catch (error) { } catch (error) {
logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, {
error: (error && error.authResponse.body) || JSON.stringify(error), error:
(error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
method: "QueryVendorRecord", method: "QueryVendorRecord",
}); });
throw error; throw error;
@@ -137,7 +140,9 @@ async function InsertVendorRecord(oauthClient, req, bill) {
return result && result.Vendor; return result && result.Vendor;
} catch (error) { } catch (error) {
logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, {
error: (error && error.authResponse.body) || JSON.stringify(error), error:
(error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
method: "InsertVendorRecord", method: "InsertVendorRecord",
}); });
throw error; throw error;
@@ -170,6 +175,9 @@ async function InsertBill(oauthClient, req, bill, vendor) {
) )
), ),
}; };
logger.log("qbo-payable-objectlog", "DEBUG", req.user.email, bill.id, {
billQbo,
});
try { try {
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder( url: urlBuilder(
@@ -186,7 +194,9 @@ async function InsertBill(oauthClient, req, bill, vendor) {
return result && result.Bill; return result && result.Bill;
} catch (error) { } catch (error) {
logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, { logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, {
error: (error && error.authResponse.body) || JSON.stringify(error), error:
(error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
method: "InsertBill", method: "InsertBill",
}); });
throw error; throw error;

View File

@@ -128,14 +128,17 @@ exports.default = async (req, res) => {
ret.push({ paymentid: payment.id, success: true }); ret.push({ paymentid: payment.id, success: true });
} catch (error) { } catch (error) {
logger.log("qbo-payment-create-error", "ERROR", req.user.email, { logger.log("qbo-payment-create-error", "ERROR", req.user.email, {
error: (error && error.authResponse.body) || JSON.stringify(error), error:
(error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
}); });
ret.push({ ret.push({
paymentid: payment.id, paymentid: payment.id,
success: false, success: false,
errorMessage: errorMessage:
(error && error.authResponse.body) || JSON.stringify(error), (error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
}); });
} }
} }
@@ -188,6 +191,9 @@ async function InsertPayment(oauthClient, req, payment, parentRef) {
}, },
], ],
}; };
logger.log("qbo-payments-objectlog", "DEBUG", req.user.email, payment.id, {
paymentQbo,
});
try { try {
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(req.cookies.qbo_realmId, "payment"), url: urlBuilder(req.cookies.qbo_realmId, "payment"),

View File

@@ -118,7 +118,8 @@ exports.default = async (req, res) => {
jobid: job.id, jobid: job.id,
success: false, success: false,
errorMessage: errorMessage:
(error && error.authResponse.body) || JSON.stringify(error), (error && error.authResponse && error.authResponse.body) ||
JSON.stringify(error),
}); });
} }
} }
@@ -398,10 +399,15 @@ async function InsertInvoice(oauthClient, req, job, bodyshop, parentTierRef) {
: {}), : {}),
}; };
logger.log("qbo-receivable-objectlog", "DEBUG", req.user.email, job.id, {
invoiceObj,
});
try { try {
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(req.cookies.qbo_realmId, "invoice"), url: urlBuilder(req.cookies.qbo_realmId, "invoice"),
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },