Compare commits
79 Commits
feature/IO
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d06037df1f | ||
|
|
e3aea55e91 | ||
|
|
bf6b1c202f | ||
|
|
0cab47f984 | ||
|
|
829e611692 | ||
|
|
23c0f8e383 | ||
|
|
fcd9c19f0b | ||
|
|
430823dde0 | ||
|
|
7e919a7221 | ||
|
|
260607cb72 | ||
|
|
810738539b | ||
|
|
80539949fb | ||
|
|
ebe5c5b113 | ||
|
|
525182c2a7 | ||
|
|
3704c0cb12 | ||
|
|
c8c844cfba | ||
|
|
4c4e16b0c9 | ||
|
|
69f727c4e5 | ||
|
|
04cff4acb1 | ||
|
|
4e4fcc3ae4 | ||
|
|
485f9d6025 | ||
|
|
a697ade93a | ||
|
|
7db07b5a94 | ||
|
|
9ec50875a2 | ||
|
|
02b6875eec | ||
|
|
e7e4c534bc | ||
|
|
e438fa1d99 | ||
|
|
4abbf50a46 | ||
|
|
3e9279d89a | ||
|
|
1305277c09 | ||
|
|
3c47c672d4 | ||
|
|
258d99cd41 | ||
|
|
83356fa4ef | ||
|
|
25429e78f8 | ||
|
|
de90bd1bb0 | ||
|
|
aa6cb4c1d2 | ||
|
|
e871ba600f | ||
|
|
fe3698980d | ||
|
|
89b640f71c | ||
|
|
d13a9cd04a | ||
|
|
c0dab92d0e | ||
|
|
9c897972ad | ||
|
|
307e244475 | ||
|
|
9d3aca646b | ||
|
|
e6e61466df | ||
|
|
db7f9fe2ab | ||
|
|
ded798fdf1 | ||
|
|
bfe94e3068 | ||
|
|
823f07409a | ||
|
|
1a4bc720c2 | ||
|
|
73cacdec24 | ||
|
|
18998c4dbe | ||
|
|
e236d6e912 | ||
|
|
523df670df | ||
|
|
ce58181fc3 | ||
|
|
bed0669f73 | ||
|
|
b0d077e104 | ||
|
|
87a01208fb | ||
|
|
2daee84fbf | ||
|
|
cdbf58f3ac | ||
|
|
f6a59bdf55 | ||
|
|
ea72d44b42 | ||
|
|
d1b9b5546b | ||
|
|
84f0affaed | ||
|
|
fc4b5c6b1d | ||
|
|
2c232a71d5 | ||
|
|
f8e1758788 | ||
|
|
5c95c72f40 | ||
|
|
98f816b069 | ||
|
|
3ca6308dd2 | ||
|
|
a2c2aa11ac | ||
|
|
b5b772d0c2 | ||
|
|
4d8a2e635c | ||
|
|
0852d55837 | ||
|
|
4c38ddf3cd | ||
|
|
e15edeadb5 | ||
|
|
422c7baada | ||
|
|
2a2f8e51b3 | ||
|
|
85b1875a22 |
@@ -22,6 +22,7 @@ import {
|
||||
} from "../redux/user/user.selectors";
|
||||
import PrivateRoute from "../utils/private-route";
|
||||
import "./App.styles.scss";
|
||||
import handleBeta from "../utils/handleBeta";
|
||||
|
||||
const ResetPassword = lazy(() =>
|
||||
import("../pages/reset-password/reset-password.component")
|
||||
@@ -57,7 +58,6 @@ export function App({
|
||||
if (!navigator.onLine) {
|
||||
setOnline(false);
|
||||
}
|
||||
|
||||
checkUserSession();
|
||||
}, [checkUserSession, setOnline]);
|
||||
|
||||
@@ -73,6 +73,7 @@ export function App({
|
||||
window.addEventListener("online", function (e) {
|
||||
setOnline(true);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (currentUser.authorized && bodyshop) {
|
||||
client.setAttribute("imexshopid", bodyshop.imexshopid);
|
||||
@@ -107,6 +108,8 @@ export function App({
|
||||
/>
|
||||
);
|
||||
|
||||
handleBeta();
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Suspense fallback={<LoadingSpinner message="ImEX Online" />}>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
DELETE_BILL_LINE,
|
||||
INSERT_NEW_BILL_LINES,
|
||||
UPDATE_BILL_LINE
|
||||
UPDATE_BILL_LINE,
|
||||
} from "../../graphql/bill-lines.queries";
|
||||
import { QUERY_BILL_BY_PK, UPDATE_BILL } from "../../graphql/bills.queries";
|
||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||
@@ -20,6 +20,7 @@ import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import BillFormContainer from "../bill-form/bill-form.container";
|
||||
import BillMarkExportedButton from "../bill-mark-exported-button/bill-mark-exported-button.component";
|
||||
import BillPrintButton from "../bill-print-button/bill-print-button.component";
|
||||
import BillReeportButtonComponent from "../bill-reexport-button/bill-reexport-button.component";
|
||||
import JobDocumentsGallery from "../jobs-documents-gallery/jobs-documents-gallery.container";
|
||||
import JobsDocumentsLocalGallery from "../jobs-documents-local-gallery/jobs-documents-local-gallery.container";
|
||||
@@ -176,7 +177,7 @@ export function BillDetailEditcontainer({
|
||||
extra={
|
||||
<Space>
|
||||
<BillDetailEditReturn data={data} />
|
||||
|
||||
<BillPrintButton billid={search.billid} />
|
||||
<Popconfirm
|
||||
visible={visible}
|
||||
onConfirm={() => form.submit()}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Button, Space } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
|
||||
export default function BillPrintButton({ billid }) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const Templates = TemplateList("job_special");
|
||||
|
||||
const submitHandler = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await GenerateDocument(
|
||||
{
|
||||
name: Templates.parts_invoice_label_single.key,
|
||||
variables: {
|
||||
id: billid,
|
||||
},
|
||||
},
|
||||
{},
|
||||
"p"
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn("Warning: Error generating a document.");
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Space wrap>
|
||||
<Button loading={loading} onClick={submitHandler}>
|
||||
{t("bills.labels.printlabels")}
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
@@ -35,6 +35,15 @@ export default function ContractsCarsComponent({
|
||||
state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
|
||||
render: (text, record) => <div>{t(record.status)}</div>,
|
||||
},
|
||||
{
|
||||
title: t("courtesycars.fields.readiness"),
|
||||
dataIndex: "readiness",
|
||||
key: "readiness",
|
||||
sorter: (a, b) => alphaSort(a.readiness, b.readiness),
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "readiness" && state.sortedInfo.order,
|
||||
render: (text, record) => t(record.readiness),
|
||||
},
|
||||
{
|
||||
title: t("courtesycars.fields.year"),
|
||||
dataIndex: "year",
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { CHECK_CC_FLEET_NUMBER } from "../../graphql/courtesy-car.queries";
|
||||
import { DateFormatter } from "../../utils/DateFormatter";
|
||||
import CourtesyCarFuelSlider from "../courtesy-car-fuel-select/courtesy-car-fuel-select.component";
|
||||
import CourtesyCarReadiness from "../courtesy-car-readiness-select/courtesy-car-readiness-select.component";
|
||||
import CourtesyCarStatus from "../courtesy-car-status-select/courtesy-car-status-select.component";
|
||||
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||
//import FormFieldsChanged from "../form-fields-changed-alert/form-fields-changed-alert.component";
|
||||
@@ -213,6 +214,9 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) {
|
||||
>
|
||||
<CourtesyCarStatus />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("courtesycars.fields.readiness")} name="readiness">
|
||||
<CourtesyCarReadiness />
|
||||
</Form.Item>
|
||||
<div>
|
||||
<Form.Item
|
||||
label={t("courtesycars.fields.nextservicekm")}
|
||||
@@ -227,8 +231,9 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) {
|
||||
>
|
||||
{() => {
|
||||
const nextservicekm = form.getFieldValue("nextservicekm");
|
||||
const mileageOver =
|
||||
nextservicekm && nextservicekm <= form.getFieldValue("mileage");
|
||||
const mileageOver = nextservicekm
|
||||
? nextservicekm <= form.getFieldValue("mileage")
|
||||
: false;
|
||||
if (mileageOver)
|
||||
return (
|
||||
<Space direction="vertical" style={{ color: "tomato" }}>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Select } from "antd";
|
||||
import React, { forwardRef, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
const { Option } = Select;
|
||||
|
||||
const CourtesyCarReadinessComponent = ({ value, onChange }, ref) => {
|
||||
const [option, setOption] = useState(value);
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
if (value !== option && onChange) {
|
||||
onChange(option);
|
||||
}
|
||||
}, [value, option, onChange]);
|
||||
|
||||
return (
|
||||
<Select
|
||||
allowClear
|
||||
ref={ref}
|
||||
value={option}
|
||||
style={{
|
||||
width: 100,
|
||||
}}
|
||||
onChange={setOption}
|
||||
>
|
||||
<Option value="courtesycars.readiness.ready">
|
||||
{t("courtesycars.readiness.ready")}
|
||||
</Option>
|
||||
<Option value="courtesycars.readiness.notready">
|
||||
{t("courtesycars.readiness.notready")}
|
||||
</Option>
|
||||
</Select>
|
||||
);
|
||||
};
|
||||
export default forwardRef(CourtesyCarReadinessComponent);
|
||||
@@ -74,10 +74,11 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
|
||||
render: (text, record) => {
|
||||
const { nextservicedate, nextservicekm, mileage } = record;
|
||||
|
||||
const mileageOver = nextservicekm <= mileage;
|
||||
const mileageOver = nextservicekm ? nextservicekm <= mileage : false;
|
||||
|
||||
const dueForService =
|
||||
nextservicedate && moment(nextservicedate).isBefore(moment());
|
||||
nextservicedate &&
|
||||
moment(nextservicedate).endOf("day").isSameOrBefore(moment());
|
||||
|
||||
return (
|
||||
<Space>
|
||||
@@ -91,6 +92,26 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t("courtesycars.fields.readiness"),
|
||||
dataIndex: "readiness",
|
||||
key: "readiness",
|
||||
sorter: (a, b) => alphaSort(a.readiness, b.readiness),
|
||||
filters: [
|
||||
{
|
||||
text: t("courtesycars.readiness.ready"),
|
||||
value: "courtesycars.readiness.ready",
|
||||
},
|
||||
{
|
||||
text: t("courtesycars.readiness.notready"),
|
||||
value: "courtesycars.readiness.notready",
|
||||
},
|
||||
],
|
||||
onFilter: (value, record) => value.includes(record.readiness),
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "readiness" && state.sortedInfo.order,
|
||||
render: (text, record) => t(record.readiness),
|
||||
},
|
||||
{
|
||||
title: t("courtesycars.fields.year"),
|
||||
dataIndex: "year",
|
||||
@@ -131,6 +152,36 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "plate" && state.sortedInfo.order,
|
||||
},
|
||||
{
|
||||
title: t("courtesycars.fields.fuel"),
|
||||
dataIndex: "fuel",
|
||||
key: "fuel",
|
||||
sorter: (a, b) => alphaSort(a.fuel, b.fuel),
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "fuel" && state.sortedInfo.order,
|
||||
render: (text, record) => {
|
||||
switch (record.fuel) {
|
||||
case 100:
|
||||
return t("courtesycars.labels.fuel.full");
|
||||
case 88:
|
||||
return t("courtesycars.labels.fuel.78");
|
||||
case 63:
|
||||
return t("courtesycars.labels.fuel.58");
|
||||
case 50:
|
||||
return t("courtesycars.labels.fuel.12");
|
||||
case 38:
|
||||
return t("courtesycars.labels.fuel.34");
|
||||
case 25:
|
||||
return t("courtesycars.labels.fuel.14");
|
||||
case 13:
|
||||
return t("courtesycars.labels.fuel.18");
|
||||
case 0:
|
||||
return t("courtesycars.labels.fuel.empty");
|
||||
default:
|
||||
return record.fuel;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t("courtesycars.labels.outwith"),
|
||||
dataIndex: "outwith",
|
||||
|
||||
@@ -13,7 +13,7 @@ import Icon, {
|
||||
FileFilled,
|
||||
//GlobalOutlined,
|
||||
HomeFilled,
|
||||
ImportOutlined,
|
||||
ImportOutlined, InfoCircleOutlined,
|
||||
LineChartOutlined,
|
||||
PaperClipOutlined,
|
||||
PhoneOutlined,
|
||||
@@ -26,8 +26,8 @@ import Icon, {
|
||||
UserOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Layout, Menu } from "antd";
|
||||
import React from "react";
|
||||
import {Layout, Menu, Switch, Tooltip} from "antd";
|
||||
import React, {useEffect, useState} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { BsKanban } from "react-icons/bs";
|
||||
import {
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import {handleBeta, setBeta, checkBeta} from "../../utils/handleBeta";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -102,9 +103,21 @@ function Header({
|
||||
{},
|
||||
bodyshop && bodyshop.imexshopid
|
||||
);
|
||||
const [betaSwitch, setBetaSwitch] = useState(false);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
const isBeta = checkBeta();
|
||||
setBetaSwitch(isBeta);
|
||||
}, []);
|
||||
|
||||
const betaSwitchChange = (checked) => {
|
||||
setBeta(checked);
|
||||
setBetaSwitch(checked);
|
||||
handleBeta();
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout.Header>
|
||||
<Menu
|
||||
@@ -431,6 +444,17 @@ function Header({
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.SubMenu>
|
||||
<Menu.Item style={{marginLeft: 'auto'}} key="profile">
|
||||
<Tooltip title="A more modern ImEX Online is ready for you to try! You can switch back at any time.">
|
||||
<InfoCircleOutlined/>
|
||||
<span style={{marginRight: 8}}>Try the new ImEX Online</span>
|
||||
<Switch
|
||||
checked={betaSwitch}
|
||||
onChange={betaSwitchChange}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Menu.Item>
|
||||
|
||||
</Menu>
|
||||
</Layout.Header>
|
||||
);
|
||||
|
||||
@@ -7,21 +7,31 @@ import { connect } from "react-redux";
|
||||
import { useHistory } from "react-router";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { UPDATE_JOB_LINES_IOU } from "../../graphql/jobs-lines.queries";
|
||||
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { CreateIouForJob } from "../jobs-detail-header-actions/jobs-detail-header-actions.duplicate.util";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
technician: selectTechnician,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(JobCreateIOU);
|
||||
|
||||
export function JobCreateIOU({ bodyshop, currentUser, job, selectedJobLines }) {
|
||||
export function JobCreateIOU({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
job,
|
||||
selectedJobLines,
|
||||
technician,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const client = useApolloClient();
|
||||
@@ -79,13 +89,19 @@ export function JobCreateIOU({ bodyshop, currentUser, job, selectedJobLines }) {
|
||||
title={t("jobs.labels.createiouwarning")}
|
||||
onConfirm={handleCreateIou}
|
||||
disabled={
|
||||
!selectedJobLines || selectedJobLines.length === 0 || !job.converted
|
||||
!selectedJobLines ||
|
||||
selectedJobLines.length === 0 ||
|
||||
!job.converted ||
|
||||
technician
|
||||
}
|
||||
>
|
||||
<Button
|
||||
loading={loading}
|
||||
disabled={
|
||||
!selectedJobLines || selectedJobLines.length === 0 || !job.converted
|
||||
!selectedJobLines ||
|
||||
selectedJobLines.length === 0 ||
|
||||
!job.converted ||
|
||||
technician
|
||||
}
|
||||
>
|
||||
{t("jobs.actions.createiou")}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
BranchesOutlined,
|
||||
ExclamationCircleFilled,
|
||||
PauseCircleOutlined,
|
||||
WarningFilled,
|
||||
BranchesOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import { Card, Col, Row, Space, Tag, Tooltip } from "antd";
|
||||
import React, { useState } from "react";
|
||||
@@ -221,6 +221,14 @@ export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
||||
<VehicleVinDisplay>
|
||||
{`${job.v_vin || t("general.labels.na")}`}
|
||||
</VehicleVinDisplay>
|
||||
{bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid ? (
|
||||
job.v_vin?.length !== 17 ? (
|
||||
<WarningFilled style={{ color: "tomato", marginLeft: ".3rem" }} />
|
||||
) : null
|
||||
) : null}
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.regie_number")}>
|
||||
{job.regie_number || t("general.labels.na")}
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.labels.relatedros")}>
|
||||
<JobsRelatedRos jobid={job.id} job={job} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import { Button, Dropdown, Menu } from "antd";
|
||||
import dataSource from "./production-list-columns.data";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import dataSource from "./production-list-columns.data";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -24,6 +24,7 @@ export function ProductionColumnsComponent({
|
||||
columnState,
|
||||
technician,
|
||||
bodyshop,
|
||||
data,
|
||||
tableState,
|
||||
}) {
|
||||
const [columns, setColumns] = columnState;
|
||||
@@ -36,6 +37,7 @@ export function ProductionColumnsComponent({
|
||||
bodyshop,
|
||||
technician,
|
||||
state: tableState,
|
||||
data: data,
|
||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||
}).filter((i) => i.key === e.key),
|
||||
]);
|
||||
@@ -46,6 +48,7 @@ export function ProductionColumnsComponent({
|
||||
technician,
|
||||
state: tableState,
|
||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||
data: data,
|
||||
});
|
||||
const menu = (
|
||||
<Menu
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PauseCircleOutlined, BranchesOutlined } from "@ant-design/icons";
|
||||
import { BranchesOutlined, PauseCircleOutlined } from "@ant-design/icons";
|
||||
import { Space, Tooltip } from "antd";
|
||||
import i18n from "i18next";
|
||||
import moment from "moment";
|
||||
@@ -6,6 +6,7 @@ import { Link } from "react-router-dom";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import { TimeFormatter } from "../../utils/DateFormatter";
|
||||
import PhoneFormatter from "../../utils/PhoneFormatter";
|
||||
import { onlyUnique } from "../../utils/arrayHelper";
|
||||
import { alphaSort, dateSort, statusSort } from "../../utils/sorters";
|
||||
import JobAltTransportChange from "../job-at-change/job-at-change.component";
|
||||
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
|
||||
@@ -25,7 +26,7 @@ import ProductionListColumnCategory from "./production-list-columns.status.categ
|
||||
import ProductionListColumnStatus from "./production-list-columns.status.component";
|
||||
import ProductionlistColumnTouchTime from "./prodution-list-columns.touchtime.component";
|
||||
|
||||
const r = ({ technician, state, activeStatuses, bodyshop }) => {
|
||||
const r = ({ technician, state, activeStatuses, data, bodyshop }) => {
|
||||
return [
|
||||
{
|
||||
title: i18n.t("jobs.actions.viewdetail"),
|
||||
@@ -536,6 +537,36 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => {
|
||||
<JobPartsQueueCount parts={record.joblines_status} record={record} />
|
||||
),
|
||||
},
|
||||
{
|
||||
title: i18n.t("jobs.labels.estimator"),
|
||||
dataIndex: "estimator",
|
||||
key: "estimator",
|
||||
sorter: (a, b) =>
|
||||
alphaSort(
|
||||
`${a.est_ct_fn || ""} ${a.est_ct_ln || ""}`.trim(),
|
||||
`${b.est_ct_fn || ""} ${b.est_ct_ln || ""}`.trim()
|
||||
),
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "estimator" && state.sortedInfo.order,
|
||||
filters:
|
||||
(data &&
|
||||
data
|
||||
.map((j) => `${j.est_ct_fn || ""} ${j.est_ct_ln || ""}`.trim())
|
||||
.filter(onlyUnique)
|
||||
.map((s) => {
|
||||
return {
|
||||
text: s || "N/A",
|
||||
value: [s],
|
||||
};
|
||||
})) ||
|
||||
[],
|
||||
onFilter: (value, record) =>
|
||||
value.includes(
|
||||
`${record.est_ct_fn || ""} ${record.est_ct_ln || ""}`.trim()
|
||||
),
|
||||
render: (text, record) =>
|
||||
`${record.est_ct_fn || ""} ${record.est_ct_ln || ""}`.trim(),
|
||||
},
|
||||
|
||||
//Added as a place holder for St Claude. Not implemented as it requires another join for a field used by only 1 client.
|
||||
// {
|
||||
|
||||
@@ -24,6 +24,7 @@ export function ProductionListTable({
|
||||
technician,
|
||||
currentUser,
|
||||
state,
|
||||
data,
|
||||
setColumns,
|
||||
setState,
|
||||
}) {
|
||||
@@ -41,6 +42,7 @@ export function ProductionListTable({
|
||||
bodyshop,
|
||||
technician,
|
||||
state,
|
||||
data: data,
|
||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||
}).find((e) => e.key === k.key),
|
||||
width: k.width,
|
||||
@@ -95,6 +97,7 @@ export function ProductionListTable({
|
||||
...ProductionListColumns({
|
||||
technician,
|
||||
state,
|
||||
data: data,
|
||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||
}).find((e) => e.key === k.key),
|
||||
width: k.width,
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
Statistic,
|
||||
Table,
|
||||
} from "antd";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import ReactDragListView from "react-drag-listview";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -79,6 +79,7 @@ export function ProductionListTable({
|
||||
bodyshop,
|
||||
technician,
|
||||
state,
|
||||
data: data,
|
||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||
}).find((e) => e.key === k.key),
|
||||
width: k.width ?? 100,
|
||||
@@ -87,6 +88,33 @@ export function ProductionListTable({
|
||||
[]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const newColumns =
|
||||
(state &&
|
||||
matchingColumnConfig &&
|
||||
matchingColumnConfig.columns.columnKeys.map((k) => {
|
||||
return {
|
||||
...ProductionListColumns({
|
||||
bodyshop,
|
||||
technician,
|
||||
state,
|
||||
data: data,
|
||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||
}).find((e) => e.key === k.key),
|
||||
width: k.width ?? 100,
|
||||
};
|
||||
})) ||
|
||||
[];
|
||||
setColumns(newColumns);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
//state,
|
||||
matchingColumnConfig,
|
||||
bodyshop,
|
||||
technician,
|
||||
data,
|
||||
]); //State removed from dependency array as it causes race condition when removing columns from table view and is not needed.
|
||||
|
||||
const handleTableChange = (pagination, filters, sorter) => {
|
||||
setState({
|
||||
...state,
|
||||
@@ -104,7 +132,8 @@ export function ProductionListTable({
|
||||
|
||||
const removeColumn = (e) => {
|
||||
const { key } = e;
|
||||
setColumns(columns.filter((i) => i.key !== key));
|
||||
const newColumns = columns.filter((i) => i.key !== key);
|
||||
setColumns(newColumns);
|
||||
};
|
||||
|
||||
const handleResize =
|
||||
@@ -227,6 +256,7 @@ export function ProductionListTable({
|
||||
<ProductionListColumnsAdd
|
||||
columnState={[columns, setColumns]}
|
||||
tableState={state}
|
||||
data={data}
|
||||
/>
|
||||
<ProductionListSaveConfigButton
|
||||
columns={columns}
|
||||
@@ -237,6 +267,7 @@ export function ProductionListTable({
|
||||
state={state}
|
||||
setState={setState}
|
||||
setColumns={setColumns}
|
||||
data={data}
|
||||
/>
|
||||
|
||||
<Input
|
||||
|
||||
@@ -30,15 +30,15 @@ export const QUERY_AVAILABLE_CC = gql`
|
||||
fuel
|
||||
id
|
||||
make
|
||||
model
|
||||
plate
|
||||
status
|
||||
year
|
||||
dailycost
|
||||
mileage
|
||||
model
|
||||
notes
|
||||
nextservicekm
|
||||
nextservicedate
|
||||
plate
|
||||
readiness
|
||||
status
|
||||
year
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -68,19 +68,20 @@ export const QUERY_ALL_CC = gql`
|
||||
insuranceexpires
|
||||
leaseenddate
|
||||
make
|
||||
mileage
|
||||
model
|
||||
nextservicedate
|
||||
nextservicekm
|
||||
notes
|
||||
plate
|
||||
purchasedate
|
||||
readiness
|
||||
registrationexpires
|
||||
serviceenddate
|
||||
servicestartdate
|
||||
status
|
||||
vin
|
||||
year
|
||||
mileage
|
||||
cccontracts(
|
||||
where: { status: { _eq: "contracts.status.out" } }
|
||||
order_by: { contract_date: desc }
|
||||
@@ -90,10 +91,10 @@ export const QUERY_ALL_CC = gql`
|
||||
scheduledreturn
|
||||
job {
|
||||
id
|
||||
ro_number
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownr_co_nm
|
||||
ro_number
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,19 +120,20 @@ export const QUERY_CC_BY_PK = gql`
|
||||
insuranceexpires
|
||||
leaseenddate
|
||||
make
|
||||
mileage
|
||||
model
|
||||
nextservicedate
|
||||
nextservicekm
|
||||
notes
|
||||
plate
|
||||
purchasedate
|
||||
readiness
|
||||
registrationexpires
|
||||
serviceenddate
|
||||
servicestartdate
|
||||
status
|
||||
vin
|
||||
year
|
||||
mileage
|
||||
cccontracts_aggregate {
|
||||
aggregate {
|
||||
count(distinct: true)
|
||||
@@ -139,21 +141,20 @@ export const QUERY_CC_BY_PK = gql`
|
||||
}
|
||||
cccontracts(offset: $offset, limit: $limit, order_by: $order) {
|
||||
agreementnumber
|
||||
driver_fn
|
||||
driver_ln
|
||||
id
|
||||
status
|
||||
start
|
||||
scheduledreturn
|
||||
kmstart
|
||||
kmend
|
||||
driver_ln
|
||||
driver_fn
|
||||
scheduledreturn
|
||||
start
|
||||
status
|
||||
job {
|
||||
ro_number
|
||||
|
||||
id
|
||||
ownr_ln
|
||||
ownr_fn
|
||||
ownr_co_nm
|
||||
id
|
||||
ro_number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,6 +364,8 @@ export const QUERY_JOBS_IN_PRODUCTION = gql`
|
||||
employee_refinish
|
||||
employee_prep
|
||||
employee_csr
|
||||
est_ct_fn
|
||||
est_ct_ln
|
||||
suspended
|
||||
date_repairstarted
|
||||
joblines_status {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { useMutation, useQuery } from "@apollo/client";
|
||||
import { Form, notification } from "antd";
|
||||
import moment from "moment";
|
||||
import queryString from "query-string";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useLocation, useParams } from "react-router-dom";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import NotFound from "../../components/not-found/not-found.component";
|
||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||
import { QUERY_CC_BY_PK, UPDATE_CC } from "../../graphql/courtesy-car.queries";
|
||||
import {
|
||||
@@ -13,13 +16,10 @@ import {
|
||||
setBreadcrumbs,
|
||||
setSelectedHeader,
|
||||
} from "../../redux/application/application.actions";
|
||||
import { pageLimit } from "../../utils/config";
|
||||
import { CreateRecentItem } from "../../utils/create-recent-item";
|
||||
import UndefinedToNull from "./../../utils/undefinedtonull";
|
||||
import CourtesyCarDetailPageComponent from "./courtesy-car-detail.page.component";
|
||||
import NotFound from "../../components/not-found/not-found.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import queryString from "query-string";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import {pageLimit} from "../../utils/config";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -112,7 +112,10 @@ export function CourtesyCarDetailPageContainer({
|
||||
setSaveLoading(true);
|
||||
|
||||
const result = await updateCourtesyCar({
|
||||
variables: { cc: { ...values }, ccId: ccId },
|
||||
variables: {
|
||||
cc: { ...UndefinedToNull(values, ["readiness"]) },
|
||||
ccId: ccId,
|
||||
},
|
||||
refetchQueries: ["QUERY_CC_BY_PK"],
|
||||
awaitRefetchQueries: true,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import { useLazyQuery, useMutation } from "@apollo/client";
|
||||
import { Form, notification } from "antd";
|
||||
import _ from "lodash";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -90,6 +90,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
{},
|
||||
values,
|
||||
{ date_open: new Date() },
|
||||
{ date_estimated: new Date() },
|
||||
{
|
||||
vehicle:
|
||||
state.vehicle.selectedid || state.vehicle.none
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
"new": "New Bill",
|
||||
"noneselected": "No bill selected.",
|
||||
"onlycmforinvoiced": "Only credit memos can be entered for any Job that has been invoiced, exported, or voided.",
|
||||
"printlabels": "Print Labels",
|
||||
"retailtotal": "Bills Retail Total",
|
||||
"savewithdiscrepancy": "You are about to save this bill with a discrepancy. The system will continue to use the calculated amount using the bill lines. Press cancel to return to the bill.",
|
||||
"state_tax": "Provincial/State Tax",
|
||||
@@ -785,6 +786,7 @@
|
||||
"notes": "Notes",
|
||||
"plate": "Plate Number",
|
||||
"purchasedate": "Purchase Date",
|
||||
"readiness": "Readiness",
|
||||
"registrationexpires": "Registration Expires On",
|
||||
"serviceenddate": "Usage End Date",
|
||||
"servicestartdate": "Usage Start Date",
|
||||
@@ -821,6 +823,10 @@
|
||||
},
|
||||
"successes": {
|
||||
"saved": "Courtesy Car saved successfully."
|
||||
},
|
||||
"readiness": {
|
||||
"notready": "Not Ready",
|
||||
"ready": "Ready"
|
||||
}
|
||||
},
|
||||
"csi": {
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
"new": "",
|
||||
"noneselected": "",
|
||||
"onlycmforinvoiced": "",
|
||||
"printlabels": "",
|
||||
"retailtotal": "",
|
||||
"savewithdiscrepancy": "",
|
||||
"state_tax": "",
|
||||
@@ -785,6 +786,7 @@
|
||||
"notes": "",
|
||||
"plate": "",
|
||||
"purchasedate": "",
|
||||
"readiness": "",
|
||||
"registrationexpires": "",
|
||||
"serviceenddate": "",
|
||||
"servicestartdate": "",
|
||||
@@ -821,6 +823,10 @@
|
||||
},
|
||||
"successes": {
|
||||
"saved": ""
|
||||
},
|
||||
"readiness": {
|
||||
"notready": "",
|
||||
"ready": ""
|
||||
}
|
||||
},
|
||||
"csi": {
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
"new": "",
|
||||
"noneselected": "",
|
||||
"onlycmforinvoiced": "",
|
||||
"printlabels": "",
|
||||
"retailtotal": "",
|
||||
"savewithdiscrepancy": "",
|
||||
"state_tax": "",
|
||||
@@ -785,6 +786,7 @@
|
||||
"notes": "",
|
||||
"plate": "",
|
||||
"purchasedate": "",
|
||||
"readiness": "",
|
||||
"registrationexpires": "",
|
||||
"serviceenddate": "",
|
||||
"servicestartdate": "",
|
||||
@@ -821,6 +823,10 @@
|
||||
},
|
||||
"successes": {
|
||||
"saved": ""
|
||||
},
|
||||
"readiness": {
|
||||
"notready": "",
|
||||
"ready": ""
|
||||
}
|
||||
},
|
||||
"csi": {
|
||||
|
||||
37
client/src/utils/handleBeta.js
Normal file
37
client/src/utils/handleBeta.js
Normal file
@@ -0,0 +1,37 @@
|
||||
export const BETA_KEY = 'betaSwitchImex';
|
||||
|
||||
export const checkBeta = () => {
|
||||
const cookie = document.cookie.split('; ').find(row => row.startsWith(BETA_KEY));
|
||||
return cookie ? cookie.split('=')[1] === 'true' : false;
|
||||
}
|
||||
|
||||
|
||||
export const setBeta = (value) => {
|
||||
const domain = window.location.hostname.split('.').slice(-2).join('.');
|
||||
document.cookie = `${BETA_KEY}=${value}; path=/; domain=.${domain}`;
|
||||
}
|
||||
|
||||
export const handleBeta = () => {
|
||||
// If the current host name does not start with beta or test, then we don't need to do anything.
|
||||
if (window.location.hostname.startsWith('localhost')) {
|
||||
console.log('Not on beta or test, so no need to handle beta.');
|
||||
return;
|
||||
}
|
||||
|
||||
const isBeta = checkBeta();
|
||||
|
||||
const currentHostName = window.location.hostname;
|
||||
|
||||
// Beta is enabled, but the current host name does start with beta.
|
||||
if (isBeta && !currentHostName.startsWith('beta')) {
|
||||
const href= `${window.location.protocol}//beta.${currentHostName}${window.location.pathname}${window.location.search}${window.location.hash}`;
|
||||
window.location.replace(href);
|
||||
}
|
||||
|
||||
// Beta is not enabled, but the current host name does start with beta.
|
||||
else if (!isBeta && currentHostName.startsWith('beta')) {
|
||||
const href = `${window.location.protocol}//${currentHostName.replace('beta.', '')}${window.location.pathname}${window.location.search}${window.location.hash}`;
|
||||
window.location.replace(href);
|
||||
}
|
||||
}
|
||||
export default handleBeta;
|
||||
@@ -1388,60 +1388,62 @@
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- id
|
||||
- created_at
|
||||
- updated_at
|
||||
- bodyshopid
|
||||
- make
|
||||
- model
|
||||
- year
|
||||
- plate
|
||||
- color
|
||||
- vin
|
||||
- fleetnumber
|
||||
- purchasedate
|
||||
- servicestartdate
|
||||
- serviceenddate
|
||||
- leaseenddate
|
||||
- status
|
||||
- nextservicekm
|
||||
- nextservicedate
|
||||
- damage
|
||||
- notes
|
||||
- fuel
|
||||
- registrationexpires
|
||||
- insuranceexpires
|
||||
- created_at
|
||||
- dailycost
|
||||
- damage
|
||||
- fleetnumber
|
||||
- fuel
|
||||
- id
|
||||
- insuranceexpires
|
||||
- leaseenddate
|
||||
- make
|
||||
- mileage
|
||||
- model
|
||||
- nextservicedate
|
||||
- nextservicekm
|
||||
- notes
|
||||
- plate
|
||||
- purchasedate
|
||||
- readiness
|
||||
- registrationexpires
|
||||
- serviceenddate
|
||||
- servicestartdate
|
||||
- status
|
||||
- updated_at
|
||||
- vin
|
||||
- year
|
||||
select_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- bodyshopid
|
||||
- color
|
||||
- created_at
|
||||
- dailycost
|
||||
- damage
|
||||
- fleetnumber
|
||||
- fuel
|
||||
- id
|
||||
- insuranceexpires
|
||||
- leaseenddate
|
||||
- make
|
||||
- mileage
|
||||
- model
|
||||
- nextservicedate
|
||||
- nextservicekm
|
||||
- notes
|
||||
- plate
|
||||
- purchasedate
|
||||
- readiness
|
||||
- registrationexpires
|
||||
- serviceenddate
|
||||
- servicestartdate
|
||||
- dailycost
|
||||
- fuel
|
||||
- mileage
|
||||
- nextservicekm
|
||||
- color
|
||||
- damage
|
||||
- fleetnumber
|
||||
- make
|
||||
- model
|
||||
- notes
|
||||
- plate
|
||||
- status
|
||||
- updated_at
|
||||
- vin
|
||||
- year
|
||||
- created_at
|
||||
- updated_at
|
||||
- bodyshopid
|
||||
- id
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
@@ -1456,31 +1458,32 @@
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- bodyshopid
|
||||
- color
|
||||
- created_at
|
||||
- dailycost
|
||||
- damage
|
||||
- fleetnumber
|
||||
- fuel
|
||||
- id
|
||||
- insuranceexpires
|
||||
- leaseenddate
|
||||
- make
|
||||
- mileage
|
||||
- model
|
||||
- nextservicedate
|
||||
- nextservicekm
|
||||
- notes
|
||||
- plate
|
||||
- purchasedate
|
||||
- readiness
|
||||
- registrationexpires
|
||||
- serviceenddate
|
||||
- servicestartdate
|
||||
- dailycost
|
||||
- fuel
|
||||
- mileage
|
||||
- nextservicekm
|
||||
- color
|
||||
- damage
|
||||
- fleetnumber
|
||||
- make
|
||||
- model
|
||||
- notes
|
||||
- plate
|
||||
- status
|
||||
- updated_at
|
||||
- vin
|
||||
- year
|
||||
- created_at
|
||||
- updated_at
|
||||
- bodyshopid
|
||||
- id
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
@@ -2020,24 +2023,24 @@
|
||||
- active:
|
||||
_eq: true
|
||||
columns:
|
||||
- labor_rates
|
||||
- percentage
|
||||
- created_at
|
||||
- updated_at
|
||||
- employeeid
|
||||
- id
|
||||
- labor_rates
|
||||
- percentage
|
||||
- teamid
|
||||
- updated_at
|
||||
select_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- labor_rates
|
||||
- percentage
|
||||
- created_at
|
||||
- updated_at
|
||||
- employeeid
|
||||
- id
|
||||
- labor_rates
|
||||
- percentage
|
||||
- teamid
|
||||
- updated_at
|
||||
filter:
|
||||
employee_team:
|
||||
bodyshop:
|
||||
@@ -2052,13 +2055,13 @@
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- labor_rates
|
||||
- percentage
|
||||
- created_at
|
||||
- updated_at
|
||||
- employeeid
|
||||
- id
|
||||
- labor_rates
|
||||
- percentage
|
||||
- teamid
|
||||
- updated_at
|
||||
filter:
|
||||
employee_team:
|
||||
bodyshop:
|
||||
@@ -2120,21 +2123,23 @@
|
||||
_eq: true
|
||||
columns:
|
||||
- active
|
||||
- name
|
||||
- created_at
|
||||
- updated_at
|
||||
- bodyshopid
|
||||
- created_at
|
||||
- id
|
||||
- max_load
|
||||
- name
|
||||
- updated_at
|
||||
select_permissions:
|
||||
- role: user
|
||||
permission:
|
||||
columns:
|
||||
- active
|
||||
- name
|
||||
- created_at
|
||||
- updated_at
|
||||
- bodyshopid
|
||||
- created_at
|
||||
- id
|
||||
- max_load
|
||||
- name
|
||||
- updated_at
|
||||
filter:
|
||||
bodyshop:
|
||||
associations:
|
||||
@@ -2150,6 +2155,7 @@
|
||||
columns:
|
||||
- active
|
||||
- bodyshopid
|
||||
- max_load
|
||||
- name
|
||||
- updated_at
|
||||
filter:
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."courtesycars" add column "readiness" text
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."courtesycars" add column "readiness" text
|
||||
null;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."employee_team_members" add column "max_load" numeric
|
||||
-- not null default '10000';
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."employee_team_members" add column "max_load" numeric
|
||||
not null default '10000';
|
||||
@@ -0,0 +1,3 @@
|
||||
alter table "public"."employee_team_members" alter column "max_load" set default '10000'::numeric;
|
||||
alter table "public"."employee_team_members" alter column "max_load" drop not null;
|
||||
alter table "public"."employee_team_members" add column "max_load" numeric;
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."employee_team_members" drop column "max_load" cascade;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."employee_teams" add column "max_load" numeric
|
||||
-- not null default '10000';
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."employee_teams" add column "max_load" numeric
|
||||
not null default '10000';
|
||||
@@ -34,6 +34,10 @@ const io = new Server(server, {
|
||||
"http://localhost:3000",
|
||||
"https://imex.online",
|
||||
"https://www.imex.online",
|
||||
"https://beta.test.imex.online",
|
||||
"https://www.beta.test.imex.online",
|
||||
"https://beta.imex.online",
|
||||
"https://www.beta.imex.online",
|
||||
],
|
||||
methods: ["GET", "POST"],
|
||||
credentials: true,
|
||||
@@ -224,6 +228,7 @@ app.post("/qbo/payments", fb.validateFirebaseIdToken, qbo.payments);
|
||||
var data = require("./server/data/data");
|
||||
app.post("/data/ah", data.autohouse);
|
||||
app.post("/data/cc", data.claimscorp);
|
||||
app.post("/data/kaizen", data.kaizen);
|
||||
app.post("/record-handler/arms", data.arms);
|
||||
|
||||
var taskHandler = require("./server/tasks/tasks");
|
||||
|
||||
@@ -507,7 +507,7 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
Body: repairCosts.BodyLaborTotalCost.toFormat(CCDineroFormat),
|
||||
Paint: repairCosts.RefinishLaborTotalCost.toFormat(CCDineroFormat),
|
||||
Prep: Dinero().toFormat(CCDineroFormat),
|
||||
Frame: Dinero(job.job_totals.rates.laf.total).toFormat(CCDineroFormat),
|
||||
Frame: repairCosts.FrameLaborTotalCost.toFormat(CCDineroFormat),
|
||||
Mech: repairCosts.MechanicalLaborTotalCost.toFormat(CCDineroFormat),
|
||||
Glass: repairCosts.GlassLaborTotalCost.toFormat(CCDineroFormat),
|
||||
Elec: repairCosts.ElectricalLaborTotalCost.toFormat(CCDineroFormat),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
exports.arms = require("./arms").default;
|
||||
exports.autohouse = require("./autohouse").default;
|
||||
exports.claimscorp = require("./claimscorp").default;
|
||||
exports.arms = require("./arms").default;
|
||||
exports.kaizen = require("./kaizen").default;
|
||||
837
server/data/kaizen.js
Normal file
837
server/data/kaizen.js
Normal file
@@ -0,0 +1,837 @@
|
||||
const path = require("path");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const Dinero = require("dinero.js");
|
||||
const moment = require("moment-timezone");
|
||||
var builder = require("xmlbuilder2");
|
||||
const _ = require("lodash");
|
||||
const logger = require("../utils/logger");
|
||||
const fs = require("fs");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
let Client = require("ssh2-sftp-client");
|
||||
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const { sendServerEmail } = require("../email/sendemail");
|
||||
const DineroFormat = "0,0.00";
|
||||
const DateFormat = "MM/DD/YYYY";
|
||||
|
||||
const repairOpCodes = ["OP4", "OP9", "OP10"];
|
||||
const replaceOpCodes = ["OP2", "OP5", "OP11", "OP12"];
|
||||
|
||||
const ftpSetup = {
|
||||
host: process.env.KAIZEN_HOST,
|
||||
port: process.env.KAIZEN_PORT,
|
||||
username: process.env.KAIZEN_USER,
|
||||
password: process.env.KAIZEN_PASSWORD,
|
||||
debug: (message, ...data) => logger.log(message, "DEBUG", "api", null, data),
|
||||
algorithms: {
|
||||
serverHostKey: [
|
||||
"ssh-rsa",
|
||||
"ssh-dss",
|
||||
"rsa-sha2-256",
|
||||
"rsa-sha2-512",
|
||||
"ecdsa-sha2-nistp256",
|
||||
"ecdsa-sha2-nistp384",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
exports.default = async (req, res) => {
|
||||
//Query for the List of Bodyshop Clients.
|
||||
logger.log("kaizen-start", "DEBUG", "api", null, null);
|
||||
const kaizenShopsIDs = ["SUMMIT", "STRATHMORE", "SUNRIDGE"];
|
||||
|
||||
const { bodyshops } = await client.request(queries.GET_KAIZEN_SHOPS, {
|
||||
imexshopid: kaizenShopsIDs,
|
||||
});
|
||||
|
||||
const specificShopIds = req.body.bodyshopIds; // ['uuid]
|
||||
const { start, end, skipUpload } = req.body; //YYYY-MM-DD
|
||||
if (req.headers["x-imex-auth"] !== process.env.AUTOHOUSE_AUTH_TOKEN) {
|
||||
res.sendStatus(401);
|
||||
return;
|
||||
}
|
||||
const allxmlsToUpload = [];
|
||||
const allErrors = [];
|
||||
try {
|
||||
for (const bodyshop of specificShopIds
|
||||
? bodyshops.filter((b) => specificShopIds.includes(b.id))
|
||||
: bodyshops) {
|
||||
logger.log("kaizen-start-shop-extract", "DEBUG", "api", bodyshop.id, {
|
||||
shopname: bodyshop.shopname,
|
||||
});
|
||||
const erroredJobs = [];
|
||||
try {
|
||||
const { jobs, bodyshops_by_pk } = await client.request(
|
||||
queries.KAIZEN_QUERY,
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
start: start
|
||||
? moment(start).startOf("hours")
|
||||
: moment().subtract(2, "hours").startOf("hour"),
|
||||
...(end && { end: moment(end).endOf("hours") }),
|
||||
}
|
||||
);
|
||||
|
||||
const kaizenObject = {
|
||||
DataFeed: {
|
||||
ShopInfo: {
|
||||
ShopName: bodyshops_by_pk.shopname,
|
||||
Jobs: jobs.map((j) =>
|
||||
CreateRepairOrderTag(
|
||||
{ ...j, bodyshop: bodyshops_by_pk },
|
||||
function ({ job, error }) {
|
||||
erroredJobs.push({ job: job, error: error.toString() });
|
||||
}
|
||||
)
|
||||
),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (erroredJobs.length > 0) {
|
||||
logger.log("kaizen-failed-jobs", "ERROR", "api", bodyshop.id, {
|
||||
count: erroredJobs.length,
|
||||
jobs: JSON.stringify(erroredJobs.map((j) => j.job.ro_number)),
|
||||
});
|
||||
}
|
||||
|
||||
var ret = builder
|
||||
.create(
|
||||
{
|
||||
// version: "1.0",
|
||||
// encoding: "UTF-8",
|
||||
//keepNullNodes: true,
|
||||
},
|
||||
kaizenObject
|
||||
)
|
||||
.end({ allowEmptyTags: true });
|
||||
|
||||
allxmlsToUpload.push({
|
||||
count: kaizenObject.DataFeed.ShopInfo.Jobs.length,
|
||||
xml: ret,
|
||||
filename: `${bodyshop.shopname}-${moment().format(
|
||||
"YYYYMMDDTHHMMss"
|
||||
)}.xml`,
|
||||
});
|
||||
|
||||
logger.log("kaizen-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
||||
shopname: bodyshop.shopname,
|
||||
});
|
||||
} catch (error) {
|
||||
//Error at the shop level.
|
||||
logger.log("kaizen-error-shop", "ERROR", "api", bodyshop.id, {
|
||||
...error,
|
||||
});
|
||||
|
||||
allErrors.push({
|
||||
bodyshopid: bodyshop.id,
|
||||
imexshopid: bodyshop.imexshopid,
|
||||
shopname: bodyshop.shopname,
|
||||
fatal: true,
|
||||
errors: [error.toString()],
|
||||
});
|
||||
} finally {
|
||||
allErrors.push({
|
||||
bodyshopid: bodyshop.id,
|
||||
imexshopid: bodyshop.imexshopid,
|
||||
shopname: bodyshop.shopname,
|
||||
errors: erroredJobs.map((ej) => ({
|
||||
ro_number: ej.job?.ro_number,
|
||||
jobid: ej.job?.id,
|
||||
error: ej.error,
|
||||
})),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (skipUpload) {
|
||||
for (const xmlObj of allxmlsToUpload) {
|
||||
fs.writeFileSync(`./logs/${xmlObj.filename}`, xmlObj.xml);
|
||||
}
|
||||
|
||||
res.json(allxmlsToUpload);
|
||||
sendServerEmail({
|
||||
subject: `Kaizen Report ${moment().format("MM-DD-YY")}`,
|
||||
text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))}
|
||||
Uploaded: ${JSON.stringify(
|
||||
allxmlsToUpload.map((x) => ({ filename: x.filename, count: x.count })),
|
||||
null,
|
||||
2
|
||||
)}
|
||||
`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let sftp = new Client();
|
||||
sftp.on("error", (errors) =>
|
||||
logger.log("kaizen-sftp-error", "ERROR", "api", null, {
|
||||
...errors,
|
||||
})
|
||||
);
|
||||
try {
|
||||
//Connect to the FTP and upload all.
|
||||
|
||||
await sftp.connect(ftpSetup);
|
||||
|
||||
for (const xmlObj of allxmlsToUpload) {
|
||||
logger.log("kaizen-sftp-upload", "DEBUG", "api", null, {
|
||||
filename: xmlObj.filename,
|
||||
});
|
||||
|
||||
const uploadResult = await sftp.put(
|
||||
Buffer.from(xmlObj.xml),
|
||||
`/${xmlObj.filename}`
|
||||
);
|
||||
logger.log("kaizen-sftp-upload-result", "DEBUG", "api", null, {
|
||||
uploadResult,
|
||||
});
|
||||
}
|
||||
|
||||
//***TODO Change filing naming when creating the cron job. IM_ShopInternalName_DDMMYYYY_HHMMSS.xml
|
||||
} catch (error) {
|
||||
logger.log("kaizen-sftp-error", "ERROR", "api", null, {
|
||||
...error,
|
||||
});
|
||||
} finally {
|
||||
sftp.end();
|
||||
}
|
||||
sendServerEmail({
|
||||
subject: `Kaizen Report ${moment().format("MM-DD-YY")}`,
|
||||
text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))}
|
||||
Uploaded: ${JSON.stringify(
|
||||
allxmlsToUpload.map((x) => ({ filename: x.filename, count: x.count })),
|
||||
null,
|
||||
2
|
||||
)}
|
||||
`,
|
||||
});
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
res.status(200).json(error);
|
||||
}
|
||||
};
|
||||
|
||||
const CreateRepairOrderTag = (job, errorCallback) => {
|
||||
//Level 2
|
||||
|
||||
if (!job.job_totals) {
|
||||
errorCallback({
|
||||
jobid: job.id,
|
||||
job: job,
|
||||
ro_number: job.ro_number,
|
||||
error: { toString: () => "No job totals for RO." },
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
||||
const repairCosts = CreateCosts(job);
|
||||
|
||||
try {
|
||||
const ret = {
|
||||
JobID: job.id,
|
||||
RoNumber: job.ro_number,
|
||||
JobStatus: job.tlos_ind
|
||||
? "Total Loss"
|
||||
: job.ro_number
|
||||
? job.status
|
||||
: "Estimate",
|
||||
Customer: {
|
||||
CompanyName: job.ownr_co_nm?.trim() || "",
|
||||
FirstName: job.ownr_fn?.trim() || "",
|
||||
LastName: job.ownr_ln?.trim() || "",
|
||||
Address1: job.ownr_addr1?.trim() || "",
|
||||
Address2: job.ownr_addr2?.trim() || "",
|
||||
City: job.ownr_city?.trim() || "",
|
||||
State: job.ownr_st?.trim() || "",
|
||||
Zip: job.ownr_zip?.trim() || "",
|
||||
},
|
||||
Vehicle: {
|
||||
Year: job.v_model_yr
|
||||
? parseInt(job.v_model_yr.match(/\d/g))
|
||||
? parseInt(job.v_model_yr.match(/\d/g).join(""), 10)
|
||||
: ""
|
||||
: "",
|
||||
Make: job.v_make_desc || "",
|
||||
Model: job.v_model_desc || "",
|
||||
BodyStyle: job.vehicle?.v_bstyle || "",
|
||||
Color: job.v_color || "",
|
||||
VIN: job.v_vin || "",
|
||||
PlateNo: job.plate_no || "",
|
||||
},
|
||||
InsuranceCompany: job.ins_co_nm || "",
|
||||
Claim: job.clm_no || "",
|
||||
Contacts: {
|
||||
CSR: job.employee_csr_rel
|
||||
? `${
|
||||
job.employee_csr_rel.last_name
|
||||
? job.employee_csr_rel.last_name
|
||||
: ""
|
||||
}${job.employee_csr_rel.last_name ? ", " : ""}${
|
||||
job.employee_csr_rel.first_name
|
||||
? job.employee_csr_rel.first_name
|
||||
: ""
|
||||
}`
|
||||
: "",
|
||||
Estimator: `${job.est_ct_ln ? job.est_ct_ln : ""}${
|
||||
job.est_ct_ln ? ", " : ""
|
||||
}${job.est_ct_fn ? job.est_ct_fn : ""}`,
|
||||
},
|
||||
Dates: {
|
||||
DateEstimated:
|
||||
(job.date_estimated &&
|
||||
moment(job.date_estimated).format(DateFormat)) ||
|
||||
"",
|
||||
DateOpened:
|
||||
(job.date_opened && moment(job.date_opened).format(DateFormat)) || "",
|
||||
DateScheduled:
|
||||
(job.scheduled_in &&
|
||||
moment(job.scheduled_in)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateArrived:
|
||||
(job.actual_in &&
|
||||
moment(job.actual_in)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateStart: job.date_repairstarted
|
||||
? (job.date_repairstarted &&
|
||||
moment(job.date_repairstarted)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
""
|
||||
: (job.actual_in &&
|
||||
moment(job.actual_in)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateScheduledCompletion:
|
||||
(job.scheduled_completion &&
|
||||
moment(job.scheduled_completion)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateCompleted:
|
||||
(job.actual_completion &&
|
||||
moment(job.actual_completion)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateScheduledDelivery:
|
||||
(job.scheduled_delivery &&
|
||||
moment(job.scheduled_delivery)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateDelivered:
|
||||
(job.actual_delivery &&
|
||||
moment(job.actual_delivery)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateInvoiced:
|
||||
(job.date_invoiced &&
|
||||
moment(job.date_invoiced)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
DateExported:
|
||||
(job.date_exported &&
|
||||
moment(job.date_exported)
|
||||
.tz(job.bodyshop.timezone)
|
||||
.format(DateFormat)) ||
|
||||
"",
|
||||
},
|
||||
Sales: {
|
||||
Labour: {
|
||||
Aluminum: Dinero(job.job_totals.rates.laa.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Body: Dinero(job.job_totals.rates.lab.total).toFormat(DineroFormat),
|
||||
Diagnostic: Dinero(job.job_totals.rates.lad.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Electrical: Dinero(job.job_totals.rates.lae.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Frame: Dinero(job.job_totals.rates.laf.total).toFormat(DineroFormat),
|
||||
Glass: Dinero(job.job_totals.rates.lag.total).toFormat(DineroFormat),
|
||||
Mechanical: Dinero(job.job_totals.rates.lam.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
OtherLabour: Dinero(job.job_totals.rates.la1.total)
|
||||
.add(Dinero(job.job_totals.rates.la2.total))
|
||||
.add(Dinero(job.job_totals.rates.la3.total))
|
||||
.add(Dinero(job.job_totals.rates.la4.total))
|
||||
.add(Dinero(job.job_totals.rates.lau.total))
|
||||
.toFormat(DineroFormat),
|
||||
Refinish: Dinero(job.job_totals.rates.lar.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Structural: Dinero(job.job_totals.rates.las.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
},
|
||||
Materials: {
|
||||
Body: Dinero(job.job_totals.rates.mash.total).toFormat(DineroFormat),
|
||||
Refinish: Dinero(job.job_totals.rates.mapa.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
},
|
||||
Parts: {
|
||||
Aftermarket: Dinero(
|
||||
job.job_totals.parts.parts.list.PAA &&
|
||||
job.job_totals.parts.parts.list.PAA.total
|
||||
).toFormat(DineroFormat),
|
||||
LKQ: Dinero(
|
||||
job.job_totals.parts.parts.list.PAL &&
|
||||
job.job_totals.parts.parts.list.PAL.total
|
||||
).toFormat(DineroFormat),
|
||||
OEM: Dinero(
|
||||
job.job_totals.parts.parts.list.PAN &&
|
||||
job.job_totals.parts.parts.list.PAN.total
|
||||
)
|
||||
.add(
|
||||
Dinero(
|
||||
job.job_totals.parts.parts.list.PAP &&
|
||||
job.job_totals.parts.parts.list.PAP.total
|
||||
)
|
||||
)
|
||||
.toFormat(DineroFormat),
|
||||
OtherParts: Dinero(
|
||||
job.job_totals.parts.parts.list.PAO &&
|
||||
job.job_totals.parts.parts.list.PAO.total
|
||||
).toFormat(DineroFormat),
|
||||
Reconditioned: Dinero(
|
||||
job.job_totals.parts.parts.list.PAM &&
|
||||
job.job_totals.parts.parts.list.PAM.total
|
||||
).toFormat(DineroFormat),
|
||||
TotalParts: Dinero(
|
||||
job.job_totals.parts.parts.list.PAA &&
|
||||
job.job_totals.parts.parts.list.PAA.total
|
||||
)
|
||||
.add(
|
||||
Dinero(
|
||||
job.job_totals.parts.parts.list.PAL &&
|
||||
job.job_totals.parts.parts.list.PAL.total
|
||||
)
|
||||
)
|
||||
.add(
|
||||
Dinero(
|
||||
job.job_totals.parts.parts.list.PAN &&
|
||||
job.job_totals.parts.parts.list.PAN.total
|
||||
)
|
||||
)
|
||||
.add(
|
||||
Dinero(
|
||||
job.job_totals.parts.parts.list.PAO &&
|
||||
job.job_totals.parts.parts.list.PAO.total
|
||||
)
|
||||
)
|
||||
.add(
|
||||
Dinero(
|
||||
job.job_totals.parts.parts.list.PAM &&
|
||||
job.job_totals.parts.parts.list.PAM.total
|
||||
)
|
||||
)
|
||||
.toFormat(DineroFormat),
|
||||
},
|
||||
OtherSales: Dinero(job.job_totals.additional.storage).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Sublet: Dinero(job.job_totals.parts.sublets.total).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Towing: Dinero(job.job_totals.additional.towing).toFormat(DineroFormat),
|
||||
ATS:
|
||||
job.job_totals.additional.additionalCostItems.includes(
|
||||
"ATS Amount"
|
||||
) === true
|
||||
? Dinero(
|
||||
job.job_totals.additional.additionalCostItems[
|
||||
job.job_totals.additional.additionalCostItems.indexOf(
|
||||
"ATS Amount"
|
||||
)
|
||||
].total
|
||||
).toFormat(DineroFormat)
|
||||
: Dinero().toFormat(DineroFormat),
|
||||
SaleSubtotal: Dinero(job.job_totals.totals.subtotal).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
Tax: Dinero(job.job_totals.totals.local_tax)
|
||||
.add(Dinero(job.job_totals.totals.state_tax))
|
||||
.add(Dinero(job.job_totals.totals.federal_tax))
|
||||
.add(Dinero(job.job_totals.additional.pvrt))
|
||||
.toFormat(DineroFormat),
|
||||
SaleTotal: Dinero(job.job_totals.totals.total_repairs).toFormat(
|
||||
DineroFormat
|
||||
),
|
||||
},
|
||||
SaleHours: {
|
||||
Aluminum: job.job_totals.rates.laa.hours.toFixed(2),
|
||||
Body: job.job_totals.rates.lab.hours.toFixed(2),
|
||||
Diagnostic: job.job_totals.rates.lad.hours.toFixed(2),
|
||||
Electrical: job.job_totals.rates.lae.hours.toFixed(2),
|
||||
Frame: job.job_totals.rates.laf.hours.toFixed(2),
|
||||
Glass: job.job_totals.rates.lag.hours.toFixed(2),
|
||||
Mechanical: job.job_totals.rates.lam.hours.toFixed(2),
|
||||
Other: (
|
||||
job.job_totals.rates.la1.hours +
|
||||
job.job_totals.rates.la2.hours +
|
||||
job.job_totals.rates.la3.hours +
|
||||
job.job_totals.rates.la4.hours +
|
||||
job.job_totals.rates.lau.hours
|
||||
).toFixed(2),
|
||||
Refinish: job.job_totals.rates.lar.hours.toFixed(2),
|
||||
Structural: job.job_totals.rates.las.hours.toFixed(2),
|
||||
TotalHours: job.joblines
|
||||
.reduce((acc, val) => acc + val.mod_lb_hrs, 0)
|
||||
.toFixed(2),
|
||||
},
|
||||
Costs: {
|
||||
Labour: {
|
||||
Aluminum: repairCosts.AluminumLabourTotalCost.toFormat(DineroFormat),
|
||||
Body: repairCosts.BodyLabourTotalCost.toFormat(DineroFormat),
|
||||
Diagnostic:
|
||||
repairCosts.DiagnosticLabourTotalCost.toFormat(DineroFormat),
|
||||
Electrical:
|
||||
repairCosts.ElectricalLabourTotalCost.toFormat(DineroFormat),
|
||||
Frame: repairCosts.FrameLabourTotalCost.toFormat(DineroFormat),
|
||||
Glass: repairCosts.GlassLabourTotalCost.toFormat(DineroFormat),
|
||||
Mechancial:
|
||||
repairCosts.MechanicalLabourTotalCost.toFormat(DineroFormat),
|
||||
OtherLabour: repairCosts.LabourMiscTotalCost.toFormat(DineroFormat),
|
||||
Refinish: repairCosts.RefinishLabourTotalCost.toFormat(DineroFormat),
|
||||
Structural:
|
||||
repairCosts.StructuralLabourTotalCost.toFormat(DineroFormat),
|
||||
TotalLabour: repairCosts.LabourTotalCost.toFormat(DineroFormat),
|
||||
},
|
||||
Materials: {
|
||||
Body: repairCosts.BMTotalCost.toFormat(DineroFormat),
|
||||
Refinish: repairCosts.PMTotalCost.toFormat(DineroFormat),
|
||||
},
|
||||
Parts: {
|
||||
Aftermarket: repairCosts.PartsAMCost.toFormat(DineroFormat),
|
||||
LKQ: repairCosts.PartsRecycledCost.toFormat(DineroFormat),
|
||||
OEM: repairCosts.PartsOemCost.toFormat(DineroFormat),
|
||||
OtherCost: repairCosts.PartsOtherCost.toFormat(DineroFormat),
|
||||
Reconditioned:
|
||||
repairCosts.PartsReconditionedCost.toFormat(DineroFormat),
|
||||
TotalParts: repairCosts.PartsAMCost.add(repairCosts.PartsRecycledCost)
|
||||
.add(repairCosts.PartsReconditionedCost)
|
||||
.add(repairCosts.PartsOemCost)
|
||||
.add(repairCosts.PartsOtherCost)
|
||||
.toFormat(DineroFormat),
|
||||
},
|
||||
Sublet: repairCosts.SubletTotalCost.toFormat(DineroFormat),
|
||||
Towing: repairCosts.TowingTotalCost.toFormat(DineroFormat),
|
||||
ATS: Dinero().toFormat(DineroFormat),
|
||||
Storage: repairCosts.StorageTotalCost.toFormat(DineroFormat),
|
||||
CostTotal: repairCosts.TotalCost.toFormat(DineroFormat),
|
||||
},
|
||||
CostHours: {
|
||||
Aluminum: repairCosts.AluminumLabourTotalHrs.toFixed(2),
|
||||
Body: repairCosts.BodyLabourTotalHrs.toFixed(2),
|
||||
Diagnostic: repairCosts.DiagnosticLabourTotalHrs.toFixed(2),
|
||||
Refinish: repairCosts.RefinishLabourTotalHrs.toFixed(2),
|
||||
Frame: repairCosts.FrameLabourTotalHrs.toFixed(2),
|
||||
Mechanical: repairCosts.MechanicalLabourTotalHrs.toFixed(2),
|
||||
Glass: repairCosts.GlassLabourTotalHrs.toFixed(2),
|
||||
Electrical: repairCosts.ElectricalLabourTotalHrs.toFixed(2),
|
||||
Structural: repairCosts.StructuralLabourTotalHrs.toFixed(2),
|
||||
Other: repairCosts.LabourMiscTotalHrs.toFixed(2),
|
||||
CostTotalHours: repairCosts.TotalHrs.toFixed(2),
|
||||
},
|
||||
};
|
||||
return ret;
|
||||
} catch (error) {
|
||||
logger.log("kaizen-job-calculate-error", "ERROR", "api", null, {
|
||||
error,
|
||||
});
|
||||
|
||||
errorCallback({ jobid: job.id, ro_number: job.ro_number, error });
|
||||
}
|
||||
};
|
||||
|
||||
const CreateCosts = (job) => {
|
||||
//Create a mapping based on AH Requirements
|
||||
|
||||
//For DMS, the keys in the object below are the CIECA part types.
|
||||
const billTotalsByCostCenters = job.bills.reduce((bill_acc, bill_val) => {
|
||||
//At the bill level.
|
||||
bill_val.billlines.map((line_val) => {
|
||||
//At the bill line level.
|
||||
|
||||
if (!bill_acc[line_val.cost_center])
|
||||
bill_acc[line_val.cost_center] = Dinero();
|
||||
|
||||
bill_acc[line_val.cost_center] = bill_acc[line_val.cost_center].add(
|
||||
Dinero({
|
||||
amount: Math.round((line_val.actual_cost || 0) * 100),
|
||||
})
|
||||
.multiply(line_val.quantity)
|
||||
.multiply(bill_val.is_credit_memo ? -1 : 1)
|
||||
);
|
||||
|
||||
return null;
|
||||
});
|
||||
return bill_acc;
|
||||
}, {});
|
||||
|
||||
//If the hourly rates for job costing are set, add them in.
|
||||
if (
|
||||
job.bodyshop.jc_hourly_rates &&
|
||||
(job.bodyshop.jc_hourly_rates.mapa ||
|
||||
typeof job.bodyshop.jc_hourly_rates.mapa === "number" ||
|
||||
isNaN(job.bodyshop.jc_hourly_rates.mapa) === false)
|
||||
) {
|
||||
if (
|
||||
!billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
]
|
||||
)
|
||||
billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
] = Dinero();
|
||||
if (job.bodyshop.use_paint_scale_data === true) {
|
||||
if (job.mixdata.length > 0) {
|
||||
billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
] = Dinero({
|
||||
amount: Math.round(
|
||||
((job.mixdata[0] && job.mixdata[0].totalliquidcost) || 0) * 100
|
||||
),
|
||||
});
|
||||
} else {
|
||||
billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
] = billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
].add(
|
||||
Dinero({
|
||||
amount: Math.round(
|
||||
(job.bodyshop.jc_hourly_rates &&
|
||||
job.bodyshop.jc_hourly_rates.mapa * 100) ||
|
||||
0
|
||||
),
|
||||
}).multiply(job.job_totals.rates.mapa.hours)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
] = billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MAPA
|
||||
].add(
|
||||
Dinero({
|
||||
amount: Math.round(
|
||||
(job.bodyshop.jc_hourly_rates &&
|
||||
job.bodyshop.jc_hourly_rates.mapa * 100) ||
|
||||
0
|
||||
),
|
||||
}).multiply(job.job_totals.rates.mapa.hours)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (job.bodyshop.jc_hourly_rates && job.bodyshop.jc_hourly_rates.mash) {
|
||||
if (
|
||||
!billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MASH
|
||||
]
|
||||
)
|
||||
billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MASH
|
||||
] = Dinero();
|
||||
billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MASH
|
||||
] = billTotalsByCostCenters[
|
||||
job.bodyshop.md_responsibility_centers.defaults.costs.MASH
|
||||
].add(
|
||||
Dinero({
|
||||
amount: Math.round(
|
||||
(job.bodyshop.jc_hourly_rates &&
|
||||
job.bodyshop.jc_hourly_rates.mash * 100) ||
|
||||
0
|
||||
),
|
||||
}).multiply(job.job_totals.rates.mash.hours)
|
||||
);
|
||||
}
|
||||
//Uses CIECA Labour types.
|
||||
const ticketTotalsByCostCenter = job.timetickets.reduce(
|
||||
(ticket_acc, ticket_val) => {
|
||||
//At the invoice level.
|
||||
if (!ticket_acc[ticket_val.cost_center])
|
||||
ticket_acc[ticket_val.cost_center] = Dinero();
|
||||
|
||||
ticket_acc[ticket_val.cost_center] = ticket_acc[
|
||||
ticket_val.cost_center
|
||||
].add(
|
||||
Dinero({
|
||||
amount: Math.round((ticket_val.rate || 0) * 100),
|
||||
}).multiply(
|
||||
(ticket_val.flat_rate
|
||||
? ticket_val.productivehrs
|
||||
: ticket_val.actualhrs) || 0
|
||||
)
|
||||
);
|
||||
|
||||
return ticket_acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
const ticketHrsByCostCenter = job.timetickets.reduce(
|
||||
(ticket_acc, ticket_val) => {
|
||||
//At the invoice level.
|
||||
if (!ticket_acc[ticket_val.cost_center])
|
||||
ticket_acc[ticket_val.cost_center] = 0;
|
||||
|
||||
ticket_acc[ticket_val.cost_center] =
|
||||
ticket_acc[ticket_val.cost_center] +
|
||||
(ticket_val.flat_rate
|
||||
? ticket_val.productivehrs
|
||||
: ticket_val.actualhrs) || 0;
|
||||
|
||||
return ticket_acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
//CIECA STANDARD MAPPING OBJECT.
|
||||
|
||||
const ciecaObj = {
|
||||
ATS: "ATS",
|
||||
LA1: "LA1",
|
||||
LA2: "LA2",
|
||||
LA3: "LA3",
|
||||
LA4: "LA4",
|
||||
LAA: "LAA",
|
||||
LAB: "LAB",
|
||||
LAD: "LAD",
|
||||
LAE: "LAE",
|
||||
LAF: "LAF",
|
||||
LAG: "LAG",
|
||||
LAM: "LAM",
|
||||
LAR: "LAR",
|
||||
LAS: "LAS",
|
||||
LAU: "LAU",
|
||||
PAA: "PAA",
|
||||
PAC: "PAC",
|
||||
PAG: "PAG",
|
||||
PAL: "PAL",
|
||||
PAM: "PAM",
|
||||
PAN: "PAN",
|
||||
PAO: "PAO",
|
||||
PAP: "PAP",
|
||||
PAR: "PAR",
|
||||
PAS: "PAS",
|
||||
TOW: "TOW",
|
||||
MAPA: "MAPA",
|
||||
MASH: "MASH",
|
||||
PASL: "PASL",
|
||||
};
|
||||
const defaultCosts =
|
||||
job.bodyshop.cdk_dealerid || job.bodyshop.pbs_serialnumber
|
||||
? ciecaObj
|
||||
: job.bodyshop.md_responsibility_centers.defaults.costs;
|
||||
|
||||
return {
|
||||
PartsTotalCost: Object.keys(billTotalsByCostCenters).reduce((acc, key) => {
|
||||
if (
|
||||
key !== defaultCosts.PAS &&
|
||||
key !== defaultCosts.PASL &&
|
||||
key !== defaultCosts.MAPA &&
|
||||
key !== defaultCosts.MASH &&
|
||||
key !== defaultCosts.TOW
|
||||
)
|
||||
return acc.add(billTotalsByCostCenters[key]);
|
||||
return acc;
|
||||
}, Dinero()),
|
||||
PartsOemCost: (billTotalsByCostCenters[defaultCosts.PAN] || Dinero()).add(
|
||||
billTotalsByCostCenters[defaultCosts.PAP] || Dinero()
|
||||
),
|
||||
PartsAMCost: billTotalsByCostCenters[defaultCosts.PAA] || Dinero(),
|
||||
PartsReconditionedCost:
|
||||
billTotalsByCostCenters[defaultCosts.PAM] || Dinero(),
|
||||
PartsRecycledCost: billTotalsByCostCenters[defaultCosts.PAL] || Dinero(),
|
||||
PartsOtherCost: billTotalsByCostCenters[defaultCosts.PAO] || Dinero(),
|
||||
|
||||
SubletTotalCost:
|
||||
billTotalsByCostCenters[defaultCosts.PAS] ||
|
||||
Dinero(billTotalsByCostCenters[defaultCosts.PASL] || Dinero()),
|
||||
|
||||
AluminumLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAA] || Dinero(),
|
||||
AluminumLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAA] || 0,
|
||||
BodyLabourTotalCost: ticketTotalsByCostCenter[defaultCosts.LAB] || Dinero(),
|
||||
BodyLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAB] || 0,
|
||||
DiagnosticLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAD] || Dinero(),
|
||||
DiagnosticLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAD] || 0,
|
||||
ElectricalLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAE] || Dinero(),
|
||||
ElectricalLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAE] || 0,
|
||||
FrameLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAF] || Dinero(),
|
||||
FrameLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAF] || 0,
|
||||
GlassLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAG] || Dinero(),
|
||||
GlassLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAG] || 0,
|
||||
LabourMiscTotalCost: (
|
||||
ticketTotalsByCostCenter[defaultCosts.LA1] || Dinero()
|
||||
)
|
||||
.add(ticketTotalsByCostCenter[defaultCosts.LA2] || Dinero())
|
||||
.add(ticketTotalsByCostCenter[defaultCosts.LA2] || Dinero())
|
||||
.add(ticketTotalsByCostCenter[defaultCosts.LA3] || Dinero())
|
||||
.add(ticketTotalsByCostCenter[defaultCosts.LA4] || Dinero())
|
||||
.add(ticketTotalsByCostCenter[defaultCosts.LAU] || Dinero()),
|
||||
LabourMiscTotalHrs:
|
||||
(ticketHrsByCostCenter[defaultCosts.LA1] || 0) +
|
||||
(ticketHrsByCostCenter[defaultCosts.LA2] || 0) +
|
||||
(ticketHrsByCostCenter[defaultCosts.LA3] || 0) +
|
||||
(ticketHrsByCostCenter[defaultCosts.LA4] || 0) +
|
||||
(ticketHrsByCostCenter[defaultCosts.LAU] || 0),
|
||||
MechanicalLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAM] || Dinero(),
|
||||
MechanicalLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAM] || 0,
|
||||
RefinishLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAR] || Dinero(),
|
||||
RefinishLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAR] || 0,
|
||||
StructuralLabourTotalCost:
|
||||
ticketTotalsByCostCenter[defaultCosts.LAS] || Dinero(),
|
||||
StructuralLabourTotalHrs: ticketHrsByCostCenter[defaultCosts.LAS] || 0,
|
||||
|
||||
PMTotalCost: billTotalsByCostCenters[defaultCosts.MAPA] || Dinero(),
|
||||
BMTotalCost: billTotalsByCostCenters[defaultCosts.MASH] || Dinero(),
|
||||
|
||||
MiscTotalCost: billTotalsByCostCenters[defaultCosts.PAO] || Dinero(),
|
||||
TowingTotalCost: billTotalsByCostCenters[defaultCosts.TOW] || Dinero(),
|
||||
StorageTotalCost: Dinero(),
|
||||
DetailTotal: Dinero(),
|
||||
DetailTotalCost: Dinero(),
|
||||
|
||||
SalesTaxTotalCost: Dinero(),
|
||||
LabourTotalCost: Object.keys(ticketTotalsByCostCenter).reduce(
|
||||
(acc, key) => {
|
||||
return acc.add(ticketTotalsByCostCenter[key]);
|
||||
},
|
||||
Dinero()
|
||||
),
|
||||
TotalCost: Object.keys(billTotalsByCostCenters).reduce((acc, key) => {
|
||||
return acc.add(billTotalsByCostCenters[key]);
|
||||
}, Dinero()),
|
||||
TotalHrs: job.timetickets.reduce((acc, ticket_val) => {
|
||||
return (
|
||||
acc +
|
||||
(ticket_val.flat_rate
|
||||
? ticket_val.productivehrs
|
||||
: ticket_val.actualhrs) || 0
|
||||
);
|
||||
}, 0),
|
||||
};
|
||||
};
|
||||
@@ -1070,6 +1070,183 @@ query ENTEGRAL_EXPORT($bodyshopid: uuid!) {
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.KAIZEN_QUERY = `query KAIZEN_EXPORT($start: timestamptz, $bodyshopid: uuid!, $end: timestamptz) {
|
||||
bodyshops_by_pk(id: $bodyshopid){
|
||||
id
|
||||
shopname
|
||||
address1
|
||||
city
|
||||
state
|
||||
zip_post
|
||||
country
|
||||
phone
|
||||
last_name_first
|
||||
md_ro_statuses
|
||||
md_order_statuses
|
||||
md_responsibility_centers
|
||||
jc_hourly_rates
|
||||
cdk_dealerid
|
||||
pbs_serialnumber
|
||||
use_paint_scale_data
|
||||
timezone
|
||||
}
|
||||
jobs(where: {_and: [{updated_at: {_gt: $start}}, {updated_at: {_lte: $end}}, {shopid: {_eq: $bodyshopid}}]}) {
|
||||
actual_completion
|
||||
actual_delivery
|
||||
actual_in
|
||||
asgn_date
|
||||
bills {
|
||||
billlines {
|
||||
actual_cost
|
||||
cost_center
|
||||
id
|
||||
quantity
|
||||
}
|
||||
federal_tax_rate
|
||||
id
|
||||
is_credit_memo
|
||||
local_tax_rate
|
||||
state_tax_rate
|
||||
}
|
||||
created_at
|
||||
clm_no
|
||||
date_estimated
|
||||
date_exported
|
||||
date_invoiced
|
||||
date_open
|
||||
date_repairstarted
|
||||
employee_body_rel {
|
||||
first_name
|
||||
last_name
|
||||
employee_number
|
||||
id
|
||||
}
|
||||
employee_csr_rel {
|
||||
first_name
|
||||
last_name
|
||||
employee_number
|
||||
id
|
||||
}
|
||||
employee_prep_rel {
|
||||
first_name
|
||||
last_name
|
||||
employee_number
|
||||
id
|
||||
}
|
||||
employee_refinish_rel {
|
||||
first_name
|
||||
last_name
|
||||
employee_number
|
||||
id
|
||||
}
|
||||
est_ct_fn
|
||||
est_ct_ln
|
||||
id
|
||||
ins_co_nm
|
||||
joblines(where: {removed: {_eq: false}}) {
|
||||
act_price
|
||||
billlines(order_by: {bill: {date: desc_nulls_last}} limit: 1) {
|
||||
actual_cost
|
||||
actual_price
|
||||
quantity
|
||||
bill {
|
||||
vendor {
|
||||
name
|
||||
}
|
||||
invoice_number
|
||||
date
|
||||
}
|
||||
}
|
||||
db_price
|
||||
id
|
||||
lbr_op
|
||||
line_desc
|
||||
line_ind
|
||||
line_no
|
||||
mod_lb_hrs
|
||||
mod_lbr_ty
|
||||
parts_order_lines(order_by: {parts_order: {order_date: desc_nulls_last}} limit: 1){
|
||||
parts_order{
|
||||
id
|
||||
order_date
|
||||
}
|
||||
}
|
||||
part_qty
|
||||
part_type
|
||||
profitcenter_part
|
||||
profitcenter_labor
|
||||
prt_dsmk_m
|
||||
prt_dsmk_p
|
||||
oem_partno
|
||||
status
|
||||
}
|
||||
job_totals
|
||||
loss_date
|
||||
mixdata(limit: 1, order_by: {updated_at: desc}) {
|
||||
jobid
|
||||
totalliquidcost
|
||||
}
|
||||
ownr_addr1
|
||||
ownr_addr2
|
||||
ownr_city
|
||||
ownr_co_nm
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownr_st
|
||||
ownr_zip
|
||||
parts_orders(limit: 1, order_by: {created_at: desc}) {
|
||||
created_at
|
||||
}
|
||||
parts_tax_rates
|
||||
plate_no
|
||||
rate_la1
|
||||
rate_la2
|
||||
rate_la3
|
||||
rate_la4
|
||||
rate_laa
|
||||
rate_lab
|
||||
rate_lad
|
||||
rate_lae
|
||||
rate_laf
|
||||
rate_lag
|
||||
rate_lam
|
||||
rate_lar
|
||||
rate_las
|
||||
rate_lau
|
||||
rate_ma2s
|
||||
rate_ma2t
|
||||
rate_ma3s
|
||||
rate_mabl
|
||||
rate_macs
|
||||
rate_mahw
|
||||
rate_matd
|
||||
rate_mapa
|
||||
rate_mash
|
||||
ro_number
|
||||
scheduled_completion
|
||||
scheduled_delivery
|
||||
scheduled_in
|
||||
status
|
||||
timetickets {
|
||||
id
|
||||
rate
|
||||
cost_center
|
||||
actualhrs
|
||||
productivehrs
|
||||
flat_rate
|
||||
}
|
||||
tlos_ind
|
||||
v_color
|
||||
v_model_yr
|
||||
v_model_desc
|
||||
v_make_desc
|
||||
v_vin
|
||||
vehicle {
|
||||
v_bstyle
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.UPDATE_JOB = `
|
||||
mutation UPDATE_JOB($jobId: uuid!, $job: jobs_set_input!) {
|
||||
update_jobs(where: { id: { _eq: $jobId } }, _set: $job) {
|
||||
@@ -1542,7 +1719,7 @@ exports.GET_CLAIMSCORP_SHOPS = `query GET_CLAIMSCORP_SHOPS {
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.GET_ENTEGRAL_SHOPS = `query GET_AUTOHOUSE_SHOPS {
|
||||
exports.GET_ENTEGRAL_SHOPS = `query GET_ENTEGRAL_SHOPS {
|
||||
bodyshops(where: {entegral_id: {_is_null: false}, _or: {entegral_id: {_neq: ""}}}){
|
||||
id
|
||||
shopname
|
||||
@@ -1562,6 +1739,26 @@ exports.GET_ENTEGRAL_SHOPS = `query GET_AUTOHOUSE_SHOPS {
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.GET_KAIZEN_SHOPS = `query GET_KAIZEN_SHOPS($imexshopid: [String]) {
|
||||
bodyshops(where: {imexshopid: {_in: $imexshopid}}){
|
||||
id
|
||||
shopname
|
||||
address1
|
||||
city
|
||||
state
|
||||
zip_post
|
||||
country
|
||||
phone
|
||||
md_ro_statuses
|
||||
md_order_statuses
|
||||
autohouseid
|
||||
md_responsibility_centers
|
||||
jc_hourly_rates
|
||||
imexshopid
|
||||
timezone
|
||||
}
|
||||
}`;
|
||||
|
||||
exports.DELETE_ALL_DMS_VEHICLES = `mutation DELETE_ALL_DMS_VEHICLES{
|
||||
delete_dms_vehicles(where: {}) {
|
||||
affected_rows
|
||||
|
||||
@@ -132,6 +132,7 @@ exports.payment_refund = async (req, res) => {
|
||||
exports.generate_payment_url = async (req, res) => {
|
||||
logger.log("intellipay-payment-url", "DEBUG", req.user?.email, null, null);
|
||||
const shopCredentials = await getShopCredentials(req.body.bodyshop);
|
||||
|
||||
try {
|
||||
const options = {
|
||||
method: "POST",
|
||||
@@ -139,7 +140,12 @@ exports.generate_payment_url = async (req, res) => {
|
||||
//TODO: Move these to environment variables/database.
|
||||
data: qs.stringify({
|
||||
...shopCredentials,
|
||||
...req.body,
|
||||
//...req.body,
|
||||
amount: Dinero({ amount: Math.round(req.body.amount * 100) }).toFormat(
|
||||
"0.00"
|
||||
),
|
||||
account: req.body.account,
|
||||
invoice: req.body.invoice,
|
||||
createshorturl: true,
|
||||
//The postback URL is set at the CP teller global terminal settings page.
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user