diff --git a/package.json b/package.json index dbe9de626..a9c93ac60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iSunFA", - "version": "0.8.2+41", + "version": "0.8.2+42", "private": false, "scripts": { "dev": "next dev", diff --git a/src/components/income_statement_report_body/income_statement_report_body_all.tsx b/src/components/income_statement_report_body/income_statement_report_body_all.tsx index f6a744bc6..d045a1294 100644 --- a/src/components/income_statement_report_body/income_statement_report_body_all.tsx +++ b/src/components/income_statement_report_body/income_statement_report_body_all.tsx @@ -9,6 +9,7 @@ import Image from 'next/image'; import React, { useState } from 'react'; import { format } from 'date-fns'; import CollapseButton from '@/components/button/collapse_button'; +import IncomeStatementReportTableRow from './income_statement_report_table_row'; interface IIncomeStatementReportBodyAllProps { reportId: string; @@ -180,31 +181,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.general && - reportFinancial.general.slice(0, 10).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.general + .slice(0, 10) + .map((value) => )} )} @@ -277,28 +256,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.general && - reportFinancial.general.slice(10, 24).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.general + .slice(10, 24) + .map((value) => )} @@ -368,28 +328,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.general && - reportFinancial.general.slice(24, 33).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.general + .slice(24, 33) + .map((value) => )}   @@ -411,28 +352,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.general && - reportFinancial.general.slice(34, 36).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - -   - - - {value.prePeriodAmount} - - -   - - - ))} + reportFinancial.general + .slice(34, 36) + .map((value) => )}
@@ -515,28 +437,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.details && - reportFinancial.details.slice(0, 15).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.details + .slice(0, 15) + .map((value) => )} )} @@ -607,28 +510,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.details && - reportFinancial.details.slice(15, 28).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.details + .slice(15, 28) + .map((value) => )} @@ -698,28 +582,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.details && - reportFinancial.details.slice(28, 39).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.details + .slice(28, 39) + .map((value) => )} @@ -791,28 +656,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.details && - reportFinancial.details.slice(39, 49).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.details + .slice(39, 49) + .map((value) => )} @@ -882,28 +728,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl {reportFinancial && reportFinancial.details && - reportFinancial.details.slice(49, 58).map((value) => ( - - - {value.code} - - - {value.name} - - - {value.curPeriodAmount} - - - {value.curPeriodPercentage} - - - {value.prePeriodAmount} - - - {value.prePeriodPercentage} - - - ))} + reportFinancial.details + .slice(49, 58) + .map((value) => )} {reportFinancial && diff --git a/src/components/income_statement_report_body/income_statement_report_table_row.tsx b/src/components/income_statement_report_body/income_statement_report_table_row.tsx new file mode 100644 index 000000000..f8553e340 --- /dev/null +++ b/src/components/income_statement_report_body/income_statement_report_table_row.tsx @@ -0,0 +1,48 @@ +import { FinancialReportItem } from '@/interfaces/report'; +import { numberBeDashIfFalsy } from '@/lib/utils/common'; + +function IncomeStatementReportTableRow({ + code, + curPeriodAmount, + curPeriodPercentage, + prePeriodAmount, + prePeriodPercentage, + name, +}: FinancialReportItem) { + /** + * Info: (20241011 - Murky) + * 將Income statement 當中沒有code 的欄位,呈現的數字變成空字串 + */ + const isCodeExist = code.length > 0; + const idCode = isCodeExist ? code : Math.random().toString(36).slice(0, 4); + const displayCode = isCodeExist ? code : ''; + const displayCurPeriodAmount: string = isCodeExist ? numberBeDashIfFalsy(curPeriodAmount) : ''; + const displayCurPeriodPercentage: string = isCodeExist + ? numberBeDashIfFalsy(curPeriodPercentage) + : ''; + const displayPrePeriodAmount: string = isCodeExist ? numberBeDashIfFalsy(prePeriodAmount) : ''; + const displayPrePeriodPercentage: string = isCodeExist + ? numberBeDashIfFalsy(prePeriodPercentage) + : ''; + + return ( + + {displayCode} + {name} + + {displayCurPeriodAmount} + + + {displayCurPeriodPercentage} + + + {displayPrePeriodAmount} + + + {displayPrePeriodPercentage} + + + ); +} + +export default IncomeStatementReportTableRow;