From a5aee28d420bd23d03e72af30814db4e1e1d92e4 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 2 Dec 2021 15:51:21 -0800 Subject: [PATCH 1/3] IO-233 CDK Updates. --- .../dms-cdk-makes/dms-cdk-makes.component.jsx | 4 +- .../dms-cdk-makes.refetch.component.jsx | 12 +++- .../dms-post-form/dms-post-form.component.jsx | 57 ++++++++++--------- .../parts-order-modal.component.jsx | 28 ++++++++- client/src/pages/dms/dms.container.jsx | 4 +- 5 files changed, 68 insertions(+), 37 deletions(-) diff --git a/client/src/components/dms-cdk-makes/dms-cdk-makes.component.jsx b/client/src/components/dms-cdk-makes/dms-cdk-makes.component.jsx index 06201284b..262d1720c 100644 --- a/client/src/components/dms-cdk-makes/dms-cdk-makes.component.jsx +++ b/client/src/components/dms-cdk-makes/dms-cdk-makes.component.jsx @@ -48,7 +48,7 @@ export function DmsCdkVehicles({ bodyshop, form, socket, job }) { ]; return ( -
+ <> {t("jobs.actions.dms.findmakemodelcode")} -
+ ); } diff --git a/client/src/components/dms-cdk-makes/dms-cdk-makes.refetch.component.jsx b/client/src/components/dms-cdk-makes/dms-cdk-makes.refetch.component.jsx index f24153a4d..f0d9ba970 100644 --- a/client/src/components/dms-cdk-makes/dms-cdk-makes.refetch.component.jsx +++ b/client/src/components/dms-cdk-makes/dms-cdk-makes.refetch.component.jsx @@ -4,9 +4,12 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; +import { + selectBodyshop, + selectCurrentUser, +} from "../../redux/user/user.selectors"; const mapStateToProps = createStructuredSelector({ - //currentUser: selectCurrentUser + currentUser: selectCurrentUser, bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ @@ -14,9 +17,12 @@ const mapDispatchToProps = (dispatch) => ({ }); export default connect(mapStateToProps, mapDispatchToProps)(DmsCdkMakesRefetch); -export function DmsCdkMakesRefetch({ bodyshop, form, socket }) { +export function DmsCdkMakesRefetch({ currentUser, bodyshop, form, socket }) { const [loading, setLoading] = useState(false); const { t } = useTranslation(); + + if (!currentUser.email.includes("@imex.")) return null; + const handleRefetch = async () => { setLoading(true); await axios.post("/cdk/getvehicles", { diff --git a/client/src/components/dms-post-form/dms-post-form.component.jsx b/client/src/components/dms-post-form/dms-post-form.component.jsx index ff7057606..911040cb2 100644 --- a/client/src/components/dms-post-form/dms-post-form.component.jsx +++ b/client/src/components/dms-post-form/dms-post-form.component.jsx @@ -122,33 +122,36 @@ export function DmsPostForm({ bodyshop, socket, job }) { {bodyshop.cdk_dealerid && ( - - - - - - - - - - - +
+ + + + + + + + + + + + +
)} ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(PartsOrderModalComponent); + +export function PartsOrderModalComponent({ + bodyshop, vendorList, sendTypeState, isReturn, @@ -16,7 +32,11 @@ export default function PartsOrderModalComponent({ job, }) { const [sendType, setSendType] = sendTypeState; - + const { OEConnection } = useTreatments( + ["OEConnection"], + {}, + bodyshop.imexshopid + ); const { t } = useTranslation(); return ( @@ -164,7 +184,9 @@ export default function PartsOrderModalComponent({ {t("general.labels.none")} {t("parts_orders.labels.email")} {t("parts_orders.labels.print")} - {t("parts_orders.labels.oec")} + {OEConnection.treatment === "on" && ( + {t("parts_orders.labels.oec")} + )} ); diff --git a/client/src/pages/dms/dms.container.jsx b/client/src/pages/dms/dms.container.jsx index 223c4e231..ac95b4b58 100644 --- a/client/src/pages/dms/dms.container.jsx +++ b/client/src/pages/dms/dms.container.jsx @@ -130,7 +130,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { return (
- + - + Date: Fri, 3 Dec 2021 09:13:24 -0800 Subject: [PATCH 2/3] IO-233 Add GST override for CDK. --- bodyshop_translations.babel | 47 +++++++++++++++++++ .../parts-order-modal.component.jsx | 8 ++-- ...p-info.responsibilitycenters.component.jsx | 8 ++++ client/src/graphql/jobs.queries.js | 1 + client/src/pages/dms/dms.container.jsx | 5 +- client/src/translations/en_us/common.json | 4 ++ client/src/translations/es/common.json | 4 ++ client/src/translations/fr/common.json | 4 ++ server/cdk/cdk-calculate-allocations.js | 24 +++++++--- server/cdk/cdk-job-export.js | 2 +- 10 files changed, 94 insertions(+), 13 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 6556d2dc7..61610950f 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -6092,6 +6092,27 @@ + + gst_override + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + la1 false @@ -12170,6 +12191,32 @@ dms + + errors + + + alreadyexported + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + labels diff --git a/client/src/components/parts-order-modal/parts-order-modal.component.jsx b/client/src/components/parts-order-modal/parts-order-modal.component.jsx index 917b853cd..cd79fe81f 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.component.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.component.jsx @@ -1,17 +1,17 @@ import { DeleteFilled, WarningFilled } from "@ant-design/icons"; -import { useTreatments, useClient } from "@splitsoftware/splitio-react"; +import { useTreatments } from "@splitsoftware/splitio-react"; import { Divider, Form, Input, InputNumber, Radio, Space, Tag } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, }); diff --git a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx index c24a12939..e5543bcba 100644 --- a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx +++ b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx @@ -550,6 +550,14 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { > + + + { remove(field.name); diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 6729a1138..cad9a6a1f 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -1919,6 +1919,7 @@ export const QUERY_JOB_EXPORT_DMS = gql` v_model_yr v_model_desc area_of_damage + date_exported } } `; diff --git a/client/src/pages/dms/dms.container.jsx b/client/src/pages/dms/dms.container.jsx index ac95b4b58..98493b605 100644 --- a/client/src/pages/dms/dms.container.jsx +++ b/client/src/pages/dms/dms.container.jsx @@ -125,7 +125,10 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { !(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) || !(data && data.jobs_by_pk) ) - return ; + return ; + + if (data.jobs_by_pk && data.jobs_by_pk.date_exported) + return ; return (
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 51497bf15..a290fe4e7 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -394,6 +394,7 @@ "ar": "Accounts Receivable", "ats": "ATS", "federal_tax": "Federal Tax", + "gst_override": "GST Override Account #", "la1": "LA1", "la2": "LA2", "la3": "LA3", @@ -761,6 +762,9 @@ } }, "dms": { + "errors": { + "alreadyexported": "This job has already been sent to the DMS. If you need to resend it, please use admin permissions to mark the job for re-export." + }, "labels": { "refreshallocations": "Refresh to see DMS Allocataions." } diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index bd1524e12..55aada7d9 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -394,6 +394,7 @@ "ar": "", "ats": "", "federal_tax": "", + "gst_override": "", "la1": "", "la2": "", "la3": "", @@ -761,6 +762,9 @@ } }, "dms": { + "errors": { + "alreadyexported": "" + }, "labels": { "refreshallocations": "" } diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 86d79c2d0..5f17415dc 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -394,6 +394,7 @@ "ar": "", "ats": "", "federal_tax": "", + "gst_override": "", "la1": "", "la2": "", "la3": "", @@ -761,6 +762,9 @@ } }, "dms": { + "errors": { + "alreadyexported": "" + }, "labels": { "refreshallocations": "" } diff --git a/server/cdk/cdk-calculate-allocations.js b/server/cdk/cdk-calculate-allocations.js index f7db405b8..0b7d84912 100644 --- a/server/cdk/cdk-calculate-allocations.js +++ b/server/cdk/cdk-calculate-allocations.js @@ -213,8 +213,7 @@ exports.default = async function (socket, jobid) { } if (job.towing_payable && job.towing_payable !== 0) { - const towAccountName = - selectedDmsAllocationConfig.profits.TOW; + const towAccountName = selectedDmsAllocationConfig.profits.TOW; const towAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === towAccountName @@ -234,8 +233,7 @@ exports.default = async function (socket, jobid) { } } if (job.storage_payable && job.storage_payable !== 0) { - const storageAccountName = - selectedDmsAllocationConfig.profits.TOW; + const storageAccountName = selectedDmsAllocationConfig.profits.TOW; const towAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === storageAccountName @@ -258,8 +256,7 @@ exports.default = async function (socket, jobid) { } if (job.adjustment_bottom_line && job.adjustment_bottom_line !== 0) { - const otherAccountName = - selectedDmsAllocationConfig.profits.PAO; + const otherAccountName = selectedDmsAllocationConfig.profits.PAO; const otherAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === otherAccountName @@ -310,7 +307,20 @@ exports.default = async function (socket, jobid) { taxAllocations[key].cost.getAmount() > 0 ) .map((key) => { - return { ...taxAllocations[key], tax: key }; + if ( + key === "federal" && + selectedDmsAllocationConfig.gst_override && + selectedDmsAllocationConfig.gst_override !== "" + ) { + const ret = { ...taxAllocations[key], tax: key }; + ret.costCenter.dms_acctnumber = + selectedDmsAllocationConfig.gst_override; + ret.profitCenter.dms_acctnumber = + selectedDmsAllocationConfig.gst_override; + return ret; + } else { + return { ...taxAllocations[key], tax: key }; + } }), ]; } catch (error) { diff --git a/server/cdk/cdk-job-export.js b/server/cdk/cdk-job-export.js index 96c7335b9..14e39a3c1 100644 --- a/server/cdk/cdk-job-export.js +++ b/server/cdk/cdk-job-export.js @@ -784,7 +784,7 @@ async function UpdateDmsVehicle(socket) { return { id: { assigningPartyId: - o.id.value === socket.dmsCust.id.value ? "CURRENT" : "PREVIOUS", + o.id.value === socket.DMSCust.id.value ? "CURRENT" : "PREVIOUS", value: o.id.value, }, }; From 48fd2b1461a9cad12e1857ba0c98a9ee34efdc69 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 3 Dec 2021 09:32:47 -0800 Subject: [PATCH 3/3] IO-233 Minor CDK UI Updates. --- .../dms-customer-selector.component.jsx | 2 - .../dms-post-form/dms-post-form.component.jsx | 14 +++- client/src/pages/dms/dms.container.jsx | 82 ++++++++++--------- 3 files changed, 54 insertions(+), 44 deletions(-) diff --git a/client/src/components/dms-customer-selector/dms-customer-selector.component.jsx b/client/src/components/dms-customer-selector/dms-customer-selector.component.jsx index 992a67240..a8baa4b0b 100644 --- a/client/src/components/dms-customer-selector/dms-customer-selector.component.jsx +++ b/client/src/components/dms-customer-selector/dms-customer-selector.component.jsx @@ -34,7 +34,6 @@ export function DmsCustomerSelector({ bodyshop }) { setVisible(true); setDmsType("pbs"); setcustomerList(customerList); - }); const onUseSelected = () => { @@ -118,7 +117,6 @@ export function DmsCustomerSelector({ bodyshop }) { if (!visible) return null; return ( - {dmsType} (
diff --git a/client/src/components/dms-post-form/dms-post-form.component.jsx b/client/src/components/dms-post-form/dms-post-form.component.jsx index 911040cb2..44b1f86fb 100644 --- a/client/src/components/dms-post-form/dms-post-form.component.jsx +++ b/client/src/components/dms-post-form/dms-post-form.component.jsx @@ -7,10 +7,10 @@ import { Form, Input, InputNumber, + Menu, Select, Space, Statistic, - Menu, Typography, } from "antd"; import Dinero from "dinero.js"; @@ -21,9 +21,9 @@ import { createStructuredSelector } from "reselect"; import { determineDmsType } from "../../pages/dms/dms.container"; import { selectBodyshop } from "../../redux/user/user.selectors"; import DmsCdkMakes from "../dms-cdk-makes/dms-cdk-makes.component"; +import DmsCdkMakesRefetch from "../dms-cdk-makes/dms-cdk-makes.refetch.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; -import DmsCdkMakesRefetch from "../dms-cdk-makes/dms-cdk-makes.refetch.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -33,7 +33,7 @@ const mapDispatchToProps = (dispatch) => ({ }); export default connect(mapStateToProps, mapDispatchToProps)(DmsPostForm); -export function DmsPostForm({ bodyshop, socket, job }) { +export function DmsPostForm({ bodyshop, socket, job, logsRef }) { const [form] = Form.useForm(); const { t } = useTranslation(); @@ -61,6 +61,14 @@ export function DmsPostForm({ bodyshop, socket, job }) { jobid: job.id, txEnvelope: values, }); + console.log(logsRef); + if (logsRef) { + console.log("executing", logsRef); + logsRef.curent && + logsRef.current.scrollIntoView({ + behavior: "smooth", + }); + } }; return ( diff --git a/client/src/pages/dms/dms.container.jsx b/client/src/pages/dms/dms.container.jsx index 98493b605..5fc7f1166 100644 --- a/client/src/pages/dms/dms.container.jsx +++ b/client/src/pages/dms/dms.container.jsx @@ -7,13 +7,13 @@ import { Result, Row, Select, - Space, + Space } from "antd"; import queryString from "query-string"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; -import { useLocation, useHistory } from "react-router-dom"; +import { useHistory, useLocation } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import SocketIO from "socket.io-client"; import AlertComponent from "../../components/alert/alert.component"; @@ -26,7 +26,7 @@ import { auth } from "../../firebase/firebase.utils"; import { QUERY_JOB_EXPORT_DMS } from "../../graphql/jobs.queries"; import { setBreadcrumbs, - setSelectedHeader, + setSelectedHeader } from "../../redux/application/application.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; @@ -66,6 +66,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { variables: { id: jobId }, skip: !jobId, }); + const logsRef = useRef(null); useEffect(() => { document.title = t("titles.dms"); @@ -151,46 +152,49 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) { socket={socket} jobId={jobId} job={data && data.jobs_by_pk} + logsRef={logsRef} /> -
- - - - - - } - > - - - +
+
+ + + + + + } + > + + + + );