Skip to content

Conversation

@Kubosaka
Copy link
Collaborator

@Kubosaka Kubosaka commented Feb 22, 2025

対応Issue

resolve #0

概要

  • 予算管理ページのCSVダウンロード用のAPIを実装
  • GET /financial_records/csv/download?year={year}にブラウザでアクセスしたらcsvがダウンロードされます

要件など

  • CSVのダウンロード
    • ダウンロードボタンは局の階層のみにする
    • CSVの出力内容
      • 局 部門 物品名 予算の申請金額 購入金額(購入報告のチェック関係なく)
      • 局、部門はまとめて並べる

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

予算_2025.csv

テスト項目

  • ブラウザでAPIを叩くとcsvがダウンロードできるか

備考

Comment on lines +141 to +144
// 2つのdsをUNION
sql := ds.Union(dsExceptItem).Order(goqu.I("id").Asc())
query, _, err := sql.ToSQL()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

局や部門だけ登録されている場合にも、予算0として、csvに書き出したいため、UNIONでselectの結果を結合
また、idでソートする(局ごとまとめたいため)

@Kubosaka Kubosaka requested a review from hikahana February 22, 2025 08:09
@Kubosaka Kubosaka self-assigned this Feb 22, 2025
Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

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

ちょっとコメント!

Comment on lines 208 to 210
csvData := make([][]string, 0)
HEADER := []string{"局", "部門", "物品", "予算申請金額", "購入金額"}
csvData = append(csvData, HEADER)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
csvData := make([][]string, 0)
HEADER := []string{"局", "部門", "物品", "予算申請金額", "購入金額"}
csvData = append(csvData, HEADER)
header := []string{"局", "部門", "物品", "予算申請金額", "購入金額"}
csvData := [][]string{header}

こんな感じでも定義できそうかも

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UpdatedAt time.Time `json:"updatedAt"`
}

type FinancialRecordDetail struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

FinancialRecordData

で良いのでは?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

途中から名前書いたため残ってましたね、修正しました
type名修正

LeftJoin(goqu.I("buy_reports"), goqu.On(goqu.I("festival_items.id").Eq(goqu.I("buy_reports.festival_item_id")))).
GroupBy("financial_records.id")

// 予算・部門がないものを取得するds
Copy link
Collaborator

Choose a reason for hiding this comment

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

このコメント要らないかも?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

個人的にはコメントで説明があったほうが後々助かるかと思いますので必要かなって思います!

@Kubosaka Kubosaka requested a review from hikahana February 24, 2025 06:47
Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

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

LGTM

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 24, 2025

Deploying finansu with  Cloudflare Pages  Cloudflare Pages

Latest commit: b0a5a41
Status: ✅  Deploy successful!
Preview URL: https://5957f9d5.finansu.pages.dev
Branch Preview URL: https://feat-kubosaka-budget-csv-dow.finansu.pages.dev

View logs

@Kubosaka Kubosaka merged commit 09b74ff into develop Feb 24, 2025
3 checks passed
@Kubosaka Kubosaka deleted the feat/kubosaka/budget-csv-download branch February 24, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants