diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 67c7f628d..2a7523483 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1338,7 +1338,7 @@ labels - deductfromlabor + deductedfromlbr false @@ -2160,6 +2160,27 @@ + + editadjwarning + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + entered_total false diff --git a/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx b/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx index 8d764bb5e..4d5316370 100644 --- a/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx +++ b/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx @@ -1,5 +1,5 @@ import { useMutation, useQuery } from "@apollo/client"; -import { Button, Form } from "antd"; +import { Button, Form, Popconfirm } from "antd"; import moment from "moment"; import queryString from "query-string"; import React, { useEffect, useState } from "react"; @@ -19,6 +19,7 @@ export default function BillDetailEditcontainer() { const search = queryString.parse(useLocation().search); const { t } = useTranslation(); const [form] = Form.useForm(); + const [visible, setVisible] = useState(false); const [updateLoading, setUpdateLoading] = useState(false); const [update_bill] = useMutation(UPDATE_BILL); const [insertBillLine] = useMutation(INSERT_NEW_BILL_LINES); @@ -29,6 +30,15 @@ export default function BillDetailEditcontainer() { skip: !!!search.billid, }); + const handleSave = () => { + //It's got a previously deducted bill line! + if (data.bills_by_pk.billlines.filter((b) => b.deductedfromlbr).length > 0) + setVisible(true); + else { + form.submit(); + } + }; + const handleFinish = async (values) => { setUpdateLoading(true); //let adjustmentsToInsert = {}; @@ -42,7 +52,7 @@ export default function BillDetailEditcontainer() { ); billlines.forEach((billline) => { - const { deductfromlabor, ...il } = billline; + const { deductedfromlbr, ...il } = billline; delete il.__typename; //Need to compare this line to the previous version of the line to see if there is a change in the adjustments. @@ -52,7 +62,7 @@ export default function BillDetailEditcontainer() { if (theOldBillLine) { //It was there! Need to change the diff. - if (theOldBillLine.deductfromlabor !== deductfromlabor) { + if (theOldBillLine.deductedfromlbr !== deductedfromlbr) { //There's a different } } @@ -64,7 +74,7 @@ export default function BillDetailEditcontainer() { billLineId: il.id, billLine: { ...il, - deductedfromlbr: deductfromlabor, + deductedfromlbr: deductedfromlbr, joblineid: il.joblineid === "noline" ? null : il.joblineid, }, }, @@ -78,7 +88,7 @@ export default function BillDetailEditcontainer() { billLines: [ { ...il, - deductedfromlbr: deductfromlabor, + deductedfromlbr: deductedfromlbr, billid: search.billid, joblineid: il.joblineid === "noline" ? null : il.joblineid, }, @@ -93,6 +103,7 @@ export default function BillDetailEditcontainer() { await refetch(); form.resetFields(); form.resetFields(); + setVisible(false); setUpdateLoading(false); }; @@ -109,19 +120,28 @@ export default function BillDetailEditcontainer() { return ( -
form.submit()} + onCancel={() => setVisible(false)} + okButtonProps={{ loading: updateLoading }} + title={t("bills.labels.editadjwarning")} > + + { const { - deductfromlabor, + deductedfromlbr, lbr_adjustment, location: lineLocation, ...restI } = i; - if (deductfromlabor) { + if (deductedfromlbr) { adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] = (adjustmentsToInsert[lbr_adjustment.mod_lbr_ty] || 0) - restI.actual_price / lbr_adjustment.rate; } return { ...restI, - deductedfromlbr: deductfromlabor, + deductedfromlbr: deductedfromlbr, joblineid: i.joblineid === "noline" ? null : i.joblineid, }; }), 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 769c17d81..276612e8e 100644 --- a/client/src/components/bill-form/bill-form.lines.component.jsx +++ b/client/src/components/bill-form/bill-form.lines.component.jsx @@ -248,19 +248,19 @@ export function BillEnterModalLinesComponent({ prev.billlines[index] && - prev.billlines[index].deductfromlabor !== + prev.billlines[index].deductedfromlbr !== cur.billlines[index] && - cur.billlines[index].deductfromlabor + cur.billlines[index].deductedfromlbr } > {() => { @@ -268,7 +268,7 @@ export function BillEnterModalLinesComponent({ getFieldValue([ "billlines", field.name, - "deductfromlabor", + "deductedfromlbr", ]) ) return ( diff --git a/client/src/components/jobs-detail-rates/jobs-detail-rates.parts.component.jsx b/client/src/components/jobs-detail-rates/jobs-detail-rates.parts.component.jsx index 46d4d1be7..62d7e6202 100644 --- a/client/src/components/jobs-detail-rates/jobs-detail-rates.parts.component.jsx +++ b/client/src/components/jobs-detail-rates/jobs-detail-rates.parts.component.jsx @@ -136,6 +136,46 @@ export function JobsDetailRatesParts({ jobRO, expanded, required = true }) { + + + + + + + + + + + + + + + + +