ProManager WIP.

This commit is contained in:
Patrick Fic
2024-03-05 08:41:52 -05:00
parent 9daf992582
commit 1ae2133d23
10 changed files with 707 additions and 690 deletions

View File

@@ -38,7 +38,7 @@ class ErrorBoundary extends React.Component {
} }
handleErrorSubmit = () => { handleErrorSubmit = () => {
InstanceRenderManager({executeFunction:true, imex: () => { InstanceRenderManager({executeFunction:true,args:[], imex: () => {
window.$crisp.push([ window.$crisp.push([
"do", "do",
"message:send", "message:send",

View File

@@ -7,41 +7,41 @@ import {
PlusCircleTwoTone, PlusCircleTwoTone,
SyncOutlined, SyncOutlined,
WarningFilled, WarningFilled,
} from "@ant-design/icons"; } from '@ant-design/icons';
import {useMutation} from "@apollo/client"; import { useMutation } from '@apollo/client';
import {Button, Dropdown, Input, Space, Table, Tag,} from "antd"; import { Button, Checkbox, Dropdown, Input, Space, Table, Tag } from 'antd';
import {PageHeader} from "@ant-design/pro-layout"; import { PageHeader } from '@ant-design/pro-layout';
import axios from "axios"; import axios from 'axios';
import React, {useState} from "react"; import React, { useState } from 'react';
import {useTranslation} from "react-i18next"; import { useTranslation } from 'react-i18next';
import {connect} from "react-redux"; import { connect } from 'react-redux';
import {createStructuredSelector} from "reselect"; import { createStructuredSelector } from 'reselect';
import {DELETE_JOB_LINE_BY_PK} from "../../graphql/jobs-lines.queries"; import { DELETE_JOB_LINE_BY_PK } from '../../graphql/jobs-lines.queries';
import {selectJobReadOnly} from "../../redux/application/application.selectors"; import { selectJobReadOnly } from '../../redux/application/application.selectors';
import {setModalContext} from "../../redux/modals/modals.actions"; import { setModalContext } from '../../redux/modals/modals.actions';
import {selectTechnician} from "../../redux/tech/tech.selectors"; import { selectTechnician } from '../../redux/tech/tech.selectors';
import {onlyUnique} from "../../utils/arrayHelper"; import { onlyUnique } from '../../utils/arrayHelper';
import {alphaSort} from "../../utils/sorters"; import { alphaSort } from '../../utils/sorters';
import JobLineLocationPopup from "../job-line-location-popup/job-line-location-popup.component"; import JobLineLocationPopup from '../job-line-location-popup/job-line-location-popup.component';
import JobLineNotePopup from "../job-line-note-popup/job-line-note-popup.component"; import JobLineNotePopup from '../job-line-note-popup/job-line-note-popup.component';
import JobLineStatusPopup from "../job-line-status-popup/job-line-status-popup.component"; import JobLineStatusPopup from '../job-line-status-popup/job-line-status-popup.component';
import JobLinesBillRefernece from "../job-lines-bill-reference/job-lines-bill-reference.component"; import JobLinesBillRefernece from '../job-lines-bill-reference/job-lines-bill-reference.component';
// import AllocationsAssignmentContainer from "../allocations-assignment/allocations-assignment.container"; // import AllocationsAssignmentContainer from "../allocations-assignment/allocations-assignment.container";
// import AllocationsBulkAssignmentContainer from "../allocations-bulk-assignment/allocations-bulk-assignment.container"; // import AllocationsBulkAssignmentContainer from "../allocations-bulk-assignment/allocations-bulk-assignment.container";
// import AllocationsEmployeeLabelContainer from "../allocations-employee-label/allocations-employee-label.container"; // import AllocationsEmployeeLabelContainer from "../allocations-employee-label/allocations-employee-label.container";
import _ from "lodash"; import _ from 'lodash';
import JobCreateIOU from "../job-create-iou/job-create-iou.component"; import JobCreateIOU from '../job-create-iou/job-create-iou.component';
import JobSendPartPriceChangeComponent from "../job-send-parts-price-change/job-send-parts-price-change.component"; import JobSendPartPriceChangeComponent from '../job-send-parts-price-change/job-send-parts-price-change.component';
import PartsOrderModalContainer from "../parts-order-modal/parts-order-modal.container"; import PartsOrderModalContainer from '../parts-order-modal/parts-order-modal.container';
import JobLinesExpander from "./job-lines-expander.component"; import JobLinesExpander from './job-lines-expander.component';
import {selectBodyshop} from "../../redux/user/user.selectors"; import { selectBodyshop } from '../../redux/user/user.selectors';
import dayjs from "../../utils/day"; import dayjs from '../../utils/day';
import JobLinesPartPriceChange from "./job-lines-part-price-change.component"; import JobLinesPartPriceChange from './job-lines-part-price-change.component';
import JoblineTeamAssignment from "../job-line-team-assignment/job-line-team-assignmnent.component"; import JoblineTeamAssignment from '../job-line-team-assignment/job-line-team-assignmnent.component';
import JobLineDispatchButton from "../job-line-dispatch-button/job-line-dispatch-button.component"; import JobLineDispatchButton from '../job-line-dispatch-button/job-line-dispatch-button.component';
import JobLineBulkAssignComponent from "../job-line-bulk-assign/job-line-bulk-assign.component"; import JobLineBulkAssignComponent from '../job-line-bulk-assign/job-line-bulk-assign.component';
import {useSplitTreatments} from "@splitsoftware/splitio-react"; import { useSplitTreatments } from '@splitsoftware/splitio-react';
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import { HasFeatureAccess } from '../feature-wrapper/feature-wrapper.component';
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
@@ -51,11 +51,11 @@ const mapStateToProps = createStructuredSelector({
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
setJobLineEditContext: (context) => setJobLineEditContext: (context) =>
dispatch(setModalContext({context: context, modal: "jobLineEdit"})), dispatch(setModalContext({ context: context, modal: 'jobLineEdit' })),
setPartsOrderContext: (context) => setPartsOrderContext: (context) =>
dispatch(setModalContext({context: context, modal: "partsOrder"})), dispatch(setModalContext({ context: context, modal: 'partsOrder' })),
setBillEnterContext: (context) => setBillEnterContext: (context) =>
dispatch(setModalContext({context: context, modal: "billEnter"})), dispatch(setModalContext({ context: context, modal: 'billEnter' })),
}); });
export function JobLinesComponent({ export function JobLinesComponent({
@@ -71,11 +71,13 @@ export function JobLinesComponent({
setJobLineEditContext, setJobLineEditContext,
form, form,
setBillEnterContext, setBillEnterContext,
}) { }) {
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK); const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
const {treatments: {Enhanced_Payroll}} = useSplitTreatments({ const {
treatments: { Enhanced_Payroll },
} = useSplitTreatments({
attributes: {}, attributes: {},
names: ["Enhanced_Payroll"], names: ['Enhanced_Payroll'],
splitKey: bodyshop.imexshopid, splitKey: bodyshop.imexshopid,
}); });
@@ -84,162 +86,144 @@ export function JobLinesComponent({
sortedInfo: {}, sortedInfo: {},
filteredInfo: {}, filteredInfo: {},
}); });
const {t} = useTranslation(); const { t } = useTranslation();
const jobIsPrivate = bodyshop.md_ins_cos.find( const jobIsPrivate = bodyshop.md_ins_cos.find((c) => c.name === job.ins_co_nm)?.private;
(c) => c.name === job.ins_co_nm
)?.private;
const columns = [ const columns = [
{ {
title: "#", title: '#',
dataIndex: "line_no", dataIndex: 'line_no',
key: "line_no", key: 'line_no',
sorter: (a, b) => a.line_no - b.line_no, sorter: (a, b) => a.line_no - b.line_no,
fixed: "left", fixed: 'left',
sortOrder: sortOrder: state.sortedInfo.columnKey === 'line_no' && state.sortedInfo.order,
state.sortedInfo.columnKey === "line_no" && state.sortedInfo.order,
}, },
{ {
title: t("joblines.fields.line_desc"), title: t('joblines.fields.line_desc'),
dataIndex: "line_desc", dataIndex: 'line_desc',
fixed: "left", fixed: 'left',
key: "line_desc", key: 'line_desc',
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc), sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
onCell: (record) => ({ onCell: (record) => ({
className: record.manual_line && "job-line-manual", className: record.manual_line && 'job-line-manual',
style: { style: {
...(record.critical ? {boxShadow: " -.5em 0 0 #FFC107"} : {}), ...(record.critical ? { boxShadow: ' -.5em 0 0 #FFC107' } : {}),
}, },
}), }),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'line_desc' && state.sortedInfo.order,
state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order,
ellipsis: true, ellipsis: true,
}, },
{ {
title: t("joblines.fields.oem_partno"), title: t('joblines.fields.oem_partno'),
dataIndex: "oem_partno", dataIndex: 'oem_partno',
key: "oem_partno", key: 'oem_partno',
sorter: (a, b) => alphaSort(a.oem_partno, b.oem_partno), sorter: (a, b) => alphaSort(a.oem_partno, b.oem_partno),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'oem_partno' && state.sortedInfo.order,
state.sortedInfo.columnKey === "oem_partno" && state.sortedInfo.order,
ellipsis: true, ellipsis: true,
onCell: (record) => ({ onCell: (record) => ({
className: record.manual_line && "job-line-manual", className: record.manual_line && 'job-line-manual',
style: { style: {
...(record.parts_dispatch_lines[0]?.accepted_at ...(record.parts_dispatch_lines[0]?.accepted_at
? {boxShadow: " -.5em 0 0 #FFC107"} ? { boxShadow: ' -.5em 0 0 #FFC107' }
: {}), : {}),
}, },
}), }),
render: (text, record) => ( render: (text, record) => (
<span class="ant-table-cell-content"> <span className="ant-table-cell-content">
{`${record.oem_partno || ""} ${ {`${record.oem_partno || ''} ${record.alt_partno ? `(${record.alt_partno})` : ''}`.trim()}
record.alt_partno ? `(${record.alt_partno})` : ""
}`.trim()}
</span> </span>
), ),
}, },
{ {
title: t("joblines.fields.op_code_desc"), title: t('joblines.fields.op_code_desc'),
dataIndex: "op_code_desc", dataIndex: 'op_code_desc',
key: "op_code_desc", key: 'op_code_desc',
sorter: (a, b) => alphaSort(a.op_code_desc, b.op_code_desc), sorter: (a, b) => alphaSort(a.op_code_desc, b.op_code_desc),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'op_code_desc' && state.sortedInfo.order,
state.sortedInfo.columnKey === "op_code_desc" && state.sortedInfo.order,
ellipsis: true, ellipsis: true,
render: (text, record) => render: (text, record) =>
`${record.op_code_desc || ""}${ `${record.op_code_desc || ''}${record.alt_partm ? ` ${record.alt_partm}` : ''}`,
record.alt_partm ? ` ${record.alt_partm}` : ""
}`,
}, },
{ {
title: t("joblines.fields.part_type"), title: t('joblines.fields.part_type'),
dataIndex: "part_type", dataIndex: 'part_type',
key: "part_type", key: 'part_type',
filteredValue: state.filteredInfo.part_type || null, filteredValue: state.filteredInfo.part_type || null,
sorter: (a, b) => alphaSort(a.part_type, b.part_type), sorter: (a, b) => alphaSort(a.part_type, b.part_type),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'part_type' && state.sortedInfo.order,
state.sortedInfo.columnKey === "part_type" && state.sortedInfo.order,
filters: [ filters: [
{ {
text: t("jobs.labels.partsfilter"), text: t('jobs.labels.partsfilter'),
value: [ value: ['PAN', 'PAC', 'PAR', 'PAL', 'PAA', 'PAM', 'PAP', 'PAS', 'PASL', 'PAG'],
"PAN",
"PAC",
"PAR",
"PAL",
"PAA",
"PAM",
"PAP",
"PAS",
"PASL",
"PAG",
],
}, },
{ {
text: t("joblines.fields.part_types.PAN"), text: t('joblines.fields.part_types.PAN'),
value: ["PAN"], value: ['PAN'],
}, },
{ {
text: t("joblines.fields.part_types.PAP"), text: t('joblines.fields.part_types.PAP'),
value: ["PAP"], value: ['PAP'],
}, },
{ {
text: t("joblines.fields.part_types.PAL"), text: t('joblines.fields.part_types.PAL'),
value: ["PAL"], value: ['PAL'],
}, },
{ {
text: t("joblines.fields.part_types.PAA"), text: t('joblines.fields.part_types.PAA'),
value: ["PAA"], value: ['PAA'],
}, },
{ {
text: t("joblines.fields.part_types.PAG"), text: t('joblines.fields.part_types.PAG'),
value: ["PAG"], value: ['PAG'],
}, },
{ {
text: t("joblines.fields.part_types.PAS"), text: t('joblines.fields.part_types.PAS'),
value: ["PAS"], value: ['PAS'],
}, },
{ {
text: t("joblines.fields.part_types.PASL"), text: t('joblines.fields.part_types.PASL'),
value: ["PASL"], value: ['PASL'],
}, },
{ {
text: t("joblines.fields.part_types.PAC"), text: t('joblines.fields.part_types.PAC'),
value: ["PAC"], value: ['PAC'],
}, },
{ {
text: t("joblines.fields.part_types.PAR"), text: t('joblines.fields.part_types.PAR'),
value: ["PAR"], value: ['PAR'],
}, },
{ {
text: t("joblines.fields.part_types.PAM"), text: t('joblines.fields.part_types.PAM'),
value: ["PAM"], value: ['PAM'],
}, },
], ],
onFilter: (value, record) => value.includes(record.part_type), onFilter: (value, record) => value.includes(record.part_type),
render: (text, record) => render: (text, record) =>
record.part_type record.part_type ? t(`joblines.fields.part_types.${record.part_type}`) : null,
? t(`joblines.fields.part_types.${record.part_type}`)
: null,
}, },
{ {
title: t("joblines.fields.act_price"), title: t('joblines.fields.act_price'),
dataIndex: "act_price", dataIndex: 'act_price',
key: "act_price", key: 'act_price',
sorter: (a, b) => a.act_price - b.act_price, sorter: (a, b) => a.act_price - b.act_price,
sortOrder: sortOrder: state.sortedInfo.columnKey === 'act_price' && state.sortedInfo.order,
state.sortedInfo.columnKey === "act_price" && state.sortedInfo.order,
ellipsis: true, ellipsis: true,
render: (text, record) => ( render: (text, record) => (
<JobLinesPartPriceChange line={record} job={job} refetch={refetch}/> <JobLinesPartPriceChange line={record} job={job} refetch={refetch} />
), ),
}, },
{ {
title: t("joblines.fields.part_qty"), title: t('joblines.fields.part_qty'),
dataIndex: "part_qty", dataIndex: 'part_qty',
key: "part_qty", key: 'part_qty',
},
{
title: t('joblines.fields.tax_part'),
dataIndex: 'tax_part',
key: 'tax_part',
render: (text, record) => <Checkbox checked={record.tax_part} />,
}, },
// { // {
// title: t("joblines.fields.total"), // title: t("joblines.fields.total"),
@@ -256,83 +240,73 @@ export function JobLinesComponent({
// ), // ),
// }, // },
{ {
title: t("joblines.fields.mod_lbr_ty"), title: t('joblines.fields.mod_lbr_ty'),
dataIndex: "mod_lbr_ty", dataIndex: 'mod_lbr_ty',
key: "mod_lbr_ty", key: 'mod_lbr_ty',
sorter: (a, b) => alphaSort(a.mod_lbr_ty, b.mod_lbr_ty), sorter: (a, b) => alphaSort(a.mod_lbr_ty, b.mod_lbr_ty),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'mod_lbr_ty' && state.sortedInfo.order,
state.sortedInfo.columnKey === "mod_lbr_ty" && state.sortedInfo.order,
render: (text, record) => render: (text, record) =>
record.mod_lbr_ty record.mod_lbr_ty ? t(`joblines.fields.lbr_types.${record.mod_lbr_ty}`) : null,
? t(`joblines.fields.lbr_types.${record.mod_lbr_ty}`)
: null,
}, },
{ {
title: t("joblines.fields.mod_lb_hrs"), title: t('joblines.fields.mod_lb_hrs'),
dataIndex: "mod_lb_hrs", dataIndex: 'mod_lb_hrs',
key: "mod_lb_hrs", key: 'mod_lb_hrs',
sorter: (a, b) => a.mod_lb_hrs - b.mod_lb_hrs, sorter: (a, b) => a.mod_lb_hrs - b.mod_lb_hrs,
sortOrder: sortOrder: state.sortedInfo.columnKey === 'mod_lb_hrs' && state.sortedInfo.order,
state.sortedInfo.columnKey === "mod_lb_hrs" && state.sortedInfo.order,
}, },
{ {
title: t("joblines.fields.line_ind"), title: t('joblines.fields.line_ind'),
dataIndex: "line_ind", dataIndex: 'line_ind',
key: "line_ind", key: 'line_ind',
sorter: (a, b) => alphaSort(a.line_ind, b.line_ind), sorter: (a, b) => alphaSort(a.line_ind, b.line_ind),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'line_ind' && state.sortedInfo.order,
state.sortedInfo.columnKey === "line_ind" && state.sortedInfo.order, responsive: ['md'],
responsive: ["md"],
}, },
...(Enhanced_Payroll.treatment === "on" ...(Enhanced_Payroll.treatment === 'on'
? [ ? [
{ {
title: t("joblines.fields.assigned_team"), title: t('joblines.fields.assigned_team'),
dataIndex: "assigned_team", dataIndex: 'assigned_team',
key: "assigned_team", key: 'assigned_team',
render: (text, record) => ( render: (text, record) => (
<JoblineTeamAssignment <JoblineTeamAssignment disabled={jobRO} jobline={record} jobId={job.id} />
disabled={jobRO}
jobline={record}
jobId={job.id}
/>
), ),
}, },
] ]
: []), : []),
{ {
title: t("joblines.fields.notes"), title: t('joblines.fields.notes'),
dataIndex: "notes", dataIndex: 'notes',
key: "notes", key: 'notes',
render: (text, record) => ( render: (text, record) => <JobLineNotePopup disabled={jobRO} jobline={record} />,
<JobLineNotePopup disabled={jobRO} jobline={record}/>
),
}, },
{ {
title: t("joblines.fields.location"), title: t('joblines.fields.location'),
dataIndex: "location", dataIndex: 'location',
key: "location", key: 'location',
render: (text, record) => ( render: (text, record) => <JobLineLocationPopup jobline={record} disabled={jobRO} />,
<JobLineLocationPopup jobline={record} disabled={jobRO}/>
),
}, },
...HasFeatureAccess({featureName: "bills"}) ? [ { ...(HasFeatureAccess({ featureName: 'bills' })
title: t("joblines.labels.billref"), ? [
dataIndex: "billref",
key: "billref",
render: (text, record) => <JobLinesBillRefernece jobline={record}/>,
responsive: ["md"],
},] : [],
{ {
title: t("joblines.fields.status"), title: t('joblines.labels.billref'),
dataIndex: "status", dataIndex: 'billref',
key: "status", key: 'billref',
render: (text, record) => <JobLinesBillRefernece jobline={record} />,
responsive: ['md'],
},
]
: []),
{
title: t('joblines.fields.status'),
dataIndex: 'status',
key: 'status',
sorter: (a, b) => alphaSort(a.status, b.status), sorter: (a, b) => alphaSort(a.status, b.status),
sortOrder: sortOrder: state.sortedInfo.columnKey === 'status' && state.sortedInfo.order,
state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
filteredValue: state.filteredInfo.status || null, filteredValue: state.filteredInfo.status || null,
filters: filters:
@@ -342,20 +316,18 @@ export function JobLinesComponent({
.filter(onlyUnique) .filter(onlyUnique)
.map((s) => { .map((s) => {
return { return {
text: s || "No Status*", text: s || 'No Status*',
value: [s], value: [s],
}; };
})) || })) ||
[], [],
onFilter: (value, record) => value.includes(record.status), onFilter: (value, record) => value.includes(record.status),
render: (text, record) => ( render: (text, record) => <JobLineStatusPopup jobline={record} disabled={jobRO} />,
<JobLineStatusPopup jobline={record} disabled={jobRO}/>
),
}, },
{ {
title: t("general.labels.actions"), title: t('general.labels.actions'),
dataIndex: "actions", dataIndex: 'actions',
key: "actions", key: 'actions',
render: (text, record) => ( render: (text, record) => (
<Space> <Space>
{(record.manual_line || jobIsPrivate) && ( {(record.manual_line || jobIsPrivate) && (
@@ -364,37 +336,37 @@ export function JobLinesComponent({
disabled={jobRO} disabled={jobRO}
onClick={() => { onClick={() => {
setJobLineEditContext({ setJobLineEditContext({
actions: {refetch: refetch, submit: form && form.submit}, actions: { refetch: refetch, submit: form && form.submit },
context: {...record, jobid: job.id}, context: { ...record, jobid: job.id },
}); });
}} }}
> >
<EditFilled/> <EditFilled />
</Button> </Button>
<Button <Button
disabled={jobRO} disabled={jobRO}
onClick={async () => { onClick={async () => {
await deleteJobLine({ await deleteJobLine({
variables: {joblineId: record.id}, variables: { joblineId: record.id },
update(cache) { update(cache) {
cache.modify({ cache.modify({
fields: { fields: {
joblines(existingJobLines, {readField}) { joblines(existingJobLines, { readField }) {
return existingJobLines.filter( return existingJobLines.filter(
(jlRef) => record.id !== readField("id", jlRef) (jlRef) => record.id !== readField('id', jlRef)
); );
}, },
}, },
}); });
}, },
}); });
await axios.post("/job/totalsssu", { await axios.post('/job/totalsssu', {
id: job.id, id: job.id,
}); });
refetch && refetch(); refetch && refetch();
}} }}
> >
<DeleteFilled/> <DeleteFilled />
</Button> </Button>
</> </>
)} )}
@@ -412,19 +384,17 @@ export function JobLinesComponent({
}; };
const handleMark = (e) => { const handleMark = (e) => {
if (e.key === "clear") { if (e.key === 'clear') {
setSelectedLines([]); setSelectedLines([]);
} else { } else {
const markedTypes = [e.key]; const markedTypes = [e.key];
if (e.key === "PAN") markedTypes.push("PAP"); if (e.key === 'PAN') markedTypes.push('PAP');
if (e.key === "PAS") markedTypes.push("PASL"); if (e.key === 'PAS') markedTypes.push('PASL');
setSelectedLines((selectedLines) => setSelectedLines((selectedLines) =>
_.uniq([ _.uniq([
...selectedLines, ...selectedLines,
...jobLines.filter( ...jobLines.filter(
(item) => (item) => markedTypes.includes(item.part_type) || markedTypes.includes(item.mod_lbr_ty)
markedTypes.includes(item.part_type) ||
markedTypes.includes(item.mod_lbr_ty)
), ),
]) ])
); );
@@ -434,46 +404,46 @@ export function JobLinesComponent({
const markMenu = { const markMenu = {
onClick: handleMark, onClick: handleMark,
items: [ items: [
{key: "PAA", label: t("joblines.fields.part_types.PAA")}, { key: 'PAA', label: t('joblines.fields.part_types.PAA') },
{key: "PAN", label: t("joblines.fields.part_types.PAN")}, { key: 'PAN', label: t('joblines.fields.part_types.PAN') },
{key: "PAL", label: t("joblines.fields.part_types.PAL")}, { key: 'PAL', label: t('joblines.fields.part_types.PAL') },
{key: "PAS", label: t("joblines.fields.part_types.PAS")}, { key: 'PAS', label: t('joblines.fields.part_types.PAS') },
{type: 'divider'}, { type: 'divider' },
{key: "LAA", label: t("joblines.fields.lbr_types.LAA")}, { key: 'LAA', label: t('joblines.fields.lbr_types.LAA') },
{key: "LAB", label: t("joblines.fields.lbr_types.LAB")}, { key: 'LAB', label: t('joblines.fields.lbr_types.LAB') },
{key: "LAD", label: t("joblines.fields.lbr_types.LAD")}, { key: 'LAD', label: t('joblines.fields.lbr_types.LAD') },
{key: "LAE", label: t("joblines.fields.lbr_types.LAE")}, { key: 'LAE', label: t('joblines.fields.lbr_types.LAE') },
{key: "LAF", label: t("joblines.fields.lbr_types.LAF")}, { key: 'LAF', label: t('joblines.fields.lbr_types.LAF') },
{key: "LAG", label: t("joblines.fields.lbr_types.LAG")}, { key: 'LAG', label: t('joblines.fields.lbr_types.LAG') },
{key: "LAM", label: t("joblines.fields.lbr_types.LAM")}, { key: 'LAM', label: t('joblines.fields.lbr_types.LAM') },
{key: "LAR", label: t("joblines.fields.lbr_types.LAR")}, { key: 'LAR', label: t('joblines.fields.lbr_types.LAR') },
{key: "LAS", label: t("joblines.fields.lbr_types.LAS")}, { key: 'LAS', label: t('joblines.fields.lbr_types.LAS') },
{key: "LAU", label: t("joblines.fields.lbr_types.LAU")}, { key: 'LAU', label: t('joblines.fields.lbr_types.LAU') },
{key: "LA1", label: t("joblines.fields.lbr_types.LA1")}, { key: 'LA1', label: t('joblines.fields.lbr_types.LA1') },
{key: "LA2", label: t("joblines.fields.lbr_types.LA2")}, { key: 'LA2', label: t('joblines.fields.lbr_types.LA2') },
{key: "LA3", label: t("joblines.fields.lbr_types.LA3")}, { key: 'LA3', label: t('joblines.fields.lbr_types.LA3') },
{key: "LA4", label: t("joblines.fields.lbr_types.LA4")}, { key: 'LA4', label: t('joblines.fields.lbr_types.LA4') },
{type: 'divider'}, { type: 'divider' },
{key: "clear", label: t("general.labels.clear")}, { key: 'clear', label: t('general.labels.clear') },
] ],
}; };
return ( return (
<div> <div>
<PartsOrderModalContainer/> <PartsOrderModalContainer />
<PageHeader <PageHeader
title={t("jobs.labels.estimatelines")} title={t('jobs.labels.estimatelines')}
extra={ extra={
<Space wrap> <Space wrap>
<Button onClick={() => refetch()}> <Button onClick={() => refetch()}>
<SyncOutlined/> <SyncOutlined />
</Button> </Button>
{job.special_coverage_policy && ( {job.special_coverage_policy && (
<Tag color="tomato"> <Tag color="tomato">
<Space> <Space>
<WarningFilled/> <WarningFilled />
<span>{t("jobs.labels.specialcoveragepolicy")}</span> <span>{t('jobs.labels.specialcoveragepolicy')}</span>
</Space> </Space>
</Tag> </Tag>
)} )}
@@ -482,7 +452,7 @@ export function JobLinesComponent({
setSelectedLines={setSelectedLines} setSelectedLines={setSelectedLines}
job={job} job={job}
/> />
{Enhanced_Payroll.treatment === "on" && ( {Enhanced_Payroll.treatment === 'on' && (
<JobLineBulkAssignComponent <JobLineBulkAssignComponent
selectedLines={selectedLines} selectedLines={selectedLines}
setSelectedLines={setSelectedLines} setSelectedLines={setSelectedLines}
@@ -498,13 +468,13 @@ export function JobLinesComponent({
} }
onClick={() => { onClick={() => {
setBillEnterContext({ setBillEnterContext({
actions: {refetch: refetch}, actions: { refetch: refetch },
context: { context: {
disableInvNumber: true, disableInvNumber: true,
job: {id: job.id}, job: { id: job.id },
bill: { bill: {
vendorid: bodyshop.inhousevendorid, vendorid: bodyshop.inhousevendorid,
invoice_number: "ih", invoice_number: 'ih',
isinhouse: true, isinhouse: true,
date: new dayjs(), date: new dayjs(),
total: 0, total: 0,
@@ -532,8 +502,8 @@ export function JobLinesComponent({
setSelectedLines([]); setSelectedLines([]);
}} }}
> >
<HomeOutlined/> <HomeOutlined />
{t("parts.actions.orderinhouse")} {t('parts.actions.orderinhouse')}
{selectedLines.length > 0 && ` (${selectedLines.length})`} {selectedLines.length > 0 && ` (${selectedLines.length})`}
</Button> </Button>
<Button <Button
@@ -545,14 +515,14 @@ export function JobLinesComponent({
} }
onClick={() => { onClick={() => {
setPartsOrderContext({ setPartsOrderContext({
actions: {refetch: refetch}, actions: { refetch: refetch },
context: { context: {
jobId: job.id, jobId: job.id,
job: job, job: job,
linesToOrder: selectedLines.map((l) => ({ linesToOrder: selectedLines.map((l) => ({
...l, ...l,
oem_partno: `${l.oem_partno || ""} ${ oem_partno: `${l.oem_partno || ''} ${
l.alt_partno ? `(${l.alt_partno})` : "" l.alt_partno ? `(${l.alt_partno})` : ''
}`.trim(), }`.trim(),
})), })),
}, },
@@ -562,7 +532,7 @@ export function JobLinesComponent({
setSelectedLines([]); setSelectedLines([]);
}} }}
> >
{t("parts.actions.order")} {t('parts.actions.order')}
{selectedLines.length > 0 && ` (${selectedLines.length})`} {selectedLines.length > 0 && ` (${selectedLines.length})`}
</Button> </Button>
<Button <Button
@@ -572,43 +542,43 @@ export function JobLinesComponent({
filteredInfo: { filteredInfo: {
...state.filteredInfo, ...state.filteredInfo,
part_type: [ part_type: [
"PAN", 'PAN',
"PAC", 'PAC',
"PAR", 'PAR',
"PAL", 'PAL',
"PAA", 'PAA',
"PAM", 'PAM',
"PAP", 'PAP',
"PAS", 'PAS',
"PASL", 'PASL',
"PAG", 'PAG',
], ],
}, },
})); }));
}} }}
> >
<FilterFilled/> {t("jobs.actions.filterpartsonly")} <FilterFilled /> {t('jobs.actions.filterpartsonly')}
</Button> </Button>
<Dropdown menu={markMenu} trigger={["click"]}> <Dropdown menu={markMenu} trigger={['click']}>
<Button>{t("jobs.actions.mark")}</Button> <Button>{t('jobs.actions.mark')}</Button>
</Dropdown> </Dropdown>
<Button <Button
disabled={jobRO || technician} disabled={jobRO || technician}
onClick={() => { onClick={() => {
setJobLineEditContext({ setJobLineEditContext({
actions: {refetch: refetch}, actions: { refetch: refetch },
context: {jobid: job.id}, context: { jobid: job.id },
}); });
}} }}
> >
{t("joblines.actions.new")} {t('joblines.actions.new')}
</Button> </Button>
{bodyshop.region_config.toLowerCase().startsWith("us") && ( {bodyshop.region_config.toLowerCase().startsWith('us') && (
<JobSendPartPriceChangeComponent job={job}/> <JobSendPartPriceChangeComponent job={job} />
)} )}
<JobCreateIOU job={job} selectedJobLines={selectedLines}/> <JobCreateIOU job={job} selectedJobLines={selectedLines} />
<Input.Search <Input.Search
placeholder={t("general.labels.search")} placeholder={t('general.labels.search')}
onChange={(e) => { onChange={(e) => {
e.preventDefault(); e.preventDefault();
setSearchText(e.target.value); setSearchText(e.target.value);
@@ -628,24 +598,20 @@ export function JobLinesComponent({
x: true, x: true,
}} }}
expandable={{ expandable={{
expandedRowRender: (record) => ( expandedRowRender: (record) => <JobLinesExpander jobline={record} jobid={job.id} />,
<JobLinesExpander jobline={record} jobid={job.id}/>
),
rowExpandable: (record) => true, rowExpandable: (record) => true,
//expandRowByClick: true, //expandRowByClick: true,
expandIcon: ({expanded, onExpand, record}) => expandIcon: ({ expanded, onExpand, record }) =>
expanded ? ( expanded ? (
<MinusCircleTwoTone onClick={(e) => onExpand(record, e)}/> <MinusCircleTwoTone onClick={(e) => onExpand(record, e)} />
) : ( ) : (
<PlusCircleTwoTone onClick={(e) => onExpand(record, e)}/> <PlusCircleTwoTone onClick={(e) => onExpand(record, e)} />
), ),
}} }}
onRow={(record, rowIndex) => { onRow={(record, rowIndex) => {
return { return {
onDoubleClick: (event) => { onDoubleClick: (event) => {
const notMatchingLines = selectedLines.filter( const notMatchingLines = selectedLines.filter((i) => i.id !== record.id);
(i) => i.id !== record.id
);
notMatchingLines.length !== selectedLines.length notMatchingLines.length !== selectedLines.length
? setSelectedLines(notMatchingLines) ? setSelectedLines(notMatchingLines)
: setSelectedLines([...selectedLines, record]); : setSelectedLines([...selectedLines, record]);
@@ -659,13 +625,9 @@ export function JobLinesComponent({
}, },
onSelect: (record, selected, selectedRows, nativeEvent) => { onSelect: (record, selected, selectedRows, nativeEvent) => {
if (selected) { if (selected) {
setSelectedLines((selectedLines) => setSelectedLines((selectedLines) => _.uniqBy([...selectedLines, record], 'id'));
_.uniqBy([...selectedLines, record], "id")
);
} else { } else {
setSelectedLines((selectedLines) => setSelectedLines((selectedLines) => selectedLines.filter((l) => l.id !== record.id));
selectedLines.filter((l) => l.id !== record.id)
);
} }
}, },
}} }}

View File

@@ -111,12 +111,14 @@ export function JobsAvailableContainer({bodyshop, currentUser, insertAuditTrail,
} }
// if (process.env.VITE_APP_COUNTRY === "USA") { // if (process.env.VITE_APP_COUNTRY === "USA") {
//Massage the CCC file set to remove duplicate UNQ_SEQ. //Massage the CCC file set to remove duplicate UNQ_SEQ.
InstanceRenderManager({executeFunction:true,rome: ResolveCCCLineIssues(estData.est_data, bodyshop) }) InstanceRenderManager({executeFunction:true,rome: ResolveCCCLineIssues, args: [estData.est_data, bodyshop], promanager: ResolveCCCLineIssues })
// } else { // } else {
//IO-539 Check for Parts Rate on PAL for SGI use case. //IO-539 Check for Parts Rate on PAL for SGI use case.
//TODO:AIO Check that the async function is actually waiting before moving on. //TODO:AIO Check that the async function is actually waiting before moving on.
InstanceRenderManager({executeFunction: true, imex: await CheckTaxRates(estData.est_data, bodyshop), rome: await CheckTaxRatesUSA(estData.est_data, bodyshop)}) await InstanceRenderManager({executeFunction: true,
debug:true,
imex: CheckTaxRates, rome: CheckTaxRatesUSA, promanager: CheckTaxRatesUSA, args: [estData.est_data, bodyshop]})
// } // }
// const newTotals = ( // const newTotals = (
@@ -238,8 +240,8 @@ export function JobsAvailableContainer({bodyshop, currentUser, insertAuditTrail,
let supp = replaceEmpty({...estData.est_data}); let supp = replaceEmpty({...estData.est_data});
//IO-539 Check for Parts Rate on PAL for SGI use case. //IO-539 Check for Parts Rate on PAL for SGI use case.
InstanceRenderManager({executeFunction:true, imex: await CheckTaxRates(supp, bodyshop), rome: await CheckTaxRatesUSA(supp, bodyshop)}) await InstanceRenderManager({executeFunction:true, imex: CheckTaxRates, rome: CheckTaxRatesUSA, promanager: CheckTaxRatesUSA, args: [(supp, bodyshop)]})
InstanceRenderManager({executeFunction:true ,rome: ResolveCCCLineIssues(supp, bodyshop) }) await InstanceRenderManager({executeFunction:true, rome: ResolveCCCLineIssues,promanager: ResolveCCCLineIssues ,args:[(supp, bodyshop)] })
delete supp.owner; delete supp.owner;
delete supp.vehicle; delete supp.vehicle;
@@ -599,8 +601,43 @@ async function CheckTaxRates(estData, bodyshop) {
line.act_price = line.act_price + line.misc_amt; line.act_price = line.act_price + line.misc_amt;
line.tax_part = !!line.misc_tax; line.tax_part = !!line.misc_tax;
} }
//WEB EST SPECIFIC CLEAN UP
InstanceRenderManager({executeFunction: true, args:[], promanager: () => {
if (line.mod_lbr_ty === "LAET" || line.mod_lbr_ty === "LAUT") {
line.notes += ` | ET/UT Update (prev = ${line.mod_lbr_ty})`;
line.mod_lbr_ty = "LAR";
}
}})
}); });
//Group by line no
// For everything but the first one, strip out the price number in
InstanceRenderManager({executeFunction:true, args:[], promanager: () => {
const groupedByLineRef = _.groupBy(estData.joblines.data, "line_ref");
Object.keys(groupedByLineRef).forEach((lineRef) => {
groupedByLineRef[lineRef].forEach((line, index) => {
//Let the first one keep it
if (index === 0) return;
//Web Est seems to have additional costs with UNQ_SEQ 0. Keep them all?
if (line.unq_seq === 0) return;
const indexInEstData = estData.joblines.data.findIndex(
(l) => l.unq_seq === line.unq_seq
);
estData.joblines.data[
indexInEstData
].notes += ` | Scrubbed due to the line_ref issue. (prev act price = ${estData.joblines.data[indexInEstData].act_price})`;
estData.joblines.data[indexInEstData].act_price = 0;
estData.joblines.data[indexInEstData].db_price = 0;
});
})
}})
//Generate the list of duplicated UNQ_SEQ that will feed into the next section to scrub the lines. //Generate the list of duplicated UNQ_SEQ that will feed into the next section to scrub the lines.
const unqSeqHash = _.groupBy(estData.joblines.data, "unq_seq"); const unqSeqHash = _.groupBy(estData.joblines.data, "unq_seq");
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter( const duplicatedUnqSeq = Object.keys(unqSeqHash).filter(

View File

@@ -327,7 +327,7 @@ export function* SetAuthLevelFromShopDetails({payload}) {
} }
try { try {
InstanceRenderManager({executeFunction:true, imex: () => { InstanceRenderManager({executeFunction:true,args:[], imex: () => {
window.$crisp.push(["set", "user:company", [payload.shopname]]); window.$crisp.push(["set", "user:company", [payload.shopname]]);
if (authRecord[0] && authRecord[0].user.validemail) { if (authRecord[0] && authRecord[0].user.validemail) {
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]); window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);

View File

@@ -16,6 +16,7 @@ export default function InstanceRenderManager({
imex, imex,
debug, debug,
instance, instance,
args,
}) { }) {
let propToReturn = null; let propToReturn = null;
@@ -38,17 +39,17 @@ export default function InstanceRenderManager({
break; break;
} }
if (executeFunction && typeof propToReturn === 'function') propToReturn();
//Checking to see if we need to default to another one.
if (propToReturn === 'imex') {
propToReturn = imex;
}
if (debug) { if (debug) {
console.log('InstanceRenderManager Debugger'); console.log('InstanceRenderManager Debugger');
console.log('========================='); console.log('=========================');
console.log({ executeFunction, rome, promanager, imex, debug, propToReturn }); console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
console.log('========================='); console.log('=========================');
} }
//Checking to see if we need to default to another one.
if (propToReturn === 'imex') {
propToReturn = imex;
}
if (executeFunction && typeof propToReturn === 'function') return propToReturn(...args);
return propToReturn === undefined ? null : propToReturn; return propToReturn === undefined ? null : propToReturn;
} }

View File

@@ -160,7 +160,7 @@ exports.sendNotification = async (req, res) => {
.send({ .send({
topic: "PRD_PATRICK-messaging", topic: "PRD_PATRICK-messaging",
notification: { notification: {
title: `ImEX Online Message - , title: `ImEX Online Message - `,
body: "Test Noti.", body: "Test Noti.",
//imageUrl: "https://thinkimex.com/img/io-fcm.png", //imageUrl: "https://thinkimex.com/img/io-fcm.png",
}, },

View File

@@ -892,8 +892,8 @@ function CalculateTaxesTotals(job, otherTotals) {
} }
}); });
// console.log("*** Taxable Amounts***"); console.log("*** Taxable Amounts***");
// console.table(JSON.parse(JSON.stringify(taxableAmounts))); console.table(JSON.parse(JSON.stringify(taxableAmounts)));
//For the taxable amounts, figure out which tax type applies. //For the taxable amounts, figure out which tax type applies.
//Then sum up the total of that tax type and then calculate the thresholds. //Then sum up the total of that tax type and then calculate the thresholds.
@@ -976,8 +976,8 @@ function CalculateTaxesTotals(job, otherTotals) {
}); });
const remainingTaxableAmounts = taxableAmountsByTier; const remainingTaxableAmounts = taxableAmountsByTier;
// console.log("*** Taxable Amounts by Tier***"); console.log("*** Taxable Amounts by Tier***");
// console.table(JSON.parse(JSON.stringify(taxableAmountsByTier))); console.table(JSON.parse(JSON.stringify(taxableAmountsByTier)));
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => { Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
try { try {

View File

@@ -78,7 +78,7 @@ async function TotalsServerSide(req, res) {
return ret; return ret;
} catch (error) { } catch (error) {
logger.log("job-totals-ssu-error", "ERROR", req.user.email, job.id, { logger.log("job-totals-ssu-error", "ERROR", req?.user?.email, job.id, {
jobid: job.id, jobid: job.id,
error, error,
}); });

View File

@@ -1,11 +1,16 @@
const RenderInstanceManager = require("../utils/instanceMgr").default; const RenderInstanceManager = require('../utils/instanceMgr').default;
exports.totals = RenderInstanceManager({ exports.totals = RenderInstanceManager({
imex: require("./job-totals").default, imex: require('./job-totals').default,
rome: require("./job-totals-USA").default, rome: require('./job-totals-USA').default,
promanager: require('./job-totals-USA').default,
}); });
exports.totalsSsu = require("./job-totals").totalsSsu; exports.totalsSsu = RenderInstanceManager({
exports.costing = require("./job-costing").JobCosting; imex: require('./job-totals').totalsSsu,
exports.costingmulti = require("./job-costing").JobCostingMulti; rome: require('./job-totals-USA').totalsSsu,
exports.statustransition = require("./job-status-transition").statustransition; promanager: require('./job-totals-USA').totalsSsu,
exports.lifecycle = require("./job-lifecycle"); });
exports.costing = require('./job-costing').JobCosting;
exports.costingmulti = require('./job-costing').JobCostingMulti;
exports.statustransition = require('./job-status-transition').statustransition;
exports.lifecycle = require('./job-lifecycle');

View File

@@ -8,29 +8,41 @@
* @property { string | object | function } imex Return this prop if Rome. * @property { string | object | function } imex Return this prop if Rome.
*/ */
function InstanceManager({ rome, promanager, imex }) { function InstanceManager({ instance, debug, executeFunction, rome, promanager, imex }) {
let propToReturn = null; let propToReturn = null;
switch (process.env.INSTANCE) { switch (instance || process.env.INSTANCE) {
case "IMEX": case 'IMEX':
propToReturn = imex; propToReturn = imex;
break; break;
case "ROME": case 'ROME':
propToReturn = rome; propToReturn = rome; //TODO:AIO Implement USE_IMEX
break; break;
case "PROMANAGER": case 'PROMANAGER':
propToReturn = promanager; //Return the rome prop if USE_ROME.
//If not USE_ROME, we want to default back to the rome prop if it's undefined.
//If null, we might want to show nothing, so make sure we return null.
propToReturn =
promanager === 'USE_ROME' ? rome : promanager !== undefined ? promanager : rome;
break; break;
default: default:
propToReturn = imex; propToReturn = imex;
break; break;
} }
// if (!propToReturn) {
// throw new Error( if (debug) {
// `Prop to return is not valid for this instance (${process.env.INSTANCE}).` console.log('InstanceRenderManager Debugger');
// ); console.log('=========================');
// } console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
return propToReturn; console.log('=========================');
}
//Checking to see if we need to default to another one.
if (propToReturn === 'imex') {
propToReturn = imex;
}
if (executeFunction && typeof propToReturn === 'function') return propToReturn(...args);
return propToReturn === undefined ? null : propToReturn;
} }
exports.default = InstanceManager exports.default = InstanceManager;