fix(billing): widen tax_rates.rate and validate the percentage range #281
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pms-339-tax-rate-column-width-and-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A tax rate is stored as the percentage as-typed (e.g. 20 for 20%), but the column was DECIMAL(5, 4) (max magnitude 9.9999), so any rate >= 10 overflowed and surfaced as an opaque 500 DATABASE_ERROR. A 10% GST, a 20% VAT, and any US combined rate at or above 10% could not be saved at all.
Migration 051 widens tax_rates.rate to DECIMAL(7, 4) (max 999.9999), a straight widening that preserves every existing row and keeps 4 decimal places of sub-percent precision. A new validate_tax_rate validator (mirroring the budget/SLA validators) requires 0 <= rate <= 100 with at most 4 decimal places and is wired onto UpsertTaxRateRequest.rate, so an out-of-range or negative value now returns a clean 422 field error instead of reaching the DB and dying there.
#PMS-339