feat(invoices): compute invoice tax and totals instead of hardcoding taxAmount to zero - #1213
Merged
Merged
Conversation
…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.
Contributor
|
Thank you for contributing to the project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InvoicesService.generateAndArchiveInvoice()previously created every invoice withtaxAmount: 0andtotalAmount: 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
billingCountryCode) with a user-profile fallback, and computes a decimal-safetaxAmount(rounded to the nearest cent) withtotalAmount = amount + taxAmountby construction. Rates cover common VAT/GST jurisdictions; unknown/zero-rate jurisdictions (e.g. US) resolve to 0.taxRate(decimal) andtaxJurisdiction(varchar) columns persist the applied rate and jurisdiction for audit purposes.totalTaxCollectedfrom the invoices issued in the period.Verification
pnpm run lint:ci,pnpm run typecheck,pnpm run build✔pnpm run migration:runon a fresh Postgres,migration:generate:check(no new drift),migration:revert✔Closes #1004