From d73f37cacc62b3247a39b463004298fb7ab6e6fc Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 20 Sep 2021 17:22:13 -0700 Subject: [PATCH] IO-952 add confirm to bill enter with discrepancy. --- bodyshop_translations.babel | 21 +++++++++++++++++++ .../bill-enter-modal.container.jsx | 9 ++++++++ .../jobs-available-table.container.jsx | 9 +------- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + client/src/utils/asyncConfirm.js | 9 ++++++++ 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 client/src/utils/asyncConfirm.js diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 34708fb9b..189eb825b 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -2779,6 +2779,27 @@ + + savewithdiscrepancy + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + state_tax 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 8e6081232..83ff2a7b2 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 @@ -18,8 +18,10 @@ import { selectBodyshop, selectCurrentUser, } from "../../redux/user/user.selectors"; +import confirmDialog from "../../utils/asyncConfirm"; import AuditTrailMapping from "../../utils/AuditTrailMappings"; 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"; const mapStateToProps = createStructuredSelector({ @@ -66,6 +68,13 @@ function BillEnterModalContainer({ }, [billEnterModal, bodyshop]); const handleFinish = async (values) => { + let totals = CalculateBillTotal(values); + if (totals.discrepancy.getAmount() !== 0) { + if (!(await confirmDialog(t("bills.labels.savewithdiscrepancy")))) { + return; + } + } + setLoading(true); const { upload, location, ...remainingValues } = values; diff --git a/client/src/components/jobs-available-table/jobs-available-table.container.jsx b/client/src/components/jobs-available-table/jobs-available-table.container.jsx index d77d5c1d3..b4758f361 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.container.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.container.jsx @@ -29,6 +29,7 @@ import { selectBodyshop, selectCurrentUser, } from "../../redux/user/user.selectors"; +import confirmDialog from "../../utils/asyncConfirm"; import AuditTrailMapping from "../../utils/AuditTrailMappings"; import AlertComponent from "../alert/alert.component"; import JobsAvailableScan from "../jobs-available-scan/jobs-available-scan.component"; @@ -394,14 +395,6 @@ function replaceEmpty(someObj, replaceValue = null) { return JSON.parse(temp); } -function confirmDialog(msg) { - return new Promise(function (resolve, reject) { - let confirmed = window.confirm(msg); - - return confirmed ? resolve(true) : resolve(false); - }); -} - async function CheckTaxRates(estData, bodyshop) { //LKQ Check if ( diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index caa7e7ab0..be00088c6 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -179,6 +179,7 @@ "noneselected": "No bill selected.", "onlycmforinvoiced": "Only credit memos can be entered for any job that has been invoiced, exported, or voided.", "retailtotal": "Bills Retail Total", + "savewithdiscrepancy": "You are about to save this bill with a discrepancy. The system will continue to use the calculated amount using the bill lines. Press cancel to return to the bill.", "state_tax": "Provincial/State Tax", "subtotal": "Subtotal", "totalreturns": "Total Returns" diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 97e443b4c..41c153e0e 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -179,6 +179,7 @@ "noneselected": "", "onlycmforinvoiced": "", "retailtotal": "", + "savewithdiscrepancy": "", "state_tax": "", "subtotal": "", "totalreturns": "" diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 084513b82..e6df8c7cc 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -179,6 +179,7 @@ "noneselected": "", "onlycmforinvoiced": "", "retailtotal": "", + "savewithdiscrepancy": "", "state_tax": "", "subtotal": "", "totalreturns": "" diff --git a/client/src/utils/asyncConfirm.js b/client/src/utils/asyncConfirm.js new file mode 100644 index 000000000..3969dda96 --- /dev/null +++ b/client/src/utils/asyncConfirm.js @@ -0,0 +1,9 @@ +function confirmDialog(msg) { + return new Promise(function (resolve, reject) { + let confirmed = window.confirm(msg); + + return confirmed ? resolve(true) : resolve(false); + }); +} + +export default confirmDialog;