Merged in development (pull request #40)

IO-785 IO-787 IO-788 IO-791 IO-789
This commit is contained in:
Patrick Fic
2021-03-22 04:09:52 +00:00
11 changed files with 100 additions and 78 deletions

View File

@@ -2076,6 +2076,27 @@
</translation>
</translations>
</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>
<name>discrepancy</name>
<definition_loaded>false</definition_loaded>

View File

@@ -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 (
<RbacWrapper action="bills:delete" noauth={<></>}>
<Button disabled={bill.exported} onClick={handleDelete} loading={loading}>
{t("general.actions.delete")}
</Button>
<Popconfirm
disabled={bill.exported}
onConfirm={handleDelete}
title={t("bills.labels.deleteconfirm")}
>
<Button
disabled={bill.exported}
// onClick={handleDelete}
loading={loading}
>
{t("general.actions.delete")}
</Button>
</Popconfirm>
</RbacWrapper>
);
}

View File

@@ -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,
},

View File

@@ -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) => (
<JobLinesBillRefernece
jobline={record}
loading={billLinesLoading}
error={billLinesError}
billLinesObject={billLinesDataObj}
/>
),
render: (text, record) => <JobLinesBillRefernece jobline={record} />,
},
{
title: t("joblines.fields.status"),
@@ -302,7 +294,7 @@ export function JobLinesComponent({
render: (text, record) => (
<div>
{record.manual_line && (
<Space >
<Space>
<Button
disabled={jobRO}
onClick={() => {
@@ -406,6 +398,9 @@ export function JobLinesComponent({
linesToOrder: selectedLines,
},
});
//Clear out the selected lines. IO-785
setSelectedLines([]);
}}
>
{t("parts.actions.order")}

View File

@@ -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 (
<div>
<Spin size="small" className="loading-spinner" />
</div>
);
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 <AlertComponent message={error.message} type="error" />;
return (
<div>{`${(billLine.actual_price * billLine.quantity).toFixed(2)} (${
billLine.bill.vendor.name

View File

@@ -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
}
}
}
}
`;

View File

@@ -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 }
}
}

View File

@@ -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 {

View File

@@ -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.",

View File

@@ -142,6 +142,7 @@
"billcmtotal": "",
"bills": "",
"dedfromlbr": "",
"deleteconfirm": "",
"discrepancy": "",
"discrepwithcms": "",
"discrepwithlbradj": "",

View File

@@ -142,6 +142,7 @@
"billcmtotal": "",
"bills": "",
"dedfromlbr": "",
"deleteconfirm": "",
"discrepancy": "",
"discrepwithcms": "",
"discrepwithlbradj": "",