Add backwards compatibility for log generation.

This commit is contained in:
Patrick Fic
2022-05-03 11:08:08 -07:00
parent 9b4e83705b
commit d533423fb6
9 changed files with 118 additions and 99 deletions

View File

@@ -48,6 +48,7 @@ export function JobsCloseExportButton({
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
PartnerResponse = await axios.post(`/qbo/receivables`, { PartnerResponse = await axios.post(`/qbo/receivables`, {
jobIds: [jobId], jobIds: [jobId],
elgen: true,
}); });
} else { } else {
//Default is QBD //Default is QBD

View File

@@ -40,6 +40,7 @@ export function JobsExportAllButton({
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
PartnerResponse = await axios.post(`/qbo/receivables`, { PartnerResponse = await axios.post(`/qbo/receivables`, {
jobIds: jobIds, jobIds: jobIds,
elgen: true,
}); });
} else { } else {
let QbXmlResponse; let QbXmlResponse;

View File

@@ -43,6 +43,7 @@ export function PayableExportAll({
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
PartnerResponse = await axios.post(`/qbo/payables`, { PartnerResponse = await axios.post(`/qbo/payables`, {
bills: billids, bills: billids,
elgen: true,
}); });
} else { } else {
let QbXmlResponse; let QbXmlResponse;

View File

@@ -44,6 +44,7 @@ export function PayableExportButton({
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
PartnerResponse = await axios.post(`/qbo/payables`, { PartnerResponse = await axios.post(`/qbo/payables`, {
bills: [billId], bills: [billId],
elgen: true,
}); });
} else { } else {
//Default is QBD //Default is QBD

View File

@@ -41,6 +41,7 @@ export function PaymentExportButton({
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
PartnerResponse = await axios.post(`/qbo/payments`, { PartnerResponse = await axios.post(`/qbo/payments`, {
payments: [paymentId], payments: [paymentId],
elgen: true,
}); });
} else { } else {
//Default is QBD //Default is QBD

View File

@@ -39,6 +39,7 @@ export function PaymentsExportAllButton({
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
PartnerResponse = await axios.post(`/qbo/payments`, { PartnerResponse = await axios.post(`/qbo/payments`, {
payments: paymentIds, payments: paymentIds,
elgen: true,
}); });
} else { } else {
let QbXmlResponse; let QbXmlResponse;

View File

@@ -45,7 +45,7 @@ exports.default = async (req, res) => {
await refreshOauthToken(oauthClient, req); await refreshOauthToken(oauthClient, req);
const BearerToken = req.headers.authorization; const BearerToken = req.headers.authorization;
const { bills: billsToQuery } = req.body; const { bills: billsToQuery, elgen } = req.body;
//Query Job Info //Query Job Info
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, { const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
headers: { headers: {
@@ -92,6 +92,7 @@ exports.default = async (req, res) => {
); );
// //No error. Mark the job exported & insert export log. // //No error. Mark the job exported & insert export log.
if (elgen) {
const result = await client const result = await client
.setHeaders({ Authorization: BearerToken }) .setHeaders({ Authorization: BearerToken })
.request(queries.QBO_MARK_BILL_EXPORTED, { .request(queries.QBO_MARK_BILL_EXPORTED, {
@@ -109,6 +110,7 @@ exports.default = async (req, res) => {
}, },
], ],
}); });
}
ret.push({ billid: bill.id, success: true }); ret.push({ billid: bill.id, success: true });
} catch (error) { } catch (error) {
@@ -121,6 +123,7 @@ exports.default = async (req, res) => {
}); });
//Add the export log error. //Add the export log error.
if (elgen) {
const result = await client const result = await client
.setHeaders({ Authorization: BearerToken }) .setHeaders({ Authorization: BearerToken })
.request(queries.INSERT_EXPORT_LOG, { .request(queries.INSERT_EXPORT_LOG, {
@@ -139,6 +142,7 @@ exports.default = async (req, res) => {
}); });
} }
} }
}
res.status(200).json(ret); res.status(200).json(ret);
} catch (error) { } catch (error) {

View File

@@ -52,7 +52,7 @@ exports.default = async (req, res) => {
await refreshOauthToken(oauthClient, req); await refreshOauthToken(oauthClient, req);
const BearerToken = req.headers.authorization; const BearerToken = req.headers.authorization;
const { payments: paymentsToQuery } = req.body; const { payments: paymentsToQuery, elgen } = req.body;
//Query Job Info //Query Job Info
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, { const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
headers: { headers: {
@@ -157,6 +157,7 @@ exports.default = async (req, res) => {
} }
// //No error. Mark the payment exported & insert export log. // //No error. Mark the payment exported & insert export log.
if (elgen) {
const result = await client const result = await client
.setHeaders({ Authorization: BearerToken }) .setHeaders({ Authorization: BearerToken })
.request(queries.QBO_MARK_PAYMENT_EXPORTED, { .request(queries.QBO_MARK_PAYMENT_EXPORTED, {
@@ -173,6 +174,7 @@ exports.default = async (req, res) => {
}, },
], ],
}); });
}
ret.push({ paymentid: payment.id, success: true }); ret.push({ paymentid: payment.id, success: true });
} catch (error) { } catch (error) {
@@ -182,6 +184,7 @@ exports.default = async (req, res) => {
(error && error.message), (error && error.message),
}); });
//Add the export log error. //Add the export log error.
if (elgen) {
const result = await client const result = await client
.setHeaders({ Authorization: BearerToken }) .setHeaders({ Authorization: BearerToken })
.request(queries.INSERT_EXPORT_LOG, { .request(queries.INSERT_EXPORT_LOG, {
@@ -198,6 +201,7 @@ exports.default = async (req, res) => {
}, },
], ],
}); });
}
ret.push({ ret.push({
paymentid: payment.id, paymentid: payment.id,

View File

@@ -46,7 +46,7 @@ exports.default = async (req, res) => {
await refreshOauthToken(oauthClient, req); await refreshOauthToken(oauthClient, req);
const BearerToken = req.headers.authorization; const BearerToken = req.headers.authorization;
const { jobIds } = req.body; const { jobIds, elgen } = req.body;
//Query Job Info //Query Job Info
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, { const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
headers: { headers: {
@@ -141,12 +141,14 @@ exports.default = async (req, res) => {
); );
// //No error. Mark the job exported & insert export log. // //No error. Mark the job exported & insert export log.
if (elgen) {
const result = await client const result = await client
.setHeaders({ Authorization: BearerToken }) .setHeaders({ Authorization: BearerToken })
.request(queries.QBO_MARK_JOB_EXPORTED, { .request(queries.QBO_MARK_JOB_EXPORTED, {
jobId: job.id, jobId: job.id,
job: { job: {
status: bodyshop.md_ro_statuses.default_exported || "Exported*", status:
bodyshop.md_ro_statuses.default_exported || "Exported*",
date_exported: moment().tz(bodyshop.timezone), date_exported: moment().tz(bodyshop.timezone),
}, },
logs: [ logs: [
@@ -159,6 +161,7 @@ exports.default = async (req, res) => {
], ],
}); });
} }
}
ret.push({ jobid: job.id, success: true }); ret.push({ jobid: job.id, success: true });
} catch (error) { } catch (error) {
ret.push({ ret.push({
@@ -169,6 +172,7 @@ exports.default = async (req, res) => {
(error && error.message), (error && error.message),
}); });
//Add the export log error. //Add the export log error.
if (elgen) {
const result = await client const result = await client
.setHeaders({ Authorization: BearerToken }) .setHeaders({ Authorization: BearerToken })
.request(queries.INSERT_EXPORT_LOG, { .request(queries.INSERT_EXPORT_LOG, {
@@ -187,6 +191,7 @@ exports.default = async (req, res) => {
}); });
} }
} }
}
res.status(200).json(ret); res.status(200).json(ret);
} catch (error) { } catch (error) {