Skip to content

Commit

Permalink
Merge pull request #3756 from CAFECA-IO/feature/fix-export-trial-bala…
Browse files Browse the repository at this point in the history
…nce-api

fix: 🐛 POST export-trial-balance API to align with format of list-trial-balance API column
  • Loading branch information
Luphia authored Dec 25, 2024
2 parents 5ac89c0 + 7205e0d commit d8ec4fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 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.5+232",
"version": "0.8.5+233",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
13 changes: 7 additions & 6 deletions src/constants/export_trial_balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ export enum ExportTrialBalanceFileType {
}

export const TrialBalanceFieldsMap: Record<ITrialBalanceHeader, string> = {
no: '科目編號',
accountingTitle: '會計科目',
beginningCreditAmount: '期初借方餘額',
beginningDebitAmount: '期初貸方餘額',
midtermCreditAmount: '期中借方餘額',
midtermDebitAmount: '期中貸方餘額',
endingCreditAmount: '期末借方餘額',
endingDebitAmount: '期末貸方餘額',
beginningDebitAmount: '期初借方餘額',
beginningCreditAmount: '期初貸方餘額',
midtermDebitAmount: '期中借方餘額',
midtermCreditAmount: '期中貸方餘額',
endingDebitAmount: '期末借方餘額',
endingCreditAmount: '期末貸方餘額',
};

export const trialBalanceAvailableFields = exportTrialBalanceFieldsSchema.options.map(
Expand Down
21 changes: 12 additions & 9 deletions src/lib/utils/trial_balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,17 @@ export const convertTrialBalanceDataToCsvData = (trialBalanceData: ITrialBalance
export function transformTrialBalanceData(
items: TrialBalanceItem[]
): Record<string, string | number>[] {
const data = items.map((item) => ({
accountingTitle: item.accountingTitle,
beginningCreditAmount: item.beginningCreditAmount,
beginningDebitAmount: item.beginningDebitAmount,
midtermCreditAmount: item.midtermCreditAmount,
midtermDebitAmount: item.midtermDebitAmount,
endingCreditAmount: item.endingCreditAmount,
endingDebitAmount: item.endingDebitAmount,
}));
const data = items.map((item) => {
return {
no: item.no,
accountingTitle: item.accountingTitle,
beginningDebitAmount: item.beginningDebitAmount,
beginningCreditAmount: item.beginningCreditAmount,
midtermDebitAmount: item.midtermDebitAmount,
midtermCreditAmount: item.midtermCreditAmount,
endingDebitAmount: item.endingDebitAmount,
endingCreditAmount: item.endingCreditAmount,
};
});
return data;
}
7 changes: 4 additions & 3 deletions src/lib/utils/zod_schema/export_trial_balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ const sortSchema = z.object({

// Info: (20241213 - Shirley) 匯出欄位驗證器
export const exportTrialBalanceFieldsSchema = z.enum([
'no',
'accountingTitle',
'beginningCreditAmount',
'beginningDebitAmount',
'midtermCreditAmount',
'beginningCreditAmount',
'midtermDebitAmount',
'endingCreditAmount',
'midtermCreditAmount',
'endingDebitAmount',
'endingCreditAmount',
]);

// Info: (20241213 - Shirley) 過濾條件驗證器
Expand Down

0 comments on commit d8ec4fb

Please sign in to comment.