Updated warning message to display unique codes only
This commit is contained in:
@@ -376,7 +376,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
$invalidMatCodes = [];
|
$invalidMatCodes = [];
|
||||||
$invalidSerialCodes=[];
|
$invalidSerialCodes = [];
|
||||||
$materialCodes = [];
|
$materialCodes = [];
|
||||||
$missingSerials = [];
|
$missingSerials = [];
|
||||||
$duplicateSerials = [];
|
$duplicateSerials = [];
|
||||||
@@ -806,6 +806,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
if (count($invalidCodes) > 10)
|
if (count($invalidCodes) > 10)
|
||||||
{
|
{
|
||||||
|
$invalidCodes = array_unique($invalidCodes);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid item codes found')
|
->title('Invalid item codes found')
|
||||||
->body('' . count($invalidCodes) . 'invalid item codes found have serial number.')
|
->body('' . count($invalidCodes) . 'invalid item codes found have serial number.')
|
||||||
@@ -819,6 +820,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
else if(count($invalidCodes) > 0)
|
else if(count($invalidCodes) > 0)
|
||||||
{
|
{
|
||||||
|
$invalidCodes = array_unique($invalidCodes);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid item codes found')
|
->title('Invalid item codes found')
|
||||||
->body('Serial invoice Item Codes found : ' . implode(', ', $invalidCodes))
|
->body('Serial invoice Item Codes found : ' . implode(', ', $invalidCodes))
|
||||||
@@ -881,6 +883,10 @@ class InvoiceValidationResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$nonNumericQtyCodes = array_unique($nonNumericQtyCodes);
|
||||||
|
$zeroQtyCodes = array_unique($zeroQtyCodes);
|
||||||
|
$notDivisibleCodes = array_unique($notDivisibleCodes);
|
||||||
|
|
||||||
$showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
|
$showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
|
||||||
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
|
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
|
||||||
$showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
|
$showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
|
||||||
@@ -964,74 +970,73 @@ class InvoiceValidationResource extends Resource
|
|||||||
->placeholder(placeholder: 'Select To DateTime')
|
->placeholder(placeholder: 'Select To DateTime')
|
||||||
->reactive()
|
->reactive()
|
||||||
->native(false),
|
->native(false),
|
||||||
])
|
])
|
||||||
->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['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
|
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
|
|
||||||
$query->where('plant_id', $data['Plant']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['invoice_number'])) {
|
|
||||||
$query->where('invoice_number', 'like', '%' . $data['invoice_number'] . '%');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['serial_number'])) {
|
|
||||||
$query->where('serial_number', 'like', '%' . $data['serial_number'] . '%');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['created_from'])) {
|
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
|
||||||
$query->where('created_at', '<=', $data['created_to']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['sticker_master_id'])) {
|
|
||||||
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
|
|
||||||
->pluck('id')
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
if (!empty($stickerMasterIds)) {
|
|
||||||
$query->whereIn('sticker_master_id', $stickerMasterIds);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
->indicateUsing(function (array $data) {
|
|
||||||
$indicators = [];
|
|
||||||
|
|
||||||
if (!empty($data['Plant'])) {
|
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
|
||||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
$query->where('plant_id', $data['Plant']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['invoice_number'])) {
|
if (!empty($data['invoice_number'])) {
|
||||||
$indicators[] = 'Invoice Number: ' . $data['invoice_number'];
|
$query->where('invoice_number', 'like', '%' . $data['invoice_number'] . '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['serial_number'])) {
|
if (!empty($data['serial_number'])) {
|
||||||
$indicators[] = 'Serial Number: ' . $data['serial_number'];
|
$query->where('serial_number', 'like', '%' . $data['serial_number'] . '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_from'])) {
|
if (!empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: ' . $data['created_from'];
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
if (!empty($data['created_to'])) {
|
||||||
$indicators[] = 'To: ' . $data['created_to'];
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['sticker_master_id'])) {
|
if (!empty($data['sticker_master_id'])) {
|
||||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
|
||||||
$indicators[] = 'Item Code: ' . $itemCode;
|
->pluck('id')
|
||||||
}
|
->toArray();
|
||||||
|
|
||||||
return $indicators;
|
if (!empty($stickerMasterIds)) {
|
||||||
})
|
$query->whereIn('sticker_master_id', $stickerMasterIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->indicateUsing(function (array $data) {
|
||||||
|
$indicators = [];
|
||||||
|
|
||||||
|
if (!empty($data['Plant'])) {
|
||||||
|
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['invoice_number'])) {
|
||||||
|
$indicators[] = 'Invoice Number: ' . $data['invoice_number'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['serial_number'])) {
|
||||||
|
$indicators[] = 'Serial Number: ' . $data['serial_number'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['created_from'])) {
|
||||||
|
$indicators[] = 'From: ' . $data['created_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['created_to'])) {
|
||||||
|
$indicators[] = 'To: ' . $data['created_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['sticker_master_id'])) {
|
||||||
|
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||||
|
$indicators[] = 'Item Code: ' . $itemCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indicators;
|
||||||
|
})
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
|
|||||||
Reference in New Issue
Block a user