Skip to content

fix(split-meow): 混幣行程加入 proactive 阻擋與編輯幣別對齊#457

Merged
s123104 merged 3 commits into
mainfrom
fix/splitp2
Jun 27, 2026
Merged

fix(split-meow): 混幣行程加入 proactive 阻擋與編輯幣別對齊#457
s123104 merged 3 commits into
mainfrom
fix/splitp2

Conversation

@s123104

@s123104 s123104 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

摘要

split-meow 混幣治理的 proactive 強化:先前 #445/#449/#451事後警告 + 停止跨幣裸加;本 PR 在動作當下阻擋靜默產生混幣行程,並修正編輯時的幣別來源。

由並行 Cursor 子代理(composer-2.5-fast,獨立 worktree)完成。

變更

  • config/currencies.ts:新增 wouldCreateMixedCurrencyTrip()(空行程/已混幣短路)。
  • SettingsTab.tsx:切換全域幣別前,若會使單幣行程變混幣 → confirm;取消則不切。
  • Calculator.tsx:存檔前同上;取消則不存。
  • HistoryTab.tsxEditExpenseSheet 改用 resolveExpenseCurrency,修正 legacy 帳目幣別符號。
  • 沿用既有 history.mixed_currency_warning(4 語系),未新增 i18n key

已知取捨

  • window.confirm(KISS 最小阻擋);日後可升級為樣式化 modal。

Test plan

  • vitest run → 184 passed(含 helper、取消 confirm 不切幣/不存檔)
  • tsc --noEmit → exit 0

🤖 Generated with Claude Code

- 新增 wouldCreateMixedCurrencyTrip,切換全域幣別或存檔前先 confirm
- 取消 confirm 不切幣別、不存檔,避免靜默產生混幣行程
- EditExpenseSheet 改用 resolveExpenseCurrency,修正 legacy 帳目幣別符號
- 沿用既有 history.mixed_currency_warning i18n key,未新增鍵

測試:vitest 184 項通過、tsc --noEmit 通過
@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: 49fb1b121f

ℹ️ 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".

incomingCurrency: CurrencyCode,
): boolean {
if (tripExpenses.length === 0) return false;
const tripCurrency = resolveTripCurrency(tripExpenses, globalCurrency);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve legacy TWD when checking mixed-currency saves

當既有行程只含舊資料(expense.currencyundefined)且目前全域幣別已被切到 KRW 時,這裡用目前的 globalCurrency 推導 tripCurrency,會把那些歷史紀錄視為 KRW;接著新增 KRW 記帳或切換到 KRW 時 incomingCurrency 會與 establishedCurrency 相同而不跳確認,仍會靜默把 KRW 金額加到實際上是 TWD 的舊行程中。ExpenseRecord.currency 的註解明確寫舊資料缺欄位時視為 TWD,所以這個 proactive guard 需要在 legacy case 使用 TWD(或先正規化舊資料)而不是目前全域幣別。

Useful? React with 👍 / 👎.

haotool added 2 commits June 27, 2026 11:52
- useCurrencyAutoDetect 會 silently 切幣,改為混幣時 skip 自動切換
- 新增 history.mixed_currency_confirm(4 語系)供 confirm 使用,語意正確
- 抽出 confirmMixedCurrencyIfNeeded helper 去除重複;補 legacy/confirm-OK/auto-detect 測試

測試:split-meow 188 項通過、tsc 通過
- currencies.ts 安全取末筆,移除 no-non-null-assertion

- 測試改用 ! 斷言與頂層 import type,符合 eslint 規則

測試:split-meow 188 項通過、pnpm lint 通過、tsc 通過
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@s123104 s123104 merged commit 513a9c1 into main Jun 27, 2026
16 checks passed
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