Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Invoice generator: the next number adds `INV` to plain numbers and changes the padding

Aperta Adatta ai principianti
#220 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
94/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, react, typescript
Ambito
frontend

Direzione di ricerca

Inizia da nextInvoiceNumber in lib/invoice-types.ts, quindi esamina i casi esistenti in lib/__tests__/invoice-types.test.ts. Aggiungi la copertura per ogni esempio, il caso di crescita della larghezza e il valore predefinito per un elenco vuoto, poi esegui npm run lint, npm run test e npm run build; i punti di chiamata del client del generatore di fatture non dovrebbero richiedere modifiche.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue hacktoberfest

nextInvoiceNumber (lib/invoice-types.ts, line 159) is meant to keep the prefix and zero padding of the highest saved invoice (its comment, lines 154 to 157), but:

Highest saved number Next number now Expected
1001 INV1002 1002
INV-07 INV-0008 INV-08
A1 A0002 A2
2026-001 2026-0002 2026-002
999 INV1000 1000
INV0007 INV0008 INV0008 (already right)

An empty prefix is falsy, so match[1] || fallbackPrefix (line 169) swaps it for INV, and Math.max(pad, match[2].length) (line 170) pads every number to at least 4 digits. On the invoice generator you see it when you save an invoice numbered 1001 and click New.

What to do

  • Keep the prefix as it is, even when it's empty, and pad to the width of the highest number's digits (match[2].length).
  • Use INV and 4 digits only for an empty list, so it still starts at INV0001.
  • A number that outgrows its width just gets longer: INV-99 gives INV-100.

Where to look

  • lib/invoice-types.ts: nextInvoiceNumber (lines 154 to 174)
  • lib/__tests__/invoice-types.test.ts: the nextInvoiceNumber tests (line 75)
  • The client calls it in several places (InvoiceGeneratorClient.tsx, lines 58, 65, 70, 76, 105 and 130), and none of them need to change.

Acceptance criteria

  • Every row in the table gives the expected number, INV-99 gives INV-100, and an empty list still gives INV0001
  • Tests for these cases (the ones that change fail on the current code)
  • npm run lint, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #220 in the description.

Lingua principale
TypeScript
Stelle
1
Fork
9
Merge medio
10h 24m
PR unite (30g)
93

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codercops/toolbelt

Tutte le issue di codercops/toolbelt

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.