Skip to content

feat: カテゴリーフィルタ時に合計金額を表示する#1141

Open
yasumorishima wants to merge 6 commits intoteam-mirai:developfrom
yasumorishima:feature/issue-248-category-filter-total-amount
Open

feat: カテゴリーフィルタ時に合計金額を表示する#1141
yasumorishima wants to merge 6 commits intoteam-mirai:developfrom
yasumorishima:feature/issue-248-category-filter-total-amount

Conversation

@yasumorishima
Copy link
Copy Markdown

@yasumorishima yasumorishima commented Feb 12, 2026

概要

Closes #248

カテゴリーフィルタが選択されている場合に、フィルタされた全取引の合計金額をテーブル上部に表示します。

変更内容

  • transaction-list-repository.interface.tsgetTotalAmount() を追加
  • prisma-transaction.repository.ts — groupByで合計金額を集計
  • get-transactions-by-slug-usecase.tstotalAmount をresultに追加
  • page.tsxtotalAmount をコンポーネントに渡す
  • InteractiveTransactionTable.tsx — フィルター合計表示UI追加
  • get-transactions-by-slug-usecase.test.ts — テスト追加

仕様

  • フィルター適用時のみ合計金額を表示(未適用時は非表示)
  • 正の値: 緑(+)、負の値: 赤(-)、ゼロ: グレー(符号なし)

テスト

  • ユニットテストでtotalAmountの有無と値を検証済み
  • フォーク内CI全通過(CodeRabbit / CodeQL / e2e / coverage / admin / knip / webapp)

Summary by CodeRabbit

リリースノート

  • 新機能
    • トランザクションテーブルにフィルター合計表示機能を追加しました。カテゴリが選択されている場合、フィルタリングされた取引の合計金額を通貨形式で表示します。合計金額は、収入・支出に応じて色が動的に変わります。デスクトップおよびモバイルの両方のレイアウトで利用可能です。

yasumorishima and others added 6 commits February 12, 2026 16:41
カテゴリーフィルタが選択されている場合に、フィルタされた全取引の
合計金額をテーブル上部に表示する機能を追加。

- ITransactionListRepository に getTotalAmount() を追加
- PrismaTransactionRepository で groupBy を用いた合計金額集計を実装
- GetTransactionsBySlugUsecase の結果に totalAmount を追加(categories
  フィルタなしの場合は null)
- InteractiveTransactionTable にフィルター合計表示を追加(収入は緑・
  支出は赤の符号付き表示)
- テスト: getTotalAmount の呼び出し有無を検証するケースを追加

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
フォーク専用のセキュリティ解析ワークフロー。
upstream PRには含めない。

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…mountアサーション追加

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 12, 2026

@yasumorishima is attempting to deploy a commit to the team-mirai Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 12, 2026

Walkthrough

カテゴリーでフィルタされた取引の合計金額を表示する機能を追加します。UIコンポーネント、ユースケース、リポジトリインターフェース、実装層、テストにわたって、取引の合計額を計算して表示するための機能を統合します。

Changes

Cohort / File(s) Summary
UIコンポーネント
webapp/src/app/o/[slug]/transactions/page.tsx, webapp/src/client/components/top-page/features/transactions-table/InteractiveTransactionTable.tsx
カテゴリーフィルタ選択時に合計額を表示するUI機能を追加。通貨フォーマッター(Intl.NumberFormat)を導入し、正負に応じた動的色付けと通貨サフィックス付きの合計額インジケーターをPC・モバイル両レイアウトに実装。
ドメイン・アプリケーション層
webapp/src/server/contexts/public-finance/domain/repositories/transaction-list-repository.interface.ts, webapp/src/server/contexts/public-finance/application/usecases/get-transactions-by-slug-usecase.ts
ITransactionListRepositoryにgetTotalAmountメソッドを追加し、GetTransactionsBySlugResultに totalAmount フィールドを追加。カテゴリーフィルタ存在時のみ合計額を計算・返却。
インフラストラクチャ層
webapp/src/server/contexts/public-finance/infrastructure/repositories/prisma-transaction.repository.ts
PrismaTransactionRepositoryにgetTotalAmountメソッドを実装。フィルタ条件に基づいて取引をグループ化し、借方・貸方を集計して符号付き合計を算出。
テスト
webapp/tests/server/contexts/public-finance/application/usecases/get-transactions-by-slug-usecase.test.ts
getTotalAmountメソッドの呼び出しと条件付き動作をテスト。カテゴリーフィルタ不在時は totalAmount が null、存在時は数値が返却されることを検証。

Sequence Diagram(s)

sequenceDiagram
    participant Client as クライアント
    participant Page as TransactionsPage
    participant UseCase as GetTransactionsBySlugUsecase
    participant Repo as PrismaTransactionRepository
    participant DB as Database

    Client->>Page: トランザクション一覧をリクエスト (カテゴリーフィルタ付き)
    Page->>UseCase: execute(filters)を呼び出し
    
    UseCase->>Repo: findAll(filters)でトランザクション一覧を取得
    Repo->>DB: フィルタ条件で問い合わせ
    DB-->>Repo: トランザクションデータ
    Repo-->>UseCase: transactions[]
    
    alt カテゴリーフィルタが存在する場合
        UseCase->>Repo: getTotalAmount(filters)で合計額を計算
        Repo->>DB: フィルタ条件で集計
        DB-->>Repo: 合計額(数値)
        Repo-->>UseCase: totalAmount: number
    else カテゴリーフィルタが存在しない場合
        UseCase->>UseCase: totalAmount = null
    end
    
    UseCase-->>Page: GetTransactionsBySlugResult {transactions, totalAmount, ...}
    Page->>InteractiveTransactionTable: totalAmountプロップを渡す
    InteractiveTransactionTable->>InteractiveTransactionTable: 合計額を通貨フォーマットして表示
    InteractiveTransactionTable-->>Client: 取引一覧と合計額を表示
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jujunjun110
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR タイトル「feat: カテゴリーフィルタ時に合計金額を表示する」は、主な変更内容(カテゴリーフィルタ時に合計金額表示機能の追加)を正確かつ明確に表現しており、変更内容と一致しています。
Linked Issues check ✅ Passed PR は Issue #248 の要件(カテゴリーフィルタ時に合計金額を表示する機能)をすべて実装しており、リポジトリインターフェース、ユースケース、UI コンポーネント、テストを整備して要件を満たしています。
Out of Scope Changes check ✅ Passed すべての変更は Issue #248 のカテゴリーフィルタ時合計金額表示機能に関連しており、範囲外の変更は検出されていません。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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