Skip to content

feat(invoices): compute invoice tax and totals instead of hardcoding taxAmount to zero - #1213

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
walexjnr:feat/1004-invoice-tax
Aug 17, 2026
Merged

feat(invoices): compute invoice tax and totals instead of hardcoding taxAmount to zero#1213
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
walexjnr:feat/1004-invoice-tax

Conversation

@walexjnr

Copy link
Copy Markdown
Contributor

Summary

InvoicesService.generateAndArchiveInvoice() previously created every invoice with taxAmount: 0 and totalAmount: payment.amount. This PR computes tax from the customer's billing jurisdiction and records the applied rate so archived invoices are valid tax documents and revenue reporting reflects the actual tax liability.

What changed

  • TaxService (new): resolves the customer's billing jurisdiction from the payment metadata (e.g. billingCountryCode) with a user-profile fallback, and computes a decimal-safe taxAmount (rounded to the nearest cent) with totalAmount = amount + taxAmount by construction. Rates cover common VAT/GST jurisdictions; unknown/zero-rate jurisdictions (e.g. US) resolve to 0.
  • Invoice entity + migration: new taxRate (decimal) and taxJurisdiction (varchar) columns persist the applied rate and jurisdiction for audit purposes.
  • Invoice document: the generated HTML now renders the tax line (rate, jurisdiction, amount) and the net amount separately from the total.
  • ReportingService: the revenue recognition report now includes totalTaxCollected from the invoices issued in the period.
  • Tests: unit tests for a zero-rate jurisdiction, a standard-rate jurisdiction, a rounding boundary, plus tax rendering in the archived document. Also fixed two pre-existing broken mocks in the invoices spec.

Verification

  • pnpm run lint:ci, pnpm run typecheck, pnpm run build
  • pnpm run migration:run on a fresh Postgres, migration:generate:check (no new drift), migration:revert
  • Invoices + tax unit tests pass ✔

Closes #1004

…taxAmount to zero

- Add TaxService that resolves the customer's billing jurisdiction (from
  payment metadata or user profile) and computes decimal-safe taxAmount
  and totalAmount = amount + taxAmount.
- Persist the applied rate and jurisdiction on the invoice via new
  taxRate/taxJurisdiction columns (with migration).
- Render the tax line in the generated invoice document.
- Reflect recorded tax in the revenue recognition report.
- Add unit tests for zero-rate, standard-rate, and rounding-boundary
  jurisdictions, and fix pre-existing broken mocks in the invoices spec.
@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 0a23fb1 into rinafcode:main Aug 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compute invoice tax and totals instead of hardcoding taxAmount to zero

2 participants