Merged in feature/IO-2762-Return-From-Bill-Reference (pull request #1435)

IO-2762 Return from Bill Reference in Parts Return Drawer

Approved-by: Dave Richer
This commit is contained in:
Allan Carr
2024-04-23 17:39:27 +00:00
committed by Dave Richer
5 changed files with 41 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import { DeleteFilled, EyeFilled, SyncOutlined } from "@ant-design/icons";
import { useMutation } from "@apollo/client";
import { useLazyQuery, useMutation } from "@apollo/client";
import {
Button,
Card,
@@ -13,20 +13,21 @@ import {
Table,
} from "antd";
import queryString from "query-string";
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { useLocation } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { QUERY_BILL_BY_PK } from "../../graphql/bills.queries";
import { DELETE_PARTS_ORDER } from "../../graphql/parts-orders.queries";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { DateFormatter } from "../../utils/DateFormatter";
import { alphaSort } from "../../utils/sorters";
import { TemplateList } from "../../utils/TemplateConstants";
import { alphaSort } from "../../utils/sorters";
import DataLabel from "../data-label/data-label.component";
import PartsOrderBackorderEta from "../parts-order-backorder-eta/parts-order-backorder-eta.component";
import PartsOrderCmReceived from "../parts-order-cm-received/parts-order-cm-received.component";
@@ -78,19 +79,46 @@ export function PartsOrderListTableComponent({
const [state, setState] = useState({
sortedInfo: {},
});
const [returnfrombill, setReturnFromBill] = useState();
const [billData, setBillData] = useState();
const search = queryString.parse(useLocation().search);
const selectedpartsorder = search.partsorderid;
const [searchText, setSearchText] = useState("");
const [billQuery] = useLazyQuery(QUERY_BILL_BY_PK);
const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER);
const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : [];
const { refetch } = billsQuery;
useEffect(() => {
if (returnfrombill === null) {
setBillData(null);
} else {
const fetchData = async () => {
const result = await billQuery({
variables: { billid: returnfrombill },
});
setBillData(result.data);
};
fetchData();
}
}, [returnfrombill, billQuery]);
const recordActions = (record, showView = false) => (
<Space wrap>
{showView && (
<Button onClick={() => handleOnRowClick(record)}>
<Button
onClick={() => {
if (record.returnfrombill) {
setReturnFromBill(record.returnfrombill);
} else {
setReturnFromBill(null);
}
handleOnRowClick(record);
}}
>
<EyeFilled />
</Button>
)}
@@ -417,7 +445,11 @@ export function PartsOrderListTableComponent({
return (
<div>
<PageHeader
title={record && `${record.vendor.name} - ${record.order_number}`}
title={
billData
? `${record.vendor.name} - ${record.order_number} - ${t("bills.labels.returnfrombill")}: ${billData.bills_by_pk.invoice_number}`
: `${record.vendor.name} - ${record.order_number}`
}
extra={recordActions(record)}
/>
<Table

View File

@@ -73,6 +73,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
order_date
deliver_by
return
returnfrombill
orderedby
parts_order_lines {
id

View File

@@ -222,6 +222,7 @@
"onlycmforinvoiced": "Only credit memos can be entered for any Job that has been invoiced, exported, or voided.",
"printlabels": "Print Labels",
"retailtotal": "Bills Retail Total",
"returnfrombill": "Return From Bill",
"savewithdiscrepancy": "You are about to save this bill with a discrepancy. The system will continue to use the calculated amount using the bill lines. Press cancel to return to the bill.",
"state_tax": "Provincial/State Tax",
"subtotal": "Subtotal",

View File

@@ -221,6 +221,7 @@
"onlycmforinvoiced": "",
"printlabels": "",
"retailtotal": "",
"returnfrombill": "",
"savewithdiscrepancy": "",
"state_tax": "",
"subtotal": "",

View File

@@ -221,6 +221,7 @@
"onlycmforinvoiced": "",
"printlabels": "",
"retailtotal": "",
"returnfrombill": "",
"savewithdiscrepancy": "",
"state_tax": "",
"subtotal": "",