removed new logic in invoice data table
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled

This commit is contained in:
dhanabalan
2026-01-30 14:47:04 +05:30
parent 341f4f20b4
commit 349d04b7f9
2 changed files with 164 additions and 177 deletions

View File

@@ -307,84 +307,84 @@ class InvoiceDataTable extends Component
// #[On('refreshInvoiceData')] // #[On('refreshInvoiceData')]
public function loadData($invoiceNumber, $plantId, $onCapFocus = false) // public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
{ // {
$this->invoiceNumber = $invoiceNumber; // $this->invoiceNumber = $invoiceNumber;
$this->plantId = $plantId; // $this->plantId = $plantId;
$this->completedInvoice = false; // $this->completedInvoice = false;
$this->isSerial = true; // $this->isSerial = true;
$this->onCapFocus = $onCapFocus; // $this->onCapFocus = $onCapFocus;
$this->emptyInvoice = false; // $this->emptyInvoice = false;
$this->hasSearched = true; // $this->hasSearched = true;
$this->materialInvoice = false; // $this->materialInvoice = false;
$this->resetPage(); // $this->resetPage();
$this->packageCount = 0; // $this->packageCount = 0;
$this->packageCount = InvoiceValidation::with('stickerMasterRelation') // $this->packageCount = InvoiceValidation::with('stickerMasterRelation')
->where('invoice_number', $this->invoiceNumber) // ->where('invoice_number', $this->invoiceNumber)
->where('plant_id', $this->plantId) // ->where('plant_id', $this->plantId)
->whereNull('scanned_status') // ->whereNull('scanned_status')
->get() // ->get()
->sum(function ($record) { // ->sum(function ($record) {
$sm = $record->stickerMasterRelation; // $sm = $record->stickerMasterRelation;
$stickCount = 0; // $stickCount = 0;
$scannedCount = 0; // $scannedCount = 0;
if ($sm) { // if ($sm) {
// if (strlen($sm->panel_box_code) > 0) $stickCount++; // // if (strlen($sm->panel_box_code) > 0) $stickCount++;
if (!empty($sm->panel_box_code)) {
$stickCount++;
if (!empty($record->panel_box_serial_number)) {
$scannedCount++;
}
}
// Tube stickers
if ($sm->tube_sticker_motor || $sm->tube_sticker_pump || $sm->tube_sticker_pumpset) {
$stickCount += $sm->tube_sticker_motor ? 1 : 0;
$stickCount += ($sm->tube_sticker_pump || ($sm->tube_sticker_pumpset != 1 && !$sm->tube_sticker_pump && $sm->pack_slip_pump)) ? 1 : 0;
$stickCount += $sm->tube_sticker_pumpset ? 1 : 0;
}
// Pack slips (only if tube stickers not applied)
elseif ($sm->pack_slip_motor || $sm->pack_slip_pump || $sm->pack_slip_pumpset) {
$stickCount += $sm->pack_slip_motor ? 1 : 0;
$stickCount += $sm->pack_slip_pump ? 1 : 0;
$stickCount += $sm->pack_slip_pumpset ? 1 : 0;
}
}
// Already scanned
$scannedCount += $record->motor_scanned_status == 1 ? 1 : 0;
$scannedCount += $record->pump_scanned_status == 1 ? 1 : 0;
$scannedCount += $record->capacitor_scanned_status == 1 ? 1 : 0;
$scannedCount += $record->scanned_status_set == 1 ? 1 : 0;
// if (!empty($sm->panel_box_code)) {
// $stickCount++;
// if (!empty($record->panel_box_serial_number)) { // if (!empty($record->panel_box_serial_number)) {
// $scannedCount++; // $scannedCount++;
// } // }
return max($stickCount - $scannedCount, 0); // }
});
$this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'); // // Tube stickers
} // if ($sm->tube_sticker_motor || $sm->tube_sticker_pump || $sm->tube_sticker_pumpset) {
// $stickCount += $sm->tube_sticker_motor ? 1 : 0;
// $stickCount += ($sm->tube_sticker_pump || ($sm->tube_sticker_pumpset != 1 && !$sm->tube_sticker_pump && $sm->pack_slip_pump)) ? 1 : 0;
// $stickCount += $sm->tube_sticker_pumpset ? 1 : 0;
// }
// // Pack slips (only if tube stickers not applied)
// elseif ($sm->pack_slip_motor || $sm->pack_slip_pump || $sm->pack_slip_pumpset) {
// $stickCount += $sm->pack_slip_motor ? 1 : 0;
// $stickCount += $sm->pack_slip_pump ? 1 : 0;
// $stickCount += $sm->pack_slip_pumpset ? 1 : 0;
// }
// }
public function getInvoiceRecordsProperty() // // Already scanned
{ // $scannedCount += $record->motor_scanned_status == 1 ? 1 : 0;
return InvoiceValidation::with('stickerMasterRelation.item') // $scannedCount += $record->pump_scanned_status == 1 ? 1 : 0;
->when(! $this->hasSearched, fn ($q) => $q->whereRaw('1 = 0')) // $scannedCount += $record->capacitor_scanned_status == 1 ? 1 : 0;
->when($this->hasSearched, fn ($q) => // $scannedCount += $record->scanned_status_set == 1 ? 1 : 0;
$q->where('invoice_number', $this->invoiceNumber)
->where('plant_id', $this->plantId) // // if (!empty($record->panel_box_serial_number)) {
->whereNull('scanned_status') // // $scannedCount++;
) // // }
->paginate(7); // return max($stickCount - $scannedCount, 0);
} // });
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
// }
// public function getInvoiceRecordsProperty()
// {
// return InvoiceValidation::with('stickerMasterRelation.item')
// ->when(! $this->hasSearched, fn ($q) => $q->whereRaw('1 = 0'))
// ->when($this->hasSearched, fn ($q) =>
// $q->where('invoice_number', $this->invoiceNumber)
// ->where('plant_id', $this->plantId)
// ->whereNull('scanned_status')
// )
// ->paginate(7);
// }
// public function getInvoiceRecordsProperty() // public function getInvoiceRecordsProperty()
// { // {
@@ -396,87 +396,87 @@ class InvoiceDataTable extends Component
// } // }
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false) public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
// { {
// $this->plantId = $plantId; $this->plantId = $plantId;
// $this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
// $this->completedInvoice = false; $this->completedInvoice = false;
// $this->isSerial = true; $this->isSerial = true;
// $this->onCapFocus = $onCapFocus; $this->onCapFocus = $onCapFocus;
// $this->emptyInvoice = false; $this->emptyInvoice = false;
// $this->hasSearched = true; $this->hasSearched = true;
// $this->materialInvoice = false; $this->materialInvoice = false;
// // Eager load stickerMasterRelation and item // Eager load stickerMasterRelation and item
// $invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item') $invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
// ->where('invoice_number', $invoiceNumber) ->where('invoice_number', $invoiceNumber)
// ->where('plant_id', $plantId) ->where('plant_id', $plantId)
// ->whereNull('scanned_status') ->whereNull('scanned_status')
// ->get(); ->get();
// $this->invoiceData = []; $this->invoiceData = [];
// $this->packageCount = 0; $this->packageCount = 0;
// foreach ($invoiceRecords as $record) { foreach ($invoiceRecords as $record) {
// $sm = $record->stickerMasterRelation; $sm = $record->stickerMasterRelation;
// // Compute code // Compute code
// $rowCode = $sm?->item?->code ?? 'N/A'; $rowCode = $sm?->item?->code ?? 'N/A';
// $stickCount = 0; $stickCount = 0;
// $scannedCount = 0; $scannedCount = 0;
// if ($sm) { if ($sm) {
// // Panel box code // Panel box code
// if (Str::length($sm->panel_box_code) > 0) { if (Str::length($sm->panel_box_code) > 0) {
// $stickCount++; $stickCount++;
// } }
// // Tube stickers logic // Tube stickers logic
// if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) { if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
// if ($sm->tube_sticker_motor == 1) $stickCount++; if ($sm->tube_sticker_motor == 1) $stickCount++;
// if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++; if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
// if ($sm->tube_sticker_pumpset == 1) $stickCount++; if ($sm->tube_sticker_pumpset == 1) $stickCount++;
// } }
// // Pack slip logic (only if tube sticker block didn't apply) // Pack slip logic (only if tube sticker block didn't apply)
// elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) { elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
// if ($sm->pack_slip_motor == 1) $stickCount++; if ($sm->pack_slip_motor == 1) $stickCount++;
// if ($sm->pack_slip_pump == 1) $stickCount++; if ($sm->pack_slip_pump == 1) $stickCount++;
// if ($sm->pack_slip_pumpset == 1) $stickCount++; if ($sm->pack_slip_pumpset == 1) $stickCount++;
// } }
// } }
// // Count already scanned // Count already scanned
// $scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0; $scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
// $scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0; $scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
// $scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0; $scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
// $scannedCount += ($record->scanned_status_set == 1) ? 1 : 0; $scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
// // Increment packageCount // Increment packageCount
// $this->packageCount += max($stickCount - $scannedCount, 0); $this->packageCount += max($stickCount - $scannedCount, 0);
// $this->invoiceData[] = [ $this->invoiceData[] = [
// 'sticker_master_id' => $record->sticker_master_id, 'sticker_master_id' => $record->sticker_master_id,
// 'serial_number' => $record->serial_number, 'serial_number' => $record->serial_number,
// 'motor_scanned_status' => $record->motor_scanned_status ?? '', 'motor_scanned_status' => $record->motor_scanned_status ?? '',
// 'pump_scanned_status' => $record->pump_scanned_status ?? '', 'pump_scanned_status' => $record->pump_scanned_status ?? '',
// 'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '', 'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
// 'scanned_status_set' => $record->scanned_status_set ?? '', 'scanned_status_set' => $record->scanned_status_set ?? '',
// 'scanned_status' => $record->scanned_status ?? '', 'scanned_status' => $record->scanned_status ?? '',
// 'panel_box_supplier' => $record->panel_box_supplier ?? '', 'panel_box_supplier' => $record->panel_box_supplier ?? '',
// 'panel_box_serial_number' => $record->panel_box_serial_number ?? '', 'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
// 'created_at' => $record->created_at, 'created_at' => $record->created_at,
// 'operator_id' => $record->operator_id, 'operator_id' => $record->operator_id,
// 'code' => $rowCode, 'code' => $rowCode,
// 'stickCount' => $stickCount, 'stickCount' => $stickCount,
// ]; ];
// } }
// if ($onCapFocus) { if ($onCapFocus) {
// $this->dispatch('focus-capacitor-input'); $this->dispatch('focus-capacitor-input');
// } else { } else {
// $this->dispatch('focus-serial-number'); $this->dispatch('focus-serial-number');
// } }
// } }
public function loadMaterialData($invoiceNumber, $plantId) public function loadMaterialData($invoiceNumber, $plantId)
@@ -592,20 +592,20 @@ class InvoiceDataTable extends Component
return; return;
} }
$this->package = InvoiceValidation::with('stickerMasterRelation') // $this->package = InvoiceValidation::with('stickerMasterRelation')
->where('invoice_number', $this->invoiceNumber) // ->where('invoice_number', $this->invoiceNumber)
->where('plant_id', $this->plantId) // ->where('plant_id', $this->plantId)
->whereNull('scanned_status') // ->whereNull('scanned_status')
->get(); // ->get();
foreach ($this->package as &$row) { foreach ($this->invoiceData as &$row) {
// if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) { if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
// if ($row->stickerMasterRelation?->item?->code == $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) { // // if ($row->stickerMasterRelation?->item?->code == $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
$stickerCode = $row->stickerMasterRelation?->item?->code ?? null; // $stickerCode = $row->stickerMasterRelation?->item?->code ?? null;
$serialNumber = $row->serial_number ?? null; // $serialNumber = $row->serial_number ?? null;
if ($stickerCode === $this->currentItemCode && $serialNumber === $this->currentSerialNumber) { // if ($stickerCode === $this->currentItemCode && $serialNumber === $this->currentSerialNumber) {
$row['panel_box_supplier'] = $supplier; $row['panel_box_supplier'] = $supplier;
$row['panel_box_item_code'] = $itemCode; $row['panel_box_item_code'] = $itemCode;
$row['panel_box_serial_number'] = $serialNumber; $row['panel_box_serial_number'] = $serialNumber;
@@ -706,18 +706,6 @@ class InvoiceDataTable extends Component
} }
break; break;
} }
else{
Notification::make()
->title('Panel Box Code')
->body("Panel Box Code not updated in db for Item Code: $this->currentItemCode and Serial Number: $this->currentSerialNumber")
->danger()
// ->duration(4000)
->seconds(2)
->send();
$this->capacitorInput = '';
return;
}
} }
$this->showCapacitorInput = false; $this->showCapacitorInput = false;
@@ -727,15 +715,15 @@ class InvoiceDataTable extends Component
$this->dispatch('focus-serial-number'); $this->dispatch('focus-serial-number');
} }
// public function render()
// {
// return view('livewire.invoice-data-table');
// }
public function render() public function render()
{ {
return view('livewire.invoice-data-table', [ return view('livewire.invoice-data-table');
'records' => $this->invoiceRecords,
]);
} }
// public function render()
// {
// return view('livewire.invoice-data-table', [
// 'records' => $this->invoiceRecords,
// ]);
// }
} }

View File

@@ -64,7 +64,7 @@
@endif @endif
{{-- Modal for serial invoice--}} {{-- Modal for serial invoice--}}
{{-- @if ($hasSearched) @if ($hasSearched)
<div class="overflow-x-auto overflow-y-visible" style="height: 385px;"> <div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
<table class="min-w-[1500px] text-sm text-center border border-gray-300"> <table class="min-w-[1500px] text-sm text-center border border-gray-300">
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300"> <table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
@@ -111,10 +111,10 @@
</tbody> </tbody>
</table> </table>
</div> </div>
@endif --}} @endif
@if ($hasSearched) {{-- @if ($hasSearched)
<div class="overflow-x-auto" style="height: 385px;"> <div class="overflow-x-auto" style="height: 385px;">
<table class="min-w-full text-sm text-center border border-gray-300"> <table class="min-w-full text-sm text-center border border-gray-300">
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300"> <table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
@@ -163,9 +163,8 @@
<div class="mt-3 flex justify-center"> <div class="mt-3 flex justify-center">
{{ $records->onEachSide(3)->links() }} {{ $records->onEachSide(3)->links() }}
</div> </div>
</div> </div> --}}
{{-- @endif --}}
@endif
{{-- Modal for Capacitor Input --}} {{-- Modal for Capacitor Input --}}
<div> <div>
@@ -199,10 +198,10 @@
</div> </div>
</div> </div>
{{-- Add this script to focus on the input --}} {{-- Add this script to focus on the input --}}
{{-- <script>
document.getElementById('capacitorInput').focus();
</script> --}}
<script> <script>
document.getElementById('capacitorInput').focus();
</script>
{{-- <script>
document.addEventListener('livewire:initialized', () => { document.addEventListener('livewire:initialized', () => {
@this.on('focus-capacitor-input', () => { @this.on('focus-capacitor-input', () => {
setTimeout(() => { setTimeout(() => {
@@ -211,7 +210,7 @@
}, 100); }, 100);
}); });
}); });
</script> </script> --}}
@endif @endif
</div> </div>