`useEntityYear`: make the year limits overridable, defaulting to the business's years (initialAccounterYear → current year)
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- graphql, typescript
Direzione di ricerca
Start with packages/client/src/components/financial-entity/use-entity-year.ts and entity-year-filter.tsx, then trace their use in LedgerSection and BalanceSection. Check whether #5228 has introduced the shared year-range helper before implementing the defaults from adminContext.initialAccounterYear, dateEstablished, and the current year. Update the hook, filter, section, and related tests; done means the overrides work, defaults are clamped, and the chosen behavior for valid out-of-range ?year= values is tested.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
useEntityYear (packages/client/src/components/financial-entity/use-entity-year.ts, from #5277, merged)
validates ?year= against two hard-coded limits, and EntityYearFilter reuses them as the picker's
minDate / maxDate:
MIN_ENTITY_YEAR = 1900,MAX_ENTITY_YEAR = 2999: "anything outside is a typo", not a business
rule. The picker therefore offers ~1100 years, almost all of them meaningless for the active
business.- The "All years" toggle, when released, goes to
new Date().getFullYear(), unrelated to any bound.
Callers cannot narrow or widen the range. The first need to widen it is already known: a future
depreciation tax report view has to look past the current year.
The same hook and filter are already used by two sections, LedgerSection and BalanceSection
(#5279), on both the business and the tax category pages, so the limits should be fixed once, in
the shared place.
Related
- #5228: report year selectors should offer the business's years (
initialAccounterYear→ current
year). Same lower/upper bound, for the report screens. This issue should reuse that issue's
shared year-range hook/helper, not add a second one. Whichever lands first introduces it. - #5229: merges
user_contextintobusinesses_admin.initial_accounter_yearmoves unchanged,
and the business start date is collapsed into one column. The client must read the years through
the GraphQLadminContextfields, never the tables, so the merge doesn't affect it. - #5277 (merged): introduced
useEntityYearandEntityYearFilter. #5279 (merged):BalanceSectionis the second consumer.
Where the years come from
| Bound | Default | Source |
|---|---|---|
| min | the year the business started using Accounter | adminContext.initialAccounterYear (user_context.initial_accounter_year) |
| min, fallback | the year the business was established | adminContext.dateEstablished (user_context.date_established) → its year |
| min, last fallback | today's lower bound | existing constant |
| max | the current calendar year | new Date().getFullYear() |
Both adminContext fields are already exposed (AdminContextInfo.initialAccounterYear: Int,
dateEstablished: TimelessDate) but are nullable, and the client boot UserContext query
(providers/user-provider.tsx) doesn't load them. The businesses_admin start-date columns are
not used: they disagree with each other (see #5229, item 3).
Desired behaviour
- Defaults. With no override, the range is
initialAccounterYear(or the fallbacks above) →
current year. - Overrides. The hook takes
{ minYear?, maxYear? }, andEntityYearFiltertakes the same two
props, so a section can narrow or widen the range, e.g.maxYear = currentYear + 5for a
future depreciation view. A section component (LedgerSectionandBalanceSection, which already take adefaultYearprop) passes
them through asminYear?/maxYear?props. - The default year stays inside the range.
defaultYearand the year the "All years" toggle
returns to are clamped to[minYear, maxYear]. - A
?year=outside the range. Decide and test one behaviour. Recommended: the range limits
what the picker offers; a?year=that is a valid 4-digit year is still honoured and stays
listed, so a linked view never silently changes and a ledger with records from before
initialAccounterYear(imported history) stays reachable. Keep 1900–2999 only as the "typo"
guard inparseYear, as today. (Same "years in use stay listed" rule as #5228.) - Return the effective bounds from the hook,
{ year, setYear, range, minYear, maxYear }, so
the filter doesn't recompute them.
Suggested approach
- A small hook that reads
adminContext { initialAccounterYear dateEstablished }once for the
active admin business and returns{ minYear, maxYear }with the fallback chain above
(shared with #5228; unit-tested for nullinitialAccounterYear, nulldateEstablished, both
set). useEntityYear(defaultYear, options?): options override the hook's defaults; the URL parsing
stays as is.EntityYearFilter:minYear?/maxYear?props, passed toYearPickerInputminDate/
maxDate. Drop the exportedMIN_ENTITY_YEAR/MAX_ENTITY_YEARas picker bounds.- Compute "current year" at call time, not at module load (see the annual-audit picker below).
Other year inputs with hard-coded limits
All of these can take the same default range, and the future-view case also needs an override.
| Site | File | Min | Max |
|---|---|---|---|
| Entity year filter (#5277; used by the ledger and balance sections) | financial-entity/entity-year-filter.tsx |
1900 | 2999 |
| Tax report (year + reference years) | reports/tax-report/tax-report-filters.tsx |
2010 | now |
| Profit & loss (year + reference years) | reports/profit-and-loss-report/profit-and-loss-report-filters.tsx |
2010 | now |
| Corporate-tax-ruling compliance | reports/corporate-tax-ruling-compliance-report/…-filters.tsx |
2010 | now |
| Yearly ledger | reports/yearly-ledger/index.tsx |
2010 | now |
| Annual revenue | screens/reports/annual-revenue/index.tsx |
2010 | now |
| Depreciation report (free text, validated) | screens/reports/depreciation-report/depreciation-report-filters.tsx |
2000 | 2100 |
| Annual audit year picker | screens/operations/annual-audit/year-picker.tsx |
2000 | current year, computed at module load (goes stale in a tab left open over New Year) |
| SHAAM 6111 | screens/reports/shaam-6111-report/years.ts |
2020 | last year |
| Form 1214 | screens/reports/form-1214-report/years.ts |
generator's supported years | – |
| Charge spread | common/inputs/charge-spread-input.tsx |
none | none (spread years are legitimately in the future; leave unbounded) |
The report-screen rows are tracked by #5228; they are listed here only so the shared range has one
definition. This issue covers the entity-page hook and filter, and defines the override API that
the depreciation report (future view) will use.
Scope / checklist
- Shared
{ minYear, maxYear }hook fromadminContextwith fallbacks and tests (reuse #5228's if it exists) -
useEntityYear(defaultYear, { minYear?, maxYear? })returns the effective bounds, clamps the default -
EntityYearFilterminYear?/maxYear?props; remove the 1900/2999 picker bounds -
LedgerSectionandBalanceSectiontakeminYear?/maxYear?and pass them touseEntityYearandEntityYearFilter - Decide and test the out-of-range
?year=behaviour (item 4) - Update the hook, filter and section tests; add a story with a widened
maxYear - Depreciation report: use the override for the future-year view (can be a separate PR)
Open questions
- Out-of-range
?year=: keep and list it (recommended), or clamp it to the range? - Entity pages under a multi-owner read scope (
activeReadScope): use the active admin business
(as the depreciation report does withuserContext.context.adminBusinessId), or the earliest
initialAccounterYearacross the scope? - Should the fallback for a business with neither
initialAccounterYearnordateEstablishedbe
the old 1900 or the 2010 used by the report screens?
🤖 Generated with Claude Code
Generated by Claude Code
- Lingua principale
- TypeScript
- Stelle
- 30
- Fork
- 10
- Merge medio
- 2g 12h
- PR unite (30g)
- 276
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Urigo/accounter-fullstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
Urigo/accounter-fullstack#5302 ·
I maintainer di solito rispondono entro 2 giorni
-
1214 annual-audit-workflow
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Urigo/accounter-fullstack#5257 ·
I maintainer di solito rispondono entro 2 giorni
-
1214 annual-audit-workflow
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Urigo/accounter-fullstack#5256 ·
I maintainer di solito rispondono entro 2 giorni
-
annual-audit-workflow
Difficoltà 1/5 1-3 ore Idoneità per principianti 87/100
Urigo/accounter-fullstack#5252 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Urigo/accounter-fullstack#4919 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di Urigo/accounter-fullstack
Issue simili
-
area: integrations documentation priority: P2 size: XS
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eddiejaoude/StackDash#798 ·
I maintainer di solito rispondono entro 1 giorno
-
bot:ai-assisted component:midnight-js status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
midnightntwrk/midnight-js#1790 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
area:vscode bug has repro platform:macos platform:vscode regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
anthropics/claude-code#113502 ·
-
Add: Rajdhani TV HDApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno