From fb12e2fb48263a921d2adeeb2131b4f438c10dcc Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 15 May 2026 11:29:08 +0530 Subject: [PATCH] changed pattern for process order wire master --- .../Pages/CreateWireMasterPacking.php | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/WireMasterPackingResource/Pages/CreateWireMasterPacking.php b/app/Filament/Resources/WireMasterPackingResource/Pages/CreateWireMasterPacking.php index 85340ce..3781279 100644 --- a/app/Filament/Resources/WireMasterPackingResource/Pages/CreateWireMasterPacking.php +++ b/app/Filament/Resources/WireMasterPackingResource/Pages/CreateWireMasterPacking.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\WireMasterPackingResource\Pages; use App\Filament\Resources\WireMasterPackingResource; +use App\Models\CustomerPoMaster; use App\Models\Item; use App\Models\Plant; use App\Models\WireMasterPacking; @@ -81,7 +82,8 @@ class CreateWireMasterPacking extends CreateRecord return; } - $pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/'; + // $pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/'; + $pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/'; if (!preg_match($pattern, $processOrder, $matches)) { @@ -182,6 +184,60 @@ class CreateWireMasterPacking extends CreateRecord ]); return; } + + $customerPoRecord = CustomerPoMaster::where('id', $customerPo) + ->where('plant_id', $plantId) + ->first(); + + $customerPoName = $customerPoRecord->customer_po; + + if ($customerPoRecord) { + $customerPoName = $customerPoRecord->customer_po; + } else { + $customerPoName = null; + } + + if(!$customerPoRecord) + { + Notification::make() + ->title("PO Not Found") + ->body("Customer PO '$customerPoName' for Item '$materialCode' not found against Plant '$plantcode'") + ->danger() + ->duration(5000) + ->send(); + + $this->form->fill([ + 'process_order' => null, + 'plant_id' => $plantId, + 'customer_po_master_id' => $customerPo, + 'wire_packing_number' => $wirePackNo, + 'Sno_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; + } + + if($weight > $customerPoRecord->quantity) + { + Notification::make() + ->title("Scanned Weight Exceeds PO Quantity") + ->body("Scanned weight '$weight' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPo' and Item '$materialCode'") + ->danger() + ->duration(5000) + ->send(); + + $this->form->fill([ + 'process_order' => null, + 'plant_id' => $plantId, + 'customer_po_master_id' => $customerPo, + 'wire_packing_number' => $wirePackNo, + 'Sno_quantity' => 0, + 'created_by' => $operatorName, + 'scanned_by' => $operatorName, + ]); + return; + } try { $existingPallet = WireMasterPacking::where('plant_id', $plantId)