feat(payments): add customer ledgers and allocations (#744)

This commit is contained in:
Darko Gjorgjijoski
2026-08-05 03:28:35 +02:00
committed by GitHub
parent 8ae82ae91e
commit f322c2b74d
74 changed files with 5693 additions and 693 deletions
@@ -21,16 +21,15 @@ class PaymentsController extends Controller
{
$limit = $request->has('limit') ? $request->limit : 10;
$payments = Payment::with(['customer', 'invoice', 'paymentMethod', 'creator'])
$payments = Payment::with(['customer', 'allocations.invoice', 'paymentMethod', 'creator'])
->whereCustomer(Auth::guard('customer')->id())
->leftJoin('invoices', 'invoices.id', '=', 'payments.invoice_id')
->applyFilters($request->only([
'payment_number',
'payment_method_id',
'orderByField',
'orderBy',
]))
->select('payments.*', 'invoices.invoice_number')
->select('payments.*')
->latest()
->paginateData($limit);
@@ -57,6 +56,6 @@ class PaymentsController extends Controller
return response()->json(['error' => 'payment_not_found'], 404);
}
return new PaymentResource($payment);
return new PaymentResource($payment->load(['allocations.invoice']));
}
}