瀏覽代碼

Add back issueDate to Project Expense

tags/Baseline_180220205_Frontend
MSI\2Fi 11 月之前
父節點
當前提交
4ea045b220
共有 6 個文件被更改,包括 35 次插入20 次删除
  1. +1
    -1
      src/app/api/invoices/actions.ts
  2. +7
    -7
      src/app/api/projectExpenses/actions.ts
  3. +1
    -1
      src/components/ExpenseSearch/CreateExpenseModal.tsx
  4. +18
    -4
      src/components/ExpenseSearch/ExpenseSearch.tsx
  5. +1
    -0
      src/components/ExpenseSearch/ExpenseSearchWrapper.tsx
  6. +7
    -7
      src/components/ExpenseSearch/ExpenseTable.tsx

+ 1
- 1
src/app/api/invoices/actions.ts 查看文件

@@ -164,7 +164,7 @@ export const deleteInvoice = async (id: number) => {
};

export const createInvoices = async (data: any) => {
console.log(data)
// console.log(data)
const createInvoices = serverFetchString<any>(`${BASE_API_URL}/invoices/create`, {
method: "Post",
body: JSON.stringify(data),


+ 7
- 7
src/app/api/projectExpenses/actions.ts 查看文件

@@ -9,19 +9,19 @@ import { revalidateTag } from "next/cache";
export type CreateNewExpense = {
expenseNo: string | undefined,
projectCode: string | undefined,
issueDate: Date
issueDate: Date,
issuedAmount: number,
receiptDate: Date
receiptDate: Date,
receivedAmount: number
}
export type PostExpenseData = {
expenseNo?: string
projectId: number
expenseNo?: string,
projectId: number,
projectCode: string,
amount: number
issueDate?: string
receiptDate?: string
amount: number,
issueDate?: string | null,
receiptDate?: string,
remarks?: string
}
export const saveProjectExpense = async (data: PostExpenseData[]) => {


+ 1
- 1
src/components/ExpenseSearch/CreateExpenseModal.tsx 查看文件

@@ -55,7 +55,7 @@ const CreateExpenseModal: React.FC<Props> = ({ isOpen, onClose, projects }) => {
const postData: PostExpenseData[] = _data.map((item) => {
return {
expenseNo: item.expenseNo,
// issueDate: item.issueDate ? dayjs(item.issueDate).format(INPUT_DATE_FORMAT) : null,
issueDate: item.issueDate ? dayjs(item.issueDate).format(INPUT_DATE_FORMAT) : null,
amount: item.amount,
projectId: projects.find((p) => p.code === item.projectCode)!.id,
projectCode: item.projectCode,


+ 18
- 4
src/components/ExpenseSearch/ExpenseSearch.tsx 查看文件

@@ -20,7 +20,7 @@ import {
Stack,
Typography,
} from "@mui/material";
import { moneyFormatter } from "@/app/utils/formatUtil";
import { INPUT_DATE_FORMAT, moneyFormatter } from "@/app/utils/formatUtil";
import { EditNote } from "@mui/icons-material";
import AddIcon from '@mui/icons-material/Add';
import { uniq } from "lodash";
@@ -32,6 +32,7 @@ import { useGridApiRef } from "@mui/x-data-grid";
import { GridEventListener } from "@mui/x-data-grid";
import { deleteDialog, successDialog } from "../Swal/CustomAlerts";
import { deleteProjectExpense, updateProjectExpense } from "@/app/api/projectExpenses/actions";
import dayjs from "dayjs";

interface Props {
expenses: ProjectExpensesResultFormatted[]
@@ -51,6 +52,7 @@ const initState: Modals = {
type expenseRow = Partial<
ProjectExpensesResultFormatted & {
_error: ExpenseRowError;
issuedDate: Date
}
>

@@ -97,9 +99,9 @@ const ExpenseSearch: React.FC<Props> = ({ expenses, projects }) => {
},
{ name: "projectCode", label: t("Project Code") },
{ name: "projectName", label: t("Project Name") },
{ name: "amount", label: t("Amount") },
{ name: "amount", label: t("Amount (HKD)"), type: 'money', needTranslation: true},
{ name: "teamCode", label: t("Team") },
// { name: "issueDate", label: t("Issue Date") },
{ name: "issueDate", label: t("Issue Date") },
{ name: "remarks", label: t("Remarks")}
],
[t]
@@ -144,7 +146,9 @@ const ExpenseSearch: React.FC<Props> = ({ expenses, projects }) => {

const handleSaveDialog = async () => {
// setDialogOpen(false);
console.log(selectedRow[0])
// console.log(selectedRow[0])
selectedRow[0].issueDate = dayjs(selectedRow[0].issuedDate).format(INPUT_DATE_FORMAT)
console.log(selectedRow[0])
await updateProjectExpense(selectedRow[0])
setDialogOpen(false);
successDialog(t("Update Success"), t).then(() => {
@@ -231,6 +235,16 @@ const ExpenseSearch: React.FC<Props> = ({ expenses, projects }) => {
flex: 0.5,
type: 'number'
},
{ field: "issuedDate",
headerName: t("Issue Date"),
editable: true,
flex: 0.4,
type: 'date',
valueGetter: (params) => {
// console.log(params.row.issuedDate)
return new Date(params.row.issuedDate)
},
},
{
field: "remarks",
headerName: t("Remarks"),


+ 1
- 0
src/components/ExpenseSearch/ExpenseSearchWrapper.tsx 查看文件

@@ -41,6 +41,7 @@ const ExpenseSearchWrapper: React.FC & SubComponents = async () => {
}
return ({
...e,
issuedDate: e.issueDate,
issueDate: formattedIssueDate,
receiptDate: formattedReceiptDate
})


+ 7
- 7
src/components/ExpenseSearch/ExpenseTable.tsx 查看文件

@@ -271,13 +271,13 @@ const editCombinedColumns = useMemo<GridColDef[]>(
renderCell: renderAutocomplete,
renderEditCell: renderAutocompleteInput
},
// {
// field: "issueDate",
// headerName: t("Issue Date"),
// editable: true,
// flex: 0.4,
// type: 'date',
// },
{
field: "issueDate",
headerName: t("Issue Date"),
editable: true,
flex: 0.4,
type: 'date',
},
{
field: "amount",
headerName: t("Amount (HKD)"),


Loading…
取消
儲存