1
0
forked from poc/pds

Refactor Invoice Validation Logic and Update UI for Serial and Material Invoices

- Improved conditional checks for invoice processing in InvoiceValidationResource on completion (or pending).
- Enhanced notifications for completed scanning processes for both serial and material invoices.
- Updated CreateInvoiceValidation page to pass invoice type to serial and material invoice on completion (or pending).
- Modified InvoiceDataTable to include a new property for serial/material invoice handling.
- Adjusted Blade view to dynamically display the correct title and messages based on invoice type (serial/material).
This commit is contained in:
dhanabalan
2025-08-05 12:00:26 +05:30
parent d6c77bd6c3
commit 197184e2ed
4 changed files with 255 additions and 132 deletions

View File

@@ -148,16 +148,16 @@ class InvoiceValidationResource extends Resource
->reactive() ->reactive()
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || !empty($get('serial_number'))) ->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || !empty($get('serial_number')))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
if(!$get('plant_id')) if (!$get('plant_id'))
{ {
$set('update_invoice', null); $set('update_invoice', null);
return; return;
} }
if($get('update_invoice') === "1") if ($get('update_invoice') == "1")
{ {
$totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count(); $totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
if($totQuan <= 0) if ($totQuan <= 0)
{ {
$set('update_invoice', null); $set('update_invoice', null);
return; return;
@@ -167,9 +167,9 @@ class InvoiceValidationResource extends Resource
$scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count(); $scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count(); $scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
if($totMQuan > 0) if ($totMQuan > 0)
{ {
if ($totQuan === $scanMQuan) if ($totQuan == $scanMQuan)
{ {
$set('update_invoice', null); $set('update_invoice', null);
return; return;
@@ -177,7 +177,7 @@ class InvoiceValidationResource extends Resource
} }
else else
{ {
if ($totQuan === $scanSQuan) if ($totQuan == $scanSQuan)
{ {
$set('update_invoice', null); $set('update_invoice', null);
return; return;
@@ -343,15 +343,57 @@ class InvoiceValidationResource extends Resource
$fullPath = Storage::disk('local')->path($path); $fullPath = Storage::disk('local')->path($path);
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx // /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
if ($totQuan > 0)
{
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
if ($totQuan == $scanSQuan)
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
Notification::make()
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
else
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
$invoicePlantId = $invoiceFirst->plant_id;
if ($plantId != $invoicePlantId)
{
Notification::make()
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
}
}
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count(); $totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); $scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
if($totQuan == $scanSQuan && $totQuan > 0) if ($totQuan > 0 && $totQuan == $scanSQuan)
{ {
Notification::make() Notification::make()
->title('Serial invoice already completed the scanning process for selected plant.') ->title('Serial invoice already completed the scanning process for selected plant.')
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) if ($disk->exists($path))
{ {
@@ -364,7 +406,7 @@ class InvoiceValidationResource extends Resource
{ {
$rows = Excel::toArray(null, $fullPath)[0]; $rows = Excel::toArray(null, $fullPath)[0];
if((count($rows) - 1) <= 0) if ((count($rows) - 1) <= 0)
{ {
Notification::make() Notification::make()
->title('Records Not Found') ->title('Records Not Found')
@@ -388,7 +430,7 @@ class InvoiceValidationResource extends Resource
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$serialNumber = trim($row[1]); $serialNumber = trim($row[1]);
@@ -399,19 +441,17 @@ class InvoiceValidationResource extends Resource
if (!empty($materialCode)) if (!empty($materialCode))
{ {
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
{ {
$invalidMatCodes[] = $materialCode; $invalidMatCodes[] = $materialCode;
} }
else else
{ {
if (empty($serialNumber)) { if (empty($serialNumber)) {
$missingSerials[] = $materialCode; $missingSerials[] = $materialCode;
} }
else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
{ {
$invalidSerialCodes[] = $serialNumber; $invalidSerialCodes[] = $serialNumber;
} }
@@ -453,7 +493,6 @@ class InvoiceValidationResource extends Resource
} }
return; return;
} }
else if (!empty($uniqueMissingSerials)) { else if (!empty($uniqueMissingSerials)) {
Notification::make() Notification::make()
->title('Missing Serial Numbers') ->title('Missing Serial Numbers')
@@ -479,7 +518,7 @@ class InvoiceValidationResource extends Resource
else if (!empty($duplicateSerialCodes)) { else if (!empty($duplicateSerialCodes)) {
Notification::make() Notification::make()
->title('Duplicate Serial Numbers') ->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in database:<br>' . implode(', ', $duplicateSerialCodes)) ->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) { if ($disk->exists($path)) {
@@ -532,30 +571,30 @@ class InvoiceValidationResource extends Resource
// Check which codes have a material_type set (not null) // Check which codes have a material_type set (not null)
$invalidCodes = $matchedItems $invalidCodes = $matchedItems
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid ->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
->pluck('item.code') ->pluck('item.code')
->toArray(); ->toArray();
if (count($invalidCodes) > 10) if (count($invalidCodes) > 10)
{ {
Notification::make() Notification::make()
->title('Invalid item codes found') ->title('Invalid item codes found')
->body('' . count($invalidCodes) . 'item codes found have material type.') ->body('' . count($invalidCodes) . 'item codes found have material type.')
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) { if ($disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
} }
return; return;
} }
else if(count($invalidCodes) > 0) else if (count($invalidCodes) > 0)
{ {
Notification::make() Notification::make()
->title('Invalid item codes found') ->title('Invalid item codes found')
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes)) ->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) { if ($disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
@@ -567,7 +606,7 @@ class InvoiceValidationResource extends Resource
// Save full file path to session // Save full file path to session
session(['uploaded_invoice_path' => $fullPath]); session(['uploaded_invoice_path' => $fullPath]);
Notification::make() Notification::make()
->title('Serial invoice imported successfully.') ->title('Serial invoice imported successfully.')
->success() ->success()
->send(); ->send();
} }
@@ -603,7 +642,6 @@ class InvoiceValidationResource extends Resource
->visible(fn (Get $get) => !empty($get('plant_id'))) ->visible(fn (Get $get) => !empty($get('plant_id')))
->directory('uploads/temp'), ->directory('uploads/temp'),
]) ])
->action(function (array $data) { ->action(function (array $data) {
$uploadedFile = $data['invoice_material']; $uploadedFile = $data['invoice_material'];
@@ -620,10 +658,52 @@ class InvoiceValidationResource extends Resource
$fullPath = Storage::disk('local')->path($path); $fullPath = Storage::disk('local')->path($path);
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
if ($totQuan > 0)
{
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->count();
if ($totQuan == $scanMQuan)
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
Notification::make()
->title("Material invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
else
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
$invoicePlantId = $invoiceFirst->plant_id;
if ($plantId != $invoicePlantId)
{
Notification::make()
->title("Material invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
}
}
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count(); $totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); $scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
if($totQuan == $scanMQuan && $totQuan > 0) if ($totQuan > 0 && $totQuan == $scanMQuan)
{ {
Notification::make() Notification::make()
->title('Material invoice already completed the scanning process for selected plant.') ->title('Material invoice already completed the scanning process for selected plant.')
@@ -639,7 +719,7 @@ class InvoiceValidationResource extends Resource
{ {
$rows = Excel::toArray(null, $fullPath)[0]; $rows = Excel::toArray(null, $fullPath)[0];
if((count($rows) - 1) <= 0) if ((count($rows) - 1) <= 0)
{ {
Notification::make() Notification::make()
->title('Records Not Found') ->title('Records Not Found')
@@ -662,7 +742,7 @@ class InvoiceValidationResource extends Resource
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$materialQuantity = trim($row[1]); $materialQuantity = trim($row[1]);
@@ -672,13 +752,13 @@ class InvoiceValidationResource extends Resource
} }
if (!empty($materialCode)) { if (!empty($materialCode)) {
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
{ {
$invalidMatCodes[] = $materialCode; $invalidMatCodes[] = $materialCode;
} }
else else
{ {
if($materialQuantity == 0) if ($materialQuantity == 0)
{ {
$invalidMaterialQuan[] = $materialCode; $invalidMaterialQuan[] = $materialCode;
} }
@@ -686,7 +766,7 @@ class InvoiceValidationResource extends Resource
{ {
$missingQuantities[] = $materialCode; $missingQuantities[] = $materialCode;
} }
else if(!is_numeric($materialQuantity)) else if (!is_numeric($materialQuantity))
{ {
$invalidMatQuan[] = $materialCode; $invalidMatQuan[] = $materialCode;
} }
@@ -821,7 +901,7 @@ class InvoiceValidationResource extends Resource
} }
return; return;
} }
else if(count($invalidCodes) > 0) else if (count($invalidCodes) > 0)
{ {
$invalidCodes = array_unique($invalidCodes); $invalidCodes = array_unique($invalidCodes);
Notification::make() Notification::make()
@@ -852,29 +932,29 @@ class InvoiceValidationResource extends Resource
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
if ($totalExcelQty === 0) { if ($totalExcelQty == 0) {
$zeroQtyCodes[] = $code; $zeroQtyCodes[] = $code;
} elseif (!is_numeric($totalExcelQty)) { } elseif (!is_numeric($totalExcelQty)) {
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) { } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
$notDivisibleCodes[] = $code; $notDivisibleCodes[] = $code;
} }
} }
} }
$showValidationNotification = function(array $codes, string $message) { $showValidationNotification = function(array $codes, string $message) {
if (count($codes) === 0) return; if (count($codes) == 0) return;
$uniqueCodes = array_unique($codes); $uniqueCodes = array_unique($codes);
$codeList = implode(', ', $uniqueCodes); $codeList = implode(', ', $uniqueCodes);
@@ -1013,7 +1093,7 @@ class InvoiceValidationResource extends Resource
->query(function ($query, array $data) { ->query(function ($query, array $data) {
// Hide all records initially if no filters are applied // Hide all records initially if no filters are applied
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) { if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
if(empty($data['invoice_type'])) if (empty($data['invoice_type']))
{ {
Notification::make() Notification::make()
->title('Please, choose invoice type to filter.') ->title('Please, choose invoice type to filter.')

View File

@@ -8,6 +8,7 @@ use App\Imports\ExcelImport;
use App\Livewire\InvoiceDataTable; use App\Livewire\InvoiceDataTable;
use App\Models\InvoiceValidation; use App\Models\InvoiceValidation;
use App\Models\Item; use App\Models\Item;
use App\Models\Plant;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Pages\Concerns\ExposesTableToWidgets; use Filament\Pages\Concerns\ExposesTableToWidgets;
@@ -74,6 +75,22 @@ class CreateInvoiceValidation extends CreateRecord
$this->plantId = $plantId; $this->plantId = $plantId;
$plant = Plant::find($plantId);
if ($plant)
{
$plantCode = $plant->code;
}
else
{
$plantCode = null;
}
//..GET SERIAL INVOICE API
//..
$updateStatus = $this->form->getState()['update_invoice'] ?? null; $updateStatus = $this->form->getState()['update_invoice'] ?? null;
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber; $this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
@@ -116,7 +133,7 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scanMQuan, 'scanned_quantity'=> $scanMQuan,
]); ]);
if ($totQuan === $scanMQuan) if ($totQuan == $scanMQuan)
{ {
Notification::make() Notification::make()
->title("Completed: Material Invoice") ->title("Completed: Material Invoice")
@@ -134,7 +151,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
} }
else else
{ {
@@ -147,7 +164,7 @@ class CreateInvoiceValidation extends CreateRecord
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
if($updateStatus === '1') if($updateStatus == '1')
{ {
//'Material invoice update in progress...'; //'Material invoice update in progress...';
$filename = $invoiceNumber . '.xlsx'; $filename = $invoiceNumber . '.xlsx';
@@ -185,7 +202,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$materialQuantity = trim($row[1]); $materialQuantity = trim($row[1]);
@@ -390,7 +407,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -399,16 +416,16 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
if ($totalExcelQty === 0) { if ($totalExcelQty == 0) {
$zeroQtyCodes[] = $code; $zeroQtyCodes[] = $code;
} elseif (!is_numeric($totalExcelQty)) { } elseif (!is_numeric($totalExcelQty)) {
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) { } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
$notDivisibleCodes[] = $code; $notDivisibleCodes[] = $code;
} }
} }
@@ -420,7 +437,7 @@ class CreateInvoiceValidation extends CreateRecord
} }
$showValidationNotification = function(array $codes, string $message) { $showValidationNotification = function(array $codes, string $message) {
if (count($codes) === 0) return; if (count($codes) == 0) return;
$uniqueCodes = array_unique($codes); $uniqueCodes = array_unique($codes);
$codeList = implode(', ', $uniqueCodes); $codeList = implode(', ', $uniqueCodes);
@@ -452,7 +469,7 @@ class CreateInvoiceValidation extends CreateRecord
$inserted = 0; $inserted = 0;
foreach ($matchedItems as $sticker) foreach ($matchedItems as $sticker)
{ {
if ($newQuan === -1 && !$hasQuanTyp) if ($newQuan == -1 && !$hasQuanTyp)
{ {
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) { InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
$query->whereNull('serial_number')->orWhere('serial_number', ''); $query->whereNull('serial_number')->orWhere('serial_number', '');
@@ -461,7 +478,7 @@ class CreateInvoiceValidation extends CreateRecord
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); $newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
} }
else if ($newQuan === -1 && $hasQuanTyp) else if ($newQuan == -1 && $hasQuanTyp)
{ {
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) { InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
$query->whereNull('serial_number')->orWhere('serial_number', ''); $query->whereNull('serial_number')->orWhere('serial_number', '');
@@ -481,7 +498,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -490,7 +507,7 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
@@ -522,7 +539,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -531,7 +548,7 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
@@ -564,7 +581,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -573,7 +590,7 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; $totalExcelQty += $excelMatQty;
} }
} }
@@ -669,7 +686,7 @@ class CreateInvoiceValidation extends CreateRecord
} }
} }
if ($inserted > 0 || $oldQuan !== $newQuan) if ($inserted > 0 || $oldQuan != $newQuan)
{ {
Notification::make() Notification::make()
->title("Material invoice successfully updatad.") ->title("Material invoice successfully updatad.")
@@ -695,13 +712,13 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if ($totalQuantity === $scannedQuantity) if ($totalQuantity == $scannedQuantity)
{ {
if ($disk->exists($filePath)) { if ($disk->exists($filePath)) {
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
} }
else else
{ {
@@ -775,7 +792,7 @@ class CreateInvoiceValidation extends CreateRecord
//$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; //$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
// $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); // $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
if ($totQuan === $scanSQuan) if ($totQuan == $scanSQuan)
{ {
Notification::make() Notification::make()
->title("Completed: Serial Invoice") ->title("Completed: Serial Invoice")
@@ -793,7 +810,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
} }
else else
{ {
@@ -804,7 +821,7 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
if($updateStatus === '1') if($updateStatus == '1')
{ {
$filename = $invoiceNumber . '.xlsx'; $filename = $invoiceNumber . '.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';
@@ -846,7 +863,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$serialNumber = trim($row[1]); $serialNumber = trim($row[1]);
@@ -1087,7 +1104,7 @@ class CreateInvoiceValidation extends CreateRecord
$inserted = 0; $inserted = 0;
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) // Skip header; if ($index == 0) // Skip header;
{ {
InvoiceValidation::where('invoice_number', $invoiceNumber) InvoiceValidation::where('invoice_number', $invoiceNumber)
->where(function($query) { ->where(function($query) {
@@ -1138,7 +1155,7 @@ class CreateInvoiceValidation extends CreateRecord
} }
} }
if ($inserted > 0 || $oldQuan !== $newQuan) if ($inserted > 0 || $oldQuan != $newQuan)
{ {
Notification::make() Notification::make()
->title("Serial invoice successfully updated.") ->title("Serial invoice successfully updated.")
@@ -1165,13 +1182,13 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if ($totalQuantity === $scannedQuantity) if ($totalQuantity == $scannedQuantity)
{ {
if ($disk->exists($filePath)) { if ($disk->exists($filePath)) {
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
} }
else else
{ {
@@ -1283,7 +1300,7 @@ class CreateInvoiceValidation extends CreateRecord
$uploadedFilename = pathinfo($fullPath, PATHINFO_FILENAME); $uploadedFilename = pathinfo($fullPath, PATHINFO_FILENAME);
// Compare with invoice number // Compare with invoice number
if ($uploadedFilename !== $invoiceNumber) { if ($uploadedFilename != $invoiceNumber) {
Notification::make() Notification::make()
->title("Uploaded file name does not match the invoice number.") ->title("Uploaded file name does not match the invoice number.")
->danger() ->danger()
@@ -1326,7 +1343,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; if ($index == 0) continue;
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
@@ -1365,7 +1382,7 @@ class CreateInvoiceValidation extends CreateRecord
} }
} }
if($invoiceType === 'M') if($invoiceType == 'M')
{ {
$invalidMatCodes = []; $invalidMatCodes = [];
$materialCodes = []; $materialCodes = [];
@@ -1375,7 +1392,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$materialQuantity = trim($row[1]); $materialQuantity = trim($row[1]);
@@ -1578,7 +1595,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -1587,23 +1604,23 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
if ($totalExcelQty === 0) { if ($totalExcelQty == 0) {
$zeroQtyCodes[] = $code; $zeroQtyCodes[] = $code;
} elseif (!is_numeric($totalExcelQty)) { } elseif (!is_numeric($totalExcelQty)) {
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) { } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
$notDivisibleCodes[] = $code; $notDivisibleCodes[] = $code;
} }
} }
} }
$showValidationNotification = function(array $codes, string $message) { $showValidationNotification = function(array $codes, string $message) {
if (count($codes) === 0) return; if (count($codes) == 0) return;
$uniqueCodes = array_unique($codes); $uniqueCodes = array_unique($codes);
$codeList = implode(', ', $uniqueCodes); $codeList = implode(', ', $uniqueCodes);
@@ -1642,7 +1659,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -1651,7 +1668,7 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
@@ -1677,7 +1694,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -1686,7 +1703,7 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
@@ -1711,7 +1728,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]); $excelCode = trim($row[0]);
$excelMatQty = trim($row[1]); $excelMatQty = trim($row[1]);
@@ -1720,7 +1737,7 @@ class CreateInvoiceValidation extends CreateRecord
continue; continue;
} }
if ($excelCode === $code && is_numeric($excelMatQty)) { if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities $totalExcelQty += $excelMatQty; // Sum up the quantities
} }
} }
@@ -1759,13 +1776,13 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if ($totalQuantity === $scannedQuantity) if ($totalQuantity == $scannedQuantity)
{ {
if ($disk->exists($filePath)) { if ($disk->exists($filePath)) {
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
} }
else else
{ {
@@ -1805,7 +1822,7 @@ class CreateInvoiceValidation extends CreateRecord
} }
} }
} }
else if($invoiceType === 'S') else if($invoiceType == 'S')
{ {
$invalidMatCodes = []; $invalidMatCodes = [];
$materialCodes = []; $materialCodes = [];
@@ -1817,7 +1834,7 @@ class CreateInvoiceValidation extends CreateRecord
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; // Skip header if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$serialNumber = trim($row[1]); $serialNumber = trim($row[1]);
@@ -2077,7 +2094,7 @@ class CreateInvoiceValidation extends CreateRecord
$inserted = 0; $inserted = 0;
foreach ($rows as $index => $row) foreach ($rows as $index => $row)
{ {
if ($index === 0) continue; if ($index == 0) continue;
$materialCode = trim($row[0]); $materialCode = trim($row[0]);
$serialNumber = trim($row[1]); $serialNumber = trim($row[1]);
@@ -2123,13 +2140,13 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if ($totalQuantity === $scannedQuantity) if ($totalQuantity == $scannedQuantity)
{ {
if ($disk->exists($filePath)) { if ($disk->exists($filePath)) {
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
} }
else else
{ {
@@ -2201,9 +2218,9 @@ class CreateInvoiceValidation extends CreateRecord
{ {
$totalQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count(); $totalQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count(); $scannedQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
if ($totalQuantity === $scannedQuantity) if ($totalQuantity == $scannedQuantity)
{ {
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, isSerial: true);
} }
else else
{ {
@@ -2255,7 +2272,7 @@ class CreateInvoiceValidation extends CreateRecord
{ {
if ($totMQuan > 0) if ($totMQuan > 0)
{ {
if ($totQuan === $scanMQuan) if ($totQuan == $scanMQuan)
{ {
Notification::make() Notification::make()
->title('Completed: Material Invoice') ->title('Completed: Material Invoice')
@@ -2282,7 +2299,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
return; return;
} }
else else
@@ -2759,7 +2776,7 @@ class CreateInvoiceValidation extends CreateRecord
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); $scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
if($totQuan === $scannedMQuantity) if($totQuan == $scannedMQuantity)
{ {
Notification::make() Notification::make()
->title('Completed: Material Invoice') ->title('Completed: Material Invoice')
@@ -2786,7 +2803,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
} }
else else
{ {
@@ -2804,7 +2821,7 @@ class CreateInvoiceValidation extends CreateRecord
} }
else else
{ {
if ($totQuan === $scanSQuan) if ($totQuan == $scanSQuan)
{ {
Notification::make() Notification::make()
->title('Completed: Serial Invoice') ->title('Completed: Serial Invoice')
@@ -2831,7 +2848,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
return; return;
} }
else else
@@ -3004,7 +3021,7 @@ class CreateInvoiceValidation extends CreateRecord
]); ]);
return; return;
} }
else if($hadMotorQr === $hasMotorQr) else if($hadMotorQr == $hasMotorQr)
{ {
Notification::make() Notification::make()
->title('Duplicate: Motor QR') ->title('Duplicate: Motor QR')
@@ -3027,7 +3044,7 @@ class CreateInvoiceValidation extends CreateRecord
$packCnt = 1; $packCnt = 1;
$scanCnt = 1; $scanCnt = 1;
$record->motor_scanned_status = 1; $record->motor_scanned_status = 1;
//if($hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr) //if($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
if($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) if($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr)
{ {
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
@@ -3038,7 +3055,7 @@ class CreateInvoiceValidation extends CreateRecord
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
if($packCnt === $scanCnt) if($packCnt == $scanCnt)
{ {
$record->scanned_status = 'Scanned'; $record->scanned_status = 'Scanned';
} }
@@ -3067,7 +3084,7 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if($totQuan === $scannedQuantity) if($totQuan == $scannedQuantity)
{ {
Notification::make() Notification::make()
->title('Completed: Serial Invoice') ->title('Completed: Serial Invoice')
@@ -3085,7 +3102,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
} }
else else
{ {
@@ -3114,7 +3131,7 @@ class CreateInvoiceValidation extends CreateRecord
]); ]);
return; return;
} }
else if($hadPumpQr === $hasPumpQr) else if($hadPumpQr == $hasPumpQr)
{ {
Notification::make() Notification::make()
->title('Duplicate: Pump QR') ->title('Duplicate: Pump QR')
@@ -3137,7 +3154,7 @@ class CreateInvoiceValidation extends CreateRecord
$packCnt = 1; $packCnt = 1;
$scanCnt = 1; $scanCnt = 1;
$record->pump_scanned_status = 1; $record->pump_scanned_status = 1;
// if($hadMotorQr === $hasMotorQr && $hadPumpSetQr === $hasPumpSetQr && ($hadCapacitorQr === '1' && $hasCapacitorQr)) // if($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr)
{ {
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
@@ -3148,7 +3165,7 @@ class CreateInvoiceValidation extends CreateRecord
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
if($packCnt === $scanCnt) if($packCnt == $scanCnt)
{ {
$record->scanned_status = 'Scanned'; $record->scanned_status = 'Scanned';
} }
@@ -3177,7 +3194,7 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if($totQuan === $scannedQuantity) if($totQuan == $scannedQuantity)
{ {
Notification::make() Notification::make()
->title('Completed: Serial Invoice') ->title('Completed: Serial Invoice')
@@ -3195,7 +3212,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
} }
else else
{ {
@@ -3226,7 +3243,7 @@ class CreateInvoiceValidation extends CreateRecord
]); ]);
return; return;
} }
else if($hadCapacitorQr === '1' && $hasCapacitorQr) else if($hadCapacitorQr == '1' && $hasCapacitorQr)
{ {
Notification::make() Notification::make()
->title('Duplicate: Capacitor QR') ->title('Duplicate: Capacitor QR')
@@ -3285,7 +3302,7 @@ class CreateInvoiceValidation extends CreateRecord
]); ]);
return; return;
} }
else if($hadPumpSetQr === $hasPumpSetQr) else if($hadPumpSetQr == $hasPumpSetQr)
{ {
Notification::make() Notification::make()
->title('Duplicate: Pump Set QR') ->title('Duplicate: Pump Set QR')
@@ -3308,7 +3325,7 @@ class CreateInvoiceValidation extends CreateRecord
$packCnt = 1; $packCnt = 1;
$scanCnt = 1; $scanCnt = 1;
$record->scanned_status_set = 1; $record->scanned_status_set = 1;
// if($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && ($hadCapacitorQr === '1' && $hasCapacitorQr)) // if($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
if($hasMotorQr || $hasPumpQr || $hasCapacitorQr) if($hasMotorQr || $hasPumpQr || $hasCapacitorQr)
{ {
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
@@ -3319,7 +3336,7 @@ class CreateInvoiceValidation extends CreateRecord
$scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
if($packCnt === $scanCnt) if($packCnt == $scanCnt)
{ {
$record->scanned_status = 'Scanned'; $record->scanned_status = 'Scanned';
} }
@@ -3348,7 +3365,7 @@ class CreateInvoiceValidation extends CreateRecord
'scanned_quantity'=> $scannedQuantity, 'scanned_quantity'=> $scannedQuantity,
]); ]);
if($totQuan === $scannedQuantity) if($totQuan == $scannedQuantity)
{ {
Notification::make() Notification::make()
->title('Completed: Serial Invoice') ->title('Completed: Serial Invoice')
@@ -3366,7 +3383,7 @@ class CreateInvoiceValidation extends CreateRecord
//$fullPath = $disk->path($filePath); //$fullPath = $disk->path($filePath);
$disk->delete($filePath); $disk->delete($filePath);
} }
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
} }
else else
{ {

View File

@@ -19,6 +19,8 @@ class InvoiceDataTable extends Component
public bool $completedInvoice = false; public bool $completedInvoice = false;
public bool $isSerial = false;
public bool $emptyInvoice = false; public bool $emptyInvoice = false;
public bool $hasSearched = false; public bool $hasSearched = false;
@@ -49,11 +51,12 @@ class InvoiceDataTable extends Component
public string $currentSerialNumber = ''; public string $currentSerialNumber = '';
public function loadCompletedData($invoiceNumber, $plantId) public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
{ {
$this->plantId = $plantId; $this->plantId = $plantId;
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
$this->completedInvoice = true; $this->completedInvoice = true;
$this->isSerial = $isSerial;
$this->emptyInvoice = false; $this->emptyInvoice = false;
$this->hasSearched = false; $this->hasSearched = false;
$this->materialInvoice = false; $this->materialInvoice = false;
@@ -64,8 +67,8 @@ class InvoiceDataTable extends Component
{ {
$this->plantId = $plantId; $this->plantId = $plantId;
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
$this->emptyInvoice = true;
$this->completedInvoice = false; $this->completedInvoice = false;
$this->emptyInvoice = true;
$this->hasSearched = false; $this->hasSearched = false;
$this->materialInvoice = false; $this->materialInvoice = false;
// $this->showCapacitorInput = false; // $this->showCapacitorInput = false;
@@ -75,9 +78,10 @@ class InvoiceDataTable extends Component
{ {
$this->plantId = $plantId; $this->plantId = $plantId;
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
$this->hasSearched = true;
$this->emptyInvoice = false;
$this->completedInvoice = false; $this->completedInvoice = false;
$this->isSerial = true;
$this->emptyInvoice = false;
$this->hasSearched = true;
$this->materialInvoice = false; $this->materialInvoice = false;
// $this->showCapacitorInput = false; // $this->showCapacitorInput = false;
@@ -113,10 +117,11 @@ class InvoiceDataTable extends Component
{ {
$this->plantId = $plantId; $this->plantId = $plantId;
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
$this->materialInvoice = true;
$this->emptyInvoice = false;
$this->completedInvoice = false; $this->completedInvoice = false;
$this->isSerial = false;
$this->emptyInvoice = false;
$this->hasSearched = false; $this->hasSearched = false;
$this->materialInvoice = true;
// $this->showCapacitorInput = false; // $this->showCapacitorInput = false;
//->where('serial_number', '!=', '') //->where('serial_number', '!=', '')
@@ -171,13 +176,12 @@ class InvoiceDataTable extends Component
$this->currentSerialNumber = $serialNumber; $this->currentSerialNumber = $serialNumber;
$this->showCapacitorInput = true; $this->showCapacitorInput = true;
// $this->capacitorInput = ''; // $this->capacitorInput = '';
$this->emptyInvoice = false;
$this->completedInvoice = false; $this->completedInvoice = false;
$this->isSerial = true;
$this->emptyInvoice = false;
$this->hasSearched = false; $this->hasSearched = false;
$this->materialInvoice = false; $this->materialInvoice = false;
$this->dispatch('focus-capacitor-input'); $this->dispatch('focus-capacitor-input');
} }
public function cancelCapacitorInput() public function cancelCapacitorInput()
@@ -330,7 +334,7 @@ class InvoiceDataTable extends Component
->success() ->success()
->seconds(2) ->seconds(2)
->send(); ->send();
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id); $this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
} }
else else
{ {

View File

@@ -1,7 +1,23 @@
<div> <div>
<div class="mb-4"> <div class="mb-4">
<h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2> <h2 class="text-lg font-bold text-gray-800">
@if ($hasSearched)
SERIAL INVOICE DATA TABLE
@elseif ($materialInvoice)
MATERIAL INVOICE DATA TABLE
@else
@if ($completedInvoice)
@if ($isSerial)
SERIAL INVOICE DATA TABLE
@else
MATERIAL INVOICE DATA TABLE
@endif
@else
INVOICE DATA TABLE
@endif
@endif
</h2>
<div class="mt-2"> <div class="mt-2">
<hr class="border-t-2 border-gray-300"> <hr class="border-t-2 border-gray-300">
</div> </div>
@@ -10,7 +26,13 @@
{{-- Modal for completed invoice--}} {{-- Modal for completed invoice--}}
@if ($completedInvoice) @if ($completedInvoice)
<div class="text-center text-red-500"> <div class="text-center text-red-500">
<p>Completed the scanning process for invoice number <strong>{{ $invoiceNumber }}</strong>.</p> <p>
@if ($isSerial)
Completed the scanning process for serial invoice number <strong>{{ $invoiceNumber }}</strong>.
@else
Completed the scanning process for material invoice number <strong>{{ $invoiceNumber }}</strong>.
@endif
</p>
</div> </div>
@endif @endif