Skip to content

Commit

Permalink
fix income statement report
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyMurky committed Oct 11, 2024
1 parent 05c985c commit 9246b82
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 202 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iSunFA",
"version": "0.8.2+41",
"version": "0.8.2+42",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -180,31 +181,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.general &&
reportFinancial.general.slice(0, 10).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td
className="border border-stroke-brand-secondary-soft p-10px text-xs"
style={{ width: '200px' }}
>
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.general
.slice(0, 10)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
)}
Expand Down Expand Up @@ -277,28 +256,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.general &&
reportFinancial.general.slice(10, 24).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="min-w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.general
.slice(10, 24)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
</section>
Expand Down Expand Up @@ -368,28 +328,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.general &&
reportFinancial.general.slice(24, 33).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.general
.slice(24, 33)
.map((value) => <IncomeStatementReportTableRow {...value} />)}

<tr>
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">&nbsp;</td>
Expand All @@ -411,28 +352,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.general &&
reportFinancial.general.slice(34, 36).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs font-semibold">
{value.code}
</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs font-semibold">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs font-semibold">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs font-semibold">
&nbsp;
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs font-semibold">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs font-semibold">
&nbsp;
</td>
</tr>
))}
reportFinancial.general
.slice(34, 36)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
<div className="relative mt-6">
Expand Down Expand Up @@ -515,28 +437,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.details &&
reportFinancial.details.slice(0, 15).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.details
.slice(0, 15)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
)}
Expand Down Expand Up @@ -607,28 +510,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.details &&
reportFinancial.details.slice(15, 28).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.details
.slice(15, 28)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
</section>
Expand Down Expand Up @@ -698,28 +582,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.details &&
reportFinancial.details.slice(28, 39).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.details
.slice(28, 39)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
</section>
Expand Down Expand Up @@ -791,28 +656,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.details &&
reportFinancial.details.slice(39, 49).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="w-177px min-w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.details
.slice(39, 49)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
</table>
</section>
Expand Down Expand Up @@ -882,28 +728,9 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<tbody>
{reportFinancial &&
reportFinancial.details &&
reportFinancial.details.slice(49, 58).map((value) => (
<tr key={value.code} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">
{value.code}
</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs">
{value.name}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.curPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.curPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{value.prePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{value.prePeriodPercentage}
</td>
</tr>
))}
reportFinancial.details
.slice(49, 58)
.map((value) => <IncomeStatementReportTableRow {...value} />)}
</tbody>
<tbody>
{reportFinancial &&
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<tr key={idCode} className="h-40px">
<td className="border border-stroke-brand-secondary-soft p-10px text-xs">{displayCode}</td>
<td className="w-177px border border-stroke-brand-secondary-soft p-10px text-xs">{name}</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{displayCurPeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{displayCurPeriodPercentage}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-end text-xs">
{displayPrePeriodAmount}
</td>
<td className="border border-stroke-brand-secondary-soft p-10px text-center text-xs">
{displayPrePeriodPercentage}
</td>
</tr>
);
}

export default IncomeStatementReportTableRow;

0 comments on commit 9246b82

Please sign in to comment.