WIP Exporting Fixes
This commit is contained in:
@@ -6,6 +6,7 @@ const Dinero = require("dinero.js");
|
||||
var builder = require("xmlbuilder");
|
||||
const moment = require("moment");
|
||||
const QbXmlUtils = require("./qbxml-utils");
|
||||
const QbxmlReceivables = require("./qbxml-receivables");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
@@ -31,42 +32,49 @@ exports.default = async (req, res) => {
|
||||
.request(queries.QUERY_PAYMENTS_FOR_EXPORT, {
|
||||
payments: paymentsToQuery,
|
||||
});
|
||||
const { payments } = result;
|
||||
const { payments, bodyshops } = result;
|
||||
const bodyshop = bodyshops[0];
|
||||
const isThreeTier = bodyshop.accountingconfig.tiers === 3;
|
||||
const twoTierPref = bodyshop.accountingconfig.twotierpref;
|
||||
|
||||
if (isThreeTier) {
|
||||
QbXmlToExecute.push({
|
||||
id: jobs_by_pk.id,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: generateSourceCustomerQbxml(jobs_by_pk, bodyshop), // Create the source customer.
|
||||
});
|
||||
}
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: jobs_by_pk.id,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: generateJobQbxml(
|
||||
jobs_by_pk,
|
||||
bodyshop,
|
||||
isThreeTier,
|
||||
2,
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: jobs_by_pk.id,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: generateJobQbxml(
|
||||
jobs_by_pk,
|
||||
bodyshop,
|
||||
isThreeTier,
|
||||
3,
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
|
||||
const QbXmlToExecute = [];
|
||||
payments.map((i) => {
|
||||
|
||||
if (isThreeTier) {
|
||||
QbXmlToExecute.push({
|
||||
id: i.id,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: QbxmlReceivables.generateSourceCustomerQbxml(i.job, bodyshop), // Create the source customer.
|
||||
});
|
||||
}
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: i.id,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: QbxmlReceivables.generateJobQbxml(
|
||||
i.job,
|
||||
bodyshop,
|
||||
isThreeTier,
|
||||
2,
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: i.id,
|
||||
okStatusCodes: ["0", "3100"],
|
||||
qbxml: QbxmlReceivables.generateJobQbxml(
|
||||
i.job,
|
||||
bodyshop,
|
||||
isThreeTier,
|
||||
3,
|
||||
twoTierPref
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
|
||||
QbXmlToExecute.push({
|
||||
id: i.id,
|
||||
okStatusCodes: ["0"],
|
||||
|
||||
Reference in New Issue
Block a user