• Claude's avatar
    Stamp every transaction with the branch it happened in · cd2faefd
    Claude authored
    Records were reaching the database with no branch, so they belonged to
    no branch and were invisible in every branch view. Three causes:
    
    1. Invoices have no branch_id column, yet three call sites read
       $invoice->branch_id and stored the result. It was always null.
       POSService did this for every point-of-sale payment, which is why the
       walk-in ("عميل عابر") sales had no branch. POS now uses the branch the
       sale was rung up in; the mobile payment controller and InvoiceShow
       take it from the participant being billed.
    
    2. PaymentService::record() only set a branch if its caller happened to
       pass one, and most callers did not.
    
    3. Nothing enforced the rule centrally.
    
    New BelongsToBranch trait stamps the active branch at creation, mirroring
    BelongsToAcademy. It is applied to the models that record an action —
    Payment, Expense, CashSession, FacilityRentPayment, POSTransaction,
    PurchaseOrder, Participant, TrainingGroup — and deliberately not to
    catalogue models such as BasePrice, PricingRule, Product and Employee,
    where a null branch legitimately means "shared across all branches".
    
    The trait adds no global scope on purpose: branch is a reporting lens,
    not an isolation boundary, and scoping globally would break console
    commands, cross-branch reports and the switcher's "all branches" mode.
    It also returns null rather than guessing when there is no request
    context, so scheduled jobs do not misfile academy-wide records.
    
    Also adds a migration trimming stray whitespace — including the
    non-breaking space U+00A0 that survives copy-paste — from names shown to
    users. Those characters are invisible in forms but render as a gap in
    page titles and receipts, and break exact-match lookups.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    cd2faefd
Name
Last commit
Last update
..
Activities Loading commit data...
Admin Loading commit data...
Assignments Loading commit data...
Attendance Loading commit data...
Audit Loading commit data...
Auth Loading commit data...
Branches Loading commit data...
CashSessions Loading commit data...
Components Loading commit data...
Concerns Loading commit data...
Dashboard Loading commit data...
Documents Loading commit data...
Enrollments Loading commit data...
Evaluations Loading commit data...
Events Loading commit data...
Facilities Loading commit data...
Financial Loading commit data...
Groups Loading commit data...
Guardian Loading commit data...
HR Loading commit data...
Inventory Loading commit data...
Invoices Loading commit data...
Messaging Loading commit data...
Notifications Loading commit data...
POS Loading commit data...
Parent Loading commit data...
Participants Loading commit data...
People Loading commit data...
Pricing Loading commit data...
Profile Loading commit data...
Programs Loading commit data...
Public Loading commit data...
Receptionist Loading commit data...
Reports Loading commit data...
Roles Loading commit data...
Schedule Loading commit data...
Settings Loading commit data...
Trainer Loading commit data...
Training Loading commit data...
Users Loading commit data...
Wallets Loading commit data...
Website Loading commit data...
WhatsApp Loading commit data...
Wizards Loading commit data...
BranchSwitcher.php Loading commit data...
Dashboard.php Loading commit data...
GlobalSearch.php Loading commit data...