Merge remote-tracking branch 'origin/release/2024-09-27' into feature/IO-2742-redis
This commit is contained in:
@@ -94,7 +94,10 @@ exports.default = async (req, res) => {
|
||||
ret.push({
|
||||
billid: bill.id,
|
||||
success: false,
|
||||
errorMessage: (error && error.authResponse && error.authResponse.body) || (error && error.message)
|
||||
errorMessage:
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
error.response?.data?.Fault?.Error.map((e) => e.Detail).join(", ") ||
|
||||
(error && error.message)
|
||||
});
|
||||
|
||||
//Add the export log error.
|
||||
@@ -191,7 +194,9 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
bodyshop.md_responsibility_centers.sales_tax_codes,
|
||||
classes,
|
||||
taxCodes,
|
||||
bodyshop.md_responsibility_centers.costs
|
||||
bodyshop.md_responsibility_centers.costs,
|
||||
bodyshop.accountingconfig,
|
||||
bodyshop.region_config
|
||||
)
|
||||
);
|
||||
|
||||
@@ -209,14 +214,14 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
AccountBasedExpenseLineDetail: {
|
||||
...(bill.job.class ? { ClassRef: { value: classes[bill.job.class] } } : {}),
|
||||
AccountRef: {
|
||||
value: accounts[bodyshop.md_responsibility_centers.taxes.federal.accountdesc]
|
||||
value: accounts[bodyshop.md_responsibility_centers.taxes.federal_itc.accountdesc]
|
||||
}
|
||||
},
|
||||
|
||||
Amount: Dinero({
|
||||
amount: Math.round(
|
||||
bill.billlines.reduce((acc, val) => {
|
||||
return acc + val.actual_cost * val.quantity;
|
||||
return acc + (val.applicable_taxes?.federal ? (val.actual_cost * val.quantity ?? 0) : 0);
|
||||
}, 0) * 100
|
||||
)
|
||||
})
|
||||
@@ -274,6 +279,8 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
} catch (error) {
|
||||
logger.log("qbo-payables-error", "DEBUG", req.user.email, bill.id, {
|
||||
error: error, //(error && error.authResponse && error.authResponse.body) || (error && error.message),
|
||||
validationError: JSON.stringify(error?.response?.data),
|
||||
accountmeta: JSON.stringify({ accounts, taxCodes, classes }),
|
||||
method: "InsertBill"
|
||||
});
|
||||
throw error;
|
||||
@@ -293,17 +300,29 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
// },
|
||||
// ],
|
||||
|
||||
const generateBillLine = (billLine, accounts, jobClass, ioSalesTaxCodes, classes, taxCodes, costCenters) => {
|
||||
const generateBillLine = (
|
||||
billLine,
|
||||
accounts,
|
||||
jobClass,
|
||||
ioSalesTaxCodes,
|
||||
classes,
|
||||
taxCodes,
|
||||
costCenters,
|
||||
accountingconfig,
|
||||
region_config
|
||||
) => {
|
||||
const account = costCenters.find((c) => c.name === billLine.cost_center);
|
||||
|
||||
return {
|
||||
DetailType: "AccountBasedExpenseLineDetail",
|
||||
|
||||
AccountBasedExpenseLineDetail: {
|
||||
...(jobClass ? { ClassRef: { value: classes[jobClass] } } : {}),
|
||||
TaxCodeRef: {
|
||||
value: taxCodes[findTaxCode(billLine.applicable_taxes, ioSalesTaxCodes)]
|
||||
},
|
||||
TaxCodeRef:
|
||||
accountingconfig.qbo && accountingconfig.qbo_usa && region_config.includes("CA_")
|
||||
? {}
|
||||
: {
|
||||
value: taxCodes[findTaxCode(billLine.applicable_taxes, ioSalesTaxCodes)]
|
||||
},
|
||||
AccountRef: {
|
||||
value: accounts[account.accountname]
|
||||
}
|
||||
|
||||
@@ -179,7 +179,11 @@ exports.default = async (req, res) => {
|
||||
ret.push({
|
||||
jobid: job.id,
|
||||
success: false,
|
||||
errorMessage: (error && error.authResponse && error.authResponse.body) || (error && error.message)
|
||||
errorMessage:
|
||||
error?.authResponse?.body ||
|
||||
error?.response?.data?.Fault?.Error.map((e) => e.Detail).join(", ") ||
|
||||
error?.response?.data ||
|
||||
error?.message
|
||||
});
|
||||
console.log(error);
|
||||
logger.log("qbo-receivable-create-error", "ERROR", req.user.email, {
|
||||
@@ -254,7 +258,6 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
|
||||
throw new Error(
|
||||
`Insurance Company '${job.ins_co_nm}' not found in shop configuration. Please make sure it exists or change the insurance company name on the job to one that exists.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
const Customer = {
|
||||
DisplayName: job.ins_co_nm.trim(),
|
||||
@@ -575,7 +578,9 @@ async function InsertInvoice(oauthClient, qbo_realmId, req, job, bodyshop, paren
|
||||
} catch (error) {
|
||||
logger.log("qbo-receivables-error", "DEBUG", req.user.email, job.id, {
|
||||
error,
|
||||
method: "InsertOwner"
|
||||
method: "InsertInvoice",
|
||||
validationError: JSON.stringify(error?.response?.data),
|
||||
accountmeta: JSON.stringify({ items, taxCodes, classes })
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user