Return warranty information with customer vehicle information. #227

This commit is contained in:
Korina Cordero 2019-07-02 07:17:38 +00:00
parent 60cab330b3
commit 1573ec0aa4

View file

@ -38,6 +38,7 @@ use App\Entity\Promo;
use App\Entity\Battery;
use App\Entity\RiderRating;
use App\Entity\JOEvent;
use App\Entity\Warranty;
use DateTime;
use Exception;
@ -673,6 +674,56 @@ class APIController extends Controller
if ($cv->getWarrantyExpiration() != null)
$wty_ex = $cv->getWarrantyExpiration()->format('Y-m-d');
// NOTE: Modify the search for the latest warranty
// get latest warranty using plate number
$warranty_results = $em->getRepository(Warranty::class)->findBy(['plate_number' => $cv->getPlateNumber()],
['date_create' => 'desc']);
$warranty = current($warranty_results);
// check for null values for battery and date claim and date expire
$batt_model = '';
$batt_size = '';
$sap_batt = '';
$claim_date = '';
$expiry_date = '';
if (!(is_null($warranty->getBatteryModel()))) {
$batt_model = $warranty->getBatteryModel()->getName();
}
if (!(is_null($warranty->getBatterySize()))) {
$batt_size = $warranty->getBattyerSize()->getName();
}
if (!(is_null($warranty->getSAPBattery()))) {
$sap_batt = $warranty->getSAPBattery()->getID();
}
if (!(is_null($warranty->getDateClaim()))) {
$claim_date = $warranty->getDateClaim()->format("d M Y g:i A");
}
if (!(is_null($warranty->getDateExpire()))) {
$expiry_date = $warranty->getDateExpire()->format("d M Y g:i A");
}
$warr[] = [
'id' => $warranty->getID(),
'serial' => $warranty->getSerial(),
'warranty_class' => $warranty->getWarrantyClass(),
'plate_number' => $warranty->getPlateNumber(),
'first_name' => $warranty->getFirstName(),
'last_name' => $warranty->getLastName(),
'mobile_number' => $warranty->getMobileNumber(),
'battery_model' => $batt_model,
'battery_size' => $batt_size,
'sap_battery' => $sap_batt,
'status' => $warranty->getStatus(),
'date_create' => $warranty->getDateCreate()->format("d M Y g:i A"),
'date_purchase' => $warranty->getDatePurchase()->format("d M Y g:i A"),
'date_expire' => $expiry_date,
'date_claim' => $claim_date,
'claim_from' => $warranty->getClaimedFrom(),
'is_activated' => $warranty->isActivated() ? 1 : 0,
];
$cv_list[] = [
'cv_id' => $cv->getID(),
'mfg_id' => $cv->getVehicle()->getManufacturer()->getID(),
@ -688,6 +739,7 @@ class APIController extends Controller
'curr_batt_id' => $battery_id,
'is_motolite' => $cv->hasMotoliteBattery() ? 1 : 0,
'is_active' => $cv->isActive() ? 1 : 0,
'warranty' => $warr,
];
}
@ -735,6 +787,7 @@ class APIController extends Controller
$batts = $vehicle->getBatteries();
foreach ($batts as $batt)
{
// TODO: Add warranty_tnv to battery information
$batt_list[] = [
'id' => $batt->getID(),
'mfg_id' => $batt->getManufacturer()->getID(),
@ -1645,6 +1698,9 @@ class APIController extends Controller
'plate_number' => $cv->getPlateNumber(),
];
// TODO: mogol get warranty object for the plate number. Return only
// latest warranty.
// rider
$rider = $jo->getRider();
if ($rider != null)
@ -1802,4 +1858,7 @@ class APIController extends Controller
return $res->getReturnResponse();
}
// TODO mogol add public function activateWarranty that takes in
// a plate number. Search for the latest warranty with the plate number
}