Refactored communication with partner app to use custom objects + error handling BOD-83 BOD-138 BOD-139
This commit is contained in:
@@ -32,7 +32,11 @@ exports.default = async (req, res) => {
|
||||
|
||||
const QbXmlToExecute = [];
|
||||
invoices.map((i) => {
|
||||
QbXmlToExecute.push(generateBill(i));
|
||||
QbXmlToExecute.push({
|
||||
id: i.id,
|
||||
okStatusCodes: ["0"],
|
||||
qbxml: generateBill(i),
|
||||
});
|
||||
});
|
||||
|
||||
//For each invoice.
|
||||
|
||||
@@ -33,14 +33,30 @@ exports.default = async (req, res) => {
|
||||
//Is this a two tier, or 3 tier setup?
|
||||
const isThreeTier = bodyshop.accountingconfig.tiers === 3;
|
||||
if (isThreeTier) {
|
||||
QbXmlToExecute.push(
|
||||
generateSourceCustomerQbxml(jobs_by_pk, bodyshop) // Create the source customer.
|
||||
);
|
||||
QbXmlToExecute.push({
|
||||
id: jobId,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: generateSourceCustomerQbxml(jobs_by_pk, bodyshop), // Create the source customer.
|
||||
});
|
||||
}
|
||||
QbXmlToExecute.push(generateJobQbxml(jobs_by_pk, bodyshop, isThreeTier, 2));
|
||||
QbXmlToExecute.push(generateJobQbxml(jobs_by_pk, bodyshop, isThreeTier, 3));
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: jobId,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: generateJobQbxml(jobs_by_pk, bodyshop, isThreeTier, 2),
|
||||
});
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: jobId,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: generateJobQbxml(jobs_by_pk, bodyshop, isThreeTier, 3),
|
||||
});
|
||||
//Generate the actual invoice.
|
||||
QbXmlToExecute.push(generateInvoiceQbxml(jobs_by_pk, bodyshop));
|
||||
QbXmlToExecute.push({
|
||||
id: jobId,
|
||||
okStatusCodes: ["0"],
|
||||
qbxml: generateInvoiceQbxml(jobs_by_pk, bodyshop),
|
||||
});
|
||||
|
||||
res.status(200).json(QbXmlToExecute);
|
||||
} catch (error) {
|
||||
@@ -196,7 +212,6 @@ const generateInvoiceQbxml = (jobs_by_pk, bodyshop) => {
|
||||
FullName: bodyshop.md_responsibility_centers.taxes.federal.accountitem,
|
||||
},
|
||||
Desc: bodyshop.md_responsibility_centers.taxes.federal.accountdesc,
|
||||
//Quantity: 1,
|
||||
Amount: federal_tax.toFormat(DineroQbFormat),
|
||||
});
|
||||
}
|
||||
@@ -207,7 +222,6 @@ const generateInvoiceQbxml = (jobs_by_pk, bodyshop) => {
|
||||
FullName: bodyshop.md_responsibility_centers.taxes.state.accountitem,
|
||||
},
|
||||
Desc: bodyshop.md_responsibility_centers.taxes.state.accountdesc,
|
||||
//Quantity: 1,
|
||||
Amount: state_tax.toFormat(DineroQbFormat),
|
||||
});
|
||||
}
|
||||
@@ -218,7 +232,6 @@ const generateInvoiceQbxml = (jobs_by_pk, bodyshop) => {
|
||||
FullName: bodyshop.md_responsibility_centers.taxes.local.accountitem,
|
||||
},
|
||||
Desc: bodyshop.md_responsibility_centers.taxes.local.accountdesc,
|
||||
//Quantity: 1,
|
||||
Amount: local_tax.toFormat(DineroQbFormat),
|
||||
});
|
||||
}
|
||||
|
||||
5
server/accounting/qbxml/qbxmlObject.json
Normal file
5
server/accounting/qbxml/qbxmlObject.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"id": "12345",
|
||||
"okStatusCodes": ["0", "31400"],
|
||||
"qbxml": "the qbxml string"
|
||||
}
|
||||
Reference in New Issue
Block a user