Commit 131911dc authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(reports): stop the daily financial print 500ing on any day with a payment

dailyFinancial() eager-loaded `createdBy` on Payment. That relation does not
exist — Payment names it `creator`, after the person rather than the column,
and the print view has always read `$payment->creator`. Eloquent throws
RelationNotFoundException on an eager load it cannot resolve, so this was not
a missed optimisation: the report 500'd on every date that had a confirmed
inbound payment and only rendered on an empty day, which is why it survived.

Caught by BranchScopedScreensTest, which renders every staff screen; it had
been failing on reports.daily-print.
Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
parent 0d3d6a5c
...@@ -22,7 +22,12 @@ public function dailyFinancial(Request $request) ...@@ -22,7 +22,12 @@ public function dailyFinancial(Request $request)
// a stale null, printed every branch's takings on one page. // a stale null, printed every branch's takings on one page.
$payments = Payment::where('direction', 'inbound')->where('status', 'confirmed') $payments = Payment::where('direction', 'inbound')->where('status', 'confirmed')
->whereDate('payment_date', $date) ->whereDate('payment_date', $date)
->with(['createdBy', 'invoice']) // `creator`, not `createdBy`: Payment names the relation after the
// person, not the column. Eloquent throws RelationNotFoundException
// on an eager load it cannot resolve, so this was not a missed
// optimisation — the whole print view 500'd on any day that had a
// payment, and only rendered on an empty day.
->with(['creator', 'invoice'])
->orderBy('payment_date') ->orderBy('payment_date')
->get(); ->get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment