Tax category select: allow creating a new tax category from the input

Open
#5,097 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
58/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
frontend

Research direction

Start with the creditor and debtor components and their SelectWithSearch empty slots, then inspect InsertTaxCategory and each listed single-select ComboBox call site. Trace how useGetTaxCategories refreshes after insertion and how the selected ID is returned to the opening field. Done when every listed select offers creation for unmatched text, selects the new category, and refreshes the shared list.

Written by the indexing model from the issue text.

Description

Summary

Tax category selection inputs only let you pick an existing tax category. If the one you need doesn't exist, you have to leave the form, go to the Tax Categories page, create it there, then come back and pick it.

Business inputs already handle this case: when a search has no matches, they offer to create a new business from the search text. Tax category inputs should work the same way.

Current behavior

  • Business selects (e.g. packages/client/src/components/documents-table/cells/creditor.tsx and debtor.tsx) use SelectWithSearch with an empty slot. When the search has no match, it renders <InsertBusiness description={search} onAdd={...} />, prefilled with the search text. Once the business is created, it is selected.
  • Tax category selects use a plain ComboBox fed by useGetTaxCategories().selectableTaxCategories, with no option to create a new one. For example:
    • components/business/configurations-section.tsx (business default tax category)
    • components/common/modals/insert-business.tsx (new business form)
    • components/financial-accounts/modify-financial-account-dialog.tsx
    • components/common/forms/edit-charge.tsx (charge default tax category)
    • components/businesses/batch-update-dialog.tsx
  • An InsertTaxCategory dialog already exists (components/common/modals/insert-tax-category.tsx, using useInsertTaxCategory) and has an onAdd(taxCategoryId) callback, but it is only reachable from the Tax Categories page header.
  • components/charges/securities-tax-category-dialog.tsx already has an ad-hoc "existing / create new" tab flow, which shows there is demand for this.

Expected behavior

  • When the search in a tax category select has no matches, offer "Create tax category '<search>'" (same UX as business inputs).
  • This opens the insert tax category form with the name prefilled from the search text.
  • When it is created:
    • the new tax category is selected in the input that opened it,
    • the tax categories list (useGetTaxCategories) is refreshed, so the new entry shows up in every select.

Implementation notes

  • Build a reusable tax category select component (or extend the existing one) on top of SelectWithSearch with an empty slot, following the creditor/debtor pattern. Avoid repeating the logic at each call site.
  • Let InsertTaxCategory accept an initial name / description prop, and optionally a custom trigger, like InsertBusiness does.
  • Swap the single-select ComboBox usages listed above to the new component. Multi-select filters, such as the businesses filter form, are out of scope.
  • Consider having securities-tax-category-dialog.tsx use the shared flow as well.

Acceptance criteria

  • Typing a name that matches no tax category shows a create option in the tax category select.
  • Creating it from there selects the new tax category in the field that opened it.
  • The new tax category is available in other tax category selects without a page reload.
  • Applied to all the single-select tax category inputs listed above.
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.