|
|
@@ -20,6 +20,7 @@ import { QrCodeScannerOutlined } from "@mui/icons-material"; |
|
|
|
import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers"; |
|
|
|
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; |
|
|
|
import dayjs from "dayjs"; |
|
|
|
import { uniq } from "lodash"; |
|
|
|
|
|
|
|
interface Props { |
|
|
|
issuedInvoice: issuedInvoiceList[]; |
|
|
@@ -45,6 +46,7 @@ type SearchQuery2 = Partial<Omit<receivedInvoiceSearchForm, "id">>; |
|
|
|
type SearchParamNames2 = keyof SearchQuery2; |
|
|
|
|
|
|
|
const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoices }) => { |
|
|
|
console.log(invoices) |
|
|
|
const { t } = useTranslation("invoices"); |
|
|
|
const [tabIndex, setTabIndex] = useState(0); |
|
|
|
|
|
|
@@ -56,7 +58,12 @@ const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoic |
|
|
|
() => [ |
|
|
|
{ label: t("Invoice No"), paramName: "invoiceNo", type: "text" }, |
|
|
|
{ label: t("Project Code"), paramName: "projectCode", type: "text" }, |
|
|
|
{ label: t("Team"), paramName: "team", type: "text" }, |
|
|
|
{ |
|
|
|
label: t("Team"), |
|
|
|
paramName: "team", |
|
|
|
type: "select", |
|
|
|
options: uniq(invoices.map((invoice) => invoice.teamCodeName)), |
|
|
|
}, |
|
|
|
{ label: t("Issue Date"), label2: t("Issue Date To"), paramName: "invoiceDate", type: "dateRange" }, |
|
|
|
{ label: t("Settle Date"), label2: t("Settle Date To"), paramName: "dueDate", type: "dateRange" }, |
|
|
|
], |
|
|
@@ -481,12 +488,11 @@ const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoic |
|
|
|
console.log(query) |
|
|
|
setFilterInovices( |
|
|
|
invoices.filter( |
|
|
|
(s) => |
|
|
|
(isDateInRange(s.issuedDate, query.invoiceDate ?? undefined, query.invoiceDateTo ?? undefined)) && |
|
|
|
(isDateInRange(s.receiptDate, query.dueDate ?? undefined, query.dueDateTo ?? undefined)) && |
|
|
|
(s.invoiceNo.toLowerCase().includes(query.invoiceNo.toLowerCase())) && |
|
|
|
(s.projectCode.toLowerCase().includes(query.projectCode.toLowerCase())) && |
|
|
|
(s.team.toLowerCase().includes(query.team.toLowerCase())) |
|
|
|
(s) => (s.invoiceNo.toLowerCase().includes(query.invoiceNo.toLowerCase())) |
|
|
|
&& (s.projectCode.toLowerCase().includes(query.projectCode.toLowerCase())) |
|
|
|
&& (query.team === "All" || query.team.toLowerCase().includes(s.team.toLowerCase())) |
|
|
|
&& (isDateInRange(s.issuedDate, query.invoiceDate ?? undefined, query.invoiceDateTo ?? undefined)) |
|
|
|
&& (isDateInRange(s.receiptDate, query.dueDate ?? undefined, query.dueDateTo ?? undefined)) |
|
|
|
), |
|
|
|
); |
|
|
|
}} |
|
|
|