From bfcc03850bbd96382c6ec2f4ba51a22ad973a6d1 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 23 Nov 2021 00:30:11 -0800 Subject: [PATCH 01/18] IO-70 Add OEC Through Partner Call. --- .../dms-cdk-makes.refetch.component.jsx | 4 +- .../help-rescue/help-rescue.component.jsx | 13 +- .../parts-order-modal.component.jsx | 1 + .../parts-order-modal.container.jsx | 51 ++++- client/src/graphql/parts-orders.queries.js | 187 ++++++++++++++++++ .../mobile-payment.component.jsx | 5 +- .../mobile-payment.container.jsx | 4 +- 7 files changed, 246 insertions(+), 19 deletions(-) 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 c0d1ee4d9..f24153a4d 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 @@ -1,10 +1,10 @@ import { Button } from "antd"; import axios from "axios"; 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 { useTranslation } from "react-i18next"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, @@ -19,7 +19,7 @@ export function DmsCdkMakesRefetch({ bodyshop, form, socket }) { const { t } = useTranslation(); const handleRefetch = async () => { setLoading(true); - const response = await axios.post("/cdk/getvehicles", { + await axios.post("/cdk/getvehicles", { cdk_dealerid: bodyshop.cdk_dealerid, bodyshopid: bodyshop.id, }); diff --git a/client/src/components/help-rescue/help-rescue.component.jsx b/client/src/components/help-rescue/help-rescue.component.jsx index 9a0d18b1e..1c3dd5ba0 100644 --- a/client/src/components/help-rescue/help-rescue.component.jsx +++ b/client/src/components/help-rescue/help-rescue.component.jsx @@ -10,14 +10,11 @@ export default function HelpRescue() { var bodyFormData = new FormData(); bodyFormData.append("Code", code); bodyFormData.append("hostederrorhandling", 1); - const res1 = await fetch( - "https://secure.logmeinrescue.com/Customer/Code.aspx", - { - mode: "no-cors", - method: "POST", - body: bodyFormData, - } - ); + await fetch("https://secure.logmeinrescue.com/Customer/Code.aspx", { + mode: "no-cors", + method: "POST", + body: bodyFormData, + }); }; return ( 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 08973075d..86fad8d3b 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 @@ -164,6 +164,7 @@ export default function PartsOrderModalComponent({ {t("general.labels.none")} {t("parts_orders.labels.email")} {t("parts_orders.labels.print")} + {t("parts_orders.labels.oec")} ); diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index ad9efeb72..61cba9406 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -1,13 +1,16 @@ -import { useMutation, useQuery } from "@apollo/client"; +import { useMutation, useQuery, useApolloClient } from "@apollo/client"; import { Form, Modal, notification } from "antd"; import moment from "moment"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; -import { logImEXEvent } from "../../firebase/firebase.utils"; +import { logImEXEvent, auth } from "../../firebase/firebase.utils"; import { UPDATE_JOB_LINE_STATUS } from "../../graphql/jobs-lines.queries"; -import { INSERT_NEW_PARTS_ORDERS } from "../../graphql/parts-orders.queries"; +import { + INSERT_NEW_PARTS_ORDERS, + QUERY_PARTS_ORDER_OEC, +} from "../../graphql/parts-orders.queries"; import { QUERY_ALL_VENDORS_FOR_ORDER } from "../../graphql/vendors.queries"; import { insertAuditTrail } from "../../redux/application/application.actions"; import { setEmailOptions } from "../../redux/email/email.actions"; @@ -26,6 +29,7 @@ import { TemplateList } from "../../utils/TemplateConstants"; import AlertComponent from "../alert/alert.component"; import LoadingSpinner from "../loading-spinner/loading-spinner.component"; import PartsOrderModalComponent from "./parts-order-modal.component"; +import axios from "axios"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -52,7 +56,7 @@ export function PartsOrderModalContainer({ insertAuditTrail, }) { const { t } = useTranslation(); - + const client = useApolloClient(); const { visible, context, actions } = partsOrderModal; const { jobId, @@ -175,7 +179,7 @@ export function PartsOrderModalContainer({ } if (refetch) refetch(); - toggleModalVisible(); + const Templates = TemplateList("partsorder", context); if (sendType === "e") { @@ -215,7 +219,44 @@ export function PartsOrderModalContainer({ {}, "p" ); + } else if (sendType === "oec") { + //Send to Partner OEC. + try { + const partsOrder = await client.query({ + query: QUERY_PARTS_ORDER_OEC, + variables: { + id: insertResult.data.insert_parts_orders.returning[0].id, + }, + }); + console.log("🚀 ~ file: parts-order-modal.container.jsx ~ line 231 ~ handleFinish ~ partsOrder", partsOrder) + + const oecResponse = await axios.post( + "http://localhost:1337/oec/", + + partsOrder.data.parts_orders_by_pk, + { + headers: { + Authorization: `Bearer ${await auth.currentUser.getIdToken()}`, + }, + } + ); + console.log( + "🚀 ~ file: parts-order-modal.container.jsx ~ line 232 ~ handleFinish ~ oecResponse", + oecResponse + ); + } catch (error) { + console.log("Error OEC.", error); + notification["error"]({ + message: t("parts_orders.errors.oec", { + error: JSON.stringify(error.message), + }), + }); + + return; + } } + + toggleModalVisible(); }; const initialValues = { diff --git a/client/src/graphql/parts-orders.queries.js b/client/src/graphql/parts-orders.queries.js index 7cd4427c9..b0ef44f1e 100644 --- a/client/src/graphql/parts-orders.queries.js +++ b/client/src/graphql/parts-orders.queries.js @@ -11,6 +11,193 @@ export const INSERT_NEW_PARTS_ORDERS = gql` } `; +export const QUERY_PARTS_ORDER_OEC = gql` +query QUERY_PARTS_ORDER_OEC($id: uuid!) { + parts_orders_by_pk(id: $id) { + job { + ro_number + clm_no + asgn_date + asgn_no + asgn_type + ciecaid + clm_addr1 + clm_city + clm_addr2 + clm_ct_fn + clm_ct_ln + clm_ct_ph + clm_ct_phx + clm_ctry + clm_ea + clm_fax + clm_faxx + clm_ofc_id + clm_ofc_nm + clm_ph1 + clm_ph1x + clm_ph2 + clm_ph2x + clm_st + clm_title + clm_total + clm_zip + ded_amt + est_addr1 + est_addr2 + est_city + est_co_nm + est_ct_fn + est_ctry + est_ct_ln + est_ea + est_ph1 + est_st + est_zip + g_bett_amt + id + ins_addr1 + ins_city + ins_addr2 + ins_co_id + ins_co_nm + ins_ct_fn + ins_ct_ln + ins_ct_ph + ins_ct_phx + ins_ctry + ins_ea + ins_fax + ins_faxx + ins_memo + ins_ph1 + ins_ph1x + ins_ph2 + ins_ph2x + ins_st + ins_title + ins_zip + insd_addr1 + insd_addr2 + insd_city + insd_co_nm + insd_ctry + insd_ea + insd_fax + insd_faxx + insd_fn + insd_ln + insd_ph1 + insd_ph1x + insd_ph2 + insd_ph2x + insd_st + insd_title + insd_zip + job_totals + loss_cat + loss_date + loss_desc + loss_of_use + loss_type + ownr_addr1 + ownr_addr2 + ownr_city + ownr_co_nm + ownr_ctry + ownr_ea + ownr_fax + ownr_faxx + ownr_ph1 + ownr_fn + ownr_ln + ownr_ph1x + ownr_ph2 + ownr_ph2x + ownr_st + ownr_title + ownr_zip + parts_tax_rates + pay_amt + pay_date + pay_type + pay_chknm + payee_nms + plate_no + plate_st + po_number + policy_no + tax_lbr_rt + tax_levies_rt + tax_paint_mat_rt + tax_predis + tax_prethr + tax_pstthr + tax_registration_number + tax_str_rt + tax_shop_mat_rt + tax_sub_rt + tax_thramt + tax_tow_rt + theft_ind + tlos_ind + towin + v_color + v_make_desc + v_model_desc + v_model_yr + v_vin + } + parts_order_lines { + jobline { + act_price + db_ref + db_price + db_hrs + glass_flag + id + lbr_amt + lbr_hrs_j + lbr_inc + lbr_op + lbr_op_j + lbr_tax + lbr_typ_j + line_desc + line_ind + line_no + line_ref + location + misc_amt + misc_sublt + misc_tax + mod_lb_hrs + mod_lbr_ty + oem_partno + op_code_desc + paint_stg + paint_tone + part_qty + part_type + price_inc + price_j + prt_dsmk_m + prt_dsmk_p + tax_part + unq_seq + } + act_price + id + db_price + line_desc + quantity + } + } +} + +`; + + export const DELETE_PARTS_ORDER = gql` mutation DELETE_PARTS_ORDER($partsOrderId: uuid!) { delete_parts_orders_by_pk(id: $partsOrderId) { diff --git a/client/src/pages/mobile-payment/mobile-payment.component.jsx b/client/src/pages/mobile-payment/mobile-payment.component.jsx index f353edbfd..2dff4b39f 100644 --- a/client/src/pages/mobile-payment/mobile-payment.component.jsx +++ b/client/src/pages/mobile-payment/mobile-payment.component.jsx @@ -1,6 +1,6 @@ import { PaymentRequestButtonElement, - useStripe, + useStripe } from "@stripe/react-stripe-js"; import React, { useEffect, useState } from "react"; @@ -60,7 +60,8 @@ export default function MobilePaymentComponent() { // it to close the browser payment method collection interface. ev.complete("success"); // Let Stripe.js handle the rest of the payment flow. - const { error, paymentIntent } = await stripe.confirmCardPayment( + const { error, //paymentIntent + } = await stripe.confirmCardPayment( "clientSecret" ); if (error) { diff --git a/client/src/pages/mobile-payment/mobile-payment.container.jsx b/client/src/pages/mobile-payment/mobile-payment.container.jsx index 18c36a1cb..7c44dd12d 100644 --- a/client/src/pages/mobile-payment/mobile-payment.container.jsx +++ b/client/src/pages/mobile-payment/mobile-payment.container.jsx @@ -1,7 +1,7 @@ -import React from "react"; -import MobilePaymentComponent from "./mobile-payment.component"; import { Elements } from "@stripe/react-stripe-js"; import { loadStripe } from "@stripe/stripe-js"; +import React from "react"; +import MobilePaymentComponent from "./mobile-payment.component"; const stripePromise = new Promise((resolve, reject) => { resolve( From 53be0bbc1a23e24f33f483fca167a2ce200a74f9 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 29 Nov 2021 08:57:44 -0800 Subject: [PATCH 02/18] IO-70 OEC WIP. --- .../parts-order-modal.container.jsx | 1 + client/src/graphql/parts-orders.queries.js | 436 +++++++++++------- 2 files changed, 259 insertions(+), 178 deletions(-) diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index 61cba9406..9ba18c30c 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -244,6 +244,7 @@ export function PartsOrderModalContainer({ "🚀 ~ file: parts-order-modal.container.jsx ~ line 232 ~ handleFinish ~ oecResponse", oecResponse ); + return; } catch (error) { console.log("Error OEC.", error); notification["error"]({ diff --git a/client/src/graphql/parts-orders.queries.js b/client/src/graphql/parts-orders.queries.js index b0ef44f1e..86c91b109 100644 --- a/client/src/graphql/parts-orders.queries.js +++ b/client/src/graphql/parts-orders.queries.js @@ -12,192 +12,272 @@ export const INSERT_NEW_PARTS_ORDERS = gql` `; export const QUERY_PARTS_ORDER_OEC = gql` -query QUERY_PARTS_ORDER_OEC($id: uuid!) { - parts_orders_by_pk(id: $id) { - job { - ro_number - clm_no - asgn_date - asgn_no - asgn_type - ciecaid - clm_addr1 - clm_city - clm_addr2 - clm_ct_fn - clm_ct_ln - clm_ct_ph - clm_ct_phx - clm_ctry - clm_ea - clm_fax - clm_faxx - clm_ofc_id - clm_ofc_nm - clm_ph1 - clm_ph1x - clm_ph2 - clm_ph2x - clm_st - clm_title - clm_total - clm_zip - ded_amt - est_addr1 - est_addr2 - est_city - est_co_nm - est_ct_fn - est_ctry - est_ct_ln - est_ea - est_ph1 - est_st - est_zip - g_bett_amt - id - ins_addr1 - ins_city - ins_addr2 - ins_co_id - ins_co_nm - ins_ct_fn - ins_ct_ln - ins_ct_ph - ins_ct_phx - ins_ctry - ins_ea - ins_fax - ins_faxx - ins_memo - ins_ph1 - ins_ph1x - ins_ph2 - ins_ph2x - ins_st - ins_title - ins_zip - insd_addr1 - insd_addr2 - insd_city - insd_co_nm - insd_ctry - insd_ea - insd_fax - insd_faxx - insd_fn - insd_ln - insd_ph1 - insd_ph1x - insd_ph2 - insd_ph2x - insd_st - insd_title - insd_zip - job_totals - loss_cat - loss_date - loss_desc - loss_of_use - loss_type - ownr_addr1 - ownr_addr2 - ownr_city - ownr_co_nm - ownr_ctry - ownr_ea - ownr_fax - ownr_faxx - ownr_ph1 - ownr_fn - ownr_ln - ownr_ph1x - ownr_ph2 - ownr_ph2x - ownr_st - ownr_title - ownr_zip - parts_tax_rates - pay_amt - pay_date - pay_type - pay_chknm - payee_nms - plate_no - plate_st - po_number - policy_no - tax_lbr_rt - tax_levies_rt - tax_paint_mat_rt - tax_predis - tax_prethr - tax_pstthr - tax_registration_number - tax_str_rt - tax_shop_mat_rt - tax_sub_rt - tax_thramt - tax_tow_rt - theft_ind - tlos_ind - towin - v_color - v_make_desc - v_model_desc - v_model_yr - v_vin - } - parts_order_lines { - jobline { + query QUERY_PARTS_ORDER_OEC($id: uuid!) { + parts_orders_by_pk(id: $id) { + parts_order_lines { + jobline { + act_price + db_ref + db_price + db_hrs + glass_flag + id + lbr_amt + lbr_hrs_j + lbr_inc + lbr_op + lbr_op_j + lbr_tax + lbr_typ_j + line_desc + line_ind + line_no + line_ref + location + misc_amt + misc_sublt + misc_tax + mod_lb_hrs + mod_lbr_ty + oem_partno + op_code_desc + paint_stg + paint_tone + part_qty + part_type + price_inc + price_j + prt_dsmk_m + prt_dsmk_p + tax_part + unq_seq + alt_co_id + alt_overrd + alt_part_i + alt_partm + alt_partno + bett_amt + bett_pctg + bett_tax + bett_type + cert_part + est_seq + } act_price - db_ref - db_price - db_hrs - glass_flag id - lbr_amt - lbr_hrs_j - lbr_inc - lbr_op - lbr_op_j - lbr_tax - lbr_typ_j + db_price line_desc - line_ind - line_no - line_ref - location - misc_amt - misc_sublt - misc_tax - mod_lb_hrs - mod_lbr_ty - oem_partno - op_code_desc - paint_stg - paint_tone - part_qty - part_type - price_inc - price_j - prt_dsmk_m - prt_dsmk_p - tax_part - unq_seq + quantity + } + job { + ro_number + clm_no + asgn_no + asgn_date + state_tax_rate + area_of_damage + asgn_no + asgn_type + ciecaid + clm_addr1 + clm_city + clm_addr2 + clm_ct_fn + clm_ct_ln + clm_ct_ph + clm_ct_phx + clm_ctry + clm_ea + clm_fax + clm_faxx + clm_ofc_id + clm_ofc_nm + clm_ph1 + clm_ph1x + clm_ph2 + clm_ph2x + clm_st + clm_title + clm_total + clm_zip + ded_amt + est_addr1 + est_addr2 + est_city + est_co_nm + est_ct_fn + est_ctry + est_ct_ln + est_ea + est_ph1 + est_st + est_zip + g_bett_amt + id + ins_addr1 + ins_city + ins_addr2 + ins_co_id + ins_co_nm + ins_ct_fn + ins_ct_ln + ins_ct_ph + ins_ct_phx + ins_ctry + ins_ea + ins_fax + ins_faxx + ins_memo + ins_ph1 + ins_ph1x + ins_ph2 + ins_ph2x + ins_st + ins_title + ins_zip + insd_addr1 + insd_addr2 + insd_city + insd_co_nm + insd_ctry + insd_ea + insd_fax + insd_faxx + insd_fn + insd_ln + insd_ph1 + insd_ph1x + insd_ph2 + insd_ph2x + insd_st + insd_title + insd_zip + job_totals + loss_cat + loss_date + loss_desc + loss_of_use + loss_type + ownr_addr1 + ownr_addr2 + ownr_city + ownr_co_nm + ownr_ctry + ownr_ea + ownr_fax + ownr_faxx + ownr_ph1 + ownr_fn + ownr_ln + ownr_ph1x + ownr_ph2 + ownr_ph2x + ownr_st + ownr_title + ownr_zip + parts_tax_rates + pay_amt + pay_date + pay_type + pay_chknm + payee_nms + plate_no + plate_st + po_number + policy_no + tax_lbr_rt + tax_levies_rt + tax_paint_mat_rt + tax_predis + tax_prethr + tax_pstthr + tax_registration_number + tax_str_rt + tax_shop_mat_rt + tax_sub_rt + tax_thramt + tax_tow_rt + theft_ind + tlos_ind + towin + v_color + v_make_desc + v_model_desc + v_model_yr + v_vin + vehicle { + v_bstyle + v_type + v_trimcode + v_tone + v_stage + v_prod_dt + v_options + v_paint_codes + v_model_yr + v_model_desc + v_mldgcode + v_makecode + v_make_desc + v_engine + v_cond + v_color + trim_color + shopid + plate_no + plate_st + db_v_code + v_vin + } + agt_zip + agt_st + agt_ph2x + agt_ph2 + agt_ph1x + agt_ph1 + agt_lic_no + agt_faxx + agt_fax + agt_ea + agt_ctry + agt_ct_phx + agt_ct_ph + agt_ct_ln + agt_ct_fn + agt_co_nm + agt_co_id + agt_city + agt_addr1 + agt_addr2 + adj_g_disc + rate_matd + rate_mash + rate_mapa + rate_mahw + rate_macs + rate_mabl + rate_ma3s + rate_ma2t + rate_ma2s + rate_lau + rate_las + rate_lar + rate_lam + rate_lag + rate_laf + rate_lae + rate_lad + rate_lab + rate_laa + rate_la4 + rate_la3 + rate_la2 + rate_la1 } - act_price - id - db_price - line_desc - quantity } } -} - `; - export const DELETE_PARTS_ORDER = gql` mutation DELETE_PARTS_ORDER($partsOrderId: uuid!) { delete_parts_orders_by_pk(id: $partsOrderId) { From 673654a9b7426b15f74ecd9bd5886ec299bca23e Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 29 Nov 2021 10:46:59 -0800 Subject: [PATCH 03/18] IO-223 WIP ARMS --- server/data/arms.js | 90 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 22 deletions(-) diff --git a/server/data/arms.js b/server/data/arms.js index b90fd66ba..3439bdeff 100644 --- a/server/data/arms.js +++ b/server/data/arms.js @@ -2,7 +2,7 @@ const path = require("path"); const queries = require("../graphql-client/queries"); const Dinero = require("dinero.js"); const moment = require("moment"); -var builder = require("xmlbuilder2"); + const _ = require("lodash"); const logger = require("../utils/logger"); require("dotenv").config({ @@ -11,6 +11,12 @@ require("dotenv").config({ `.env.${process.env.NODE_ENV || "development"}` ), }); +const soap = require("soap"); + +const entegralEndpoint = + process.env.NODE_ENV === "production" + ? "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq" + : "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq"; const client = require("../graphql-client/graphql-client").client; const uuid = require("uuid").v4; @@ -43,7 +49,7 @@ exports.default = async (req, res) => { DocumentVerNum: GetSupplementNumber(job.joblines), //TODO Get Supplement Number DocumentStatus: GetDocumentstatus(job, bodyshop), CreateDateTime: moment().format(), - // TransmitDateTime: "2009-03-11T11:58:31.0404914-07:00", Omitted from ARMS docs + TransmitDateTime: moment().format(), // Omitted from ARMS docs }, EventInfo: { AssignmentEvent: { @@ -51,7 +57,7 @@ exports.default = async (req, res) => { job.asgn_date && moment(job.asgn_date).format(), }, EstimateEvent: { - UploadDateTime: "2009-03-02T17:00:00.0000000-08:00", //TODO Figure out what this actually is. 'Date Estimate was uploaded' + UploadDateTime: moment().format(), }, RepairEvent: { ArrivalDateTime: @@ -266,10 +272,12 @@ exports.default = async (req, res) => { job.loss_date && moment(job.loss_date).format(), LossDescCode: "Collision", PrimaryPOI: { - POICode: job.area_of_damage.impact1, + POICode: + job.area_of_damage && job.area_of_damage.impact1, }, SecondaryPOI: { - POICode: job.area_of_damage.impact2, + POICode: + job.area_of_damage && job.area_of_damage.impact2, }, }, TotalLossInd: job.tlos_ind, @@ -443,7 +451,7 @@ exports.default = async (req, res) => { TotalTypeDesc: "Body Labor", TotalHours: job.job_totals.rates.lab.hours, TotalAmt: Dinero(job.job_totals.rates.lab.total).toFormat( - 0.0 + "0.0" ), }, { @@ -451,7 +459,7 @@ exports.default = async (req, res) => { TotalTypeDesc: "Frame Labor", TotalHours: job.job_totals.rates.laf.hours, TotalAmt: Dinero(job.job_totals.rates.laf.total).toFormat( - 0.0 + "0.0" ), }, { @@ -459,7 +467,7 @@ exports.default = async (req, res) => { TotalTypeDesc: "Mechanical Labor", TotalHours: job.job_totals.rates.lam.hours, TotalAmt: Dinero(job.job_totals.rates.lam.total).toFormat( - 0.0 + "0.0" ), }, { @@ -467,7 +475,7 @@ exports.default = async (req, res) => { TotalTypeDesc: "Refinish Labor", TotalHours: job.job_totals.rates.lar.hours, TotalAmt: Dinero(job.job_totals.rates.lar.total).toFormat( - 0.0 + "0.0" ), }, ], @@ -541,14 +549,14 @@ exports.default = async (req, res) => { TotalType: "MAPA", TotalTypeDesc: "Paint Materials", TotalAmt: Dinero(job.job_totals.rates.mapa.total).toFormat( - 0.0 + "0.0" ), }, { TotalType: "MASH", TotalTypeDesc: "Shop Materials", TotalAmt: Dinero(job.job_totals.rates.mash.total).toFormat( - 0.0 + "0.0" ), }, // { @@ -569,7 +577,7 @@ exports.default = async (req, res) => { TotalType: "OTTW", TotalTypeDesc: "Towing", TotalAmt: Dinero(job.job_totals.additional.towing).toFormat( - 0.0 + "0.0" ), }, { @@ -586,7 +594,7 @@ exports.default = async (req, res) => { TotalSubType: "T2", TotalTypeDesc: "Net Total", TotalAmt: Dinero(job.job_totals.totals.subtotal).toFormat( - 0.0 + "0.0" ), }, { @@ -594,7 +602,7 @@ exports.default = async (req, res) => { TotalSubType: "F7", TotalTypeDesc: "Sales Tax", TotalAmt: Dinero(job.job_totals.totals.state_tax).toFormat( - 0.0 + "0.0" ), }, { @@ -722,15 +730,15 @@ exports.default = async (req, res) => { // }, ProductionStatus: { ProductionStage: { - ProductionStageCode: 4, - ProductionStageDateTime: "2009-03-11T11:58:32.1898319-07:00", - ProductionStageStatusComment: - "Going to be painted this afternoon", + ProductionStageCode: GetProductionStageCode(job), + ProductionStageDateTime: moment().format(), + // ProductionStageStatusComment: + // "Going to be painted this afternoon", }, RepairStatus: { - RepairStatusCode: 2, - RepairStatusDateTime: "2009-03-11T11:58:32.1898319-07:00", - RepairStatusMemo: "Waiting on back ordered parts", + RepairStatusCode: GetRepairStatusCode(job), + RepairStatusDateTime: moment().format(), + // RepairStatusMemo: "Waiting on back ordered parts", }, }, // RepairOrderNotes: { @@ -771,6 +779,37 @@ exports.default = async (req, res) => { logger.log("arms-end-shop-extract", "DEBUG", "api", bodyshop.id, { shopname: bodyshop.shopname, }); + console.log(new Buffer.from( + `${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}` + ).toString("base64")) + + try { + const entegralSoapClient = await soap.createClientAsync( + entegralEndpoint, + { + wsdl_headers: { + Authorization: `Basic ${new Buffer.from( + `${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}` + ).toString("base64")}`, + }, + } + ); + } catch (error) { + console.log(error); + } + + // const soapResponseVehicleInsertUpdate = + // await entegralSoapClient.RepairOrderFolderAddRq ({ + // arg0: CDK_CREDENTIALS, + // arg1: { id: JobData.bodyshop.cdk_dealerid }, + // arg2: { + // fileType: "VEHICLES", + // vehiclesVehicleId: DMSVid.vehiclesVehId, + // }, + // }); + + // const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate; + res.json(ret); } catch (error) { //Error at the shop level. @@ -793,7 +832,7 @@ exports.default = async (req, res) => { } } - res.sendStatus(200); + // res.sendStatus(200); } catch (error) { res.status(200).json(error); } @@ -815,3 +854,10 @@ function GetDocumentstatus(job, bodyshop) { return "0"; } } + +function GetRepairStatusCode(job) { + return "25"; +} +function GetProductionStageCode(job) { + return "33"; +} From 5db43dd065d17557941d7d04bc2db02461b0cd87 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 29 Nov 2021 15:04:34 -0800 Subject: [PATCH 04/18] IO-70 Add basic functions of OEC. --- bodyshop_translations.babel | 44 ++++++++++++++++++- .../parts-order-modal.container.jsx | 17 ++++--- client/src/graphql/parts-orders.queries.js | 5 +++ client/src/translations/en_us/common.json | 4 +- client/src/translations/es/common.json | 4 +- client/src/translations/fr/common.json | 4 +- hasura/metadata/tables.yaml | 14 +++++- .../down.sql | 4 ++ .../up.sql | 2 + 9 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 hasura/migrations/1638223143109_alter_table_public_joblines_add_column_tran_code/down.sql create mode 100644 hasura/migrations/1638223143109_alter_table_public_joblines_add_column_tran_code/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index c49f9a9da..36e0ccaaf 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1,4 +1,4 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + + + + + + + : + + + + + + + + : + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Salvage or Assembly + + + + + + + + + + + + + + PAN + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 0 + + + + + 1 + 2 + 3 + 4 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + False + + + + + False + + + + False + False + False + False + False + False + False + False + False + False + False + False + False + False + True + + + + + False + + + False + + + + + + + \ No newline at end of file diff --git a/_reference/OEC/AudatexMapping.xml b/_reference/OEC/AudatexMapping.xml new file mode 100644 index 000000000..0068c7229 --- /dev/null +++ b/_reference/OEC/AudatexMapping.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Audatex.xsl + + diff --git a/_reference/OEC/CCC.xsl b/_reference/OEC/CCC.xsl new file mode 100644 index 000000000..96e58c428 --- /dev/null +++ b/_reference/OEC/CCC.xsl @@ -0,0 +1,607 @@ + + + + + + + + + + + + + + + + OECTrans.ImportTrans + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + 0 + + + + + + + CCC.xml + CCC.xsl + + + + + + + + + + + + + + + + + -- + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + + + + + + + : + + + + + + + + : + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PAN + + + + + + + + + + + + + + + + + + + + + + Salvage or Assembly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PAN + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 4 + 0 + + + + + 1 + 2 + 3 + 4 + 4 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + 0 + + + + + + + + + + + + + + + + + + False + + + + + + False + + + False + + False + False + False + False + False + False + False + False + False + False + + + False + False + False + False + True + + + + + False + + + False + + + + + + + \ No newline at end of file diff --git a/_reference/OEC/CCCMapping.xml b/_reference/OEC/CCCMapping.xml new file mode 100644 index 000000000..ab4d3b4a1 --- /dev/null +++ b/_reference/OEC/CCCMapping.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ccc.xsl + + diff --git a/_reference/OEC/Mitchell.xsl b/_reference/OEC/Mitchell.xsl new file mode 100644 index 000000000..48fbd5d65 --- /dev/null +++ b/_reference/OEC/Mitchell.xsl @@ -0,0 +1,580 @@ + + + + + + + + + + + + + + + + OECTrans.ImportTrans + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + Mitchell.xml + Mitchell.xsl + + + + + + + + + + + + + + + + + -- + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + x + + + + + + + + + + + + + + + + : + + + + + + + + : + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Salvage or Assembly + + + + + + + + + + + + + + PAN + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 4 + 4 + 0 + + + + + 1 + 2 + 3 + 4 + 4 + 4 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + False + + + + + False + + + False + False + False + False + False + False + False + False + False + False + False + False + False + False + False + True + + + + + False + + + False + + + + + + + \ No newline at end of file diff --git a/_reference/OEC/MitchellMapping.xml b/_reference/OEC/MitchellMapping.xml new file mode 100644 index 000000000..91ba33d17 --- /dev/null +++ b/_reference/OEC/MitchellMapping.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mitchell.xsl + + From 39ec9d92ec19f392681db1805519e3f0c55affd7 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 2 Dec 2021 10:50:11 -0800 Subject: [PATCH 11/18] IO-233 CDK updates. --- bodyshop_translations.babel | 141 +++++++ .../bill-form/bill-form.lines.component.jsx | 24 +- .../dms-allocations-summary.component.jsx | 1 + .../dms-post-form/dms-post-form.component.jsx | 78 ++-- .../jobs-close-auto-allocate.component.jsx | 5 +- .../labor-allocations-table.component.jsx | 7 +- .../labor-allocations-table.utility.js | 12 +- .../parts-order-list-table.component.jsx | 12 +- .../shop-employees-form.component.jsx | 17 +- ...p-info.responsibilitycenters.component.jsx | 346 ++++++++++++------ .../time-ticket-modal.component.jsx | 7 +- .../time-ticket-modal.container.jsx | 17 +- client/src/graphql/jobs.queries.js | 1 + .../pages/jobs-close/jobs-close.component.jsx | 24 +- client/src/translations/en_us/common.json | 12 + client/src/translations/es/common.json | 12 + client/src/translations/fr/common.json | 12 + client/src/utils/Ciecaselect.jsx | 103 ++++++ hasura/metadata/tables.yaml | 3 + .../down.sql | 4 + .../up.sql | 2 + server/cdk/cdk-calculate-allocations.js | 46 ++- server/graphql-client/queries.js | 3 + 23 files changed, 688 insertions(+), 201 deletions(-) create mode 100644 client/src/utils/Ciecaselect.jsx create mode 100644 hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/down.sql create mode 100644 hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 3dd56671f..6556d2dc7 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -6491,6 +6491,27 @@ + + pag + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + pal false @@ -12146,6 +12167,37 @@ + + dms + + + labels + + + refreshallocations + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + documents @@ -17809,6 +17861,32 @@ + + labels + + + refreshallocations + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + post false @@ -18315,6 +18393,27 @@ + + sendtodms + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + sync false @@ -20419,6 +20518,27 @@ + + dms_allocation + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + driveable false @@ -22151,6 +22271,27 @@ + + po_number + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + policy_no false diff --git a/client/src/components/bill-form/bill-form.lines.component.jsx b/client/src/components/bill-form/bill-form.lines.component.jsx index 22aa62f23..29bd6cbc7 100644 --- a/client/src/components/bill-form/bill-form.lines.component.jsx +++ b/client/src/components/bill-form/bill-form.lines.component.jsx @@ -14,6 +14,7 @@ import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import CiecaSelect, { GetPartTypeName } from "../../utils/Ciecaselect"; import BillLineSearchSelect from "../bill-line-search-select/bill-line-search-select.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; @@ -72,11 +73,13 @@ export function BillEnterModalLinesComponent({ quantity: opt.part_qty || 1, actual_price: opt.cost, cost_center: opt.part_type - ? responsibilityCenters.defaults && - (responsibilityCenters.defaults.costs[ - opt.part_type - ] || - null) + ? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid + ? GetPartTypeName(opt.part_type) + : responsibilityCenters.defaults && + (responsibilityCenters.defaults.costs[ + opt.part_type + ] || + null) : null, }; } @@ -224,6 +227,7 @@ export function BillEnterModalLinesComponent({ key: `${field.index}cost_center`, name: [field.name, "cost_center"], label: t("billlines.fields.cost_center"), + valuePropName: "value", rules: [ { required: true, @@ -233,10 +237,12 @@ export function BillEnterModalLinesComponent({ }; }, formInput: (record, index) => ( - + {bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber + ? CiecaSelect(true, false) + : responsibilityCenters.costs.map((item) => ( + {item.name} + ))} ), }, diff --git a/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx b/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx index acfd796df..65357295b 100644 --- a/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx +++ b/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx @@ -95,6 +95,7 @@ export function DmsAllocationsSummary({ socket, bodyshop, jobId, title }) { columns={columns} rowKey="center" dataSource={allocationsSummary} + locale={{ emptyText: t("dms.labels.refreshallocations") }} summary={() => { const totals = allocationsSummary.reduce( (acc, val) => { 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 6bea7a433..ff7057606 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 @@ -221,7 +221,47 @@ export function DmsPostForm({ bodyshop, socket, job }) { + {t("jobs.fields.dms.payer.controlnumber")}{" "} + + {bodyshop.cdk_configuration.controllist && + bodyshop.cdk_configuration.controllist.map( + (key, idx) => ( + { + form.setFieldsValue({ + payers: form + .getFieldValue("payers") + .map((row, mapIndex) => { + if (index !== mapIndex) + return row; + + return { + ...row, + controlnumber: + key.controlnumber, + }; + }), + }); + }} + > + {key.name} + + ) + )} + + } + > + e.preventDefault()}> + + + + + } key={`${index}controlnumber`} name={[field.name, "controlnumber"]} rules={[ @@ -254,42 +294,6 @@ export function DmsPostForm({ bodyshop, socket, job }) { }} - - {bodyshop.cdk_configuration.controllist && - bodyshop.cdk_configuration.controllist.map( - (key, idx) => ( - { - form.setFieldsValue({ - payers: form - .getFieldValue("payers") - .map((row, mapIndex) => { - if (index !== mapIndex) return row; - - return { - ...row, - controlnumber: key.controlnumber, - }; - }), - }); - }} - > - {key.name} - - ) - )} - - } - > - e.preventDefault()}> - {t("bodyshop.labels.dms.cdk.controllist")}{" "} - - - - { remove(field.name); diff --git a/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx b/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx index 6d766f9e6..b9d787433 100644 --- a/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx +++ b/client/src/components/jobs-close-auto-allocate/jobs-close-auto-allocate.component.jsx @@ -54,6 +54,7 @@ export function JobsCloseAutoAllocate({ bodyshop, joblines, form, disabled }) { const handleMenuClick = ({ item, key, keyPath, domEvent }) => { logImEXEvent("jobs_close_allocate_auto_dms"); + form.setFieldsValue({ dms_allocation: key }); handleAllocate( bodyshop.md_responsibility_centers.dms_defaults.find( (x) => x.name === key @@ -64,7 +65,9 @@ export function JobsCloseAutoAllocate({ bodyshop, joblines, form, disabled }) { const overlay = (bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( {bodyshop.md_responsibility_centers.dms_defaults.map((mapping) => ( - {mapping.name} + + {mapping.name} + ))} ); diff --git a/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx b/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx index 5bb74b8c8..cecc22795 100644 --- a/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx +++ b/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx @@ -38,12 +38,7 @@ export function LaborAllocationsTable({ useEffect(() => { if (!!joblines && !!timetickets && !!bodyshop); setTotals( - CalculateAllocationsTotals( - bodyshop.md_responsibility_centers, - joblines, - timetickets, - adjustments - ) + CalculateAllocationsTotals(bodyshop, joblines, timetickets, adjustments) ); if (!jobId) setTotals([]); }, [joblines, timetickets, bodyshop, adjustments, jobId]); diff --git a/client/src/components/labor-allocations-table/labor-allocations-table.utility.js b/client/src/components/labor-allocations-table/labor-allocations-table.utility.js index 29f8001f7..78d5aa2c6 100644 --- a/client/src/components/labor-allocations-table/labor-allocations-table.utility.js +++ b/client/src/components/labor-allocations-table/labor-allocations-table.utility.js @@ -1,9 +1,12 @@ +import i18next from "i18next"; + export const CalculateAllocationsTotals = ( - responsibilitycenters, + bodyshop, joblines, timetickets, adjustments = [] ) => { + const responsibilitycenters = bodyshop.md_responsibility_centers; const jobCodes = joblines.map((item) => item.mod_lbr_ty); //.filter((value, index, self) => self.indexOf(value) === index && !!value); const ticketCodes = timetickets.map((item) => item.ciecacode); @@ -15,7 +18,12 @@ export const CalculateAllocationsTotals = ( const r = allCodes.reduce((acc, value) => { const r = { opcode: value, - cost_center: responsibilitycenters.defaults.costs[value], + cost_center: + bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber + ? i18next.t( + `joblines.fields.lbr_types.${value && value.toUpperCase()}` + ) + : responsibilitycenters.defaults.costs[value], mod_lbr_ty: value, total: joblines.reduce((acc2, val2) => { return val2.mod_lbr_ty === value ? acc2 + val2.mod_lb_hrs : acc2; diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index 4264f4272..cb9625452 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -23,6 +23,7 @@ import { DELETE_PARTS_ORDER } from "../../graphql/parts-orders.queries"; import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { setModalContext } from "../../redux/modals/modals.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import { GetPartTypeName } from "../../utils/Ciecaselect"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { DateFormatter } from "../../utils/DateFormatter"; import { alphaSort } from "../../utils/sorters"; @@ -165,10 +166,15 @@ export function PartsOrderListTableComponent({ quantity: pol.quantity, actual_price: pol.act_price, + cost_center: pol.jobline?.part_type - ? responsibilityCenters.defaults.costs[ - pol.jobline.part_type - ] || null + ? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid + ? GetPartTypeName(pol.jobline.part_type) + : responsibilityCenters.defaults && + (responsibilityCenters.defaults.costs[ + pol.jobline.part_type + ] || + null) : null, }; }), diff --git a/client/src/components/shop-employees/shop-employees-form.component.jsx b/client/src/components/shop-employees/shop-employees-form.component.jsx index 02289e356..acfadbcde 100644 --- a/client/src/components/shop-employees/shop-employees-form.component.jsx +++ b/client/src/components/shop-employees/shop-employees-form.component.jsx @@ -14,6 +14,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; +import CiecaSelect from "../../utils/Ciecaselect"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -218,6 +219,7 @@ export function ShopEmployeesFormComponent({ label={t("employees.fields.cost_center")} key={`${index}`} name={[field.name, "cost_center"]} + valuePropName="value" rules={[ { required: true, @@ -232,11 +234,16 @@ export function ShopEmployeesFormComponent({ > {t("timetickets.labels.shift")} - {bodyshop.md_responsibility_centers.costs.map((c) => ( - - {c.name} - - ))} + + {bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber + ? CiecaSelect(false, true) + : bodyshop.md_responsibility_centers.costs.map( + (c) => ( + + {c.name} + + ) + )} - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber)&& ( + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( <> {form.getFieldValue("cdk_dealerid")} @@ -164,7 +164,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { }, ]} > - {t("jobs.fields.ro_number")} @@ -582,7 +582,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-ats`} name={[field.name, "costs", "ATS"]} > - {costOptions.map((item, idx) => ( {item} @@ -613,7 +613,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAA`} name={[field.name, "costs", "LAA"]} > - {costOptions.map((item, idx) => ( {item} @@ -644,7 +644,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAB`} name={[field.name, "costs", "LAB"]} > - {costOptions.map((item, idx) => ( {item} @@ -675,7 +675,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAD`} name={[field.name, "costs", "LAD"]} > - {costOptions.map((item, idx) => ( {item} @@ -706,7 +706,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAE`} name={[field.name, "costs", "LAE"]} > - {costOptions.map((item, idx) => ( {item} @@ -737,7 +737,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAF`} name={[field.name, "costs", "LAF"]} > - {costOptions.map((item, idx) => ( {item} @@ -768,7 +768,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAG`} name={[field.name, "costs", "LAG"]} > - {costOptions.map((item, idx) => ( {item} @@ -799,7 +799,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAM`} name={[field.name, "costs", "LAM"]} > - {costOptions.map((item, idx) => ( {item} @@ -830,7 +830,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAR`} name={[field.name, "costs", "LAR"]} > - {costOptions.map((item, idx) => ( {item} @@ -861,7 +861,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAS`} name={[field.name, "costs", "LAS"]} > - {costOptions.map((item, idx) => ( {item} @@ -892,7 +892,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LAU`} name={[field.name, "costs", "LAU"]} > - {costOptions.map((item, idx) => ( {item} @@ -923,7 +923,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LA1`} name={[field.name, "costs", "LA1"]} > - {costOptions.map((item, idx) => ( {item} @@ -954,7 +954,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LA2`} name={[field.name, "costs", "LA2"]} > - {costOptions.map((item, idx) => ( {item} @@ -985,7 +985,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LA3`} name={[field.name, "costs", "LA3"]} > - {costOptions.map((item, idx) => ( {item} @@ -1016,7 +1016,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-LA4`} name={[field.name, "costs", "LA4"]} > - {costOptions.map((item, idx) => ( {item} @@ -1047,7 +1047,7 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-PAA`} name={[field.name, "costs", "PAA"]} > - {costOptions.map((item, idx) => ( {item} @@ -1078,7 +1078,38 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { key={`${index}costs-PAC`} name={[field.name, "costs", "PAC"]} > - + {costOptions.map((item, idx) => ( + + {item} + + ))} + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAG`} + name={[field.name, "costs", "PAG"]} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAG`} + name={[field.name, "profits", "PAG"]} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAG"]} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAG"]} + > + + + + + + + + + + + + + + )} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 30b9fc6ac..51497bf15 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -413,6 +413,7 @@ "mash": "Shop Materials", "paa": "Aftermarket", "pac": "Chrome", + "pag": "Glass", "pal": "LKQ", "pam": "Remanufactured", "pan": "OEM", @@ -759,6 +760,11 @@ "projectedmonthlysales": "Projected Monthly Sales" } }, + "dms": { + "labels": { + "refreshallocations": "Refresh to see DMS Allocataions." + } + }, "documents": { "actions": { "delete": "Delete Selected Documents", @@ -1107,6 +1113,9 @@ "createnewcustomer": "Create New Customer", "findmakemodelcode": "Find Make/Model Code", "getmakes": "", + "labels": { + "refreshallocations": "Refresh this component to see the DMS allocations." + }, "post": "Post", "refetchmakesmodels": "Refetch Make and Model Codes", "usegeneric": "Use Generic Customer", @@ -1132,6 +1141,7 @@ "removefromproduction": "Remove from Production", "schedule": "Schedule", "sendcsi": "Send CSI", + "sendtodms": "Send to DMS", "sync": "Sync", "uninvoice": "Uninvoice", "unvoid": "Unvoid Job", @@ -1241,6 +1251,7 @@ "story": "Story", "vinowner": "VIN Owner" }, + "dms_allocation": "DMS Allocation", "driveable": "Driveable", "employee_body": "Body", "employee_csr": "Customer Service Rep.", @@ -1327,6 +1338,7 @@ "pas": "Sublet", "pay_date": "Pay Date", "phoneshort": "PH", + "po_number": "PO Number", "policy_no": "Policy #", "ponumber": "PO Number", "production_vars": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index e79d937b3..bd1524e12 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -413,6 +413,7 @@ "mash": "", "paa": "", "pac": "", + "pag": "", "pal": "", "pam": "", "pan": "", @@ -759,6 +760,11 @@ "projectedmonthlysales": "" } }, + "dms": { + "labels": { + "refreshallocations": "" + } + }, "documents": { "actions": { "delete": "", @@ -1107,6 +1113,9 @@ "createnewcustomer": "", "findmakemodelcode": "", "getmakes": "", + "labels": { + "refreshallocations": "" + }, "post": "", "refetchmakesmodels": "", "usegeneric": "", @@ -1132,6 +1141,7 @@ "removefromproduction": "", "schedule": "Programar", "sendcsi": "", + "sendtodms": "", "sync": "", "uninvoice": "", "unvoid": "", @@ -1241,6 +1251,7 @@ "story": "", "vinowner": "" }, + "dms_allocation": "", "driveable": "", "employee_body": "", "employee_csr": "Representante de servicio al cliente.", @@ -1327,6 +1338,7 @@ "pas": "", "pay_date": "Fecha de Pay", "phoneshort": "PH", + "po_number": "", "policy_no": "Política #", "ponumber": "numero postal", "production_vars": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 9caebf657..86d79c2d0 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -413,6 +413,7 @@ "mash": "", "paa": "", "pac": "", + "pag": "", "pal": "", "pam": "", "pan": "", @@ -759,6 +760,11 @@ "projectedmonthlysales": "" } }, + "dms": { + "labels": { + "refreshallocations": "" + } + }, "documents": { "actions": { "delete": "", @@ -1107,6 +1113,9 @@ "createnewcustomer": "", "findmakemodelcode": "", "getmakes": "", + "labels": { + "refreshallocations": "" + }, "post": "", "refetchmakesmodels": "", "usegeneric": "", @@ -1132,6 +1141,7 @@ "removefromproduction": "", "schedule": "Programme", "sendcsi": "", + "sendtodms": "", "sync": "", "uninvoice": "", "unvoid": "", @@ -1241,6 +1251,7 @@ "story": "", "vinowner": "" }, + "dms_allocation": "", "driveable": "", "employee_body": "", "employee_csr": "représentant du service à la clientèle", @@ -1327,6 +1338,7 @@ "pas": "", "pay_date": "Date d'Pay", "phoneshort": "PH", + "po_number": "", "policy_no": "Politique #", "ponumber": "Numéro de bon de commande", "production_vars": { diff --git a/client/src/utils/Ciecaselect.jsx b/client/src/utils/Ciecaselect.jsx new file mode 100644 index 000000000..3b22deb5a --- /dev/null +++ b/client/src/utils/Ciecaselect.jsx @@ -0,0 +1,103 @@ +import React from "react"; +import { Select } from "antd"; +import i18n from "../translations/i18n"; + +export default function CiecaSelect(parts = true, labor = true) { + return ( + <> + {labor && ( + <> + + {i18n.t("joblines.fields.lbr_types.LAA")} + + + {i18n.t("joblines.fields.lbr_types.LAB")} + + + {i18n.t("joblines.fields.lbr_types.LAD")} + + + {i18n.t("joblines.fields.lbr_types.LAE")} + + + {i18n.t("joblines.fields.lbr_types.LAF")} + + + {i18n.t("joblines.fields.lbr_types.LAG")} + + + {i18n.t("joblines.fields.lbr_types.LAM")} + + + {i18n.t("joblines.fields.lbr_types.LAR")} + + + {i18n.t("joblines.fields.lbr_types.LAS")} + + + {i18n.t("joblines.fields.lbr_types.LAU")} + + + {i18n.t("joblines.fields.lbr_types.LA1")} + + + {i18n.t("joblines.fields.lbr_types.LA2")} + + + {i18n.t("joblines.fields.lbr_types.LA3")} + + + {i18n.t("joblines.fields.lbr_types.LA4")} + + + )} + {parts && ( + <> + + {i18n.t("joblines.fields.part_types.PAA")} + + + {i18n.t("joblines.fields.part_types.PAC")} + + + + {i18n.t("joblines.fields.part_types.PAL")} + + + {i18n.t("joblines.fields.part_types.PAG")} + + + {i18n.t("joblines.fields.part_types.PAM")} + + + {i18n.t("joblines.fields.part_types.PAP")} + + + {i18n.t("joblines.fields.part_types.PAN")} + + + {i18n.t("joblines.fields.part_types.PAO")} + + + {i18n.t("joblines.fields.part_types.PAR")} + + + {i18n.t("joblines.fields.part_types.PAS")} + + + )} + + ); +} + +export function GetPartTypeName(part_type) { + console.log(part_type); + if (!part_type) return null; + return i18n.t(`joblines.fields.part_types.${part_type.toUpperCase()}`); +} + +export function Get(part_type) { + console.log(part_type); + if (!part_type) return null; + return i18n.t(`joblines.fields.part_types.${part_type.toUpperCase()}`); +} diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 237c695b7..9bdea1b51 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -2616,6 +2616,7 @@ - ded_status - deliverchecklist - depreciation_taxes + - dms_allocation - driveable - employee_body - employee_csr @@ -2868,6 +2869,7 @@ - ded_status - deliverchecklist - depreciation_taxes + - dms_allocation - driveable - employee_body - employee_csr @@ -3130,6 +3132,7 @@ - ded_status - deliverchecklist - depreciation_taxes + - dms_allocation - driveable - employee_body - employee_csr diff --git a/hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/down.sql b/hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/down.sql new file mode 100644 index 000000000..c434a9935 --- /dev/null +++ b/hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."jobs" add column "dms_allocation" text +-- null; diff --git a/hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/up.sql b/hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/up.sql new file mode 100644 index 000000000..34284d636 --- /dev/null +++ b/hasura/migrations/1638467360308_alter_table_public_jobs_add_column_dms_allocation/up.sql @@ -0,0 +1,2 @@ +alter table "public"."jobs" add column "dms_allocation" text + null; diff --git a/server/cdk/cdk-calculate-allocations.js b/server/cdk/cdk-calculate-allocations.js index dc386e618..f7db405b8 100644 --- a/server/cdk/cdk-calculate-allocations.js +++ b/server/cdk/cdk-calculate-allocations.js @@ -106,10 +106,23 @@ exports.default = async function (socket, jobid) { return acc; }, {}); + const selectedDmsAllocationConfig = + bodyshop.md_responsibility_centers.dms_defaults.find( + (d) => d.name === job.dms_allocation + ); + CdkBase.createLogEvent( + socket, + "DEBUG", + `Using DMS Allocation ${ + selectedDmsAllocationConfig && selectedDmsAllocationConfig.name + } for cost export.` + ); + const costCenterHash = job.bills.reduce((bill_acc, bill_val) => { bill_val.billlines.map((line_val) => { - if (!bill_acc[line_val.cost_center]) - bill_acc[line_val.cost_center] = Dinero(); + if (!bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]]) + bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]] = + Dinero(); let lineDinero = Dinero({ amount: Math.round((line_val.actual_cost || 0) * 100), @@ -117,8 +130,10 @@ exports.default = async function (socket, jobid) { .multiply(line_val.quantity) .multiply(bill_val.is_credit_memo ? -1 : 1); - bill_acc[line_val.cost_center] = - bill_acc[line_val.cost_center].add(lineDinero); + bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]] = + bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]].add( + lineDinero + ); return null; }); return bill_acc; @@ -136,17 +151,19 @@ exports.default = async function (socket, jobid) { ), }); //Add it to the right cost center. - if (!costCenterHash[ticket.cost_center]) - costCenterHash[ticket.cost_center] = Dinero(); + if (!costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]]) + costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]] = + Dinero(); - costCenterHash[ticket.cost_center] = - costCenterHash[ticket.cost_center].add(TicketTotal); + costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]] = + costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]].add( + TicketTotal + ); }); if (!hasMapaLine && job.job_totals.rates.mapa.total.amount > 0) { // console.log("Adding MAPA Line Manually."); - const mapaAccountName = - bodyshop.md_responsibility_centers.defaults.profits.MAPA; + const mapaAccountName = selectedDmsAllocationConfig.profits.MAPA; const mapaAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === mapaAccountName @@ -167,8 +184,7 @@ exports.default = async function (socket, jobid) { if (!hasMashLine && job.job_totals.rates.mash.total.amount > 0) { // console.log("Adding MASH Line Manually."); - const mashAccountName = - bodyshop.md_responsibility_centers.defaults.profits.MASH; + const mashAccountName = selectedDmsAllocationConfig.profits.MASH; const mashAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === mashAccountName @@ -198,7 +214,7 @@ exports.default = async function (socket, jobid) { if (job.towing_payable && job.towing_payable !== 0) { const towAccountName = - bodyshop.md_responsibility_centers.defaults.profits.TOW; + selectedDmsAllocationConfig.profits.TOW; const towAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === towAccountName @@ -219,7 +235,7 @@ exports.default = async function (socket, jobid) { } if (job.storage_payable && job.storage_payable !== 0) { const storageAccountName = - bodyshop.md_responsibility_centers.defaults.profits.TOW; + selectedDmsAllocationConfig.profits.TOW; const towAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === storageAccountName @@ -243,7 +259,7 @@ exports.default = async function (socket, jobid) { if (job.adjustment_bottom_line && job.adjustment_bottom_line !== 0) { const otherAccountName = - bodyshop.md_responsibility_centers.defaults.profits.PAO; + selectedDmsAllocationConfig.profits.PAO; const otherAccount = bodyshop.md_responsibility_centers.profits.find( (c) => c.name === otherAccountName diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 580ca169c..fd30f7242 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -253,6 +253,7 @@ query QUERY_JOBS_FOR_PBS_EXPORT($id: uuid!) { ro_number clm_total clm_no + dms_allocation invoice_allocation ownerid ownr_ln @@ -1200,6 +1201,7 @@ exports.GET_CDK_ALLOCATIONS = `query QUERY_JOB_CLOSE_DETAILS($id: uuid!) { cdk_configuration } ro_number + dms_allocation invoice_allocation ins_co_id id @@ -1261,6 +1263,7 @@ exports.GET_CDK_ALLOCATIONS = `query QUERY_JOB_CLOSE_DETAILS($id: uuid!) { cost_center productivehrs rate + ciecacode employee { flat_rate } From 8d3c2f7af6db665a293798bcf89b5ab7c09dc98a Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 2 Dec 2021 13:11:23 -0800 Subject: [PATCH 12/18] IO-233 CDK Updates. --- .../bill-enter-modal/bill-enter-modal.container.jsx | 5 ++++- .../src/components/bill-form/bill-form.lines.component.jsx | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx index e617cf3b5..d7adeb4fe 100644 --- a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx +++ b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx @@ -251,7 +251,10 @@ function BillEnterModalContainer({ keyboard="false" onOk={() => form.submit()} onCancel={handleCancel} - afterClose={() => form.resetFields()} + afterClose={() => { + form.resetFields(); + setLoading(false); + }} footer={ diff --git a/client/src/components/bill-form/bill-form.lines.component.jsx b/client/src/components/bill-form/bill-form.lines.component.jsx index 29bd6cbc7..3f78412cd 100644 --- a/client/src/components/bill-form/bill-form.lines.component.jsx +++ b/client/src/components/bill-form/bill-form.lines.component.jsx @@ -7,14 +7,14 @@ import { Select, Space, Switch, - Table, + Table } 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 CiecaSelect, { GetPartTypeName } from "../../utils/Ciecaselect"; +import CiecaSelect from "../../utils/Ciecaselect"; import BillLineSearchSelect from "../bill-line-search-select/bill-line-search-select.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; @@ -74,7 +74,7 @@ export function BillEnterModalLinesComponent({ actual_price: opt.cost, cost_center: opt.part_type ? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid - ? GetPartTypeName(opt.part_type) + ? opt.part_type : responsibilityCenters.defaults && (responsibilityCenters.defaults.costs[ opt.part_type From a5aee28d420bd23d03e72af30814db4e1e1d92e4 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 2 Dec 2021 15:51:21 -0800 Subject: [PATCH 13/18] 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 14/18] 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 15/18] 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} /> -
- - - - - - } - > - - - +
+
+ + + + + + } + > + + + + ); From 5125b207216e66f23ecdfcc77e2f7eb5de33a996 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 3 Dec 2021 11:17:07 -0800 Subject: [PATCH 16/18] IO-233 Update CDK URLs. --- server/cdk/cdk-wsdl.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/cdk/cdk-wsdl.js b/server/cdk/cdk-wsdl.js index 0cdb862b9..fedf33a9a 100644 --- a/server/cdk/cdk-wsdl.js +++ b/server/cdk/cdk-wsdl.js @@ -15,10 +15,10 @@ const CDK_CREDENTIALS = { }; exports.CDK_CREDENTIALS = CDK_CREDENTIALS; -// const cdkDomain = -// process.env.NODE_ENV === "production" -// ? "https://3pa.dmotorworks.com" -// : "https://uat-3pa.dmotorworks.com"; +const cdkDomain = + process.env.NODE_ENV === "production" + ? "https://3pa.dmotorworks.com" + : "https://uat-3pa.dmotorworks.com"; function CheckCdkResponseForError(socket, soapResponse) { if (!soapResponse[0]) { @@ -75,7 +75,7 @@ function checkIndividualResult(socket, ResultToCheck) { exports.checkIndividualResult = checkIndividualResult; -const cdkDomain = "https://uat-3pa.dmotorworks.com"; +//const cdkDomain = "https://uat-3pa.dmotorworks.com"; exports.default = { // VehicleSearch: `${cdkDomain}/pip-vehicle/services/VehicleSearch?wsdl`, HelpDataBase: `${cdkDomain}/pip-help-database-location/services/HelpDatabaseLocation?wsdl`, From cdbcef323f348a292bed2cfa8a4e686b23ae94cf Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 3 Dec 2021 13:57:48 -0800 Subject: [PATCH 17/18] IO-233 Update Receive Bills --- .../parts-order-list-table/parts-order-list-table.component.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index cb9625452..c4f8d0317 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -169,7 +169,7 @@ export function PartsOrderListTableComponent({ cost_center: pol.jobline?.part_type ? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid - ? GetPartTypeName(pol.jobline.part_type) + ? pol.jobline.part_type : responsibilityCenters.defaults && (responsibilityCenters.defaults.costs[ pol.jobline.part_type From 551839553340ca98cf2bdb5fee8188829a28ead0 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 3 Dec 2021 14:05:17 -0800 Subject: [PATCH 18/18] Resolve CI. --- .../parts-order-list-table.component.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index c4f8d0317..2a2701d6e 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -10,7 +10,7 @@ import { PageHeader, Popconfirm, Space, - Table, + Table } from "antd"; import queryString from "query-string"; import React, { useState } from "react"; @@ -23,7 +23,6 @@ import { DELETE_PARTS_ORDER } from "../../graphql/parts-orders.queries"; import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { setModalContext } from "../../redux/modals/modals.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; -import { GetPartTypeName } from "../../utils/Ciecaselect"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { DateFormatter } from "../../utils/DateFormatter"; import { alphaSort } from "../../utils/sorters";