Improve error messages for clarity and consistency in InvoiceOutValidationResource
This commit is contained in:
@@ -394,12 +394,12 @@ class InvoiceOutValidationResource extends Resource
|
|||||||
$scannedBy = trim($row[4]);
|
$scannedBy = trim($row[4]);
|
||||||
|
|
||||||
if (empty($qrcode)) {
|
if (empty($qrcode)) {
|
||||||
throw new \Exception("Missing QR Code");
|
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
||||||
}
|
}
|
||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
if (!$plant) {
|
if (!$plant) {
|
||||||
throw new \Exception("Invalid plant code: {$plantCode}");
|
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$formattedDate = null;
|
$formattedDate = null;
|
||||||
@@ -416,7 +416,7 @@ class InvoiceOutValidationResource extends Resource
|
|||||||
->format('Y-m-d H:i:s');
|
->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception("Invalid date format: {$scannedAt}");
|
throw new \Exception("Invalid date format : '{$scannedAt}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,12 +456,11 @@ class InvoiceOutValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
$successCount++;
|
$successCount++;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$failedRecords[] = [
|
$failedRecords[] = [
|
||||||
'row' => $rowNumber,
|
'row' => $rowNumber,
|
||||||
'qrcode' => $qrcode ?? null,
|
'qrcode' => $qrcode ?? null,
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user