Bug fixes for RAPIController. #309
This commit is contained in:
parent
8e613a43b1
commit
c9185e6139
1 changed files with 23 additions and 22 deletions
|
|
@ -17,10 +17,12 @@ use App\Ramcar\APIResult;
|
|||
use App\Ramcar\JOStatus;
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\CMBServiceType;
|
||||
use App\Ramcar\ServiceType;
|
||||
use App\Ramcar\WarrantyClass;
|
||||
use App\Ramcar\APIRiderStatus;
|
||||
use App\Ramcar\TransactionOrigin;
|
||||
use App\Ramcar\CMBTradeInType;
|
||||
use App\Ramcar\TradeInType;
|
||||
use App\Ramcar\InvoiceStatus;
|
||||
use App\Ramcar\ModeOfPayment;
|
||||
use App\Ramcar\JOEventType;
|
||||
|
|
@ -50,6 +52,7 @@ use DateTime;
|
|||
use DateInterval;
|
||||
|
||||
// Rider API controller
|
||||
// TODO: Need to refactor this into a service
|
||||
class RAPIController extends Controller
|
||||
{
|
||||
protected $session;
|
||||
|
|
@ -637,27 +640,30 @@ class RAPIController extends Controller
|
|||
|
||||
// save to customer vehicle battery record
|
||||
// TODO: this has to move to JOHandler
|
||||
$this->updateVehicleBattery($obj);
|
||||
$this->updateVehicleBattery($jo);
|
||||
|
||||
// create warranty
|
||||
if ($obj->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
|
||||
$em->flush();
|
||||
|
||||
// create warranty
|
||||
if (($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW) ||
|
||||
($jo->getServiceType() == CMBServiceType::BATTERY_REPLACEMENT_NEW))
|
||||
{
|
||||
$serial = null;
|
||||
$warranty_class = $obj->getWarrantyClass();
|
||||
$first_name = $obj->getCustomer()->getFirstName();
|
||||
$last_name = $obj->getCustomer()->getLastName();
|
||||
$mobile_number = $obj->getCustomer()->getPhoneMobile();
|
||||
$warranty_class = $jo->getWarrantyClass();
|
||||
$first_name = $jo->getCustomer()->getFirstName();
|
||||
$last_name = $jo->getCustomer()->getLastName();
|
||||
$mobile_number = $jo->getCustomer()->getPhoneMobile();
|
||||
|
||||
// check if date fulfilled is null
|
||||
if ($obj->getDateFulfill() == null)
|
||||
$date_purchase = $obj->getDateCreate();
|
||||
if ($jo->getDateFulfill() == null)
|
||||
$date_purchase = $jo->getDateCreate();
|
||||
else
|
||||
$date_purchase = $obj->getDateFulfill();
|
||||
$date_purchase = $jo->getDateFulfill();
|
||||
|
||||
$plate_number = $wh->cleanPlateNumber($obj->getCustomerVehicle()->getPlateNumber());
|
||||
$plate_number = $wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
||||
|
||||
$batt_list = array();
|
||||
$invoice = $obj->getInvoice();
|
||||
$invoice = $jo->getInvoice();
|
||||
if (!empty($invoice))
|
||||
{
|
||||
// get battery
|
||||
|
|
@ -675,8 +681,6 @@ class RAPIController extends Controller
|
|||
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
// send mqtt event (fulfilled)
|
||||
$rider = $this->session->getRider();
|
||||
$image_url = $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/assets/images/user.gif';
|
||||
|
|
@ -691,12 +695,6 @@ class RAPIController extends Controller
|
|||
];
|
||||
$mclient->sendEvent($jo, $payload);
|
||||
|
||||
// create the warranty if new battery only
|
||||
if ($jo->getServiceType () == CMBServiceType::BATTERY_REPLACEMENT_NEW)
|
||||
{
|
||||
$this->createWarranty($jo);
|
||||
}
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
|
|
@ -815,7 +813,8 @@ class RAPIController extends Controller
|
|||
|
||||
// check service type
|
||||
$stype_id = $req->request->get('stype_id');
|
||||
if (!CMBServiceType::validate($stype_id))
|
||||
if ((!CMBServiceType::validate($stype_id)) ||
|
||||
(!ServiceType::validate($stype_id)))
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid service type - ' . $stype_id);
|
||||
|
|
@ -877,7 +876,8 @@ class RAPIController extends Controller
|
|||
|
||||
// check trade in
|
||||
$trade_in = $req->request->get('trade_in');
|
||||
if (!CMBTradeInType::validate($trade_in))
|
||||
if ((!CMBTradeInType::validate($trade_in)) ||
|
||||
(!TradeInType::validate($trade_in)))
|
||||
$trade_in = null;
|
||||
|
||||
// check mode of payment
|
||||
|
|
@ -966,6 +966,7 @@ class RAPIController extends Controller
|
|||
return;
|
||||
|
||||
// warranty expiration
|
||||
$warr_months = 0;
|
||||
$warr = $jo->getWarrantyClass();
|
||||
if ($warr == WarrantyClass::WTY_PRIVATE)
|
||||
$warr_months = $battery->getWarrantyPrivate();
|
||||
|
|
|
|||
Loading…
Reference in a new issue