From 0c8e709e11a2226b8416170dfa0616834f6cbc10 Mon Sep 17 00:00:00 2001 From: jing12345678910 Date: Wed, 14 Aug 2024 15:06:11 +0800 Subject: [PATCH] generate 401 report --- package.json | 3 +- .../tax_report_body_all.tsx | 655 ++++++++++++++++++ src/constants/report.ts | 2 + src/interfaces/report_type.ts | 7 + src/locales/cn/common.json | 2 + src/locales/en/common.json | 4 +- src/locales/tw/common.json | 2 + .../reports/[reportId]/report_401/index.tsx | 55 ++ tsconfig.json | 5 +- 9 files changed, 731 insertions(+), 4 deletions(-) create mode 100644 src/components/tax_report_body_all/tax_report_body_all.tsx create mode 100644 src/pages/users/reports/[reportId]/report_401/index.tsx diff --git a/package.json b/package.json index 6f6eaaaeb..d0e82065e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iSunFA", - "version": "0.8.0+6", + "version": "0.8.0+7", "private": false, "scripts": { "dev": "next dev", @@ -63,6 +63,7 @@ "@types/cookie": "^0.6.0", "@types/jest": "^29.5.11", "@types/jsonwebtoken": "^9.0.6", + "@types/next-auth": "^3.15.0", "@types/node": "^20", "@types/nodemailer": "^6.4.15", "@types/react": "^18", diff --git a/src/components/tax_report_body_all/tax_report_body_all.tsx b/src/components/tax_report_body_all/tax_report_body_all.tsx new file mode 100644 index 000000000..7bbf64816 --- /dev/null +++ b/src/components/tax_report_body_all/tax_report_body_all.tsx @@ -0,0 +1,655 @@ +/* eslint-disable tailwindcss/no-arbitrary-value */ +// TODO: 在 tailwindcss.config 註冊 css 變數,取消 eslint-disable (20240723 - Shirley Anna) +import { SkeletonList } from '@/components/skeleton/skeleton'; +import { APIName } from '@/constants/api_connection'; +import { NON_EXISTING_REPORT_ID } from '@/constants/config'; +import { DEFAULT_SKELETON_COUNT_FOR_PAGE } from '@/constants/display'; +import { useUserCtx } from '@/contexts/user_context'; +import { FinancialReport, TaxReport401 } from '@/interfaces/report'; +import { generate401Report } from '@/lib/utils/report/report_401'; +import APIHandler from '@/lib/utils/api_handler'; +import React, { useEffect, useState } from 'react'; +// import { format } from 'date-fns'; + +interface ITaxReportBodyAllProps { + reportId: string; +} + +const TaxReportBodyAll = ({ reportId }: ITaxReportBodyAllProps) => { + const { isAuthLoading, selectedCompany } = useUserCtx(); + // Info: (20240814 - Anna) 使用 useState 定義 report401 變量的狀態,並將其類型設為 TaxReport401 | null + const [report401, setReport401] = useState(null); + useEffect(() => { + const fetchReport = async () => { + if (selectedCompany) { + const reportData = await generate401Report(selectedCompany.id, Date.now() / 1000); + setReport401(reportData); + } + }; + + fetchReport(); + }, [selectedCompany]); + + if (!report401) { + return ( +
+ +
+ ); + } + + const hasCompanyId = isAuthLoading === false && !!selectedCompany?.id; + const { + data: reportFinancial, + code: getReportFinancialCode, + success: getReportFinancialSuccess, + isLoading: getReportFinancialIsLoading, + } = APIHandler( + APIName.REPORT_GET_BY_ID, + { + params: { + companyId: selectedCompany?.id, + reportId: reportId ?? NON_EXISTING_REPORT_ID, + }, + }, + hasCompanyId + ); + + if (getReportFinancialIsLoading === undefined || getReportFinancialIsLoading) { + return ( +
+ +
+ ); + } else if ( + !getReportFinancialSuccess || + !reportFinancial || + !Object.prototype.hasOwnProperty.call(reportFinancial, 'otherInfo') || + !reportFinancial.otherInfo || + !Object.prototype.hasOwnProperty.call(reportFinancial.otherInfo, 'revenueAndExpenseRatio') || + !Object.prototype.hasOwnProperty.call(reportFinancial.otherInfo, 'revenueToRD') + ) { + return
錯誤 {getReportFinancialCode}
; + } + /* Info: 格式化數字為千分位 (20240730 - Anna) */ + // const formatNumber = (num: number) => num.toLocaleString(); + /* Info: 轉換和格式化日期 (20240730 - Anna) */ + // const curDateFrom = new Date(reportFinancial.curDate.from * 1000); + // const curDateTo = new Date(reportFinancial.curDate.to * 1000); + // const preDateFrom = new Date(reportFinancial.preDate.from * 1000); + // const preDateTo = new Date(reportFinancial.preDate.to * 1000); + // const formattedCurFromDate = format(curDateFrom, 'yyyy-MM-dd'); + // const formattedCurToDate = format(curDateTo, 'yyyy-MM-dd'); + // const formattedPreFromDate = format(preDateFrom, 'yyyy-MM-dd'); + // const formattedPreToDate = format(preDateTo, 'yyyy-MM-dd'); + + const page1 = ( +
+
+ + + + + + + + + + + + + + + +
統一編號28682266
營業人名稱 + {report401?.basicInfo.businessName || 'N/A'} + {report401?.sales.breakdown.triplicateAndElectronic.amount || 'N/A'} +
稅籍編號123456789
+
+

+ 財政部 + + {''}北區{''} + + 國稅局營業人銷售額與稅額申報書(401) +

+

(一般稅額計算-專營應稅營業人使用)

+
+

所屬年月份:112年11–12月

+

金額單位:新臺幣元

+
+
+ + + + + + + + + + + + + + + + + +
+ 註記欄 + + 核准按月申報 +
+ 總繳單位 +
+ 核准合併 +
總機構彙總申報
各單位分別申報
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
負責人姓名營業地址 + 231新北市新店區中興路一段222號(營業地址) + 使用發票份數
+ 銷項 + + 項目 + + 區分 + + 應稅 + + 零稅率銷售額 + + 稅額 +
+ 計算 +
代號 + 項目 + 稅額
+ 銷售額 + + 稅額 + 1本期(月)銷項稅額合計② 101
+ 三聯式發票、電子計算機發票 + 12 + 3 (非經海關出口應附證明文件者) + 7得扣抵進項稅額合計⑨+⑩ 107
+ 收銀機發票(三聯式)及電子發票 + 5678上期(月)累積留抵稅額108
+ 二聯式發票、收銀機發票(二聯式) + 910 + 11 (經海關出口免附證明文件者) + 10小計(7+8)110
+ 免用發票 + 13141511本期(月)應實繳稅額(1-10)111
+ 減:退回及折讓 + 17181912本期(月)申報留抵稅額(10-1)112
+ 合計 + 21①22②23③13得退稅限額合計③×5%+⑩ 113
+ 銷售額總計 +
+ ①+③ +
+ 25⑦ + +
+ 元( +
+ 內含銷售 +
+ 固定資產 +
+ ㉗ 元) +
+
14 + 本期(月)應退稅額(如 +
+ 12>13 +
+ 13>12 +
+ 則為 +
+ 13 +
+ 12 +
+ ) +
114
15本期(月)累積留抵稅額(12-14)115
+ 進項 + + 項目 + + 區分 + + 得扣抵進項稅額 + + 本期(月)應退稅額
+ 處理方式 +
+
+ +

利用存款帳戶劃撥

+
+
+ 金額 + + 稅額 + +
+ +

領取退稅支票

+
+
+
+
+ + 統一發票扣抵聯
+ (包括一般稅額計算之電子計算機發票扣抵聯) +
+
+
+
進貨及費用2829 + 保稅區營業人按進口報關程序銷售貨物至我國 +
+ 境內課稅區之免開立統一發票銷售額 +
+
+

82

+

+
+
固定資產3031
+ 三聯式收銀機發票扣抵聯
+ 及一般稅額計算之電子發票 +
進貨及費用3233 + 申報單位蓋章處(統一發票專用章) + + 核收機關及人員蓋章處 +
固定資產3435 +

+ 附 1.統一發票明細表 + +

+

+ 2.進項憑證 + + +

+

+ 3.海關代徵營業稅繳納證 + +

+

+ 4.退回(出)及折讓證明單、海關退還溢繳營業稅申報單 + +

+

+ 5.營業稅繳款書申報聯 + +

+

+ 6.零稅率銷售額清單 + +

+

+ 7.營業稅一次性移轉訂價調整聲明書 + +

+

+ 8.營業稅聲明事項表 + +

+

申報日期: 年 月 日

+
+

核收日期: 年 月 日

+
+ 載有稅額之其他憑證
+ (包括二聯式收銀機發票) +
進貨及費用3637
固定資產3839
+ 海關代徵營業稅繳納證扣抵聯 + 進貨及費用7879
固定資產8081
+ 減 :退出、折讓及海關退還
+ 溢繳稅款 +
進貨及費用4041
固定資產8081
+ 合計 + 進貨及費用4445⑨
固定資產4647⑩
+

進項總金額 (包括不得扣抵憑證及普通收據)

+
進貨及費用48 + 元 + + 申辦情形 + + 姓名 + + 身分證統一編號 + + 電話 + + 登錄文(字)號 +
固定資產49 + 元 +
+ 進口免稅貨物 + 73 + 元 + 自行申報
+ 購買國外勞務 + 74 + 元 + 委任申報
說明 +

一、 本申報書適用專營應稅及零稅率之營業人填報。

+

+ 二、 + 如營業人申報當期(月)之銷售額包括有免稅、特種稅額計算銷售額者,請改用(403)申報書申報。 +

+

+ 三、 + 營業人如有依財政部108年11月15日台財稅字第10804629000號令規定進行一次性移轉訂價調整申報營業稅,除跨境受控交易為進口貨物外,請另填報「營業稅一次性移轉訂價調整聲明書」並檢附相關證明文件,併 +
+ 同會計年度最後一期營業稅申報。 +

+

+ 四、 + 納稅者如有依納稅者權利保護法第7條第8項但書規定,為重要事項陳述者,請另填報「營業稅聲明事項表」並檢附相關證明文件。 +

+
+
+

紙張尺度(297 ×210)公厘 ods檔案格式

+
+
+ ); + + return ( +
+ {page1} +
+
+ ); +}; + +export default TaxReportBodyAll; diff --git a/src/constants/report.ts b/src/constants/report.ts index 7f0d930e3..07d36076c 100644 --- a/src/constants/report.ts +++ b/src/constants/report.ts @@ -73,6 +73,8 @@ export const FinancialReportTypesKeyReportSheetTypeMapping: { [FinancialReportTypesKey.balance_sheet]: ReportSheetType.BALANCE_SHEET, [FinancialReportTypesKey.comprehensive_income_statement]: ReportSheetType.INCOME_STATEMENT, [FinancialReportTypesKey.cash_flow_statement]: ReportSheetType.CASH_FLOW_STATEMENT, + // Info: (20240814 - Anna) 增加401報表 + [FinancialReportTypesKey.report_401]: ReportSheetType.REPORT_401, // [FinancialReportTypesKey.change_in_equity_statement]: ReportSheetType.CHANGE_IN_EQUITY_STATEMENT, }; diff --git a/src/interfaces/report_type.ts b/src/interfaces/report_type.ts index 71d88dde7..191674a59 100644 --- a/src/interfaces/report_type.ts +++ b/src/interfaces/report_type.ts @@ -3,6 +3,8 @@ export enum FinancialReportTypesKey { balance_sheet = 'balance_sheet', comprehensive_income_statement = 'comprehensive_income_statement', cash_flow_statement = 'cash_flow_statement', + // Info: (20240814 - Anna) 增加401報表 + report_401 = 'report_401', // change_in_equity_statement = 'change_in_equity_statement' } @@ -57,6 +59,11 @@ export const FinancialReportTypesMap: Record< id: FinancialReportTypesKey.cash_flow_statement, name: 'Cash Flow Statement', }, + // Info: (20240814 - Anna) 增加401報表 + [FinancialReportTypesKey.report_401]: { + id: FinancialReportTypesKey.report_401, + name: 'report_401', + }, // [FinancialReportTypesKey.change_in_equity_statement]: { // id: FinancialReportTypesKey.change_in_equity_statement, // name: 'Change in Equity Statement', diff --git a/src/locales/cn/common.json b/src/locales/cn/common.json index 890acfa91..1a7561364 100644 --- a/src/locales/cn/common.json +++ b/src/locales/cn/common.json @@ -210,6 +210,8 @@ "BALANCE_SHEET": "资产负债表", "CASH_FLOW_STATEMENT": "现金流量表", "STATEMENT_OF_CASH_FLOWS": "现金流量表", + "REPORT_401": "一般营业人销售额与税额申报书(401)", + "401_REPORT": "一般营业人销售额与税额申报书(401)", "CHANGE_IN_EQUITY_STATEMENT": "权益变动表", "RED_FLAG_ANALYSIS": "风险分析", "POWERED_BY": "技术支持" diff --git a/src/locales/en/common.json b/src/locales/en/common.json index de540b0c0..c9f38705d 100644 --- a/src/locales/en/common.json +++ b/src/locales/en/common.json @@ -212,7 +212,9 @@ "STATEMENT_OF_CASH_FLOWS": "Statement of Cash Flows", "CHANGE_IN_EQUITY_STATEMENT": "Change in Equity Statement", "RED_FLAG_ANALYSIS": "Red Flag Analysis", - "POWERED_BY": "Powered by" + "POWERED_BY": "Powered by", + "REPORT_401": "Business Tax Return(401)", + "401_REPORT": "Business Tax Return(401)" }, "AUDIT_REPORT": { "AUDIT_REPORT": "Audit Report", diff --git a/src/locales/tw/common.json b/src/locales/tw/common.json index be509bcf4..716b4e95e 100644 --- a/src/locales/tw/common.json +++ b/src/locales/tw/common.json @@ -210,6 +210,8 @@ "BALANCE_SHEET": "資產負債表", "CASH_FLOW_STATEMENT": "現金流量表", "STATEMENT_OF_CASH_FLOWS": "現金流量表", + "REPORT_401": "一般營業人銷售額與稅額申報書(401)", + "401_REPORT": "一般營業人銷售額與稅額申報書(401)", "CHANGE_IN_EQUITY_STATEMENT": "權益變動表", "RED_FLAG_ANALYSIS": "風險分析", "POWERED_BY": "技術支持" diff --git a/src/pages/users/reports/[reportId]/report_401/index.tsx b/src/pages/users/reports/[reportId]/report_401/index.tsx new file mode 100644 index 000000000..c9b8a0ee3 --- /dev/null +++ b/src/pages/users/reports/[reportId]/report_401/index.tsx @@ -0,0 +1,55 @@ +import Head from 'next/head'; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import { GetServerSideProps } from 'next'; +import { useUserCtx } from '@/contexts/user_context'; +import { DEFAULT_SKELETON_COUNT_FOR_PAGE } from '@/constants/display'; +import { SkeletonList } from '@/components/skeleton/skeleton'; +import TaxReportBodyAll from '@/components/tax_report_body_all/tax_report_body_all'; + +interface ITaxReportPageProps { + reportId: string; +} + +const TaxReportPage = ({ reportId }: ITaxReportPageProps) => { + const { isAuthLoading } = useUserCtx(); + + const displayedBody = isAuthLoading ? ( +
+ +
+ ) : ( +
+ +
+ ); + + return ( + <> + + + + + Tax Report + + +
{displayedBody}
+ + ); +}; + +export const getServerSideProps: GetServerSideProps = async ({ params, locale }) => { + if (!params || !params.reportId || typeof params.reportId !== 'string') { + return { + notFound: true, + }; + } + + return { + props: { + reportId: params.reportId, + ...(await serverSideTranslations(locale as string, ['common'])), + }, + }; +}; + +export default TaxReportPage; diff --git a/tsconfig.json b/tsconfig.json index d53430889..7d2e61c1b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,8 @@ "**/*.ts", "**/*.tsx", "tailwind.config.ts", - "src/lib/utils/email.js" -, "scripts/update_version.js" ], + "src/lib/utils/email.js", + "scripts/update_version.js" + ], "exclude": ["node_modules"] }