S1-3 Fiscal-year fact extraction #8

Closed
opened 2026-11-06 01:18:48 +00:00 by chris-kreidl · 2 comments
chris-kreidl commented 2026-11-06 01:18:48 +00:00 (Migrated from github.com)

As a user, I want every metric to come from the same, latest fiscal year so that rankings don't mix 2014 and 2026 data.

Fixes #1.

Acceptance criteria

  • Find the latest 10-K fiscal year-end. Take balance-sheet values at that date and income values for the ~12 months ending on it.
  • If a metric has no value for that period, it is null. It never falls back to an older value.
  • Results record which XBRL tag supplied each value (for the detail view in E5)
  • EBIT falls back to pretax income + interest expense when no operating income is reported (HRB FY26: $853.9M + $80.6M = $934.5M)
  • Debt lines are identified by what they contain, not by tag name: DRI uses LongTermDebt for the noncurrent portion only
  • Fixture tests against test/fixtures/expected.ts: HRB EBIT $934.5M; CPB debt $7,137M (commercial paper is inside DebtCurrent, not added on top); MU and DRI debt lines match FY26

Definition of Done

  • Acceptance criteria met and demonstrated
  • bun test passes; new logic has tests
  • bun check is clean and bun fmt --check passes
  • Runs end to end on real data (not just fixtures)
  • Committed with Closes #<this issue>
*As a user, I want every metric to come from the same, latest fiscal year so that rankings don't mix 2014 and 2026 data.* Fixes #1. ### Acceptance criteria - [ ] Find the latest 10-K fiscal year-end. Take balance-sheet values *at* that date and income values for the ~12 months *ending* on it. - [ ] If a metric has no value for that period, it is `null`. It never falls back to an older value. - [ ] Results record which XBRL tag supplied each value (for the detail view in E5) - [ ] EBIT falls back to pretax income + interest expense when no operating income is reported (HRB FY26: $853.9M + $80.6M = $934.5M) - [ ] Debt lines are identified by what they contain, not by tag name: DRI uses `LongTermDebt` for the noncurrent portion only - [ ] Fixture tests against `test/fixtures/expected.ts`: HRB EBIT $934.5M; CPB debt $7,137M (commercial paper is inside `DebtCurrent`, not added on top); MU and DRI debt lines match FY26 ### Definition of Done - [ ] Acceptance criteria met and demonstrated - [ ] `bun test` passes; new logic has tests - [ ] `bun check` is clean and `bun fmt --check` passes - [ ] Runs end to end on real data (not just fixtures) - [ ] Committed with `Closes #<this issue>`
chris-kreidl commented 2026-11-06 02:18:59 +00:00 (Migrated from github.com)

@claude implement this story

@claude implement this story
claude[bot] commented 2026-11-06 02:19:16 +00:00 (Migrated from github.com)

Claude finished @chris-kreidl's task in 1m 33s —— View job • claude/issue-8-20261106-0219 • Create PR ➔


🤖 Claude: Implemented S1-3 on branch claude/issue-8-20261106-0219.

What changed

  • src/extract.ts: extractFiscalYearFacts(companyfacts).
    • The fiscal year-end is the latest 10-K Assets date.
    • Balance-sheet values are taken at that date. Income values come from a 350–380 day period ending on it. Only 10-K USD facts are used.
    • A metric with no value for that period is null. There is no fallback to an older period.
    • Each value is { value, tags[] }, so derived values list every input tag.
    • EBIT is OperatingIncomeLoss, otherwise pretax income + interest expense. HRB gives $934.5M.
    • Debt is split into current and noncurrent lines, plus a total.
      • DebtCurrent is treated as an aggregate, so CommercialPaper is never added. CPB total is $7,137M.
      • LongTermDebt is treated as the noncurrent portion. If it equals the filer's DebtLongtermAndShorttermCombinedAmount, it is recognised as a total and the current portion is subtracted.
      • MU and DRI debt lines match FY26.
  • test/extract.test.ts: 24 new tests against expected.ts, plus synthetic cases for nulls, 10-Q exclusion, period windows and the combined-total check.
  • CLAUDE.md: structure note for src/extract.ts.

Definition of Done

  • Acceptance criteria met: see the tests above.
  • bun test: 85 pass, 0 fail.
  • bun check is clean. bun fmt --check passes on the changed files.
  • Real-data run is still needed. data/ isn't available in this environment, so I tested against fixtures only.

Decisions for Chris

  • EBIT fallback: if pretax income or interest expense is missing, EBIT is null. It does not assume zero interest.
  • Current debt without DebtCurrent: I sum ShortTermBorrowings and LongTermDebtCurrent. I couldn't check this against a fixture.
  • Not wired in: analyze.ts still uses the old logic. The issue doesn't ask to replace it, and I think that belongs to S1-4 or the M1 CLI.
  • Zero values: HRB reports LongTermDebtCurrent = 0, which is kept as a real value and not treated as null.

· Branch

**Claude finished @chris-kreidl's task in 1m 33s** —— [View job](https://github.com/chris-kreidl/screener/actions/runs/42149536723) • [`claude/issue-8-20261106-0219`](https://github.com/chris-kreidl/screener/tree/claude/issue-8-20261106-0219) • [Create PR ➔](https://github.com/chris-kreidl/screener/compare/main...claude/issue-8-20261106-0219?quick_pull=1&title=S1-3%20Fiscal-year%20fact%20extraction&body=Closes%20%238%0A%0AAdds%20%60src%2Fextract.ts%60%20with%20tests.%20Real-data%20verification%20is%20still%20needed%20(fixtures%20only).%0A%0A%23%23%23%20Definition%20of%20Done%0A-%20%5Bx%5D%20Acceptance%20criteria%20met%20and%20demonstrated%0A-%20%5Bx%5D%20%60bun%20test%60%20passes%20(85%20pass)%3B%20new%20logic%20has%20tests%0A-%20%5Bx%5D%20%60bun%20check%60%20clean%20and%20%60bun%20fmt%20--check%60%20passes%0A-%20%5B%20%5D%20Runs%20end%20to%20end%20on%20real%20data%20(not%20available%20in%20CI)%0A%0A%F0%9F%A4%96%20Generated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.com%2Fclaude-code)) --- 🤖 **Claude:** Implemented S1-3 on branch `claude/issue-8-20261106-0219`. ### What changed - `src/extract.ts`: `extractFiscalYearFacts(companyfacts)`. - The fiscal year-end is the latest 10-K `Assets` date. - Balance-sheet values are taken *at* that date. Income values come from a 350–380 day period *ending* on it. Only 10-K USD facts are used. - A metric with no value for that period is `null`. There is no fallback to an older period. - Each value is `{ value, tags[] }`, so derived values list every input tag. - EBIT is `OperatingIncomeLoss`, otherwise pretax income + interest expense. HRB gives $934.5M. - Debt is split into current and noncurrent lines, plus a total. - `DebtCurrent` is treated as an aggregate, so `CommercialPaper` is never added. CPB total is $7,137M. - `LongTermDebt` is treated as the noncurrent portion. If it equals the filer's `DebtLongtermAndShorttermCombinedAmount`, it is recognised as a total and the current portion is subtracted. - MU and DRI debt lines match FY26. - `test/extract.test.ts`: 24 new tests against `expected.ts`, plus synthetic cases for nulls, 10-Q exclusion, period windows and the combined-total check. - `CLAUDE.md`: structure note for `src/extract.ts`. ### Definition of Done - [x] Acceptance criteria met: see the tests above. - [x] `bun test`: 85 pass, 0 fail. - [x] `bun check` is clean. `bun fmt --check` passes on the changed files. - [ ] **Real-data run is still needed.** `data/` isn't available in this environment, so I tested against fixtures only. ### Decisions for Chris - **EBIT fallback:** if pretax income or interest expense is missing, EBIT is `null`. It does not assume zero interest. - **Current debt without `DebtCurrent`:** I sum `ShortTermBorrowings` and `LongTermDebtCurrent`. I couldn't check this against a fixture. - **Not wired in:** `analyze.ts` still uses the old logic. The issue doesn't ask to replace it, and I think that belongs to S1-4 or the M1 CLI. - **Zero values:** HRB reports `LongTermDebtCurrent` = 0, which is kept as a real value and not treated as `null`. · [Branch](https://github.com/chris-kreidl/screener/tree/claude/issue-8-20261106-0219)
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/screener#8
No description provided.