IO-2887 Returnfrombill Parts Drawer Info
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import { DeleteFilled, EyeFilled } from "@ant-design/icons";
|
import { DeleteFilled } from "@ant-design/icons";
|
||||||
import { PageHeader } from "@ant-design/pro-layout";
|
import { PageHeader } from "@ant-design/pro-layout";
|
||||||
import { useLazyQuery, useMutation } from "@apollo/client";
|
import { useLazyQuery, useMutation } from "@apollo/client";
|
||||||
import { Button, Drawer, Grid, Popconfirm, Space, Table } from "antd";
|
import { Button, Drawer, Grid, Popconfirm, Space, Table } from "antd";
|
||||||
|
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -83,47 +82,34 @@ export function PartsOrderListTableDrawerComponent({
|
|||||||
sortedInfo: {}
|
sortedInfo: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
const [returnfrombill, setReturnFromBill] = useState();
|
const [billData, setBillData] = useState(null);
|
||||||
const [billData, setBillData] = useState();
|
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const selectedpartsorder = search.partsorderid;
|
const selectedpartsorder = search.partsorderid;
|
||||||
|
|
||||||
const [billQuery] = useLazyQuery(QUERY_BILL_BY_PK);
|
|
||||||
const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER);
|
const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER);
|
||||||
const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : [];
|
const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : [];
|
||||||
const { refetch } = billsQuery;
|
const { refetch } = billsQuery;
|
||||||
|
const [billQuery] = useLazyQuery(QUERY_BILL_BY_PK);
|
||||||
|
const selectedPartsOrderRecord = parts_orders.find((r) => r.id === selectedpartsorder);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (returnfrombill === null) {
|
const fetchData = async () => {
|
||||||
setBillData(null);
|
if (selectedPartsOrderRecord?.returnfrombill) {
|
||||||
} else {
|
try {
|
||||||
const fetchData = async () => {
|
const { data } = await billQuery({
|
||||||
const result = await billQuery({
|
variables: { billid: selectedPartsOrderRecord.returnfrombill }
|
||||||
variables: { billid: returnfrombill }
|
});
|
||||||
});
|
setBillData(data);
|
||||||
setBillData(result.data);
|
} catch (error) {
|
||||||
};
|
console.error("Error fetching bill data:", error);
|
||||||
fetchData();
|
}
|
||||||
}
|
}
|
||||||
}, [returnfrombill, billQuery]);
|
};
|
||||||
|
fetchData();
|
||||||
|
}, [selectedPartsOrderRecord, billQuery]);
|
||||||
|
|
||||||
const recordActions = (record, showView = false) => (
|
const recordActions = (record) => (
|
||||||
<Space direction="horizontal" wrap>
|
<Space direction="horizontal" wrap>
|
||||||
{showView && (
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
if (record.returnfrombill) {
|
|
||||||
setReturnFromBill(record.returnfrombill);
|
|
||||||
} else {
|
|
||||||
setReturnFromBill(null);
|
|
||||||
}
|
|
||||||
handleOnRowClick(record);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<EyeFilled />
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
disabled={jobRO || record.return || record.vendor.id === bodyshop.inhousevendorid}
|
disabled={jobRO || record.return || record.vendor.id === bodyshop.inhousevendorid}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -133,16 +119,14 @@ export function PartsOrderListTableDrawerComponent({
|
|||||||
context: {
|
context: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
job: job,
|
job: job,
|
||||||
partsorderlines: record.parts_order_lines.map((pol) => {
|
partsorderlines: record.parts_order_lines.map((pol) => ({
|
||||||
return {
|
joblineid: pol.job_line_id,
|
||||||
joblineid: pol.job_line_id,
|
id: pol.id,
|
||||||
id: pol.id,
|
line_desc: pol.line_desc,
|
||||||
line_desc: pol.line_desc,
|
quantity: pol.quantity,
|
||||||
quantity: pol.quantity,
|
act_price: pol.act_price,
|
||||||
act_price: pol.act_price,
|
oem_partno: pol.oem_partno
|
||||||
oem_partno: pol.oem_partno
|
}))
|
||||||
};
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -167,7 +151,6 @@ export function PartsOrderListTableDrawerComponent({
|
|||||||
disabled={jobRO}
|
disabled={jobRO}
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
//Delete the parts return.!
|
//Delete the parts return.!
|
||||||
|
|
||||||
await deletePartsOrder({
|
await deletePartsOrder({
|
||||||
variables: { partsOrderId: record.id },
|
variables: { partsOrderId: record.id },
|
||||||
update(cache) {
|
update(cache) {
|
||||||
@@ -191,7 +174,6 @@ export function PartsOrderListTableDrawerComponent({
|
|||||||
disabled={(jobRO ? !record.return : jobRO) || record.vendor.id === bodyshop.inhousevendorid}
|
disabled={(jobRO ? !record.return : jobRO) || record.vendor.id === bodyshop.inhousevendorid}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
logImEXEvent("parts_order_receive_bill");
|
logImEXEvent("parts_order_receive_bill");
|
||||||
|
|
||||||
setBillEnterContext({
|
setBillEnterContext({
|
||||||
actions: { refetch: refetch },
|
actions: { refetch: refetch },
|
||||||
context: {
|
context: {
|
||||||
@@ -199,24 +181,20 @@ export function PartsOrderListTableDrawerComponent({
|
|||||||
bill: {
|
bill: {
|
||||||
vendorid: record.vendor.id,
|
vendorid: record.vendor.id,
|
||||||
is_credit_memo: record.return,
|
is_credit_memo: record.return,
|
||||||
billlines: record.parts_order_lines.map((pol) => {
|
billlines: record.parts_order_lines.map((pol) => ({
|
||||||
return {
|
joblineid: pol.job_line_id || "noline",
|
||||||
joblineid: pol.job_line_id || "noline",
|
line_desc: pol.line_desc,
|
||||||
line_desc: pol.line_desc,
|
quantity: pol.quantity,
|
||||||
quantity: pol.quantity,
|
actual_price: pol.act_price,
|
||||||
|
cost_center: pol.jobline?.part_type
|
||||||
actual_price: pol.act_price,
|
? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid
|
||||||
|
? pol.jobline.part_type !== "PAE"
|
||||||
cost_center: pol.jobline?.part_type
|
? pol.jobline.part_type
|
||||||
? bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid
|
: null
|
||||||
? pol.jobline.part_type !== "PAE"
|
: responsibilityCenters.defaults &&
|
||||||
? pol.jobline.part_type
|
(responsibilityCenters.defaults.costs[pol.jobline.part_type] || null)
|
||||||
: null
|
: null
|
||||||
: responsibilityCenters.defaults &&
|
}))
|
||||||
(responsibilityCenters.defaults.costs[pol.jobline.part_type] || null)
|
|
||||||
: null
|
|
||||||
};
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -243,8 +221,6 @@ export function PartsOrderListTableDrawerComponent({
|
|||||||
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedPartsOrderRecord = parts_orders.find((r) => r.id === selectedpartsorder);
|
|
||||||
|
|
||||||
const rowExpander = (record) => {
|
const rowExpander = (record) => {
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user