fix(split-meow): 混幣行程停止跨幣別錯誤加總與結算#451
Conversation
- 混幣行程的總額、各人餘額與結算改為短路不計算,避免裸加不同幣別 - 隱藏混幣情境的「各人結算」區塊,僅保留警告,杜絕誤導金額 - 抽出 resolveExpenseCurrency 等純函式至 currencies SSOT 並補單元測試 - 編輯既有費用改用該筆 currency 快照顯示符號,不再依賴全域幣別 測試:split-meow typecheck 通過、vitest 3 檔 71 測試全過
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47353cc4db
ℹ️ 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".
| expenses: { currency?: CurrencyCode }[], | ||
| globalCurrency: CurrencyCode, | ||
| ): CurrencyCode { | ||
| return expenses[expenses.length - 1]?.currency ?? globalCurrency; |
There was a problem hiding this comment.
Treat legacy expenses as TWD before mixed detection
在既有舊資料缺少 currency 的情境下,ExpenseRecord 的契約註明這些記錄應視為 TWD,但這裡把最舊一筆缺欄位的行程幣別 fallback 成目前全域幣別。若使用者有 KRW 功能上線前的 TWD 記錄,之後全域幣別切到 KRW 並在同一行程新增 KRW 費用,isMixedCurrencyTrip 會把舊 TWD 費用也視為 KRW,導致這次混幣 guard 被繞過,總額/餘額/結算仍會裸加不同幣別;請在解析舊記錄時固定 default 為 TWD 或先做 migration。
Useful? React with 👍 / 👎.
摘要
混幣行程(同一行程混用多種幣別)先前在「各人結算」仍把不同幣別的裸數字相加,顯示誤導金額。本 PR 收斂為:混幣時短路不計算總額/餘額/結算,僅保留警告並隱藏結算區塊。
背景 / 證據
isMixedCurrency原本只擋總額與結算區塊,但balances仍裸加 TWD+KRW。變更
currencies.ts:抽出純函式resolveExpenseCurrency/resolveTripCurrency/isMixedCurrencyTrip/computeMemberBalances作為領域 SSOT,並補單元測試。HistoryTab.tsx:混幣時totalSpent=0、balances={}、settlements=[],隱藏「各人結算」;useShallow窄 selector 訂閱;EditExpenseSheet改用該筆expense.currency快照顯示符號。影響範圍
僅
apps/split-meow;單幣別行程行為完全不變。驗收
pnpm --filter @app/split-meow typecheck✅useStore/currencies/HomeAndHistorySmoke共 71 測試通過(全套 181 通過)✅🤖 Generated with Claude Code