diff --git a/client/src/components/job-at-change/schedule-event.component.jsx b/client/src/components/job-at-change/schedule-event.component.jsx index 123bc9879..f37290fbc 100644 --- a/client/src/components/job-at-change/schedule-event.component.jsx +++ b/client/src/components/job-at-change/schedule-event.component.jsx @@ -69,12 +69,17 @@ export function ScheduleEventComponent({ variables: { id: event.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, - actual_completion: data.jobs_by_pk.actual_completion, - scheduled_delivery: data.jobs_by_pk.scheduled_delivery, - actual_delivery: data.jobs_by_pk.actual_delivery + scheduled_completion: data.jobs_by_pk.scheduled_completion + ? data.jobs_by_pk.scheduled_completion + : totalHours && bodyshop.ss_configuration.nobusinessdays + ? dayjs().businessDaysAdd(totalHours / (bodyshop.target_touchtime || 1), "day") + : dayjs().add(totalHours / (bodyshop.target_touchtime || 1), "day"), + scheduled_delivery: data.jobs_by_pk.scheduled_delivery }); } }, diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx index 3b6d8ec1a..c14099f89 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx @@ -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 diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx index c55163479..18890e507 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx @@ -1,6 +1,6 @@ import { Button, Col, Form, Input, Row, Select, Space, Switch, Typography } from "antd"; import axios from "axios"; -import React, { useState } from "react"; +import { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -8,16 +8,16 @@ import { calculateScheduleLoad } from "../../redux/application/application.actio import { selectBodyshop } from "../../redux/user/user.selectors"; import { DateFormatter } from "../../utils/DateFormatter"; import dayjs from "../../utils/day"; +import BlurWrapper from "../feature-wrapper/blur-wrapper.component"; import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component"; import EmailInput from "../form-items-formatted/email-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; +import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component"; import ScheduleDayViewContainer from "../schedule-day-view/schedule-day-view.container"; import ScheduleExistingAppointmentsList from "../schedule-existing-appointments-list/schedule-existing-appointments-list.component"; -import "./schedule-job-modal.scss"; -import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component"; -import BlurWrapper from "../feature-wrapper/blur-wrapper.component"; import UpsellComponent, { upsellEnum } from "../upsell/upsell.component"; +import "./schedule-job-modal.scss"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop @@ -60,10 +60,12 @@ export function ScheduleJobModalComponent({ const totalHours = lbrHrsData.jobs_by_pk.labhrs.aggregate.sum.mod_lb_hrs + lbrHrsData.jobs_by_pk.larhrs.aggregate.sum.mod_lb_hrs; - if (values.start && !values.scheduled_completion) - form.setFieldsValue({ - scheduled_completion: dayjs(values.start).businessDaysAdd(totalHours / bodyshop.target_touchtime, "day") - }); + if (values.start && !values.scheduled_completion) { + const addDays = bodyshop.ss_configuration.nobusinessdays + ? dayjs(values.start).add(totalHours / (bodyshop.target_touchtime || 1), "day") + : dayjs(values.start).businessDaysAdd(totalHours / (bodyshop.target_touchtime || 1), "day"); + form.setFieldsValue({ scheduled_completion: addDays }); + } } }; diff --git a/client/src/components/shop-info/shop-info.scheduling.component.jsx b/client/src/components/shop-info/shop-info.scheduling.component.jsx index 36fd0e6d1..4c88b5704 100644 --- a/client/src/components/shop-info/shop-info.scheduling.component.jsx +++ b/client/src/components/shop-info/shop-info.scheduling.component.jsx @@ -1,16 +1,15 @@ import { DeleteFilled } from "@ant-design/icons"; import { Button, Divider, Form, Input, InputNumber, Select, Space, Switch, TimePicker } from "antd"; -import React from "react"; import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import ColorpickerFormItemComponent from "../form-items-formatted/colorpicker-form-item.component"; import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import { ColorPicker } from "./shop-info.rostatus.component"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop }); @@ -78,6 +77,13 @@ export function ShopInfoSchedulingComponent({ form, bodyshop }) { > + + +