Skip to content

feat: 有価証券届出書の財務サマリー対応とdoc-descriptionフィルタ追加#6

Merged
beatinaniwa merged 5 commits into
mainfrom
feat/financial-summary-fallback-and-doc-description-filter
Apr 1, 2026
Merged

feat: 有価証券届出書の財務サマリー対応とdoc-descriptionフィルタ追加#6
beatinaniwa merged 5 commits into
mainfrom
feat/financial-summary-fallback-and-doc-description-filter

Conversation

@beatinaniwa

Copy link
Copy Markdown
Owner

概要

IPO企業の財務分析でedinet-cliを使用した際に判明した2つの課題を修正。

  1. doc financialが有価証券届出書で空のサマリーを返す問題: 届出書にはcurrent期間が存在せず、すべてprior1〜prior5の過去データのためpopulateSummaryが何も抽出できなかった。フォールバックロジックを追加し、最も直近の利用可能期間からサマリーを生成するよう改修。
  2. doc listにdoc-descriptionフィルタがない問題: doc_type 030で検索すると投資信託が大量に混入し、IPO書類の特定にgrepが必要だった。--doc-descriptionフラグを追加し、書類説明のサブストリングマッチでフィルタ可能に。

変更内容

  • internal/financial/summary.go: populateSummaryを改修。current期間がない場合にperiodOrder順で最も優先度の高い期間にフォールバック。補足キー(EPS・配当等)のみの期間はスキップ
  • internal/financial/types.go: ParseResult/FinancialDataSummaryPeriodフィールドを追加
  • internal/financial/parser.go: BuildAndDeriveSummaryの戻り値変更に対応
  • internal/service/financial.go: SummaryPeriodの伝播とフィルタ後の再計算
  • internal/service/document.go: ListOptionsDocDescription追加、filterDocumentsにフィルタロジック追加
  • cmd/doc.go: --doc-descriptionフラグの登録と配線
  • internal/schema/schema.go: schemaにフラグ追加
  • テストファイル7本: 新規テスト15個追加(ユニット・統合・リグレッション)

Codexローカルレビューの結果

  • 3ラウンド(修正: 4件、スキップ: 2件)
  • スキップ理由: EDINETデータ特性上の理論的エッジケース(filing_dateの非補足キー混入、カバレッジベースの期間選択)で実用上の影響なし

doc financialが有価証券届出書(IPO時)で空のサマリーを返す問題を修正。
populateSummaryを改修し、current期間がない場合にprior1等へフォールバックする。
また、doc listに--doc-descriptionフラグを追加し、書類説明での絞り込みを可能にした。

@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: 4b2cab4b43

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

Comment on lines +95 to +102
if additiveKeys[item.SummaryKey] {
existing := summary[item.SummaryKey]
if existing == nil {
v := *item.Value
summary[item.SummaryKey] = &v
} else {
v := *existing + *item.Value
summary[item.SummaryKey] = &v

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid double-counting additive keys across periods

When bestPeriod is extracted and then filing_date is extracted, additive keys are always accumulated, so a key like interest_bearing_debt is summed even if the values come from different periods. In filing-style data that has both prior1 and filing_date debt items, this inflates debt and any derived ratios because the summary mixes two snapshots instead of choosing one period for additive metrics.

Useful? React with 👍 / 👎.

bestPeriodとfiling_dateの両方にinterest_bearing_debt等が存在する場合に
合算されてしまう問題を修正。additive keysはbestPeriod内でのみ累積し、
filing_dateからは非additive keysのみ補足する。
@beatinaniwa

Copy link
Copy Markdown
Owner Author

@codex review

@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: 784b775b24

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

Comment thread internal/financial/summary.go Outdated
Comment on lines +97 to +99
if additiveKeys[item.SummaryKey] {
if !allowAdditive {
continue

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 additive keys in filing_date extraction

The new allowAdditive gate drops every additive key when the target period is filing_date, so interest_bearing_debt is silently omitted whenever debt is only present in FilingDateInstant rows (or missing from the selected best period). That removes real extracted values and can suppress derived metrics like debt_to_equity, which is a regression from the prior logic that included filing-date debt values.

Useful? React with 👍 / 👎.

bestPeriodにdebt等がない場合にfiling_dateからも取得できるよう修正。
ただしbestPeriodで既に設定済みの場合は混在を防ぐためスキップする。
@beatinaniwa

Copy link
Copy Markdown
Owner Author

@codex review

@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: 3e163c134c

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

Comment thread internal/financial/summary.go Outdated
Comment on lines +109 to +113
} else {
// Supplemental period: only fill if not already set
if _, exists := summary[item.SummaryKey]; !exists {
v := *item.Value
summary[item.SummaryKey] = &v

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 Accumulate additive keys in filing_date-only fallback

When bestPeriod is empty, populateSummary still calls extractItems("filing_date", false), which routes additive keys through the supplemental branch that only sets the first value. In filing-date-only documents (or when additive values exist only on filing_date), duplicated additive items like multiple interest_bearing_debt lines are no longer summed, so debt-derived outputs can be understated compared to prior behavior.

Useful? React with 👍 / 👎.

bestPeriodが空の場合、filing_dateをprimaryソースとして扱い
additive keys(interest_bearing_debt等)の累積を有効にする。
@beatinaniwa

Copy link
Copy Markdown
Owner Author

@codex review

@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: 24de8e0588

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

Comment thread internal/financial/summary.go Outdated
Comment on lines +110 to +113
// Supplemental period: only fill if not already set
if _, exists := summary[item.SummaryKey]; !exists {
v := *item.Value
summary[item.SummaryKey] = &v

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Accumulate filing-date additive keys when used as fallback

When a primary bestPeriod exists but does not contain interest_bearing_debt, supplemental extraction from filing_date only keeps the first matching line item and drops the rest. In extractItems(..., additive=false), the exists guard prevents summing multiple additive components (e.g., short-term + long-term debt), so debt can be understated whenever the key is sourced from filing-date data. This is a data-accuracy regression for filings where core metrics come from one period and debt components only appear at filing date.

Useful? React with 👍 / 👎.

additive keys(interest_bearing_debt等)は同一期間内で合算するが、
bestPeriodで既に設定済みの場合はfiling_dateからは取得しない。
filing_date-onlyの場合は期間内合算が正しく動作する。
@beatinaniwa

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

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

@beatinaniwa beatinaniwa merged commit 3d03f90 into main Apr 1, 2026
2 checks passed
@beatinaniwa beatinaniwa deleted the feat/financial-summary-fallback-and-doc-description-filter branch April 1, 2026 16:26
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