diff --git a/Modules/Station/app/Http/Controllers/ShiftController.php b/Modules/Station/app/Http/Controllers/ShiftController.php index 49ba696..39fe3d8 100644 --- a/Modules/Station/app/Http/Controllers/ShiftController.php +++ b/Modules/Station/app/Http/Controllers/ShiftController.php @@ -561,6 +561,26 @@ public function update(Request $request, Shift $shift): RedirectResponse 'payment_readings.*.receipt.max' => 'حجم المستند يجب أن يكون أقل من 10MB', ]);  + // التحقق من أن مجموع قراءات المكائن لا يتجاوز مجموع البطاقات + if ($request->has('payment_readings') && is_array($request->payment_readings)) { + $totalPaymentReadings = collect($request->payment_readings) + ->sum(function ($reading) { + return isset($reading['amount']) ? (float) $reading['amount'] : 0; + }); + + $cardReceivedAmount = $request->card_received_amount ?? 0; + + if ($totalPaymentReadings > $cardReceivedAmount) { + return back()->withInput()->withErrors([ + 'payment_readings' => sprintf( + 'مجموع قراءات مكائن الدفع الإلكتروني (%.2f) يتجاوز مجموع البطاقات (%.2f)', + $totalPaymentReadings, + $cardReceivedAmount + ) + ]); + } + } + $user = Auth::user();  // التحقق من الصلاحية