From ac6903edcbc44190d2116f0ae51b3cfdc502909a Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 17 Oct 2022 16:58:03 -0700 Subject: [PATCH] IO-2072 add parts label to bill posting screen. --- bodyshop_translations.babel | 42 +++++++++++++++++++ .../bill-enter-modal.container.jsx | 32 +++++++++++++- .../job-scoreboard-add-button.component.jsx | 7 ++++ client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + client/src/utils/TemplateConstants.js | 6 +++ 7 files changed, 91 insertions(+), 2 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 0b3b72468..b6274d250 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -3078,6 +3078,27 @@ + + generatepartslabel + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + iouexists false @@ -26210,6 +26231,27 @@ + + alreadyaddedtoscoreboard + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + alreadyclosed false 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 2200809ee..ca94a70b3 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 @@ -1,5 +1,5 @@ import { useApolloClient, useMutation } from "@apollo/client"; -import { Button, Form, Modal, notification, Space } from "antd"; +import { Button, Checkbox, Form, Modal, notification, Space } from "antd"; import _ from "lodash"; import React, { useEffect, useState, useMemo } from "react"; import { useTranslation } from "react-i18next"; @@ -26,6 +26,9 @@ import BillFormContainer from "../bill-form/bill-form.container"; import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility"; import { handleUpload } from "../documents-upload/documents-upload.utility"; import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility"; +import useLocalStorage from "../../utils/useLocalStorage"; +import { GenerateDocument } from "../../utils/RenderTemplate"; +import { TemplateList } from "../../utils/TemplateConstants"; const mapStateToProps = createStructuredSelector({ billEnterModal: selectBillEnterModal, @@ -38,6 +41,8 @@ const mapDispatchToProps = (dispatch) => ({ dispatch(insertAuditTrail({ jobid, operation })), }); +const Templates = TemplateList("job_special"); + function BillEnterModalContainer({ billEnterModal, toggleModalVisible, @@ -54,7 +59,10 @@ function BillEnterModalContainer({ const [updateInventoryLines] = useMutation(UPDATE_INVENTORY_LINES); const [loading, setLoading] = useState(false); const client = useApolloClient(); - + const [generateLabel, setGenerateLabel] = useLocalStorage( + "enter_bill_generate_label", + false + ); const formValues = useMemo(() => { return { ...billEnterModal.context.bill, @@ -275,6 +283,20 @@ function BillEnterModalContainer({ notification["success"]({ message: t("bills.successes.created"), }); + + if (generateLabel) { + GenerateDocument( + { + name: Templates.parts_invoice_label_single.key, + variables: { + id: billId, + }, + }, + {}, + "p" + ); + } + if (billEnterModal.actions.refetch) billEnterModal.actions.refetch(); insertAuditTrail({ @@ -330,6 +352,12 @@ function BillEnterModalContainer({ }} footer={ + setGenerateLabel(e.target.checked)} + > + {t("bills.labels.generatepartslabel")} +