feat(billing): finish PMS-33 story (invoices, payments, gateways, tax rates) #25
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/billing-story-pms-33"
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?
Implements YouTrack story PMS-33 (billing). 8 commits, one per sub-task. Targets
maindirectly - no dependency on the auth / tickets / portal PRs.Sub-tasks
src/modules/billing/{mod.rs, models.rs, routes.rs, service.rs}, wired intocreate_api_routerviamerge(replaces the/invoicesand/paymentsstubs).GET /api/v1/invoicespaginated + filterable (company / status / contract / q).GET /api/v1/invoices/:idreturns the invoice + everyinvoice_linesrow, two round-trips.POST /api/v1/invoicesatomically incrementsinvoice_sequences(per tenant), writes header + lines in one transaction, computessubtotal/total/balance_due.PUT /api/v1/invoices/:idrejects edits on frozen statuses (sent / paid / partially_paid / void / written_off), recomputes totals on tax/discount/line changes, stampssent_aton first transition intosent./api/v1/payments. Post bumpsinvoices.amount_paid/balance_due/statusand stampspaid_atin the same transaction; delete reverses.ENCRYPTION_KEY.create_api_routergrows anencryption_keyparameter;main.rsparses it fromAppConfig::encryption_key.GET /api/v1/tax-rates/lookup?name=...(treatstax_rates.nameas jurisdiction key; falls back to tenant default).Behaviour-visible changes
/api/v1/invoices*,/api/v1/payments*,/api/v1/payment-gateways*,/api/v1/tax-rates*move from 501 to real reads/writes.RequireFinance(super_admin / admin / finance roles).create_api_routersignature grows anencryption_key: [u8; 32]parameter - any downstream caller of the function needs to pass it.Test plan
cargo check --bin mokosh-serverclean (verified locally).POST /api/v1/invoicesreturns an invoice with a freshINV-000001-style number;GET /api/v1/invoiceslists it;GET /api/v1/invoices/:idreturns it with lines.POST /api/v1/paymentsagainst a draft invoice flips its status appropriately.PUT /api/v1/payment-gateways {"provider":"stripe", "config": {...}}round-trips throughGET /api/v1/payment-gatewayswith the same config back (decrypted).GET /api/v1/tax-rates/lookup?name=US-CAafter seeding atax_ratesrow returns the right rate.Closes #PMS-33
Creates `mokosh-server::modules::billing` with `models.rs`, `service.rs`, and `routes.rs`. The module exposes the wire-shaped DTOs for invoices, payments, payment-gateway configs, and tax rates - all four tables already exist in `001_initial_schema.sql`, so the data layer just needs an HTTP face. `billing_routes` is wired into `create_api_router` via `merge` (not `nest`), replacing the prior `nest("/invoices", stub_routes())` and `nest("/payments", stub_routes())` placeholders. The router is empty in this commit; subsequent commits in the PMS-33 story add the endpoint families: - PMS-35..38 invoices CRUD - PMS-39 payments - PMS-40 payment gateway configs (encrypted at rest) - PMS-41 tax rates #PMS-34 State DonePull request closed