Skip to content

Commit

Permalink
Merge pull request #2354 from CAFECA-IO/feature/print_401_report_new
Browse files Browse the repository at this point in the history
print_401_report
  • Loading branch information
Luphia authored Sep 12, 2024
2 parents 67a2400 + 3b5c1e8 commit b90102d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ module.exports = {
'react/require-default-props': 'off',
'no-eval': 'error',
'no-new-func': 'error',
'react/no-is-mounted': 'off',
},

// 整合 prettier 和解決 prettier 衝突問題
Expand Down
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.1+9",
"version": "0.8.1+10",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
32 changes: 21 additions & 11 deletions src/components/view_financial_section/view_financial_section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
CashFlowStatementReport,
FinancialReport,
IncomeStatementReport,
TaxReport401Content,
// TaxReport401,
} from '@/interfaces/report';
import { useUserCtx } from '@/contexts/user_context';
Expand All @@ -34,14 +35,23 @@ interface IViewReportSectionProps {
reportId: string;
}
// Info: (20240815 - Anna)增加類型保護函數
function isTaxReport401(report: FinancialReport): boolean {
return (
'basicInfo' in report &&
'sales' in report &&
'purchases' in report &&
'taxCalculation' in report &&
'imports' in report &&
'bondedAreaSalesToTaxArea' in report
function isTaxReport401(report: TaxReport401Content): boolean {
// Info: (20240912 - Anna) 將回傳的值檢查是否是0,如果是0就轉換成字串"0"
// Info: (20240912 - Anna) 轉換為字串"0",為了避免回傳0時,判斷報表為無效,導致列印按鈕一直是禁用狀態
const basicInfo = report.content.basicInfo ? report.content.basicInfo : '0';
const sales = report.content.sales ? report.content.sales : '0';
const purchases = report.content.purchases ? report.content.purchases : '0';
const taxCalculation = report.content.taxCalculation ? report.content.taxCalculation : '0';
const imports = report.content.imports ? report.content.imports : '0';
const bondedAreaSalesToTaxArea =
report.content.bondedAreaSalesToTaxArea === 0 ? '0' : report.content.bondedAreaSalesToTaxArea;
return !!(
basicInfo &&
sales &&
purchases &&
taxCalculation &&
imports &&
bondedAreaSalesToTaxArea
);
}
const generateThumbnails = (count: number) => {
Expand Down Expand Up @@ -165,8 +175,8 @@ const ViewFinancialSection = ({
return !isValidCashFlowStatementReport(reportFinancial as CashFlowStatementReport);
// Info:(20240815 - Anna) 新增定義 isValidReport401 函數
case ReportSheetType.REPORT_401:
// Info:(20240815 - Anna)使用 isTaxReport401 進行類型檢查
return !isTaxReport401(reportFinancial);
// Info:(20240912 - Anna) 將 reportFinancial 轉換為 TaxReport401Content 類型
return !isTaxReport401(reportFinancial as unknown as TaxReport401Content);
default:
return true;
}
Expand Down Expand Up @@ -420,7 +430,7 @@ const ViewFinancialSection = ({
<div className="mt-9 flex w-full flex-col items-center justify-center">
<div className="flex h-850px flex-col gap-3">
{isLoading || thumbnailUrls.length === 0 ? (
<p>{t('report_401:MY_REPORTS_SECTION.LOADING')}</p>
<p>{t('common:COMMON.LOADING')}</p>
) : isInvalidReport ? null : thumbnailUrls.length > 0 ? (
thumbnailUrls.map((thumbnailUrl, index) => (
<div
Expand Down

0 comments on commit b90102d

Please sign in to comment.