Merge branch '707-add-checking-for-warranty-serial-length' into 'master'

Resolve "Add checking for warranty serial length"

Closes #707

See merge request jankstudio/resq!823
This commit is contained in:
Kendrick Chan 2022-09-27 01:11:39 +00:00
commit c1ef75b8f5

View file

@ -23,7 +23,8 @@ use DateTime;
class LoadWarrantySerialCommand extends Command
{
const FIELD_COUNT = 7;
const FIELD_COUNT = 7;
const SERIAL_LENGTH = 20;
protected $em;
protected $upload_logger;
@ -277,8 +278,25 @@ class LoadWarrantySerialCommand extends Command
return $data;
}
// validate the date created
// check length of serial
$serial = trim($row[0]);
if (strlen($serial) > SELF::SERIAL_LENGTH)
{
// log
$error = 'Serial length too long';
$this->logLoadInfo($user_id, false, $serial, $error);
$data = [
'serial' => $serial,
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// validate the date created
$str_date_create = trim($row[3]);
$date_create = $this->convertDateCreate($str_date_create);