Merged in development (pull request #40)
IO-785 IO-787 IO-788 IO-791 IO-789
This commit is contained in:
@@ -2076,6 +2076,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>deleteconfirm</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>discrepancy</name>
|
<name>discrepancy</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { Button, notification } from "antd";
|
import { Button, notification, Popconfirm } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DELETE_BILL } from "../../graphql/bills.queries";
|
import { DELETE_BILL } from "../../graphql/bills.queries";
|
||||||
@@ -47,9 +47,19 @@ export default function BillDeleteButton({ bill }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<RbacWrapper action="bills:delete" noauth={<></>}>
|
<RbacWrapper action="bills:delete" noauth={<></>}>
|
||||||
<Button disabled={bill.exported} onClick={handleDelete} loading={loading}>
|
<Popconfirm
|
||||||
{t("general.actions.delete")}
|
disabled={bill.exported}
|
||||||
</Button>
|
onConfirm={handleDelete}
|
||||||
|
title={t("bills.labels.deleteconfirm")}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
disabled={bill.exported}
|
||||||
|
// onClick={handleDelete}
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
|
{t("general.actions.delete")}
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
</RbacWrapper>
|
</RbacWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ export default function BillDetailEditcontainer() {
|
|||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
setUpdateLoading(true);
|
setUpdateLoading(true);
|
||||||
|
//let adjustmentsToInsert = {};
|
||||||
|
|
||||||
const { billlines, upload, ...bill } = values;
|
const { billlines, upload, ...bill } = values;
|
||||||
const updates = [];
|
const updates = [];
|
||||||
updates.push(
|
updates.push(
|
||||||
@@ -39,8 +41,22 @@ export default function BillDetailEditcontainer() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
billlines.forEach((il) => {
|
billlines.forEach((billline) => {
|
||||||
|
const { deductfromlabor, ...il } = billline;
|
||||||
delete il.__typename;
|
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) {
|
if (il.id) {
|
||||||
updates.push(
|
updates.push(
|
||||||
updateBillLine({
|
updateBillLine({
|
||||||
@@ -48,6 +64,7 @@ export default function BillDetailEditcontainer() {
|
|||||||
billLineId: il.id,
|
billLineId: il.id,
|
||||||
billLine: {
|
billLine: {
|
||||||
...il,
|
...il,
|
||||||
|
deductedfromlbr: deductfromlabor,
|
||||||
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -61,6 +78,7 @@ export default function BillDetailEditcontainer() {
|
|||||||
billLines: [
|
billLines: [
|
||||||
{
|
{
|
||||||
...il,
|
...il,
|
||||||
|
deductedfromlbr: deductfromlabor,
|
||||||
billid: search.billid,
|
billid: search.billid,
|
||||||
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { DeleteFilled, FilterFilled, SyncOutlined } from "@ant-design/icons";
|
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 { 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 { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
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 { DELETE_JOB_LINE_BY_PK } from "../../graphql/jobs-lines.queries";
|
||||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
@@ -48,26 +47,26 @@ export function JobLinesComponent({
|
|||||||
}) {
|
}) {
|
||||||
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
|
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
|
||||||
|
|
||||||
const {
|
// const {
|
||||||
loading: billLinesLoading,
|
// loading: billLinesLoading,
|
||||||
error: billLinesError,
|
// error: billLinesError,
|
||||||
data: billLinesData,
|
// data: billLinesData,
|
||||||
} = useQuery(QUERY_BILLS_BY_JOB_REF, {
|
// } = useQuery(QUERY_BILLS_BY_JOB_REF, {
|
||||||
variables: { jobId: job && job.id },
|
// variables: { jobId: job && job.id },
|
||||||
skip: loading || !job,
|
// skip: loading || !job,
|
||||||
});
|
// });
|
||||||
|
|
||||||
const billLinesDataObj = useMemo(() => {
|
// const billLinesDataObj = useMemo(() => {
|
||||||
if (!billLinesData) return {};
|
// if (!billLinesData) return {};
|
||||||
const ret = {};
|
// const ret = {};
|
||||||
billLinesData.billlines.map((b) => {
|
// billLinesData.billlines.map((b) => {
|
||||||
if (b.joblineid) {
|
// if (b.joblineid) {
|
||||||
ret[b.joblineid] = { ...b, total: b.actual_price * b.quantity };
|
// ret[b.joblineid] = { ...b, total: b.actual_price * b.quantity };
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
});
|
// });
|
||||||
return ret;
|
// return ret;
|
||||||
}, [billLinesData]);
|
// }, [billLinesData]);
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
sortedInfo: {},
|
sortedInfo: {},
|
||||||
@@ -231,14 +230,7 @@ export function JobLinesComponent({
|
|||||||
title: t("joblines.labels.billref"),
|
title: t("joblines.labels.billref"),
|
||||||
dataIndex: "billref",
|
dataIndex: "billref",
|
||||||
key: "billref",
|
key: "billref",
|
||||||
render: (text, record) => (
|
render: (text, record) => <JobLinesBillRefernece jobline={record} />,
|
||||||
<JobLinesBillRefernece
|
|
||||||
jobline={record}
|
|
||||||
loading={billLinesLoading}
|
|
||||||
error={billLinesError}
|
|
||||||
billLinesObject={billLinesDataObj}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("joblines.fields.status"),
|
title: t("joblines.fields.status"),
|
||||||
@@ -302,7 +294,7 @@ export function JobLinesComponent({
|
|||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<div>
|
<div>
|
||||||
{record.manual_line && (
|
{record.manual_line && (
|
||||||
<Space >
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
disabled={jobRO}
|
disabled={jobRO}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -406,6 +398,9 @@ export function JobLinesComponent({
|
|||||||
linesToOrder: selectedLines,
|
linesToOrder: selectedLines,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Clear out the selected lines. IO-785
|
||||||
|
setSelectedLines([]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("parts.actions.order")}
|
{t("parts.actions.order")}
|
||||||
|
|||||||
@@ -1,26 +1,10 @@
|
|||||||
import { Spin } from "antd";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import AlertComponent from "../alert/alert.component";
|
|
||||||
|
|
||||||
export default function JobLinesBillRefernece({
|
export default function JobLinesBillRefernece({ jobline }) {
|
||||||
jobline,
|
const billLine = jobline.billlines && jobline.billlines[0];
|
||||||
loading,
|
|
||||||
error,
|
|
||||||
billLinesObject,
|
|
||||||
}) {
|
|
||||||
if (loading)
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Spin size="small" className="loading-spinner" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
if (!billLinesObject) return null;
|
|
||||||
|
|
||||||
const billLine = billLinesObject[jobline.id];
|
|
||||||
if (!billLine) return null;
|
if (!billLine) return null;
|
||||||
|
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>{`${(billLine.actual_price * billLine.quantity).toFixed(2)} (${
|
<div>{`${(billLine.actual_price * billLine.quantity).toFixed(2)} (${
|
||||||
billLine.bill.vendor.name
|
billLine.bill.vendor.name
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ export const CHECK_BILL_INVOICE_NUMBER = gql`
|
|||||||
bills_aggregate(
|
bills_aggregate(
|
||||||
where: {
|
where: {
|
||||||
_and: {
|
_and: {
|
||||||
invoice_number: { _eq: $invoice_number }
|
invoice_number: { _ilike: $invoice_number }
|
||||||
vendorid: { _eq: $vendorid }
|
vendorid: { _eq: $vendorid }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -521,6 +521,20 @@ export const GET_JOB_BY_PK = gql`
|
|||||||
tax_part
|
tax_part
|
||||||
db_ref
|
db_ref
|
||||||
manual_line
|
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 {
|
parts_order_lines {
|
||||||
id
|
id
|
||||||
parts_order {
|
parts_order {
|
||||||
|
|||||||
@@ -142,6 +142,7 @@
|
|||||||
"billcmtotal": "Retail Total of Credit Memos",
|
"billcmtotal": "Retail Total of Credit Memos",
|
||||||
"bills": "Bills",
|
"bills": "Bills",
|
||||||
"dedfromlbr": "Deducted from Labor",
|
"dedfromlbr": "Deducted from Labor",
|
||||||
|
"deleteconfirm": "Are you sure you want to delete this bill? It cannot be undone.",
|
||||||
"discrepancy": "Discrepancy",
|
"discrepancy": "Discrepancy",
|
||||||
"discrepwithcms": "Discrepancy including Credit Memos",
|
"discrepwithcms": "Discrepancy including Credit Memos",
|
||||||
"discrepwithlbradj": "Discrepancy including Lbr. Adj.",
|
"discrepwithlbradj": "Discrepancy including Lbr. Adj.",
|
||||||
|
|||||||
@@ -142,6 +142,7 @@
|
|||||||
"billcmtotal": "",
|
"billcmtotal": "",
|
||||||
"bills": "",
|
"bills": "",
|
||||||
"dedfromlbr": "",
|
"dedfromlbr": "",
|
||||||
|
"deleteconfirm": "",
|
||||||
"discrepancy": "",
|
"discrepancy": "",
|
||||||
"discrepwithcms": "",
|
"discrepwithcms": "",
|
||||||
"discrepwithlbradj": "",
|
"discrepwithlbradj": "",
|
||||||
|
|||||||
@@ -142,6 +142,7 @@
|
|||||||
"billcmtotal": "",
|
"billcmtotal": "",
|
||||||
"bills": "",
|
"bills": "",
|
||||||
"dedfromlbr": "",
|
"dedfromlbr": "",
|
||||||
|
"deleteconfirm": "",
|
||||||
"discrepancy": "",
|
"discrepancy": "",
|
||||||
"discrepwithcms": "",
|
"discrepwithcms": "",
|
||||||
"discrepwithlbradj": "",
|
"discrepwithlbradj": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user