Skip to content

Commit

Permalink
Merge branch 'develop' into feature/remain_mock
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphia authored Sep 26, 2024
2 parents 354058b + ee03f92 commit c8f52a1
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="relative z-1 mb-16px flex justify-between font-semibold text-surface-brand-secondary">
<p>一、項目彙總格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="relative z-1 w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -682,7 +682,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>一、項目彙總格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -728,7 +728,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps

<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -785,7 +785,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -842,7 +842,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -899,7 +899,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -956,7 +956,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -1013,7 +1013,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -1070,7 +1070,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -1127,7 +1127,7 @@ const BalanceSheetReportBodyAll = ({ reportId }: IBalanceSheetReportBodyAllProps
<section className="mx-1 text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-16px flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>一、項目彙總格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.general && renderTable(reportFinancial.general, 0, 10)}
</section>
Expand All @@ -345,7 +345,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>一、項目彙總格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.general && renderTable(reportFinancial.general, 10, 19)}
<div className="relative -z-10">
Expand All @@ -360,7 +360,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo

<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.details && renderTable(reportFinancial.details, 0, 3)}

Expand Down Expand Up @@ -394,7 +394,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.details && renderTable(reportFinancial.details, 0, 13)}

Expand Down Expand Up @@ -428,7 +428,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.details && renderTable(reportFinancial.details, 13, 26)}

Expand Down Expand Up @@ -462,7 +462,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.details && renderTable(reportFinancial.details, 26, 41)}

Expand Down Expand Up @@ -496,7 +496,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>二、細項分類格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.details && renderTable(reportFinancial.details, 41, 55)}

Expand Down Expand Up @@ -530,7 +530,7 @@ const CashFlowStatementReportBodyAll = ({ reportId }: ICashFlowStatementReportBo
<section className="relative mx-1 text-text-neutral-secondary">
<div className="mb-1 mt-8 flex justify-between text-xs font-semibold text-surface-brand-secondary">
<p>一、項目彙總格式</p>
<p>單位:新台幣仟元</p>
<p>單位:新台幣元</p>
</div>
{reportFinancial && reportFinancial.details && renderTable(reportFinancial.details, 55, 70)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="relative z-1 mb-16px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">一、項目彙總格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="relative z-1 w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -216,7 +216,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">一、項目彙總格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -309,7 +309,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">一、項目彙總格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -452,7 +452,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">二、細項分類格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -543,7 +543,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">二、細項分類格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -634,7 +634,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">二、細項分類格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -725,7 +725,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">二、細項分類格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -818,7 +818,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="relative text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">二、細項分類格式</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元 每股盈餘單位:新台幣元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元 每股盈餘單位:新台幣元</p>
</div>
<table className="relative z-10 w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -945,7 +945,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
<section className="relative text-text-neutral-secondary">
<div className="mb-16px mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">三、投入費用和成本,與收入的倍數關係</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元</p>
</div>
<table className="relative z-10 w-full border-collapse bg-white">
<thead>
Expand Down Expand Up @@ -1101,7 +1101,7 @@ const IncomeStatementReportBodyAll = ({ reportId }: IIncomeStatementReportBodyAl
)}
<div className="mb-4 mt-32px flex justify-between font-semibold text-surface-brand-secondary">
<p className="text-xs font-bold leading-5">四、收入提撥至研發費用比例</p>
<p className="text-xs font-bold leading-5">單位:新台幣仟元</p>
<p className="text-xs font-bold leading-5">單位:新台幣元</p>
</div>
<table className="relative z-10 mb-75px w-full border-collapse bg-white">
<thead>
Expand Down
70 changes: 45 additions & 25 deletions src/lib/utils/report/balance_sheet_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,46 +68,66 @@ export default class BalanceSheetGenerator extends FinancialReportGenerator {
SPECIAL_ACCOUNTS.OTHER_COMPREHENSIVE_INCOME.code
);

const netIncomeInEquity = await findUniqueAccountByCodeInPrisma(
SPECIAL_ACCOUNTS.NET_INCOME_IN_EQUITY.code
);

const otherEquityOther = await findUniqueAccountByCodeInPrisma(
SPECIAL_ACCOUNTS.OTHER_EQUITY_OTHER.code
);

closeAccount.push({
id: -1,
id: netIncomeInEquity?.id || -1,
amount: curPeriod ? netIncome.curPeriodAmount : netIncome.prePeriodAmount,
description: SPECIAL_ACCOUNTS.NET_INCOME.name,
debit: SPECIAL_ACCOUNTS.NET_INCOME.debit,
accountId: netIncomeAccount?.id || -1,
description: SPECIAL_ACCOUNTS.NET_INCOME_IN_EQUITY.name,
debit: SPECIAL_ACCOUNTS.NET_INCOME_IN_EQUITY.debit,
accountId: netIncomeInEquity?.id || -1,
voucherId: -1,
createdAt: 1,
updatedAt: 1,
deletedAt: null,
account: netIncomeAccount || {
...SPECIAL_ACCOUNTS.NET_INCOME,
id: -1,
companyId: this.companyId,
createdAt: 1,
updatedAt: 1,
deletedAt: null,
},
account: netIncomeAccount
? {
...netIncomeAccount,
code: SPECIAL_ACCOUNTS.NET_INCOME_IN_EQUITY.code,
debit: SPECIAL_ACCOUNTS.NET_INCOME_IN_EQUITY.debit,
}
: {
...SPECIAL_ACCOUNTS.NET_INCOME_IN_EQUITY,
id: -1,
companyId: this.companyId,
createdAt: 1,
updatedAt: 1,
deletedAt: null,
},
});

closeAccount.push({
id: -1,
id: otherEquityOther?.id || -1,
amount: curPeriod
? otherComprehensiveIncome.curPeriodAmount
: otherComprehensiveIncome.prePeriodAmount,
description: SPECIAL_ACCOUNTS.OTHER_COMPREHENSIVE_INCOME.name,
debit: SPECIAL_ACCOUNTS.OTHER_COMPREHENSIVE_INCOME.debit,
accountId: otherComprehensiveIncomeAccount?.id || -1,
description: SPECIAL_ACCOUNTS.OTHER_EQUITY_OTHER.name,
debit: SPECIAL_ACCOUNTS.OTHER_EQUITY_OTHER.debit,
accountId: otherEquityOther?.id || -1,
voucherId: -1,
createdAt: 1,
updatedAt: 1,
deletedAt: null,
account: otherComprehensiveIncomeAccount || {
...SPECIAL_ACCOUNTS.OTHER_COMPREHENSIVE_INCOME,
id: -1,
companyId: this.companyId,
createdAt: 1,
updatedAt: 1,
deletedAt: null,
},
account: otherComprehensiveIncomeAccount
? {
...otherComprehensiveIncomeAccount,
code: SPECIAL_ACCOUNTS.OTHER_EQUITY_OTHER.code,
debit: SPECIAL_ACCOUNTS.OTHER_EQUITY_OTHER.debit,
}
: {
...SPECIAL_ACCOUNTS.OTHER_EQUITY_OTHER,
id: -1,
companyId: this.companyId,
createdAt: 1,
updatedAt: 1,
deletedAt: null,
},
});

return closeAccount;
Expand All @@ -118,12 +138,12 @@ export default class BalanceSheetGenerator extends FinancialReportGenerator {

// Info: (20240801 - Murky) 暫時關閉本期損益和其他其他綜合損益權益
const closeAccount = await this.closeAccountFromIncomeStatement(curPeriod);

lineItemsFromDB = lineItemsFromDB.concat(closeAccount);

const accountForest = await this.getAccountForestByReportSheet();

const lineItemsMap = transformLineItemsFromDBToMap(lineItemsFromDB);

const updatedAccountForest = updateAccountAmounts(accountForest, lineItemsMap);

return updatedAccountForest;
Expand Down
Loading

0 comments on commit c8f52a1

Please sign in to comment.