Browse Source

update "export financial status by project excel"

tags/Baseline_30082024_FRONTEND_UAT
cyril.tsui 1 year ago
parent
commit
6702103c9a
2 changed files with 35 additions and 3 deletions
  1. +29
    -1
      src/app/api/financialsummary/actions.ts
  2. +6
    -2
      src/components/ProjectFinancialSummary/ProjectFinancialSummary.tsx

+ 29
- 1
src/app/api/financialsummary/actions.ts View File

@@ -81,6 +81,21 @@ export interface ExportFinancialSummaryByClientExcel {
financialSummaryByClients: FinancialSummaryByClientExcel[]
}

export interface FinancialSummaryByProjectExcel {
projectCode: string;
projectName: string;
customerName: string;
subsidiaryName?: string | null;
totalFee: number;
cumulativeExpenditure: number;
totalInvoiced: number;
totalReceived: number;
}

export interface ExportFinancialSummaryByProjectExcel {
financialSummaryByProjects: FinancialSummaryByProjectExcel[]
}

export const exportFinancialSummaryByClientExcel = cache(async (data: ExportFinancialSummaryByClientExcel) => {
const reportBlob = await serverFetchBlob<FileResponse>(
`${BASE_API_URL}/dashboard/exportFinancialSummaryByClientExcel`,
@@ -91,5 +106,18 @@ export const exportFinancialSummaryByClientExcel = cache(async (data: ExportFina
},
);

return reportBlob
return reportBlob
})

export const exportFinancialSummaryByProjectExcel = cache(async (data: ExportFinancialSummaryByProjectExcel) => {
const reportBlob = await serverFetchBlob<FileResponse>(
`${BASE_API_URL}/dashboard/exportFinancialSummaryByProjectExcel`,
{
method: "POST",
body: JSON.stringify(data),
headers: { "Content-Type": "application/json" },
},
);

return reportBlob
})

+ 6
- 2
src/components/ProjectFinancialSummary/ProjectFinancialSummary.tsx View File

@@ -19,7 +19,7 @@ import SearchBox, { Criterion } from "../SearchBox";
import ProgressByClientSearch from "@/components/ProgressByClientSearch";
import { Suspense } from "react";
import { fetchFinancialSummaryCard } from "@/app/api/financialsummary";
import { exportFinancialSummaryByClientExcel, searchFinancialSummaryByClient,searchFinancialSummaryByProject } from "@/app/api/financialsummary/actions";
import { exportFinancialSummaryByClientExcel, exportFinancialSummaryByProjectExcel, searchFinancialSummaryByClient,searchFinancialSummaryByProject } from "@/app/api/financialsummary/actions";
import ProjectFinancialCard from "./ProjectFinancialCard";
import VisibilityIcon from '@mui/icons-material/Visibility';
import { downloadFile } from "@/app/utils/commonUtil";
@@ -467,7 +467,11 @@ const columns2 = [
console.log(clientFinancialRows)
};

const handleExportByProject = () => {
const handleExportByProject = async () => {
const response = await exportFinancialSummaryByProjectExcel({financialSummaryByProjects: projectFinancialRows})
if (response) {
downloadFile(new Uint8Array(response.blobValue), response.filename!!)
}
console.log(projectFinancialRows)
};



Loading…
Cancel
Save