Merged in feature/IO-3509-Duplicate-Job-Open-Estimate-Date (pull request #2891)
IO-3509 Duplicate Job Open Estimate Date Approved-by: Dave Richer
This commit is contained in:
@@ -50,7 +50,8 @@ export function JobCreateIOU({ bodyshop, currentUser, job, selectedJobLines, tec
|
|||||||
config: {
|
config: {
|
||||||
status: bodyshop.md_ro_statuses.default_open,
|
status: bodyshop.md_ro_statuses.default_open,
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
useremail: currentUser.email
|
useremail: currentUser.email,
|
||||||
|
timezone: bodyshop.timezone
|
||||||
},
|
},
|
||||||
currentUser
|
currentUser
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ export function JobsDetailHeaderActions({
|
|||||||
DuplicateJob({
|
DuplicateJob({
|
||||||
apolloClient: client,
|
apolloClient: client,
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
config: { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported },
|
config: { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported, timezone: bodyshop.timezone },
|
||||||
completionCallback: (newJobId) => {
|
completionCallback: (newJobId) => {
|
||||||
history(`/manage/jobs/${newJobId}`);
|
history(`/manage/jobs/${newJobId}`);
|
||||||
notification.success({
|
notification.success({
|
||||||
@@ -279,7 +279,7 @@ export function JobsDetailHeaderActions({
|
|||||||
DuplicateJob({
|
DuplicateJob({
|
||||||
apolloClient: client,
|
apolloClient: client,
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
config: { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported },
|
config: { defaultOpenStatus: bodyshop.md_ro_statuses.default_imported, timezone: bodyshop.timezone },
|
||||||
completionCallback: (newJobId) => {
|
completionCallback: (newJobId) => {
|
||||||
history(`/manage/jobs/${newJobId}`);
|
history(`/manage/jobs/${newJobId}`);
|
||||||
notification.success({
|
notification.success({
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default async function DuplicateJob({
|
|||||||
}) {
|
}) {
|
||||||
logImEXEvent("job_duplicate");
|
logImEXEvent("job_duplicate");
|
||||||
|
|
||||||
const { defaultOpenStatus } = config;
|
const { defaultOpenStatus, timezone } = config;
|
||||||
//get a list of all fields on the job
|
//get a list of all fields on the job
|
||||||
const res = await apolloClient.query({
|
const res = await apolloClient.query({
|
||||||
query: QUERY_JOB_FOR_DUPE,
|
query: QUERY_JOB_FOR_DUPE,
|
||||||
@@ -31,9 +31,12 @@ export default async function DuplicateJob({
|
|||||||
delete existingJob.updatedat;
|
delete existingJob.updatedat;
|
||||||
delete existingJob.cieca_stl;
|
delete existingJob.cieca_stl;
|
||||||
delete existingJob.cieca_ttl;
|
delete existingJob.cieca_ttl;
|
||||||
|
!keepJobLines && delete existingJob.clm_total;
|
||||||
|
|
||||||
const newJob = {
|
const newJob = {
|
||||||
...existingJob,
|
...existingJob,
|
||||||
|
date_estimated: dayjs().tz(timezone, false).format("YYYY-MM-DD"),
|
||||||
|
date_open: dayjs(),
|
||||||
status: defaultOpenStatus
|
status: defaultOpenStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,7 +73,7 @@ export default async function DuplicateJob({
|
|||||||
export async function CreateIouForJob({ apolloClient, jobId, config, jobLinesToKeep, currentUser }) {
|
export async function CreateIouForJob({ apolloClient, jobId, config, jobLinesToKeep, currentUser }) {
|
||||||
logImEXEvent("job_create_iou");
|
logImEXEvent("job_create_iou");
|
||||||
|
|
||||||
const { status } = config;
|
const { status, timezone } = config;
|
||||||
//get a list of all fields on the job
|
//get a list of all fields on the job
|
||||||
const res = await apolloClient.query({
|
const res = await apolloClient.query({
|
||||||
query: QUERY_JOB_FOR_DUPE,
|
query: QUERY_JOB_FOR_DUPE,
|
||||||
@@ -88,10 +91,10 @@ export async function CreateIouForJob({ apolloClient, jobId, config, jobLinesToK
|
|||||||
|
|
||||||
const newJob = {
|
const newJob = {
|
||||||
...existingJob,
|
...existingJob,
|
||||||
|
|
||||||
converted: true,
|
converted: true,
|
||||||
status: status,
|
status: status,
|
||||||
iouparent: jobId,
|
iouparent: jobId,
|
||||||
|
date_estimated: dayjs().tz(timezone, false).format("YYYY-MM-DD"),
|
||||||
date_open: dayjs(),
|
date_open: dayjs(),
|
||||||
audit_trails: {
|
audit_trails: {
|
||||||
data: [
|
data: [
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ exports.totalsSsu = async function (req, res) {
|
|||||||
throw new Error("Failed to update job totals");
|
throw new Error("Failed to update job totals");
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).send();
|
res.status(200).json({ success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("job-totals-ssu-USA-error", "error", req?.user?.email, id, {
|
logger.log("job-totals-ssu-USA-error", "error", req?.user?.email, id, {
|
||||||
jobid: id,
|
jobid: id,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
res.status(503).send();
|
res.status(503).json({ error: "Failed to calculate totals" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ exports.totalsSsu = async function (req, res) {
|
|||||||
throw new Error("Failed to update job totals");
|
throw new Error("Failed to update job totals");
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).send();
|
res.status(200).json({ success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("job-totals-ssu-error", "error", req.user.email, id, {
|
logger.log("job-totals-ssu-error", "error", req.user.email, id, {
|
||||||
jobid: id,
|
jobid: id,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
});
|
});
|
||||||
res.status(503).send();
|
res.status(503).json({ error: "Failed to calculate totals" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user