Merged in release/2022-05-06 (pull request #458)
Add backwards compatibility for log generation.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,23 +92,25 @@ exports.default = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// //No error. Mark the job exported & insert export log.
|
// //No error. Mark the job exported & insert export log.
|
||||||
const result = await client
|
if (elgen) {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
const result = await client
|
||||||
.request(queries.QBO_MARK_BILL_EXPORTED, {
|
.setHeaders({ Authorization: BearerToken })
|
||||||
billId: bill.id,
|
.request(queries.QBO_MARK_BILL_EXPORTED, {
|
||||||
bill: {
|
billId: bill.id,
|
||||||
exported: true,
|
bill: {
|
||||||
exported_at: moment().tz(bodyshop.timezone),
|
exported: true,
|
||||||
},
|
exported_at: moment().tz(bodyshop.timezone),
|
||||||
logs: [
|
|
||||||
{
|
|
||||||
bodyshopid: bodyshop.id,
|
|
||||||
billid: bill.id,
|
|
||||||
successful: true,
|
|
||||||
useremail: req.user.email,
|
|
||||||
},
|
},
|
||||||
],
|
logs: [
|
||||||
});
|
{
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
|
billid: bill.id,
|
||||||
|
successful: true,
|
||||||
|
useremail: req.user.email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ret.push({ billid: bill.id, success: true });
|
ret.push({ billid: bill.id, success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -121,22 +123,24 @@ exports.default = async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Add the export log error.
|
//Add the export log error.
|
||||||
const result = await client
|
if (elgen) {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
const result = await client
|
||||||
.request(queries.INSERT_EXPORT_LOG, {
|
.setHeaders({ Authorization: BearerToken })
|
||||||
logs: [
|
.request(queries.INSERT_EXPORT_LOG, {
|
||||||
{
|
logs: [
|
||||||
bodyshopid: bodyshop.id,
|
{
|
||||||
billid: bill.id,
|
bodyshopid: bodyshop.id,
|
||||||
successful: false,
|
billid: bill.id,
|
||||||
message: JSON.stringify([
|
successful: false,
|
||||||
(error && error.authResponse && error.authResponse.body) ||
|
message: JSON.stringify([
|
||||||
(error && error.message),
|
(error && error.authResponse && error.authResponse.body) ||
|
||||||
]),
|
(error && error.message),
|
||||||
useremail: req.user.email,
|
]),
|
||||||
},
|
useremail: req.user.email,
|
||||||
],
|
},
|
||||||
});
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,22 +157,24 @@ exports.default = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// //No error. Mark the payment exported & insert export log.
|
// //No error. Mark the payment exported & insert export log.
|
||||||
const result = await client
|
if (elgen) {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
const result = await client
|
||||||
.request(queries.QBO_MARK_PAYMENT_EXPORTED, {
|
.setHeaders({ Authorization: BearerToken })
|
||||||
paymentId: payment.id,
|
.request(queries.QBO_MARK_PAYMENT_EXPORTED, {
|
||||||
payment: {
|
paymentId: payment.id,
|
||||||
exportedat: moment().tz(bodyshop.timezone),
|
payment: {
|
||||||
},
|
exportedat: moment().tz(bodyshop.timezone),
|
||||||
logs: [
|
|
||||||
{
|
|
||||||
bodyshopid: bodyshop.id,
|
|
||||||
paymentid: payment.id,
|
|
||||||
successful: true,
|
|
||||||
useremail: req.user.email,
|
|
||||||
},
|
},
|
||||||
],
|
logs: [
|
||||||
});
|
{
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
|
paymentid: payment.id,
|
||||||
|
successful: true,
|
||||||
|
useremail: req.user.email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ret.push({ paymentid: payment.id, success: true });
|
ret.push({ paymentid: payment.id, success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -182,22 +184,24 @@ exports.default = async (req, res) => {
|
|||||||
(error && error.message),
|
(error && error.message),
|
||||||
});
|
});
|
||||||
//Add the export log error.
|
//Add the export log error.
|
||||||
const result = await client
|
if (elgen) {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
const result = await client
|
||||||
.request(queries.INSERT_EXPORT_LOG, {
|
.setHeaders({ Authorization: BearerToken })
|
||||||
logs: [
|
.request(queries.INSERT_EXPORT_LOG, {
|
||||||
{
|
logs: [
|
||||||
bodyshopid: bodyshop.id,
|
{
|
||||||
paymentid: payment.id,
|
bodyshopid: bodyshop.id,
|
||||||
successful: false,
|
paymentid: payment.id,
|
||||||
message: JSON.stringify([
|
successful: false,
|
||||||
(error && error.authResponse && error.authResponse.body) ||
|
message: JSON.stringify([
|
||||||
(error && error.message),
|
(error && error.authResponse && error.authResponse.body) ||
|
||||||
]),
|
(error && error.message),
|
||||||
useremail: req.user.email,
|
]),
|
||||||
},
|
useremail: req.user.email,
|
||||||
],
|
},
|
||||||
});
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
paymentid: payment.id,
|
paymentid: payment.id,
|
||||||
|
|||||||
@@ -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,23 +141,26 @@ exports.default = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// //No error. Mark the job exported & insert export log.
|
// //No error. Mark the job exported & insert export log.
|
||||||
const result = await client
|
if (elgen) {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
const result = await client
|
||||||
.request(queries.QBO_MARK_JOB_EXPORTED, {
|
.setHeaders({ Authorization: BearerToken })
|
||||||
jobId: job.id,
|
.request(queries.QBO_MARK_JOB_EXPORTED, {
|
||||||
job: {
|
jobId: job.id,
|
||||||
status: bodyshop.md_ro_statuses.default_exported || "Exported*",
|
job: {
|
||||||
date_exported: moment().tz(bodyshop.timezone),
|
status:
|
||||||
},
|
bodyshop.md_ro_statuses.default_exported || "Exported*",
|
||||||
logs: [
|
date_exported: moment().tz(bodyshop.timezone),
|
||||||
{
|
|
||||||
bodyshopid: bodyshop.id,
|
|
||||||
jobid: job.id,
|
|
||||||
successful: true,
|
|
||||||
useremail: req.user.email,
|
|
||||||
},
|
},
|
||||||
],
|
logs: [
|
||||||
});
|
{
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
|
jobid: job.id,
|
||||||
|
successful: true,
|
||||||
|
useremail: req.user.email,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ret.push({ jobid: job.id, success: true });
|
ret.push({ jobid: job.id, success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -169,22 +172,24 @@ exports.default = async (req, res) => {
|
|||||||
(error && error.message),
|
(error && error.message),
|
||||||
});
|
});
|
||||||
//Add the export log error.
|
//Add the export log error.
|
||||||
const result = await client
|
if (elgen) {
|
||||||
.setHeaders({ Authorization: BearerToken })
|
const result = await client
|
||||||
.request(queries.INSERT_EXPORT_LOG, {
|
.setHeaders({ Authorization: BearerToken })
|
||||||
logs: [
|
.request(queries.INSERT_EXPORT_LOG, {
|
||||||
{
|
logs: [
|
||||||
bodyshopid: bodyshop.id,
|
{
|
||||||
jobid: job.id,
|
bodyshopid: bodyshop.id,
|
||||||
successful: false,
|
jobid: job.id,
|
||||||
message: JSON.stringify([
|
successful: false,
|
||||||
(error && error.authResponse && error.authResponse.body) ||
|
message: JSON.stringify([
|
||||||
(error && error.message),
|
(error && error.authResponse && error.authResponse.body) ||
|
||||||
]),
|
(error && error.message),
|
||||||
useremail: req.user.email,
|
]),
|
||||||
},
|
useremail: req.user.email,
|
||||||
],
|
},
|
||||||
});
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user