Invoice generator shows a subtotal of -$0.00 when the line items cancel out

Đã đóng
#315 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

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

@shresthgoel77-png đang làm issue này rồi.

Từ ngày 23/10/2026.

  • #331 của @shresthgoel77-png — đã merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug good first issue hacktoberfest

In the invoice generator, add three line items with tax at 0: "Website build" 1200.00, "Deposit received" -1000.10 and "Credit" -199.90. the subtotal shows "-$0.00", while tax and total show "$0.00". In floating point the sum is about -2.8e-14, and roundTo (lib/invoice-types.ts, lines 82 to 93) turns that into -0: it rounds the absolute value to 0 and then multiplies by the sign (line 92). Intl.NumberFormat prints -0 as "-$0.00", in the preview (InvoicePreview.tsx, line 118) and in the PDF (lib/invoice-pdf.ts, line 263).

What to do

  • Make roundTo return 0 instead of -0, so every caller gets the fix.

Where to look

  • lib/invoice-types.ts: roundTo (lines 82 to 93) and computeTotals (lines 95 to 107)
  • lib/__tests__/invoice-types.test.ts

Acceptance criteria

  • The example above shows a subtotal of "$0.00"
  • A real negative amount (a -200.00 line on its own) still shows its minus sign
  • Tests that 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 #315 in the description.

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

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.