diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 81ac10113..74c41de5e 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -2076,6 +2076,27 @@ + + deleteconfirm + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + discrepancy false diff --git a/client/src/components/bill-delete-button/bill-delete-button.component.jsx b/client/src/components/bill-delete-button/bill-delete-button.component.jsx index 4629c29c3..723f6e4ca 100644 --- a/client/src/components/bill-delete-button/bill-delete-button.component.jsx +++ b/client/src/components/bill-delete-button/bill-delete-button.component.jsx @@ -1,5 +1,5 @@ import { useMutation } from "@apollo/client"; -import { Button, notification } from "antd"; +import { Button, notification, Popconfirm } from "antd"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { DELETE_BILL } from "../../graphql/bills.queries"; @@ -47,9 +47,19 @@ export default function BillDeleteButton({ bill }) { return ( >}> - - {t("general.actions.delete")} - + + + {t("general.actions.delete")} + + ); } 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 bf4467758..8d764bb5e 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 @@ -31,6 +31,8 @@ export default function BillDetailEditcontainer() { const handleFinish = async (values) => { setUpdateLoading(true); + //let adjustmentsToInsert = {}; + const { billlines, upload, ...bill } = values; const updates = []; updates.push( @@ -39,8 +41,22 @@ export default function BillDetailEditcontainer() { }) ); - billlines.forEach((il) => { + billlines.forEach((billline) => { + const { deductfromlabor, ...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. + const theOldBillLine = data.bills_by_pk.billlines.find( + (bl) => bl.id === billline.id + ); + + if (theOldBillLine) { + //It was there! Need to change the diff. + if (theOldBillLine.deductfromlabor !== deductfromlabor) { + //There's a different + } + } + if (il.id) { updates.push( updateBillLine({ @@ -48,6 +64,7 @@ export default function BillDetailEditcontainer() { billLineId: il.id, billLine: { ...il, + deductedfromlbr: deductfromlabor, joblineid: il.joblineid === "noline" ? null : il.joblineid, }, }, @@ -61,6 +78,7 @@ export default function BillDetailEditcontainer() { billLines: [ { ...il, + deductedfromlbr: deductfromlabor, billid: search.billid, joblineid: il.joblineid === "noline" ? null : il.joblineid, }, diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index b5ef60cd8..211ebb909 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -1,11 +1,10 @@ import { DeleteFilled, FilterFilled, SyncOutlined } from "@ant-design/icons"; -import { useMutation, useQuery } from "@apollo/client"; +import { useMutation } from "@apollo/client"; import { Button, Dropdown, Input, Menu, Space, Table } from "antd"; -import React, { useMemo, useState } from "react"; +import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; -import { QUERY_BILLS_BY_JOB_REF } from "../../graphql/bill-lines.queries"; import { DELETE_JOB_LINE_BY_PK } from "../../graphql/jobs-lines.queries"; import { selectJobReadOnly } from "../../redux/application/application.selectors"; import { setModalContext } from "../../redux/modals/modals.actions"; @@ -48,26 +47,26 @@ export function JobLinesComponent({ }) { const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK); - const { - loading: billLinesLoading, - error: billLinesError, - data: billLinesData, - } = useQuery(QUERY_BILLS_BY_JOB_REF, { - variables: { jobId: job && job.id }, - skip: loading || !job, - }); + // const { + // loading: billLinesLoading, + // error: billLinesError, + // data: billLinesData, + // } = useQuery(QUERY_BILLS_BY_JOB_REF, { + // variables: { jobId: job && job.id }, + // skip: loading || !job, + // }); - const billLinesDataObj = useMemo(() => { - if (!billLinesData) return {}; - const ret = {}; - billLinesData.billlines.map((b) => { - if (b.joblineid) { - ret[b.joblineid] = { ...b, total: b.actual_price * b.quantity }; - } - return null; - }); - return ret; - }, [billLinesData]); + // const billLinesDataObj = useMemo(() => { + // if (!billLinesData) return {}; + // const ret = {}; + // billLinesData.billlines.map((b) => { + // if (b.joblineid) { + // ret[b.joblineid] = { ...b, total: b.actual_price * b.quantity }; + // } + // return null; + // }); + // return ret; + // }, [billLinesData]); const [state, setState] = useState({ sortedInfo: {}, @@ -231,14 +230,7 @@ export function JobLinesComponent({ title: t("joblines.labels.billref"), dataIndex: "billref", key: "billref", - render: (text, record) => ( - - ), + render: (text, record) => , }, { title: t("joblines.fields.status"), @@ -302,7 +294,7 @@ export function JobLinesComponent({ render: (text, record) => ( {record.manual_line && ( - + { @@ -406,6 +398,9 @@ export function JobLinesComponent({ linesToOrder: selectedLines, }, }); + + //Clear out the selected lines. IO-785 + setSelectedLines([]); }} > {t("parts.actions.order")} diff --git a/client/src/components/job-lines-bill-reference/job-lines-bill-reference.component.jsx b/client/src/components/job-lines-bill-reference/job-lines-bill-reference.component.jsx index fee230c89..02cfb7e73 100644 --- a/client/src/components/job-lines-bill-reference/job-lines-bill-reference.component.jsx +++ b/client/src/components/job-lines-bill-reference/job-lines-bill-reference.component.jsx @@ -1,26 +1,10 @@ -import { Spin } from "antd"; import React from "react"; -import AlertComponent from "../alert/alert.component"; -export default function JobLinesBillRefernece({ - jobline, - loading, - error, - billLinesObject, -}) { - if (loading) - return ( - - - - ); - if (!billLinesObject) return null; +export default function JobLinesBillRefernece({ jobline }) { + const billLine = jobline.billlines && jobline.billlines[0]; - const billLine = billLinesObject[jobline.id]; if (!billLine) return null; - if (error) return ; - return ( {`${(billLine.actual_price * billLine.quantity).toFixed(2)} (${ billLine.bill.vendor.name diff --git a/client/src/graphql/bill-lines.queries.js b/client/src/graphql/bill-lines.queries.js index 86c4ac943..1b49812c7 100644 --- a/client/src/graphql/bill-lines.queries.js +++ b/client/src/graphql/bill-lines.queries.js @@ -22,26 +22,3 @@ export const INSERT_NEW_BILL_LINES = gql` } } `; - -export const QUERY_BILLS_BY_JOB_REF = gql` - query QUERY_BILLS_BY_JOB_REF($jobId: uuid!) { - billlines( - where: { bill: { jobid: { _eq: $jobId } } } - limit: 1 - order_by: { bill: { date: desc } } - ) { - id - quantity - actual_cost - actual_price - joblineid - bill { - id - vendor { - id - name - } - } - } - } -`; diff --git a/client/src/graphql/bills.queries.js b/client/src/graphql/bills.queries.js index 3165354bb..348abaac0 100644 --- a/client/src/graphql/bills.queries.js +++ b/client/src/graphql/bills.queries.js @@ -206,7 +206,7 @@ export const CHECK_BILL_INVOICE_NUMBER = gql` bills_aggregate( where: { _and: { - invoice_number: { _eq: $invoice_number } + invoice_number: { _ilike: $invoice_number } vendorid: { _eq: $vendorid } } } diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index a5ba0086d..f7b6b8730 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -521,6 +521,20 @@ export const GET_JOB_BY_PK = gql` tax_part db_ref manual_line + billlines(limit: 1, order_by: { bill: { date: desc } }) { + id + quantity + actual_cost + actual_price + joblineid + bill { + id + vendor { + id + name + } + } + } parts_order_lines { id parts_order { diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index eb2c10880..f1b5f4069 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -142,6 +142,7 @@ "billcmtotal": "Retail Total of Credit Memos", "bills": "Bills", "dedfromlbr": "Deducted from Labor", + "deleteconfirm": "Are you sure you want to delete this bill? It cannot be undone.", "discrepancy": "Discrepancy", "discrepwithcms": "Discrepancy including Credit Memos", "discrepwithlbradj": "Discrepancy including Lbr. Adj.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index f23591572..7b9b58d0f 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -142,6 +142,7 @@ "billcmtotal": "", "bills": "", "dedfromlbr": "", + "deleteconfirm": "", "discrepancy": "", "discrepwithcms": "", "discrepwithlbradj": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 33ea8081a..fc223467f 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -142,6 +142,7 @@ "billcmtotal": "", "bills": "", "dedfromlbr": "", + "deleteconfirm": "", "discrepancy": "", "discrepwithcms": "", "discrepwithlbradj": "",