Skip to content

Feat/walt/purchase report sort frontend#1044

Open
nakatashingo wants to merge 43 commits into
developfrom
feat/walt/purchase-report-sort-frontend
Open

Feat/walt/purchase report sort frontend#1044
nakatashingo wants to merge 43 commits into
developfrom
feat/walt/purchase-report-sort-frontend

Conversation

@nakatashingo
Copy link
Copy Markdown
Collaborator

@nakatashingo nakatashingo commented Jan 24, 2026

対応Issue

https://www.notion.so/nutfes-nutmeg/FinanSu-2b941f19206380518f1af6de573da465
https://nut-m-e-g.slack.com/archives/C020WQ3GY07/p1765010563203229

概要

  • 購入報告一覧において,「局名」「氏名」で立替者の絞り込みを可能に
  • 購入報告一覧において,「未精算金額」「未封詰め金額」の合計金額を表示

画面スクリーンショット等

image image
  • URL
    スクリーンショット

テスト項目

  • 購入報告一覧のサマリ(未精算/未封詰め)の初期の表示が正しいか確認
  • 任意のレコードで封詰めのチェックを切り替えた後にサマリが更新されるか確認
  • 封詰め積みのレコードで生産チェックを切り替えた後,サマリが更新されることを確認
  • フィルタでの絞り込み後,サマリが更新されることを確認

備考

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @nakatashingo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、購入報告一覧ページのユーザビリティを大幅に向上させるための機能追加です。具体的には、立替者(局名および氏名)による絞り込み機能と、未清算金額および未封詰め金額の合計表示機能が導入されました。これにより、ユーザーはより効率的に必要な情報を探し、全体の財務状況を把握できるようになります。

Highlights

  • 立替者絞り込み機能の追加: 購入報告一覧ページに、立替者(局名と氏名)で絞り込みを行うための新しいモーダルコンポーネントが追加されました。
  • 合計金額表示機能の追加: 購入報告一覧ページに、未清算金額と未封詰め金額の合計を表示する新しいコンポーネントが追加され、財務状況の概要を素早く確認できるようになりました。
  • 既存ページへの機能統合: 上記の絞り込み機能と合計金額表示機能が、既存の購入報告リストページ(purchase_report_list/index.tsx)に統合され、ユーザーインターフェースが改善されました。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 24, 2026

Deploying finansu with  Cloudflare Pages  Cloudflare Pages

Latest commit: a57da05
Status: ✅  Deploy successful!
Preview URL: https://f1be018e.finansu.pages.dev
Branch Preview URL: https://feat-walt-purchase-report-so.finansu.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

このプルリクエストでは、購入報告一覧ページに立替者による絞り込み機能と、未清算・未封詰め金額の合計表示機能が追加されました。新機能の実装は概ね良好ですが、状態管理のロジックにいくつか改善の余地があります。特に、絞り込みモーダル内の状態管理が冗長であり、簡潔にすることができます。また、APIからのデータ取得部分で、より堅牢な型チェックを行うことで、将来的なエラーを防ぐことができます。詳細は各コメントを参照してください。

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
@nakatashingo nakatashingo marked this pull request as ready for review January 31, 2026 13:12
Copy link
Copy Markdown
Member

@TkymHrt TkymHrt left a comment

Choose a reason for hiding this comment

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

レビューしました! コード全体はきれいにまとまっていて良さそうです。

1点、「立替者」の絞り込みについて追加で実装をお願いしたいです!
すでにシードデータで試したときに気づいているかもだけれど、現状だと一覧は paid_by (文字列)なのに、絞り込みは paid_by_user_id 基準だから、IDがないデータが検索に引っかからないんだよねー

API側では、paid_by での完全一致フィルタが使えるように対応済みだから、フロント側でも利用できるように調整してもらいたいです!

@nakatashingo nakatashingo requested a review from TkymHrt February 7, 2026 12:30
Copy link
Copy Markdown
Member

@TkymHrt TkymHrt left a comment

Choose a reason for hiding this comment

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

封詰め・清算のステータス変更とかレコード削除の後も未清算金額・未封詰め金額のサマリが古い値のままかな。(一通り動作テストして、テスト項目書いといてくれると助かる!)

const onSuccess = useCallback(() => {
mutateBuyReportData();
}, [mutateBuyReportData]);

たぶんこんな感じ

const {
  data: buyReportsSummaryData,
  isLoading: isBuyReportsSummaryLoading,
  error: buyReportsSummaryError,
  mutate: mutateBuyReportsSummary, 
} = useGetBuyReportsSummary(...);

const onSuccess = useCallback(() => {
  mutateBuyReportData();
  mutateBuyReportsSummary(); 
}, [mutateBuyReportData, mutateBuyReportsSummary]);

Copy link
Copy Markdown
Member

@TkymHrt TkymHrt left a comment

Choose a reason for hiding this comment

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

氏名のセレクトで、usersテーブルに存在するユーザーしか選択肢に出てないねー

paid_by_user_idがnullでpaid_by文字列のみ持つ過去データにも後方互換性を持たせたいんだけれど・・・
レガシーオプション?みたいな実装をしてくれているけれど仕事してなさそう?

取得済みのbuyReportsデータにpaidByが含まれてるから、そこから値を抽出してドロップダウンに表示するとか、自由入力に対応させるとかが必要かなー

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/components/purchasereports/PurchaseReportSummaryAmounts.tsx Outdated
Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
nakatashingo and others added 2 commits May 18, 2026 22:51
…type guard

useGetUsers() already returns User[] in generated types, making the complex
unknown-cast filtering unreachable. Remove the isUser guard and replace the
useMemo with a direct usersResponse?.data ?? [] access.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/utils/purchaseReportFilters.ts Outdated
nakatashingo and others added 2 commits May 18, 2026 23:10
…x catch binding

- Remove selectedBureauId spread from API params: BUREAUS.id != financial_records.id
- Add NOTE comment explaining the mismatch until proper wiring is implemented
- Change catch {} to catch (e) {} to preserve thrown exception in error log
- Simplify PaidByFilterInput.paidBy type from string|null|undefined to string|null
- Change selectedPaidBy state initial value from undefined to null for consistency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ll state

onApply.paidBy and selectedPaidBy were typed as string|null|undefined while
the parent state and normalizePaidBy return type are string|null, causing
a TS2345 type error.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
nakatashingo and others added 2 commits May 18, 2026 23:33
…y ids

- Add useGetFinancialRecords to map BUREAUS.id → financial_records.id by name,
  then pass the resolved financial_record_id to both buy-reports detail and
  summary API params so bureau filter actually narrows the results
- Move useGetUsers after buyReports, pass ids of paidByUserId values found in
  the current reports instead of fetching all users unconditionally

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread mysql/seed/000001_initial_schema_seed.sql Outdated
nakatashingo and others added 2 commits May 18, 2026 23:46
Remove unintended file_metas rows (id 4-7) added to the seed file on this branch.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread view/next-project/src/pages/purchase_report_list/index.tsx Outdated
Comment thread view/next-project/src/components/purchasereports/PurchaseReportSummaryAmounts.tsx Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment on lines +75 to +98
const bureauToFinancialRecordId = useMemo(() => {
const records = financialRecordsData?.data?.financialRecords ?? [];
return new Map(
BUREAUS.flatMap((bureau) => {
const record = records.find((r) => r.name === bureau.name);
return record?.id != null ? ([[bureau.id, record.id]] as const) : [];
}),
);
}, [financialRecordsData]);

const financialRecordId =
selectedBureauId != null ? (bureauToFinancialRecordId.get(selectedBureauId) ?? null) : null;

const hasSelectedBureauWithoutFinancialRecord =
selectedBureauId != null && financialRecordId == null;

const getBuyReportsDetailsParams: GetBuyReportsDetailsParams = {
year: selectedYear,
...(financialRecordId != null
? { financial_record_id: financialRecordId }
: hasSelectedBureauWithoutFinancialRecord
? { financial_record_id: -1 }
: {}),
...paidByFilterParams,
Comment on lines +65 to +83
const nameOptions = useMemo(
(): NameOption[] => [
{ value: '', label: '絞り込みなし' },
...legacyPaidByOptions.map((name) => ({ value: `legacy:${name}`, label: name })),
...filteredUsers.map((u) => {
const bureauName = bureauNameMap.get(u.bureauID);
const label = draftBureauId || !bureauName ? u.name : `${bureauName} ${u.name}`;
return { value: `user:${u.id}`, label };
}),
],
[filteredUsers, legacyPaidByOptions, bureauNameMap, draftBureauId],
);

const nameSelectValue =
draftPaidByUserId != null
? (nameOptions.find((o) => o.value === `user:${draftPaidByUserId}`) ?? nameOptions[0])
: draftPaidBy != null
? (nameOptions.find((o) => o.value === `legacy:${draftPaidBy}`) ?? nameOptions[0])
: nameOptions[0];
Copy link
Copy Markdown
Member

@TkymHrt TkymHrt left a comment

Choose a reason for hiding this comment

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

ask
立替者の所属局と購入報告の申請局が混在してるけど、要件ってこれで良いんだっけ?

imo
後方互換性まだ怪しそう。
現在のユーザー名と一致する paidBy を除外してるから、同名の過去データは選択肢にも出ないし、検索にも引っかからないんじゃないかな。バックエンド側で解消しないとか・・・

以下、Codexが見つけたやつ

  1. ステータス更新後に余分な PUT が再発火し得ます。
    view/next-project/src/pages/purchase_report_list/index.tsx:268updateStatususeEffect から呼ばれ、成功後に view/next-project/src/pages/purchase_report_list/index.tsx:278 で一覧を mutate します。その再取得結果を view/next-project/src/pages/purchase_report_list/index.tsx:196effect がまた sealChecks/settlementChecks に流し込み、updateStatus の依存が変わって同じ buyReportId で再度 PUT されます。更新処理は checkbox/confirm のイベントハンドラ内で完結させるか、成功後に buyReportId をリセットしてください。

  2. 年度選択が再取得で最新年度に戻る可能性があります。
    view/next-project/src/pages/purchase_report_list/index.tsx:53effectyearPeriods が変わるたびに selectedYear を最新年度へ上書きします。SWR の再検証やフォーカス復帰で、ユーザーが選んだ過去年が勝手に戻り得ます。初期化は prev === 0 のときだけに限定してください。

  3. 差分ファイルに lint warning が残っています。
    view/next-project/src/pages/purchase_report_list/index.tsx:125legacyPaidByOptions は未使用です。加えて usersResponse?.data ?? [] / modalUsersResponse?.data ?? [] の空配列生成が hook 依存警告を出しています。

Copy link
Copy Markdown
Member

@TkymHrt TkymHrt left a comment

Choose a reason for hiding this comment

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

// paid_by_user_idを優先
if paidByUserID != "" {
conditions["buy_reports.paid_by_user_id"] = paidByUserID

ここを下記みたいに変えればフロントのリファクタ無しで互換性問題は解決できそう。

		ds = ds.Where(
			goqu.Or(
				goqu.I("buy_reports.paid_by_user_id").Eq(paidByUserID),
				goqu.I("buy_reports.paid_by").Eq(
					dialect.From("users").
						Select(goqu.I("users.name")).
						Where(goqu.I("users.id").Eq(paidByUserID)),
				),
			),
		)

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.

3 participants