Fix issues found during testing of warranty creation. #551
This commit is contained in:
parent
c97755cce0
commit
a13c364934
3 changed files with 19 additions and 8 deletions
|
|
@ -3013,14 +3013,14 @@ class APIController extends Controller implements LoggedController
|
||||||
// $cust = $this->updateCustomerInfo($req, $em);
|
// $cust = $this->updateCustomerInfo($req, $em);
|
||||||
|
|
||||||
// update warranty
|
// update warranty
|
||||||
$res = $this->updateWarranty($res, $em, $trans, $req, $serial, $inv_filename, $wcard_filename);
|
$res = $this->updateWarranty($res, $em, $trans, $req, $serial, $inv_filename, $wcard_filename, $rt);
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updateWarranty($res, $em, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null)
|
protected function updateWarranty($res, $em, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null, $rt)
|
||||||
{
|
{
|
||||||
// get serial
|
// get serial
|
||||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||||
|
|
@ -3052,7 +3052,7 @@ class APIController extends Controller implements LoggedController
|
||||||
if (!$is_customer_warranty)
|
if (!$is_customer_warranty)
|
||||||
{
|
{
|
||||||
$res->setError(true)
|
$res->setError(true)
|
||||||
->setErrorMessage('Warranty registred to a vehicle not in your list of vehicles.');
|
->setErrorMessage('Warranty registered to a vehicle not in your list of vehicles.');
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,11 @@ class CustomerWarrantyController extends APIController
|
||||||
}
|
}
|
||||||
|
|
||||||
$sku = $warr_serial->getSKU();
|
$sku = $warr_serial->getSKU();
|
||||||
$batt = $em->getRepository(SAPBattery::class)->find($sku);
|
// check if sku is null
|
||||||
|
$batt = null;
|
||||||
|
if ($sku != null)
|
||||||
|
$batt = $em->getRepository(SAPBattery::class)->find($sku);
|
||||||
|
|
||||||
// TODO: put this in a config file
|
// TODO: put this in a config file
|
||||||
$image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png';
|
$image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png';
|
||||||
if ($batt != null)
|
if ($batt != null)
|
||||||
|
|
@ -279,6 +283,8 @@ class CustomerWarrantyController extends APIController
|
||||||
{
|
{
|
||||||
error_log('HERE - register');
|
error_log('HERE - register');
|
||||||
// check required parameters
|
// check required parameters
|
||||||
|
// TODO: maybe add vmake_id? since warranty cannot be created with no vmake
|
||||||
|
// TODO: maye also add mobile and email since customer creation won't let mobile and email be null
|
||||||
$required_params = [
|
$required_params = [
|
||||||
'first_name',
|
'first_name',
|
||||||
'last_name',
|
'last_name',
|
||||||
|
|
@ -409,15 +415,19 @@ class CustomerWarrantyController extends APIController
|
||||||
// default date purchase to today
|
// default date purchase to today
|
||||||
// NOTE: might need to change this later
|
// NOTE: might need to change this later
|
||||||
$date_pur = new DateTime();
|
$date_pur = new DateTime();
|
||||||
|
$date_pur_cust = new DateTime();
|
||||||
|
|
||||||
// get date purchase specified by customer
|
// get date purchase specified by customer
|
||||||
$date_pur_cust = DateTime::createFromFormat('Y-m-d', $req->request->get('date_purchase'));
|
if (!empty($req->request->get('date_purchase')))
|
||||||
if (!$date_pur_cust)
|
|
||||||
{
|
{
|
||||||
return new APIResponse(false, 'Invalid date format for date of purchase.');
|
$date_pur_cust = DateTime::createFromFormat('Y-m-d', $req->request->get('date_purchase'));
|
||||||
|
if (!$date_pur_cust)
|
||||||
|
{
|
||||||
|
return new APIResponse(false, 'Invalid date format for date of purchase.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// chstomer check
|
// customer check
|
||||||
$priv_promo = $req->request->get('priv_promo', false);
|
$priv_promo = $req->request->get('priv_promo', false);
|
||||||
if ($cust == null)
|
if ($cust == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -646,6 +646,7 @@ class WarrantyController extends APIController
|
||||||
$w_last_name = $warranty->getLastName();
|
$w_last_name = $warranty->getLastName();
|
||||||
|
|
||||||
$new_cust = new Customer();
|
$new_cust = new Customer();
|
||||||
|
// TODO: add customer source
|
||||||
$new_cust->setFirstName($w_first_name)
|
$new_cust->setFirstName($w_first_name)
|
||||||
->setLastName($w_last_name)
|
->setLastName($w_last_name)
|
||||||
->setPhoneMobile($w_mobile_num);
|
->setPhoneMobile($w_mobile_num);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue