IO-256 Add vendor credits.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user