From 3da0f131d20651dddd343b192c3b87bbcbbd74f7 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 19 Mar 2021 11:07:43 -0700 Subject: [PATCH 1/5] IO-785 Unmark joblines on order. --- .../src/components/job-detail-lines/job-lines.component.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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..382f6da86 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -302,7 +302,7 @@ export function JobLinesComponent({ render: (text, record) => (
{record.manual_line && ( - + + + + ); } 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": "", From f07eddb38ee7d53a20e7c85a9c001e8525b7f41c Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 19 Mar 2021 11:23:42 -0700 Subject: [PATCH 3/5] IO-788 Insensitive invoice query. --- client/src/graphql/bills.queries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } } } From 4fec7cf1867c191f13bd444113b5014b27859b85 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 19 Mar 2021 12:04:34 -0700 Subject: [PATCH 4/5] IO-791 Bill edit deduct from labor WIP. --- .../bill-detail-edit.container.jsx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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, }, From 613ab4c540acb185599a6ff1029e40082cbc9f52 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 19 Mar 2021 15:36:18 -0700 Subject: [PATCH 5/5] IO-789 Adjust main job query to pull bill data. --- .../job-detail-lines/job-lines.component.jsx | 52 ++++++++----------- .../job-lines-bill-reference.component.jsx | 20 +------ client/src/graphql/bill-lines.queries.js | 23 -------- client/src/graphql/jobs.queries.js | 14 +++++ 4 files changed, 38 insertions(+), 71 deletions(-) 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 382f6da86..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"), 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/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 {