Refactor validation logic in CreateInvoiceValidation to include additional checks for package types (use pack_slip if tube_sticker does not exist) and streamline code structure
This commit is contained in:
@@ -1059,7 +1059,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$missPackCodes = $matchedItems
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->panel_box_code)) //filter invalid
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
@@ -2064,7 +2064,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$missPackCodes = $matchedItems
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->panel_box_code))
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code))
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
@@ -3077,6 +3077,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$hasPumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null;
|
||||
$hasCapacitorQr = $record->stickerMasterRelation->panel_box_code ?? null;
|
||||
|
||||
if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
|
||||
{
|
||||
$hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null;
|
||||
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
|
||||
$hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null;
|
||||
}
|
||||
|
||||
$hadMotorQr = $record->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $record->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
||||
@@ -3085,23 +3092,23 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Item Code')
|
||||
->body("Scanned 'Item Code' doesn't have valid package type to proceed!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
->title('Invalid: Item Code')
|
||||
->body("Scanned 'Item Code' doesn't have valid package type to proceed!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity'=> $scanSQuan,
|
||||
]);
|
||||
return;
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity'=> $scanSQuan,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($isMarkM) {
|
||||
|
||||
Reference in New Issue
Block a user