IO-3164 Schedule Completion Business Days

Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
Allan Carr
2025-04-21 12:27:33 -07:00
parent d02a6bc197
commit c21cc8d6b9
7 changed files with 41 additions and 27 deletions

View File

@@ -44,18 +44,16 @@ export function JobsDetailHeaderActionsToggleProduction({
variables: { id: job.id },
onCompleted: (data) => {
if (data?.jobs_by_pk) {
const totalHours =
(data.jobs_by_pk.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) +
(data.jobs_by_pk.larhrs?.aggregate?.sum?.mod_lb_hrs || 0);
form.setFieldsValue({
actual_in: data.jobs_by_pk.actual_in ? data.jobs_by_pk.actual_in : dayjs(),
scheduled_completion: data.jobs_by_pk.scheduled_completion
? data.jobs_by_pk.scheduled_completion
: data.jobs_by_pk.labhrs &&
data.jobs_by_pk.larhrs &&
dayjs().businessDaysAdd(
(data.jobs_by_pk.labhrs.aggregate.sum.mod_lb_hrs ||
0 + data.jobs_by_pk.larhrs.aggregate.sum.mod_lb_hrs ||
0) / bodyshop.target_touchtime,
"day"
),
: totalHours && bodyshop.ss_configuration.nobusinessdays
? dayjs().businessDaysAdd(totalHours / (bodyshop.target_touchtime || 1), "day")
: dayjs().add(totalHours / (bodyshop.target_touchtime || 1), "day"),
actual_completion: data.jobs_by_pk.actual_completion,
scheduled_delivery: data.jobs_by_pk.scheduled_delivery,
actual_delivery: data.jobs_by_pk.actual_delivery