IO-233 WIP CDK

This commit is contained in:
Patrick Fic
2021-09-09 15:18:43 -07:00
parent f3e078b481
commit 22e30ae5cb
4 changed files with 74 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ export function LaborAllocationsTable({
sorter: (a, b) => alphaSort(a.cost_center, b.cost_center),
sortOrder:
state.sortedInfo.columnKey === "cost_center" && state.sortedInfo.order,
render: (text, record) => `${record.cost_center} (${record.mod_lbr_ty})`,
},
{
title: t("jobs.labels.hrs_total"),

View File

@@ -16,6 +16,7 @@ export const CalculateAllocationsTotals = (
const r = {
opcode: value,
cost_center: responsibilitycenters.defaults.costs[value],
mod_lbr_ty: value,
total: joblines.reduce((acc2, val2) => {
return val2.mod_lbr_ty === value ? acc2 + val2.mod_lb_hrs : acc2;
}, 0),

View File

@@ -181,6 +181,8 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
"DEBUG",
`{8} Successfully posted sransaction to DMS.`
);
await MarkJobExported(socket, socket.JobData.id);
} else {
//Get the error code
CdkBase.createLogEvent(
@@ -217,6 +219,7 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
"ERROR",
`Error encountered in CdkSelectedCustomer. ${error}`
);
await InsertFailedExportLog(socket, error);
} finally {
//Ensure we always insert logEvents
//GQL to insert logevents.
@@ -568,7 +571,7 @@ async function InsertDmsCustomer(socket, newCustomerNumber) {
await soapClientCustomerInsertUpdate.insertAsync(
{
arg0: CDK_CREDENTIALS,
arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid },
arg2: { userId: null },
arg3: {
//Copied the required fields from the other integration.
@@ -1219,3 +1222,44 @@ async function DeleteDmsWip(socket) {
throw new Error(error);
}
}
async function MarkJobExported(socket, jobid) {
CdkBase.createLogEvent(socket, "DEBUG", `Querying job data for id ${jobid}`);
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
const result = await client
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
.request(queries.MARK_JOB_EXPORTED, {
jobId: jobid,
job: {
status:
socket.JobData.bodyshop.md_ro_statuses.default_exported ||
"Exported*",
date_exported: new Date(),
},
log: {
bodyshopid: socket.JobData.bodyshop.id,
jobid: jobid,
successful: true,
useremail: socket.user.email,
},
});
return result;
}
async function InsertFailedExportLog(socket, error) {
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
const result = await client
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
.request(queries.INSERT_EXPORT_LOG, {
log: {
bodyshopid: socket.JobData.bodyshop.id,
jobid: socket.JobData.id,
successful: false,
message: [error],
useremail: socket.user.email,
},
});
return result;
}

View File

@@ -177,6 +177,7 @@ query QUERY_JOBS_FOR_CDK_EXPORT($id: uuid!) {
ca_customer_gst
bodyshop {
id
md_ro_statuses
md_responsibility_centers
accountingconfig
cdk_dealerid
@@ -1067,3 +1068,29 @@ exports.SET_QBO_AUTH = `mutation SET_QBO_AUTH($email: String!, $qbo_auth: jsonb!
}
}
`;
exports.MARK_JOB_EXPORTED = `
mutation MARK_JOB_EXPORTED($jobId: uuid!, $job: jobs_set_input!, $log: exportlog_insert_input!) {
update_jobs(where: {id: {_eq: $jobId}}, _set: $job) {
returning {
id
date_exported
status
alt_transport
ro_number
production_vars
lbr_adjustments
}
}
insert_exportlog_one(object: $log) {
id
}
}
`;
exports.INSERT_EXPORT_LOG = `
mutation INSERT_EXPORT_LOG($log: exportlog_insert_input!) {
insert_exportlog_one(object: $log) {
id
}
}
`;