Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng Phù hợp với người mới
#220 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
94/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu với nextInvoiceNumber trong lib/invoice-types.ts, sau đó xem lại các trường hợp hiện có trong lib/__tests__/invoice-types.test.ts. Bổ sung phạm vi kiểm thử cho mọi ví dụ, trường hợp độ rộng tăng lên và giá trị mặc định cho danh sách rỗng, sau đó chạy npm run lint, npm run test và npm run build; các điểm gọi phía client của invoice generator không nên yêu cầu thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
1
Fork
9
Merge trung bình
7 giờ 54 phút
Pull request đã merge (30 ngày)
165

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codercops/toolbelt

Tất cả issue của codercops/toolbelt

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.