• Mahmoud Aglan's avatar
    feat(accounting): billing sources — a new revenue path needs a row, not a developer · 5e36f062
    Mahmoud Aglan authored
    Removes the "this module needs code" category rather than labelling it.
    
    Most unbilled money in the ERP has one shape: a module writes a priced row into
    its own table and never tells accounting. Wiring each module by hand means a
    developer for every revenue path, forever — which is what I handed over last
    time instead of solving it.
    
    A billing source declares that shape as data: which table holds the money, which
    column is the amount, which rows are still outstanding, who owes it, and how it
    posts. One screen then lists every outstanding charge across every source and
    collects it through PaymentService — the same funnel a member payment uses, so
    it gets a receipt, treasury custody and a journal entry.
    
    Seeded and working immediately: hourly court bookings, sports subscriptions,
    lockers, facility reservations, private matches, rental invoices, annual member
    subscriptions.
    
    Edge cases handled deliberately:
    
    - No free-text SQL anywhere. Filters are structured (column / operator / value)
      rendered into prepared statements; a settings screen that accepted a WHERE
      clause would be an injection hole. Identifiers are matched against
      information_schema and a strict pattern before interpolation.
    - Every source is re-validated on save AND before every listing, because a
      migration can drop a column underneath a source that was fine yesterday. An
      invalid source is shown as broken instead of silently returning nothing.
    - The amount is re-read from the source row at collection time, never trusted
      from the form, so a stale list or a tampered field cannot set the charge.
    - Double-collection is blocked by our own billing_source_collections table
      rather than the module's paid flag — some sources have no write-back column at
      all, and a module can overwrite its own flag. The check is repeated at collect
      time to cover the gap between listing and click.
    - Partial collection only where the source allows it, never above the row total.
    - A player is not a member: a member_id that members does not have is dropped
      rather than tripping the payment foreign key.
    - Write-back is best-effort and isolated — a missing column must not undo a real
      payment, so the failure is logged and the receipt stands.
    - Zero and negative rows are excluded; an empty IN () renders as a false
      predicate rather than a syntax error.
    - Payer names resolve in two queries, not two per row.
    - A source with collections against it deactivates instead of deleting, because
      those rows are the audit trail for real money.
    
    Permission keys were read off role_permissions rather than assumed —
    payment.create does not exist in this install.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    5e36f062
Name
Last commit
Last update
..
Academies Loading commit data...
AcademyContracts Loading commit data...
AccessMatrix Loading commit data...
Accounting Loading commit data...
Achievements Loading commit data...
ActivitySubscriptions Loading commit data...
Alerts Loading commit data...
Archive Loading commit data...
Audit Loading commit data...
Auth Loading commit data...
Branches Loading commit data...
Carnets Loading commit data...
Cashier Loading commit data...
Children Loading commit data...
Coaches Loading commit data...
Dashboard Loading commit data...
Death Loading commit data...
Disciplines Loading commit data...
Divorce Loading commit data...
Documents Loading commit data...
Facilities Loading commit data...
FacilityDashboards Loading commit data...
FacilityGrids Loading commit data...
Fines Loading commit data...
Foreign Loading commit data...
Forms Loading commit data...
HR Loading commit data...
Honorary Loading commit data...
Installments Loading commit data...
Interviews Loading commit data...
Inventory Loading commit data...
MatchCenter Loading commit data...
MedicalBoard Loading commit data...
Members Loading commit data...
News Loading commit data...
Notifications Loading commit data...
ParentPortal Loading commit data...
Payments Loading commit data...
PlayerAffairs Loading commit data...
PlayerApi Loading commit data...
PlayerAuth Loading commit data...
PlaygroundAdmin Loading commit data...
PoolManagement Loading commit data...
Pricing Loading commit data...
Procurement Loading commit data...
Receipts Loading commit data...
Rentals Loading commit data...
Reports Loading commit data...
Reservations Loading commit data...
Roles Loading commit data...
Rules Loading commit data...
Sales Loading commit data...
Scheduling Loading commit data...
Seasonal Loading commit data...
ServiceCatalog Loading commit data...
Sessions Loading commit data...
Settings Loading commit data...
Sports Loading commit data...
SportsActivity Loading commit data...
SportsDashboard Loading commit data...
Spouses Loading commit data...
Subscriptions Loading commit data...
Support Loading commit data...
Temporary Loading commit data...
Tournaments Loading commit data...
TrainerPortal Loading commit data...
Training Loading commit data...
TrainingGroups Loading commit data...
Transfers Loading commit data...
Treasury Loading commit data...
Tutorials Loading commit data...
Users Loading commit data...
Waiver Loading commit data...
Workflow Loading commit data...