Add backwards compatibility for log generation.
This commit is contained in:
@@ -48,6 +48,7 @@ export function JobsCloseExportButton({
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||
PartnerResponse = await axios.post(`/qbo/receivables`, {
|
||||
jobIds: [jobId],
|
||||
elgen: true,
|
||||
});
|
||||
} else {
|
||||
//Default is QBD
|
||||
|
||||
@@ -40,6 +40,7 @@ export function JobsExportAllButton({
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||
PartnerResponse = await axios.post(`/qbo/receivables`, {
|
||||
jobIds: jobIds,
|
||||
elgen: true,
|
||||
});
|
||||
} else {
|
||||
let QbXmlResponse;
|
||||
|
||||
@@ -43,6 +43,7 @@ export function PayableExportAll({
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||
PartnerResponse = await axios.post(`/qbo/payables`, {
|
||||
bills: billids,
|
||||
elgen: true,
|
||||
});
|
||||
} else {
|
||||
let QbXmlResponse;
|
||||
|
||||
@@ -44,6 +44,7 @@ export function PayableExportButton({
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||
PartnerResponse = await axios.post(`/qbo/payables`, {
|
||||
bills: [billId],
|
||||
elgen: true,
|
||||
});
|
||||
} else {
|
||||
//Default is QBD
|
||||
|
||||
@@ -41,6 +41,7 @@ export function PaymentExportButton({
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||
PartnerResponse = await axios.post(`/qbo/payments`, {
|
||||
payments: [paymentId],
|
||||
elgen: true,
|
||||
});
|
||||
} else {
|
||||
//Default is QBD
|
||||
|
||||
@@ -39,6 +39,7 @@ export function PaymentsExportAllButton({
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) {
|
||||
PartnerResponse = await axios.post(`/qbo/payments`, {
|
||||
payments: paymentIds,
|
||||
elgen: true,
|
||||
});
|
||||
} else {
|
||||
let QbXmlResponse;
|
||||
|
||||
@@ -45,7 +45,7 @@ exports.default = async (req, res) => {
|
||||
await refreshOauthToken(oauthClient, req);
|
||||
|
||||
const BearerToken = req.headers.authorization;
|
||||
const { bills: billsToQuery } = req.body;
|
||||
const { bills: billsToQuery, elgen } = req.body;
|
||||
//Query Job Info
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
@@ -92,23 +92,25 @@ exports.default = async (req, res) => {
|
||||
);
|
||||
|
||||
// //No error. Mark the job exported & insert export log.
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QBO_MARK_BILL_EXPORTED, {
|
||||
billId: bill.id,
|
||||
bill: {
|
||||
exported: true,
|
||||
exported_at: moment().tz(bodyshop.timezone),
|
||||
},
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: bill.id,
|
||||
successful: true,
|
||||
useremail: req.user.email,
|
||||
if (elgen) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QBO_MARK_BILL_EXPORTED, {
|
||||
billId: bill.id,
|
||||
bill: {
|
||||
exported: true,
|
||||
exported_at: moment().tz(bodyshop.timezone),
|
||||
},
|
||||
],
|
||||
});
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: bill.id,
|
||||
successful: true,
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
ret.push({ billid: bill.id, success: true });
|
||||
} catch (error) {
|
||||
@@ -121,22 +123,24 @@ exports.default = async (req, res) => {
|
||||
});
|
||||
|
||||
//Add the export log error.
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: bill.id,
|
||||
successful: false,
|
||||
message: JSON.stringify([
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
(error && error.message),
|
||||
]),
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
if (elgen) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: bill.id,
|
||||
successful: false,
|
||||
message: JSON.stringify([
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
(error && error.message),
|
||||
]),
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ exports.default = async (req, res) => {
|
||||
await refreshOauthToken(oauthClient, req);
|
||||
|
||||
const BearerToken = req.headers.authorization;
|
||||
const { payments: paymentsToQuery } = req.body;
|
||||
const { payments: paymentsToQuery, elgen } = req.body;
|
||||
//Query Job Info
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
@@ -157,22 +157,24 @@ exports.default = async (req, res) => {
|
||||
}
|
||||
|
||||
// //No error. Mark the payment exported & insert export log.
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QBO_MARK_PAYMENT_EXPORTED, {
|
||||
paymentId: payment.id,
|
||||
payment: {
|
||||
exportedat: moment().tz(bodyshop.timezone),
|
||||
},
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
paymentid: payment.id,
|
||||
successful: true,
|
||||
useremail: req.user.email,
|
||||
if (elgen) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QBO_MARK_PAYMENT_EXPORTED, {
|
||||
paymentId: payment.id,
|
||||
payment: {
|
||||
exportedat: moment().tz(bodyshop.timezone),
|
||||
},
|
||||
],
|
||||
});
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
paymentid: payment.id,
|
||||
successful: true,
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
ret.push({ paymentid: payment.id, success: true });
|
||||
} catch (error) {
|
||||
@@ -182,23 +184,25 @@ exports.default = async (req, res) => {
|
||||
(error && error.message),
|
||||
});
|
||||
//Add the export log error.
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
paymentid: payment.id,
|
||||
successful: false,
|
||||
message: JSON.stringify([
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
(error && error.message),
|
||||
]),
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (elgen) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
paymentid: payment.id,
|
||||
successful: false,
|
||||
message: JSON.stringify([
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
(error && error.message),
|
||||
]),
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
ret.push({
|
||||
paymentid: payment.id,
|
||||
success: false,
|
||||
|
||||
@@ -46,7 +46,7 @@ exports.default = async (req, res) => {
|
||||
await refreshOauthToken(oauthClient, req);
|
||||
|
||||
const BearerToken = req.headers.authorization;
|
||||
const { jobIds } = req.body;
|
||||
const { jobIds, elgen } = req.body;
|
||||
//Query Job Info
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
@@ -141,23 +141,26 @@ exports.default = async (req, res) => {
|
||||
);
|
||||
|
||||
// //No error. Mark the job exported & insert export log.
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QBO_MARK_JOB_EXPORTED, {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
status: bodyshop.md_ro_statuses.default_exported || "Exported*",
|
||||
date_exported: moment().tz(bodyshop.timezone),
|
||||
},
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: job.id,
|
||||
successful: true,
|
||||
useremail: req.user.email,
|
||||
if (elgen) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.QBO_MARK_JOB_EXPORTED, {
|
||||
jobId: job.id,
|
||||
job: {
|
||||
status:
|
||||
bodyshop.md_ro_statuses.default_exported || "Exported*",
|
||||
date_exported: moment().tz(bodyshop.timezone),
|
||||
},
|
||||
],
|
||||
});
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: job.id,
|
||||
successful: true,
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
ret.push({ jobid: job.id, success: true });
|
||||
} catch (error) {
|
||||
@@ -169,22 +172,24 @@ exports.default = async (req, res) => {
|
||||
(error && error.message),
|
||||
});
|
||||
//Add the export log error.
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: job.id,
|
||||
successful: false,
|
||||
message: JSON.stringify([
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
(error && error.message),
|
||||
]),
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
if (elgen) {
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: BearerToken })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: job.id,
|
||||
successful: false,
|
||||
message: JSON.stringify([
|
||||
(error && error.authResponse && error.authResponse.body) ||
|
||||
(error && error.message),
|
||||
]),
|
||||
useremail: req.user.email,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user