IO-233 WIP CDK
This commit is contained in:
@@ -57,6 +57,7 @@ export function LaborAllocationsTable({
|
|||||||
sorter: (a, b) => alphaSort(a.cost_center, b.cost_center),
|
sorter: (a, b) => alphaSort(a.cost_center, b.cost_center),
|
||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "cost_center" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "cost_center" && state.sortedInfo.order,
|
||||||
|
render: (text, record) => `${record.cost_center} (${record.mod_lbr_ty})`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("jobs.labels.hrs_total"),
|
title: t("jobs.labels.hrs_total"),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export const CalculateAllocationsTotals = (
|
|||||||
const r = {
|
const r = {
|
||||||
opcode: value,
|
opcode: value,
|
||||||
cost_center: responsibilitycenters.defaults.costs[value],
|
cost_center: responsibilitycenters.defaults.costs[value],
|
||||||
|
mod_lbr_ty: value,
|
||||||
total: joblines.reduce((acc2, val2) => {
|
total: joblines.reduce((acc2, val2) => {
|
||||||
return val2.mod_lbr_ty === value ? acc2 + val2.mod_lb_hrs : acc2;
|
return val2.mod_lbr_ty === value ? acc2 + val2.mod_lb_hrs : acc2;
|
||||||
}, 0),
|
}, 0),
|
||||||
|
|||||||
@@ -181,6 +181,8 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
|||||||
"DEBUG",
|
"DEBUG",
|
||||||
`{8} Successfully posted sransaction to DMS.`
|
`{8} Successfully posted sransaction to DMS.`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await MarkJobExported(socket, socket.JobData.id);
|
||||||
} else {
|
} else {
|
||||||
//Get the error code
|
//Get the error code
|
||||||
CdkBase.createLogEvent(
|
CdkBase.createLogEvent(
|
||||||
@@ -217,6 +219,7 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
|||||||
"ERROR",
|
"ERROR",
|
||||||
`Error encountered in CdkSelectedCustomer. ${error}`
|
`Error encountered in CdkSelectedCustomer. ${error}`
|
||||||
);
|
);
|
||||||
|
await InsertFailedExportLog(socket, error);
|
||||||
} finally {
|
} finally {
|
||||||
//Ensure we always insert logEvents
|
//Ensure we always insert logEvents
|
||||||
//GQL to insert logevents.
|
//GQL to insert logevents.
|
||||||
@@ -568,7 +571,7 @@ async function InsertDmsCustomer(socket, newCustomerNumber) {
|
|||||||
await soapClientCustomerInsertUpdate.insertAsync(
|
await soapClientCustomerInsertUpdate.insertAsync(
|
||||||
{
|
{
|
||||||
arg0: CDK_CREDENTIALS,
|
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 },
|
arg2: { userId: null },
|
||||||
arg3: {
|
arg3: {
|
||||||
//Copied the required fields from the other integration.
|
//Copied the required fields from the other integration.
|
||||||
@@ -1219,3 +1222,44 @@ async function DeleteDmsWip(socket) {
|
|||||||
throw new Error(error);
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ query QUERY_JOBS_FOR_CDK_EXPORT($id: uuid!) {
|
|||||||
ca_customer_gst
|
ca_customer_gst
|
||||||
bodyshop {
|
bodyshop {
|
||||||
id
|
id
|
||||||
|
md_ro_statuses
|
||||||
md_responsibility_centers
|
md_responsibility_centers
|
||||||
accountingconfig
|
accountingconfig
|
||||||
cdk_dealerid
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user