Allow for same plate number update on register api call #540
This commit is contained in:
parent
b2fcec5462
commit
3bc4bb8db7
1 changed files with 13 additions and 1 deletions
|
|
@ -88,6 +88,11 @@ class CustomerWarrantyController extends APIController
|
||||||
return trim(strtoupper($serial));
|
return trim(strtoupper($serial));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function cleanPlateNumber($plate_num)
|
||||||
|
{
|
||||||
|
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
||||||
|
}
|
||||||
|
|
||||||
public function check($serial, EntityManagerInterface $em, Request $req)
|
public function check($serial, EntityManagerInterface $em, Request $req)
|
||||||
{
|
{
|
||||||
// check required parameters
|
// check required parameters
|
||||||
|
|
@ -303,6 +308,8 @@ class CustomerWarrantyController extends APIController
|
||||||
|
|
||||||
protected function updateWarranty($em, $req, $serial, $inv_filename = null, $wcard_filename = null)
|
protected function updateWarranty($em, $req, $serial, $inv_filename = null, $wcard_filename = null)
|
||||||
{
|
{
|
||||||
|
$plate_num = $this->cleanPlateNumber($req->request->get('plate_num'));
|
||||||
|
|
||||||
error_log('warranty serial check');
|
error_log('warranty serial check');
|
||||||
// get serial
|
// get serial
|
||||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||||
|
|
@ -317,7 +324,12 @@ class CustomerWarrantyController extends APIController
|
||||||
// skip warranty if it already exists
|
// skip warranty if it already exists
|
||||||
if ($warr != null)
|
if ($warr != null)
|
||||||
{
|
{
|
||||||
return new APIResponse(false, 'Warranty registred to a vehicle not in your list of vehicles.');
|
$warr_plate_num = $this->cleanPlateNumber($warr->getPlateNumber());
|
||||||
|
|
||||||
|
if ($plate_num != $warr_plate_num)
|
||||||
|
{
|
||||||
|
return new APIResponse(false, 'Plate number does not match vehicle registered to warranty.');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// check if warranty is registered to a serial owned by customer
|
// check if warranty is registered to a serial owned by customer
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue