Skip to content

feat(split-meow): 搶救每筆支出幣別與匯率快照#445

Merged
s123104 merged 1 commit into
mainfrom
fix/rescue-split-meow-currency
Jun 26, 2026
Merged

feat(split-meow): 搶救每筆支出幣別與匯率快照#445
s123104 merged 1 commit into
mainfrom
fix/rescue-split-meow-currency

Conversation

@s123104

@s123104 s123104 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

摘要

搶救因 governance 分支被 PR #433 取代而遺失的 split-meow 每筆支出幣別+匯率快照功能(原 commit 87fcbe30,原屬已關閉路徑的 #411)。

背景

變更

  • ExpenseRecord 新增 currency + exchangeRateKrwPerTwd 快照欄位,記帳時保存
  • HistoryTab 個別金額用各筆快照幣別、KRW 副標即時換算 TWD、彙總/結算採 trip 主導幣別 fallback
  • 新增 formatKrwAsTwd helper;currencies.test 合併 main 完整版 + formatKrwAsTwd 測試
  • 補 002:split-meow 幣別快照 + fix(ratewise): 為導覽 case-3 加上有界網路 fallback #426 SW bounded-nav 稽核條目

驗證

🤖 Generated with Claude Code

- 從被 PR433 取代的 governance 分支搶救 split-meow 幣別快照功能(原 commit 87fcbe3)
- ExpenseRecord 保存記帳當下 currency 與 exchangeRateKrwPerTwd 快照
- HistoryTab 個別金額用各筆快照幣別、KRW 副標即時換算 TWD、彙總結算採 trip 主導幣別
- currencies.test 合併 main 完整版(detectCurrencyFromTimezone)與 formatKrwAsTwd 測試
- 補 002:split-meow 幣別快照與 PR426 SW bounded-nav 稽核條目(本次 +2,累計 +68)

測試:split-meow vitest 175/175 通過、typecheck 通過

Generated with Claude Code
via Happy

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e814a9bbf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +183 to +185
const tripCurrency: CurrencyCode = tripExpenses[tripExpenses.length - 1]?.currency ?? currency;
// 取得單筆記錄的顯示幣別(優先使用記帳當下快照,舊資料 fallback 主導幣別)。
const expenseCurrency = (exp: ExpenseRecord): CurrencyCode => exp.currency ?? tripCurrency;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 將舊費用缺幣別時回退為 TWD

這裡把沒有 currency 快照的舊資料回退到目前全域 currency,因此既有使用者升級後只要在設定切到 KRW,升級前以 TWD 記下的費用仍會被顯示/分享為 ₩,與 ExpenseRecord 註解「舊資料缺此欄位時視為 TWD」相反,也沒有真正修復這次要救回的舊 TWD→切 KRW 場景。請將 legacy fallback 固定為 TWD(或在 persist migrate 補上 TWD 快照)。

Useful? React with 👍 / 👎.

</span>
<h2 className="text-4xl font-medium text-on-surface tracking-tight">
{formatAmount(totalSpent, currency)}
{formatAmount(totalSpent, tripCurrency)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 先把不同幣別換算後再計算彙總

當同一行程先用 TWD 記 NT$100、再切到 KRW 用匯率快照 43.5 記 ₩30,000 時,totalSpent/balances 仍直接相加原始數字,這行只把 30,100 格式化成 tripCurrency(例如 NT$30,100),結算也用同一組 raw balances;正確應該先依每筆 currency/exchangeRateKrwPerTwd 換算到行程主幣別後再加總與結算,否則混合幣別行程會產生錯誤債務。

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant