Common IRS code select input (searchable by code + name, shows both)

Open
#5,101 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
react, typescript
Domain
frontend

Research direction

Start with the listed IRS code form fields and the existing ComboBox or SelectWithSearch components; inspect how forms handle nullable values and sort-code autofill. Then trace the shaam6111 code-name constants and decide how the options reach the client. Done means replacing all five listed inputs with a shared searchable select, preserving clear and unknown values and autofill, with tests for matching and unknown-value rendering.

Written by the indexing model from the issue text.

Description

Summary

IRS code fields across the client are plain numeric inputs. To fill them in you have to know the code by heart, and nothing confirms you typed the right one. Create one shared IRS code select that:

  • lists the valid IRS codes,
  • searches by code and name (e.g. typing 1030 or שירותים both find 1030 – הכנסות ממתן שירותים בארץ),
  • shows both code and name in the options and in the selected value,

and use it everywhere an IRS code is entered.

Current behavior

IRS code is entered as a free number (NumberInput / text) in:

  • packages/client/src/components/common/forms/modify-tax-category-fields.tsx: tax category irsCode (insert/edit tax category)
  • packages/client/src/components/common/forms/modify-sort-code-fields.tsx: sort code defaultIrsCode (insert/edit sort code)
  • packages/client/src/components/business/configurations-section.tsx: business irsCode
  • packages/client/src/components/common/modals/insert-business.tsx: business irsCode
  • packages/client/src/components/businesses/batch-update-dialog.tsx: batch irsCode (a text field with integer validation)

Read-only displays, such as components/tax-categories/cells/irs-code.tsx and the businesses table column, show only the bare number.

Source of code names

The code-to-name mappings already exist in @accounter/shaam6111-generator:

  • PROFIT_LOSS_CODE_NAMES (src/types/profit-and-loss.ts)
  • BALANCE_SHEET_CODE_NAMES (src/types/balance-sheet.ts)
  • TAX_ADJUSTMENT_CODE_NAMES (src/types/tax-adjustment.ts)

Options for getting them to the client:

  1. Preferred: add a GraphQL query, e.g. irsCodes: [IrsCode!]! with { code: Int!, name: String!, section/group }, served by the server from the shaam6111 constants. This keeps one source of truth, and the client doesn't need to depend on the generator package.
  2. Alternatively, import the constants straight into the client, if the package can be bundled for the browser cleanly.

Decide which code groups count as valid IRS codes for businesses / tax categories (probably profit & loss plus balance sheet), and group the options by section in the dropdown.

Proposed component

  • IrsCodeSelect (e.g. components/common/inputs/irs-code-select.tsx), built on the existing ComboBox / SelectWithSearch primitives.
  • Props: value: number | null, onChange(code: number | null), disabled, placeholder, clearable, plus className so the dirty-field marker styling keeps working.
  • Search matches the code (prefix/substring) and the name (case-insensitive substring).
  • Option label: {code} – {name}. Group headers by section if there are several.
  • Handles a stored value that isn't in the list (legacy data): show it as {code} – (unknown) rather than dropping it.
  • Works with react-hook-form FormField the way the current inputs do. The existing behavior where changing the sort code sets the IRS code from defaultIrsCode must keep working.

Also consider

  • A small IrsCodeLabel / helper to display code – name in read-only places: the tax categories table cell, the businesses table column, and the IRS codes report.

Acceptance criteria

  • There is a shared, reusable IRS code select component, with search over code + name, that shows both.
  • It replaces the numeric IRS code inputs in all the places listed above.
  • Clearing the value still works (sends null where the current forms do).
  • Sort code → default IRS code autofill still works.
  • Unknown / legacy codes are shown, not lost.
  • Unit tests cover the search matching and rendering of unknown values.
Dominant language
TypeScript
Stars
30
Forks
10
Avg merge
2d 12h
Merged PRs (30d)
276

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Urigo/accounter-fullstack

All issues in Urigo/accounter-fullstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.