From 453236cf3ae812bb39555e2637e8883bdbd7aae1 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 11 Apr 2024 09:49:00 -0700 Subject: [PATCH] Bug fixes and formatting for RO guard. --- bodyshop_translations.babel | 21 +++++ .../job-close-ro-gaurd.labor.jsx | 38 ++++----- .../job-close-ro-guard.ar.jsx | 38 ++++----- .../job-close-ro-guard.bills.jsx | 24 +++--- .../job-close-ro-guard.container.jsx | 23 ++++-- .../job-close-ro-guard.profit.jsx | 34 ++++---- .../job-close-ro-guard.sublet.jsx | 81 ++++++++----------- .../job-close-ro-guard.tt-lifecycle.jsx | 14 ++-- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 11 files changed, 146 insertions(+), 130 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 8683bea4c..b8ca6e6f1 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -34201,6 +34201,27 @@ + + profitbypassrequired + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + profits false diff --git a/client/src/components/job-close-ro-guard/job-close-ro-gaurd.labor.jsx b/client/src/components/job-close-ro-guard/job-close-ro-gaurd.labor.jsx index 8a874d5b7..82721ccbc 100644 --- a/client/src/components/job-close-ro-guard/job-close-ro-gaurd.labor.jsx +++ b/client/src/components/job-close-ro-guard/job-close-ro-gaurd.labor.jsx @@ -1,20 +1,20 @@ -import React from 'react'; +import React from "react"; -import { useQuery } from '@apollo/client'; -import { useSplitTreatments } from '@splitsoftware/splitio-react'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { GET_LINE_TICKET_BY_PK } from '../../graphql/jobs-lines.queries'; -import { selectJobReadOnly } from '../../redux/application/application.selectors'; -import { selectBodyshop } from '../../redux/user/user.selectors'; -import AlertComponent from '../alert/alert.component'; -import LaborAllocationsTableComponent from '../labor-allocations-table/labor-allocations-table.component'; -import PayrollLaborAllocationsTable from '../labor-allocations-table/labor-allocations-table.payroll.component'; -import LoadingSkeleton from '../loading-skeleton/loading-skeleton.component'; +import { useQuery } from "@apollo/client"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries"; +import { selectJobReadOnly } from "../../redux/application/application.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import AlertComponent from "../alert/alert.component"; +import LaborAllocationsTableComponent from "../labor-allocations-table/labor-allocations-table.component"; +import PayrollLaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.payroll.component"; +import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, - jobRO: selectJobReadOnly, + jobRO: selectJobReadOnly }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -24,21 +24,21 @@ export default connect(mapStateToProps, mapDispatchToProps)(JobCloseRoGuardLabor export function JobCloseRoGuardLabor({ job, jobRO, bodyshop, form, warningCallback }) { const { loading, error, data, refetch } = useQuery(GET_LINE_TICKET_BY_PK, { variables: { id: job.id }, - fetchPolicy: 'network-only', - nextFetchPolicy: 'network-only', + fetchPolicy: "network-only", + nextFetchPolicy: "network-only" }); const { - treatments: { Enhanced_Payroll }, + treatments: { Enhanced_Payroll } } = useSplitTreatments({ attributes: {}, - names: ['Enhanced_Payroll'], - splitKey: bodyshop.imexshopid, + names: ["Enhanced_Payroll"], + splitKey: bodyshop.imexshopid }); if (loading) return ; if (error) return ; - return Enhanced_Payroll.treatment === 'on' ? ( + return Enhanced_Payroll.treatment === "on" ? ( ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -41,25 +41,21 @@ export function JobCloseRoGuardProfit({ job, jobRO, bodyshop, form, warningCallb useEffect(() => { if (balance.getAmount() !== 0) { - warningCallback({ key: 'ar', warning: t('jobs.labels.outstanding_ar') }); + warningCallback({ key: "ar", warning: t("jobs.labels.outstanding_ar") }); } }, [balance, t, warningCallback]); return ( - - {total.toFormat()} + + {total.toFormat()} {balance.toFormat()} {balance.getAmount() !== 0 && ( - + )} ); diff --git a/client/src/components/job-close-ro-guard/job-close-ro-guard.bills.jsx b/client/src/components/job-close-ro-guard/job-close-ro-guard.bills.jsx index 23a0fe478..4bf03ea46 100644 --- a/client/src/components/job-close-ro-guard/job-close-ro-guard.bills.jsx +++ b/client/src/components/job-close-ro-guard/job-close-ro-guard.bills.jsx @@ -1,17 +1,17 @@ -import React from 'react'; +import React from "react"; -import { useQuery } from '@apollo/client'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { QUERY_BILLS_BY_JOBID } from '../../graphql/bills.queries'; -import { selectJobReadOnly } from '../../redux/application/application.selectors'; -import { selectBodyshop } from '../../redux/user/user.selectors'; -import AlertComponent from '../alert/alert.component'; -import JobBillsTotalComponent from '../job-bills-total/job-bills-total.component'; +import { useQuery } from "@apollo/client"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { QUERY_BILLS_BY_JOBID } from "../../graphql/bills.queries"; +import { selectJobReadOnly } from "../../redux/application/application.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import AlertComponent from "../alert/alert.component"; +import JobBillsTotalComponent from "../job-bills-total/job-bills-total.component"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, - jobRO: selectJobReadOnly, + jobRO: selectJobReadOnly }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -21,8 +21,8 @@ export default connect(mapStateToProps, mapDispatchToProps)(JobCloseRoGuardBills export function JobCloseRoGuardBills({ job, jobRO, bodyshop, form, warningCallback }) { const { loading, error, data } = useQuery(QUERY_BILLS_BY_JOBID, { variables: { jobid: job.id }, - fetchPolicy: 'network-only', - nextFetchPolicy: 'network-only', + fetchPolicy: "network-only", + nextFetchPolicy: "network-only" }); if (error) return ; diff --git a/client/src/components/job-close-ro-guard/job-close-ro-guard.container.jsx b/client/src/components/job-close-ro-guard/job-close-ro-guard.container.jsx index 04a07bd98..8dfdb1574 100644 --- a/client/src/components/job-close-ro-guard/job-close-ro-guard.container.jsx +++ b/client/src/components/job-close-ro-guard/job-close-ro-guard.container.jsx @@ -76,20 +76,27 @@ export function JobCloseRoGuardContainer({ job, jobRO, bodyshop, form }) { - + - - - {InstanceRenderManager({ rome: })} - + {InstanceRenderManager({ + imex: ( + + {/* */} + + + ), + rome: ( + + {/* */} + + + ) + })} diff --git a/client/src/components/job-close-ro-guard/job-close-ro-guard.profit.jsx b/client/src/components/job-close-ro-guard/job-close-ro-guard.profit.jsx index 4cbbca357..2add7848d 100644 --- a/client/src/components/job-close-ro-guard/job-close-ro-guard.profit.jsx +++ b/client/src/components/job-close-ro-guard/job-close-ro-guard.profit.jsx @@ -1,20 +1,19 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState } from "react"; -import { LockOutlined } from '@ant-design/icons'; -import { Card, Form, Input } from 'antd'; -import axios from 'axios'; -import { useTranslation } from 'react-i18next'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { selectJobReadOnly } from '../../redux/application/application.selectors'; -import { selectBodyshop } from '../../redux/user/user.selectors'; -import JobCostingStatistics from '../job-costing-statistics/job-costing-statistics.component'; -import LoadingSkeleton from '../loading-skeleton/loading-skeleton.component'; +import { Alert, Card } from "antd"; +import axios from "axios"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectJobReadOnly } from "../../redux/application/application.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import JobCostingStatistics from "../job-costing-statistics/job-costing-statistics.component"; +import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, - jobRO: selectJobReadOnly, + jobRO: selectJobReadOnly }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -31,7 +30,7 @@ export function JobCloseRoGuardProfit({ job, jobRO, bodyshop, form, warningCallb try { if (job.id) { setLoading(true); - const { data } = await axios.post('/job/costing', { jobid: job.id }); + const { data } = await axios.post("/job/costing", { jobid: job.id }); setCostingData(data); } } catch (error) {} @@ -45,16 +44,19 @@ export function JobCloseRoGuardProfit({ job, jobRO, bodyshop, form, warningCallb parseFloat(costingData?.summaryData.gppercent) < bodyshop?.md_ro_guard?.totalgppercent_minimum; useEffect(() => { - if (enforceProfitPassword && typeof warningCallback === 'function') { - warningCallback({ key: 'profit', warning: t('jobs.labels.profitbypassrequired') }); + if (enforceProfitPassword && typeof warningCallback === "function") { + warningCallback({ key: "profit", warning: t("jobs.labels.profitbypassrequired") }); } }, [enforceProfitPassword, t, warningCallback]); if (loading || !costingData) return ; return ( - + + {enforceProfitPassword && ( + + )} ); } diff --git a/client/src/components/job-close-ro-guard/job-close-ro-guard.sublet.jsx b/client/src/components/job-close-ro-guard/job-close-ro-guard.sublet.jsx index e44e58adf..c6468c012 100644 --- a/client/src/components/job-close-ro-guard/job-close-ro-guard.sublet.jsx +++ b/client/src/components/job-close-ro-guard/job-close-ro-guard.sublet.jsx @@ -1,17 +1,17 @@ -import React, { useEffect } from 'react'; +import React, { useEffect } from "react"; -import { Alert, Card, Table } from 'antd'; -import { t } from 'i18next'; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { selectJobReadOnly } from '../../redux/application/application.selectors'; -import { selectBodyshop } from '../../redux/user/user.selectors'; -import CurrencyFormatter from '../../utils/CurrencyFormatter'; -import { alphaSort } from '../../utils/sorters'; +import { Alert, Card, Table } from "antd"; +import { t } from "i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectJobReadOnly } from "../../redux/application/application.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import CurrencyFormatter from "../../utils/CurrencyFormatter"; +import { alphaSort } from "../../utils/sorters"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, - jobRO: selectJobReadOnly, + jobRO: selectJobReadOnly }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) @@ -20,69 +20,56 @@ export default connect(mapStateToProps, mapDispatchToProps)(JobCloseRGuardSublet export function JobCloseRGuardSublet({ job, jobRO, bodyshop, form, warningCallback }) { const subletsNotDone = job?.joblines.filter( - (j) => - (j.part_type === 'PAS' || j.part_type === 'PASL') && - (!j.sublet_completed || !j.sublet_ignored) + (j) => (j.part_type === "PAS" || j.part_type === "PASL") && (!j.sublet_completed || !j.sublet_ignored) ); const columns = [ { - title: t('joblines.fields.line_desc'), - dataIndex: 'line_desc', - fixed: 'left', - key: 'line_desc', + title: t("joblines.fields.line_desc"), + dataIndex: "line_desc", + fixed: "left", + key: "line_desc", sorter: (a, b) => alphaSort(a.line_desc, b.line_desc), onCell: (record) => ({ - className: record.manual_line && 'job-line-manual', + className: record.manual_line && "job-line-manual", style: { - ...(record.critical ? { boxShadow: ' -.5em 0 0 #FFC107' } : {}), - }, + ...(record.critical ? { boxShadow: " -.5em 0 0 #FFC107" } : {}) + } }), - ellipsis: true, + ellipsis: true }, { - title: t('joblines.fields.act_price'), - dataIndex: 'act_price', - key: 'act_price', + title: t("joblines.fields.act_price"), + dataIndex: "act_price", + key: "act_price", sorter: (a, b) => a.act_price - b.act_price, ellipsis: true, - render: (text, record) => {record.act_price}, + render: (text, record) => {record.act_price} }, { - title: t('joblines.fields.part_qty'), - dataIndex: 'part_qty', - key: 'part_qty', + title: t("joblines.fields.part_qty"), + dataIndex: "part_qty", + key: "part_qty" }, { - title: t('joblines.fields.notes'), - dataIndex: 'notes', - key: 'notes', - }, + title: t("joblines.fields.notes"), + dataIndex: "notes", + key: "notes" + } ]; useEffect(() => { if (subletsNotDone.length > 0) { - warningCallback({ key: 'sublet', warning: t('jobs.labels.outstanding_sublets') }); + warningCallback({ key: "sublet", warning: t("jobs.labels.outstanding_sublets") }); } }, [subletsNotDone.length, warningCallback]); return ( - - + +
{subletsNotDone.length > 0 && ( - + )} ); diff --git a/client/src/components/job-close-ro-guard/job-close-ro-guard.tt-lifecycle.jsx b/client/src/components/job-close-ro-guard/job-close-ro-guard.tt-lifecycle.jsx index 1b0f60514..2fe16e07d 100644 --- a/client/src/components/job-close-ro-guard/job-close-ro-guard.tt-lifecycle.jsx +++ b/client/src/components/job-close-ro-guard/job-close-ro-guard.tt-lifecycle.jsx @@ -1,14 +1,14 @@ -import React from 'react'; +import React from "react"; -import { connect } from 'react-redux'; -import { createStructuredSelector } from 'reselect'; -import { selectJobReadOnly } from '../../redux/application/application.selectors'; -import { selectBodyshop } from '../../redux/user/user.selectors'; -import JobLifecycleComponent from '../job-lifecycle/job-lifecycle.component'; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectJobReadOnly } from "../../redux/application/application.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import JobLifecycleComponent from "../job-lifecycle/job-lifecycle.component"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, - jobRO: selectJobReadOnly, + jobRO: selectJobReadOnly }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 7f62004ec..9c398c1ec 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -2003,6 +2003,7 @@ "ppc": "This line contains a part price change.", "ppdnotexported": "PPDs not Exported", "profileadjustments": "Profile Disc./Mkup", + "profitbypassrequired": "Minimum gross profit requirements have not been met.", "profits": "Job Profits", "prt_dsmk_total": "Line Item Adjustment", "rates": "Rates", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 1a710dc95..72c5de71b 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2003,6 +2003,7 @@ "ppc": "", "ppdnotexported": "", "profileadjustments": "", + "profitbypassrequired": "", "profits": "", "prt_dsmk_total": "", "rates": "Tarifas", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 25d9e4dde..4bc52d79f 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2003,6 +2003,7 @@ "ppc": "", "ppdnotexported": "", "profileadjustments": "", + "profitbypassrequired": "", "profits": "", "prt_dsmk_total": "", "rates": "Les taux",