|
@@ -8,6 +8,7 @@ import EditNote from "@mui/icons-material/EditNote"; |
|
|
import { moneyFormatter } from "@/app/utils/formatUtil" |
|
|
import { moneyFormatter } from "@/app/utils/formatUtil" |
|
|
import { Button, ButtonGroup, Stack, Tab, Tabs, TabsProps, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, TextField, CardContent, Typography, Divider, Card } from "@mui/material"; |
|
|
import { Button, ButtonGroup, Stack, Tab, Tabs, TabsProps, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, TextField, CardContent, Typography, Divider, Card } from "@mui/material"; |
|
|
import FileUploadIcon from '@mui/icons-material/FileUpload'; |
|
|
import FileUploadIcon from '@mui/icons-material/FileUpload'; |
|
|
|
|
|
import AddIcon from '@mui/icons-material/Add'; |
|
|
import { deleteInvoice, importIssuedInovice, importReceivedInovice, updateInvoice } from "@/app/api/invoices/actions"; |
|
|
import { deleteInvoice, importIssuedInovice, importReceivedInovice, updateInvoice } from "@/app/api/invoices/actions"; |
|
|
import { deleteDialog, errorDialogWithContent, successDialog } from "../Swal/CustomAlerts"; |
|
|
import { deleteDialog, errorDialogWithContent, successDialog } from "../Swal/CustomAlerts"; |
|
|
import { invoiceList, issuedInvoiceList, issuedInvoiceSearchForm, receivedInvoiceList, receivedInvoiceSearchForm } from "@/app/api/invoices"; |
|
|
import { invoiceList, issuedInvoiceList, issuedInvoiceSearchForm, receivedInvoiceList, receivedInvoiceSearchForm } from "@/app/api/invoices"; |
|
@@ -17,6 +18,8 @@ import { useGridApiRef } from "@mui/x-data-grid"; |
|
|
import StyledDataGrid from "../StyledDataGrid"; |
|
|
import StyledDataGrid from "../StyledDataGrid"; |
|
|
|
|
|
|
|
|
import { uniq } from "lodash"; |
|
|
import { uniq } from "lodash"; |
|
|
|
|
|
import CreateInvoiceModal from "./CreateInvoiceModal"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
interface Props { |
|
@@ -44,7 +47,7 @@ type SearchParamNames2 = keyof SearchQuery2; |
|
|
|
|
|
|
|
|
const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoices }) => { |
|
|
const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoices }) => { |
|
|
// console.log(invoices) |
|
|
// console.log(invoices) |
|
|
const { t } = useTranslation("invoices"); |
|
|
|
|
|
|
|
|
const { t } = useTranslation("Invoice"); |
|
|
const [tabIndex, setTabIndex] = useState(0); |
|
|
const [tabIndex, setTabIndex] = useState(0); |
|
|
|
|
|
|
|
|
const [filteredIssuedInvoices, setFilteredIssuedInvoices] = useState(issuedInvoice); |
|
|
const [filteredIssuedInvoices, setFilteredIssuedInvoices] = useState(issuedInvoice); |
|
@@ -122,6 +125,16 @@ const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoic |
|
|
} |
|
|
} |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
const [modelOpen, setModelOpen] = useState<boolean>(false); |
|
|
|
|
|
|
|
|
|
|
|
const handleAddInvoiceClick = useCallback(() => { |
|
|
|
|
|
setModelOpen(true) |
|
|
|
|
|
},[]) |
|
|
|
|
|
|
|
|
|
|
|
const handleModalClose = useCallback(() => { |
|
|
|
|
|
setModelOpen(false) |
|
|
|
|
|
},[]) |
|
|
|
|
|
|
|
|
const handleImportError = (response: any) => { |
|
|
const handleImportError = (response: any) => { |
|
|
if (response.emptyRowList.length >= 1) { |
|
|
if (response.emptyRowList.length >= 1) { |
|
|
showErrorDialog( |
|
|
showErrorDialog( |
|
@@ -458,6 +471,14 @@ const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoic |
|
|
spacing={2} |
|
|
spacing={2} |
|
|
> |
|
|
> |
|
|
<ButtonGroup variant="contained"> |
|
|
<ButtonGroup variant="contained"> |
|
|
|
|
|
{/* <Button |
|
|
|
|
|
startIcon={<AddIcon />} |
|
|
|
|
|
variant="outlined" |
|
|
|
|
|
component="label" |
|
|
|
|
|
onClick={handleAddInvoiceClick} |
|
|
|
|
|
> |
|
|
|
|
|
{t("Create Invoice")} |
|
|
|
|
|
</Button> */} |
|
|
<Button startIcon={<FileUploadIcon />} variant="contained" component="label"> |
|
|
<Button startIcon={<FileUploadIcon />} variant="contained" component="label"> |
|
|
<input |
|
|
<input |
|
|
id='importExcel' |
|
|
id='importExcel' |
|
@@ -504,11 +525,11 @@ const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoic |
|
|
<Card sx={{ display: "block" }}> |
|
|
<Card sx={{ display: "block" }}> |
|
|
<CardContent> |
|
|
<CardContent> |
|
|
<Stack direction="row" justifyContent="space-between"> |
|
|
<Stack direction="row" justifyContent="space-between"> |
|
|
<Typography variant="h6">{t('Total Issued Amount (HKD):')}</Typography> |
|
|
|
|
|
|
|
|
<Typography variant="h6">{t('Total Issued Amount (HKD)')}:</Typography> |
|
|
<Typography variant="h6">{moneyFormatter.format(filteredIvoices.reduce((acc, current) => (acc + current.issuedAmount), 0))}</Typography> |
|
|
<Typography variant="h6">{moneyFormatter.format(filteredIvoices.reduce((acc, current) => (acc + current.issuedAmount), 0))}</Typography> |
|
|
</Stack> |
|
|
</Stack> |
|
|
<Stack direction="row" justifyContent="space-between"> |
|
|
<Stack direction="row" justifyContent="space-between"> |
|
|
<Typography variant="h6">{t('Total Received Amount (HKD):')}</Typography> |
|
|
|
|
|
|
|
|
<Typography variant="h6">{t('Total Received Amount (HKD)')}:</Typography> |
|
|
<Typography variant="h6">{moneyFormatter.format(filteredIvoices.reduce((acc, current) => (acc + current.receivedAmount), 0))}</Typography> |
|
|
<Typography variant="h6">{moneyFormatter.format(filteredIvoices.reduce((acc, current) => (acc + current.receivedAmount), 0))}</Typography> |
|
|
</Stack> |
|
|
</Stack> |
|
|
</CardContent> |
|
|
</CardContent> |
|
@@ -593,7 +614,10 @@ const InvoiceSearch: React.FC<Props> = ({ issuedInvoice, receivedInvoice, invoic |
|
|
</Button> |
|
|
</Button> |
|
|
</DialogActions> |
|
|
</DialogActions> |
|
|
</Dialog> |
|
|
</Dialog> |
|
|
|
|
|
|
|
|
|
|
|
<CreateInvoiceModal |
|
|
|
|
|
isOpen={modelOpen} |
|
|
|
|
|
onClose={handleModalClose} |
|
|
|
|
|
/> |
|
|
</> |
|
|
</> |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|