@@ -21,6 +21,7 @@ export interface InvoiceResultV2 { | |||||
projectCode: string; | projectCode: string; | ||||
projectName: string; | projectName: string; | ||||
team: string; | team: string; | ||||
teamCodeName: string; | |||||
stage: string; | stage: string; | ||||
paymentMilestone: string; | paymentMilestone: string; | ||||
paymentMilestoneDate: string; | paymentMilestoneDate: string; | ||||
@@ -72,6 +73,7 @@ export interface invoiceList { | |||||
issuedAmount: number; | issuedAmount: number; | ||||
receivedAmount: number; | receivedAmount: number; | ||||
team: string; | team: string; | ||||
teamCodeName: string; | |||||
} | } | ||||
export interface invoiceColum { | export interface invoiceColum { | ||||
@@ -11,6 +11,7 @@ export interface ProjectResult { | |||||
name: string; | name: string; | ||||
category: string; | category: string; | ||||
team: string; | team: string; | ||||
teamCodeName: string; | |||||
teamId: number; | teamId: number; | ||||
client: string; | client: string; | ||||
status: string; | status: string; | ||||
@@ -134,7 +134,7 @@ const EditStaff: React.FC<formProps> = ({ Staff, combos }) => { | |||||
haveError = true | haveError = true | ||||
formProps.setError("salaryId", { message: t("Please Enter Salary."), type: "required" }) | formProps.setError("salaryId", { message: t("Please Enter Salary."), type: "required" }) | ||||
} | } | ||||
if (data.joinDate &&data.departDate && new Date(data.departDate) <= new Date(data.joinDate)) { | |||||
if (data.joinDate && data.departDate && new Date(data.departDate) <= new Date(data.joinDate)) { | |||||
haveError = true | haveError = true | ||||
formProps.setError("departDate", { message: t("Depart Date cannot be earlier than Join Date."), type: "required" }) | formProps.setError("departDate", { message: t("Depart Date cannot be earlier than Join Date."), type: "required" }) | ||||
} | } | ||||
@@ -20,6 +20,7 @@ import { QrCodeScannerOutlined } from "@mui/icons-material"; | |||||
import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers"; | import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers"; | ||||
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; | import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; | ||||
import dayjs from "dayjs"; | import dayjs from "dayjs"; | ||||
import { uniq } from "lodash"; | |||||
interface Props { | interface Props { | ||||
issuedInvoice: issuedInvoiceList[]; | issuedInvoice: issuedInvoiceList[]; | ||||
@@ -45,6 +46,7 @@ type SearchQuery2 = Partial<Omit<receivedInvoiceSearchForm, "id">>; | |||||
type SearchParamNames2 = keyof SearchQuery2; | type SearchParamNames2 = keyof SearchQuery2; | ||||
const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoices }) => { | const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoices }) => { | ||||
console.log(invoices) | |||||
const { t } = useTranslation("invoices"); | const { t } = useTranslation("invoices"); | ||||
const [tabIndex, setTabIndex] = useState(0); | 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("Invoice No"), paramName: "invoiceNo", type: "text" }, | ||||
{ label: t("Project Code"), paramName: "projectCode", 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("Issue Date"), label2: t("Issue Date To"), paramName: "invoiceDate", type: "dateRange" }, | ||||
{ label: t("Settle Date"), label2: t("Settle Date To"), paramName: "dueDate", 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) | console.log(query) | ||||
setFilterInovices( | setFilterInovices( | ||||
invoices.filter( | 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)) | |||||
), | ), | ||||
); | ); | ||||
}} | }} | ||||
@@ -55,6 +55,7 @@ const InvoiceSearchWrapper: React.FC & SubComponents = async () => { | |||||
projectCode: invoice.projectCode, | projectCode: invoice.projectCode, | ||||
projectName: invoice.projectName, | projectName: invoice.projectName, | ||||
team: invoice.team, | team: invoice.team, | ||||
teamCodeName: invoice.teamCodeName, | |||||
issuedDate: timestampToDateString(invoice.invoiceDate)!!, | issuedDate: timestampToDateString(invoice.invoiceDate)!!, | ||||
receiptDate: timestampToDateString(invoice.receiptDate)!!, | receiptDate: timestampToDateString(invoice.receiptDate)!!, | ||||
issuedAmount: invoice.issueAmount, | issuedAmount: invoice.issueAmount, | ||||
@@ -20,6 +20,7 @@ type SearchQuery = Partial<Omit<ProjectResult, "id">>; | |||||
type SearchParamNames = keyof SearchQuery; | type SearchParamNames = keyof SearchQuery; | ||||
const ProjectSearch: React.FC<Props> = ({ projects, projectCategories, abilities }) => { | const ProjectSearch: React.FC<Props> = ({ projects, projectCategories, abilities }) => { | ||||
console.log(projects) | |||||
const router = useRouter(); | const router = useRouter(); | ||||
const { t } = useTranslation("projects"); | const { t } = useTranslation("projects"); | ||||
@@ -32,8 +33,8 @@ const ProjectSearch: React.FC<Props> = ({ projects, projectCategories, abilities | |||||
{ | { | ||||
label: t("Client name"), | label: t("Client name"), | ||||
paramName: "client", | paramName: "client", | ||||
type: "select", | |||||
options: uniq(projects.map((project) => project.client)), | |||||
type: "autocomplete", | |||||
options: uniq(projects.map((project) => ({value: project.client, label: project.client}))), | |||||
}, | }, | ||||
{ | { | ||||
label: t("Project category"), | label: t("Project category"), | ||||
@@ -45,7 +46,7 @@ const ProjectSearch: React.FC<Props> = ({ projects, projectCategories, abilities | |||||
label: t("Team"), | label: t("Team"), | ||||
paramName: "team", | paramName: "team", | ||||
type: "select", | type: "select", | ||||
options: uniq(projects.map((project) => project.team)), | |||||
options: uniq(projects.map((project) => project.teamCodeName)), | |||||
}, | }, | ||||
{ | { | ||||
label: t("Status"), | label: t("Status"), | ||||
@@ -101,7 +102,8 @@ const ProjectSearch: React.FC<Props> = ({ projects, projectCategories, abilities | |||||
p.name.toLowerCase().includes(query.name.toLowerCase()) && | p.name.toLowerCase().includes(query.name.toLowerCase()) && | ||||
(query.client === "All" || p.client === query.client) && | (query.client === "All" || p.client === query.client) && | ||||
(query.category === "All" || p.category === query.category) && | (query.category === "All" || p.category === query.category) && | ||||
(query.team === "All" || p.team === query.team) && | |||||
// (query.team === "All" || p.team === query.team) && | |||||
(query.team === "All" || query.team.toLowerCase().includes(p.team.toLowerCase())) && | |||||
(query.status === "All" || p.status === query.status), | (query.status === "All" || p.status === query.status), | ||||
), | ), | ||||
); | ); | ||||
@@ -25,17 +25,17 @@ type SearchParamNames = keyof SearchQuery; | |||||
const ResourceOverconsumptionReport: React.FC<Props> = ({ team, customer, subsidiaries, needAll }) => { | const ResourceOverconsumptionReport: React.FC<Props> = ({ team, customer, subsidiaries, needAll }) => { | ||||
const { t } = useTranslation("report"); | const { t } = useTranslation("report"); | ||||
const statusCombo = ["Potential Overconsumption"] | const statusCombo = ["Potential Overconsumption"] | ||||
const teamCombo = team.map(t => `${t.name} - ${t.code}`) | |||||
const teamCombo = team.map(t => `${t.code} - ${t.name}`).sort() | |||||
const custCombo = customer.map(c => ({ | const custCombo = customer.map(c => ({ | ||||
value: `custId-${c.id}`, | value: `custId-${c.id}`, | ||||
label: `${c.code} - ${c.name}`, | label: `${c.code} - ${c.name}`, | ||||
group: t("Client") | group: t("Client") | ||||
})) | |||||
})).sort() | |||||
const subsidiariesCombo = subsidiaries.map(sub => ({ | const subsidiariesCombo = subsidiaries.map(sub => ({ | ||||
value: `subsidiaryId-${sub.id}`, | value: `subsidiaryId-${sub.id}`, | ||||
label: `${sub.code} - ${sub.name}`, | label: `${sub.code} - ${sub.name}`, | ||||
group: t("Subsidiary") | group: t("Subsidiary") | ||||
})) | |||||
})).sort() | |||||
// const staffCombo = staffs.map(staff => `${staff.name} - ${staff.staffId}`) | // const staffCombo = staffs.map(staff => `${staff.name} - ${staff.staffId}`) | ||||
// console.log(staffs) | // console.log(staffs) | ||||