From 00816b4226ebfe25d4a0a63f9a08283dc07a0730 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 21 Jan 2020 08:14:05 +0000 Subject: [PATCH 1/6] Add warranty creation after job order fulfillment. #304 --- src/Controller/JobOrderController.php | 40 ++++++++++++++++++++++++++- src/Service/WarrantyHandler.php | 3 +- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index 8e9c7d46..d38b7e9c 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -32,6 +32,7 @@ use App\Service\MapTools; use App\Service\HubCounter; use App\Service\MQTTClient; use App\Service\APNSClient; +use App\Service\WarrantyHandler; use Doctrine\ORM\Query; use Doctrine\DBAL\Connection; @@ -1404,7 +1405,8 @@ class JobOrderController extends Controller ->setWarrantyExpiration($warr_date); } - public function fulfillmentSubmit(Request $req, ValidatorInterface $validator, MQTTClient $mclient, $id) + public function fulfillmentSubmit(Request $req, ValidatorInterface $validator, + MQTTClient $mclient, $id, WarrantyHandler $wh) { $this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.'); @@ -1480,6 +1482,42 @@ class JobOrderController extends Controller // save to customer vehicle battery record $this->updateVehicleBattery($obj); + // create warranty + if ($obj->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW) + { + $serial = null; + $warranty_class = $obj->getWarrantyClass(); + $first_name = $obj->getCustomer()->getFirstName(); + $last_name = $obj->getCustomer()->getLastName(); + $mobile_number = $obj->getCustomer()->getPhoneMobile(); + + // check if date fulfilled is null + if ($obj->getDateFulfill() == null) + $date_purchase = $obj->getDateCreate(); + else + $date_purchase = $obj->getDateFulfill(); + + $plate_number = $wh->cleanPlateNumber($obj->getCustomerVehicle()->getPlateNumber()); + + $batt_list = array(); + $invoice = $obj->getInvoice(); + if (!empty($invoice)) + { + // get battery + $invoice_items = $invoice->getItems(); + foreach ($invoice_items as $item) + { + $battery = $item->getBattery(); + if ($battery != null) + { + $batt_list[] = $item->getBattery(); + } + } + } + + $wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class); + } + // validated! save the entity $em->flush(); diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php index bfc30021..641658d7 100644 --- a/src/Service/WarrantyHandler.php +++ b/src/Service/WarrantyHandler.php @@ -78,7 +78,8 @@ class WarrantyHandler ->setFirstName($first_name) ->setLastName($last_name) ->setMobileNumber($mobile_number) - ->setDatePurchase($date_purchase); + ->setDatePurchase($date_purchase) + ->setWarrantyClass($warranty_class); $this->em->persist($warranty); $this->em->flush(); From fb2d716721302f92bfd47a190c583fb142fe9386 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 21 Jan 2020 08:38:52 +0000 Subject: [PATCH 2/6] Add update of customer vehicle and warranty creation after rider sets JO to fulfilled. #304 --- src/Controller/RAPIController.php | 95 ++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/src/Controller/RAPIController.php b/src/Controller/RAPIController.php index ddd66d5e..a1d709a6 100644 --- a/src/Controller/RAPIController.php +++ b/src/Controller/RAPIController.php @@ -27,6 +27,7 @@ use App\Ramcar\JOEventType; use App\Service\InvoiceCreator; use App\Service\MQTTClient; +use App\Service\WarrantyHandler; use App\Entity\RiderSession; use App\Entity\Customer; @@ -590,7 +591,7 @@ class RAPIController extends Controller return $res->getReturnResponse(); } - public function payment(Request $req, MQTTClient $mclient) + public function payment(Request $req, MQTTClient $mclient, WarrantyHandler $wh) { $em = $this->getDoctrine()->getManager(); $required_params = ['jo_id']; @@ -618,6 +619,46 @@ class RAPIController extends Controller // TODO: tag rider as unavailable + // save to customer vehicle battery record + // TODO: this has to move to JOHandler + $this->updateVehicleBattery($obj); + + // create warranty + if ($obj->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW) + { + $serial = null; + $warranty_class = $obj->getWarrantyClass(); + $first_name = $obj->getCustomer()->getFirstName(); + $last_name = $obj->getCustomer()->getLastName(); + $mobile_number = $obj->getCustomer()->getPhoneMobile(); + + // check if date fulfilled is null + if ($obj->getDateFulfill() == null) + $date_purchase = $obj->getDateCreate(); + else + $date_purchase = $obj->getDateFulfill(); + + $plate_number = $wh->cleanPlateNumber($obj->getCustomerVehicle()->getPlateNumber()); + + $batt_list = array(); + $invoice = $obj->getInvoice(); + if (!empty($invoice)) + { + // get battery + $invoice_items = $invoice->getItems(); + foreach ($invoice_items as $item) + { + $battery = $item->getBattery(); + if ($battery != null) + { + $batt_list[] = $item->getBattery(); + } + } + } + + $wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class); + } + $em->flush(); // send mqtt event (fulfilled) @@ -868,4 +909,56 @@ class RAPIController extends Controller return $res->getReturnResponse(); } + + protected function updateVehicleBattery(JobOrder $jo) + { + // check if new battery + if ($jo->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW) + return; + + // customer vehicle + $cv = $jo->getCustomerVehicle(); + if ($cv == null) + return; + + // invoice + $invoice = $jo->getInvoice(); + if ($invoice == null) + return; + + // invoice items + $items = $invoice->getItems(); + if (count($items) <= 0) + return; + + // get first battery from invoice + $battery = null; + foreach ($items as $item) + { + $battery = $item->getBattery(); + if ($battery != null) + break; + } + + // no battery in order + if ($battery == null) + return; + + // warranty expiration + $warr = $jo->getWarrantyClass(); + if ($warr == WarrantyClass::WTY_PRIVATE) + $warr_months = $battery->getWarrantyPrivate(); + else if ($warr == WarrantyClass::WTY_COMMERCIAL) + $warr_months = $battery->getWarrantyCommercial(); + else if ($warr == WarrantyClass::WTY_TNV) + $warr_months = 12; + + $warr_date = new DateTime(); + $warr_date->add(new DateInterval('P' . $warr_months . 'M')); + + // update customer vehicle battery + $cv->setCurrentBattery($battery) + ->setHasMotoliteBattery(true) + ->setWarrantyExpiration($warr_date); + } } From 69f0612a2d96427c8f9a429b68286ae9cd29fca9 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 24 Jan 2020 04:05:48 +0000 Subject: [PATCH 3/6] Replace hardcoded country code prefixes with variables set in .env and messages files. #309 --- config/services.yaml | 1 + src/Controller/CustomerController.php | 5 ++++- src/Controller/JobOrderController.php | 11 +++++++---- src/Entity/Customer.php | 8 ++++---- templates/customer/form.html.twig | 10 +++++----- templates/job-order/form.html.twig | 8 ++++---- templates/job-order/form.pdf.html.twig | 4 ++-- templates/search/legacyjo_details.html.twig | 6 +++--- templates/ticket/form.html.twig | 2 +- templates/warranty/form.html.twig | 2 +- translations/messages.en.yaml | 1 + translations/resq.messages.en.yaml | 1 + 12 files changed, 34 insertions(+), 25 deletions(-) diff --git a/config/services.yaml b/config/services.yaml index b62024ce..c8916c9b 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -11,6 +11,7 @@ parameters: app_acl_file: 'acl.yaml' app_access_key: 'access_keys' cvu_brand_id: "%env(CVU_BRAND_ID)%" + country_code: "%env(COUNTRY_CODE)%" services: # default configuration for services in *this* file diff --git a/src/Controller/CustomerController.php b/src/Controller/CustomerController.php index d03d735a..1f3849ad 100644 --- a/src/Controller/CustomerController.php +++ b/src/Controller/CustomerController.php @@ -584,11 +584,14 @@ class CustomerController extends Controller // build vehicles array $vehicles = []; + // get country code from services.yaml + $country_code = $this->getParameter('country_code'); + foreach ($obj_rows as $cv) { $cust = $cv->getCustomer(); $vehicles[] = [ 'id' => $cv->getID(), - 'text' => $cv->getPlateNumber() . ' ' . $cust->getFirstName() . ' ' . $cust->getLastName() . ' (+63' . $cust->getPhoneMobile() . ')', + 'text' => $cv->getPlateNumber() . ' ' . $cust->getFirstName() . ' ' . $cust->getLastName() . ' (' . $country_code . $cust->getPhoneMobile() . ')', ]; } diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index d38b7e9c..2036ffe0 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -1977,6 +1977,9 @@ class JobOrderController extends Controller $translated_title = $translator->trans('jo_title_pdf'); $translated_logo = $translator->trans('image_jo_pdf'); + // get the country code from services.yaml + $country_code = $this->getParameter('country_code'); + // generate the pdf $pdf = new FPDF('P', 'mm', 'letter'); $pdf->AddPage(); @@ -2029,7 +2032,7 @@ class JobOrderController extends Controller $pdf->SetXY($col2_x, $y); $pdf->Cell($label_width, $line_height, 'Mobile Phone:'); - $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? '+63' . $customer->getPhoneMobile() : '', 0, 'L'); + $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneMobile() ? $country_code . $customer->getPhoneMobile() : '', 0, 'L'); // get Y after right cell $y2 = $pdf->GetY(); @@ -2046,7 +2049,7 @@ class JobOrderController extends Controller $pdf->SetXY($col2_x, $y); $pdf->Cell($label_width, $line_height, 'Landline:'); - $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? '+63' . $customer->getPhoneLandline() : '', 0, 'L'); + $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneLandline() ? $country_code . $customer->getPhoneLandline() : '', 0, 'L'); // get Y after right cell $y2 = $pdf->GetY(); @@ -2056,11 +2059,11 @@ class JobOrderController extends Controller $pdf->SetXY($col2_x, $y); $pdf->Cell($label_width, $line_height, 'Office Phone:'); - $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? '+63' . $customer->getPhoneOffice() : '', 0, 'L'); + $pdf->MultiCell(0, $line_height, $customer && $customer->getPhoneOffice() ? $country_code . $customer->getPhoneOffice() : '', 0, 'L'); $pdf->SetX($col2_x); $pdf->Cell($label_width, $line_height, 'Fax:'); - $pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? '+63' . $customer->getPhoneFax() : '', 0, 'L'); + $pdf->MultiCell($val_width, $line_height, $customer && $customer->getPhoneFax() ? $country_code . $customer->getPhoneFax() : '', 0, 'L'); // insert vehicle info $cv = $obj->getCustomerVehicle(); diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 880f0213..d9dd9b98 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -258,16 +258,16 @@ class Customer $phones = []; if (!empty($this->phone_mobile)) - $phones[] = '+63' . $this->phone_mobile; + $phones[] = $this->phone_mobile; if (!empty($this->phone_landline)) - $phones[] = '+63' . $this->phone_landline; + $phones[] = $this->phone_landline; if (!empty($this->phone_office)) - $phones[] = '+63' . $this->phone_office; + $phones[] = $this->phone_office; if (!empty($this->phone_fax)) - $phones[] = '+63' . $this->phone_fax; + $phones[] = $this->phone_fax; return $phones; } diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 58d35568..af85fd94 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -131,7 +131,7 @@ Mobile Phone
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -141,7 +141,7 @@ Landline
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -153,7 +153,7 @@ Office Phone
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -163,7 +163,7 @@ Fax
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -600,7 +600,7 @@ // input mask $("#mobile-number").inputmask("mask", { - mask: "639999999999", + mask: "{% trans %}country_code_prefix{% endtrans %}9999999999", placeholder: "" }); diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index 1d3e0275..1914dfe9 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -110,7 +110,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -118,7 +118,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -128,7 +128,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -136,7 +136,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/templates/job-order/form.pdf.html.twig b/templates/job-order/form.pdf.html.twig index 9944a44c..5499f1fb 100644 --- a/templates/job-order/form.pdf.html.twig +++ b/templates/job-order/form.pdf.html.twig @@ -89,7 +89,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -97,7 +97,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/templates/search/legacyjo_details.html.twig b/templates/search/legacyjo_details.html.twig index 15b3ea94..bb9d51d6 100644 --- a/templates/search/legacyjo_details.html.twig +++ b/templates/search/legacyjo_details.html.twig @@ -53,7 +53,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -61,7 +61,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -71,7 +71,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/templates/ticket/form.html.twig b/templates/ticket/form.html.twig index 1666c59d..84328ab8 100644 --- a/templates/ticket/form.html.twig +++ b/templates/ticket/form.html.twig @@ -71,7 +71,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/templates/warranty/form.html.twig b/templates/warranty/form.html.twig index d99470cb..4af98004 100644 --- a/templates/warranty/form.html.twig +++ b/templates/warranty/form.html.twig @@ -86,7 +86,7 @@ Mobile Phone
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 2ee4305a..a495b2d4 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -10,6 +10,7 @@ battery_size_tradein_premium: Trade-in Premium battery_size_tradein_other: Trade-in Other add_cust_vehicle_battery_info: This vehicle is using a Motolite battery jo_title_pdf: Motolite Res-Q Job Order +country_code_prefix: '+63' # # images image_logo_login: /assets/images/logo-resq.png diff --git a/translations/resq.messages.en.yaml b/translations/resq.messages.en.yaml index babf41d2..966b6fd9 100644 --- a/translations/resq.messages.en.yaml +++ b/translations/resq.messages.en.yaml @@ -10,6 +10,7 @@ battery_size_tradein_premium: Trade-in Premium battery_size_tradein_other: Trade-in Other add_cust_vehicle_battery_info: This vehicle is using a Motolite battery jo_title_pdf: Motolite Res-Q Job Order +country_code_prefix: '+63' # images image_logo_login: /assets/images/logo-resq.png From 8e613a43b1d3f7831af7eae60759c2f16655b594 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 24 Jan 2020 06:22:12 +0000 Subject: [PATCH 4/6] Bug fixes from merge. Remove hardcoded country code prefixes from onestep form. #309 --- .env.dist | 2 ++ src/Controller/RAPIController.php | 6 +----- templates/job-order/cmb.form.onestep.html.twig | 8 ++++---- templates/job-order/form.onestep.html.twig | 8 ++++---- translations/messages.en.yaml | 5 ----- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.env.dist b/.env.dist index a9fe4b6a..b0392b88 100644 --- a/.env.dist +++ b/.env.dist @@ -28,6 +28,8 @@ RT_SHORTCODE=1234 MQTT_IP_ADDRESS=localhost MQTT_PORT=8883 MQTT_CERT=/location/of/cert/file.crt +MQTT_WS_HOST=insertiphere +MQTT_WS_PORT=8083 # redis client REDIS_CLIENT_SCHEME=tcp diff --git a/src/Controller/RAPIController.php b/src/Controller/RAPIController.php index e1949091..abbc833b 100644 --- a/src/Controller/RAPIController.php +++ b/src/Controller/RAPIController.php @@ -931,7 +931,6 @@ class RAPIController extends Controller return $res->getReturnResponse(); } -<<<<<<< HEAD protected function updateVehicleBattery(JobOrder $jo) { // check if new battery @@ -983,7 +982,7 @@ class RAPIController extends Controller ->setHasMotoliteBattery(true) ->setWarrantyExpiration($warr_date); } -======= + protected function createWarranty($jo) { $em = $this->getDoctrine()->getManager(); @@ -1057,7 +1056,4 @@ class RAPIController extends Controller $expire_date->add(new DateInterval('P'.$warranty_period.'M')); return $expire_date; } - - ->>>>>>> 0297d66dd56b2b01db9c618c32e2367223048a56 } diff --git a/templates/job-order/cmb.form.onestep.html.twig b/templates/job-order/cmb.form.onestep.html.twig index 7bdcc8bb..1b043791 100644 --- a/templates/job-order/cmb.form.onestep.html.twig +++ b/templates/job-order/cmb.form.onestep.html.twig @@ -96,7 +96,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -104,7 +104,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -114,7 +114,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -122,7 +122,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/templates/job-order/form.onestep.html.twig b/templates/job-order/form.onestep.html.twig index c9e14254..f7a60b1f 100644 --- a/templates/job-order/form.onestep.html.twig +++ b/templates/job-order/form.onestep.html.twig @@ -94,7 +94,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -102,7 +102,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -112,7 +112,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
@@ -120,7 +120,7 @@
- +63 + {% trans %}country_code_prefix{% endtrans %}
diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 827eb65b..04ebdc42 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -9,14 +9,9 @@ battery_size_tradein_brand: Trade-in Motolite battery_size_tradein_premium: Trade-in Premium battery_size_tradein_other: Trade-in Other add_cust_vehicle_battery_info: This vehicle is using a Motolite battery -<<<<<<< HEAD -jo_title_pdf: Motolite Res-Q Job Order -country_code_prefix: '+63' -======= jo_title_pdf: Res-Q for CMB Job Order country_code_prefix: '+60' delivery_instructions_label: 'Delivery Instructions - CarFix Job Order No.' ->>>>>>> 0297d66dd56b2b01db9c618c32e2367223048a56 # images image_logo_login: /assets/images/black-text-logo-01.png From c9185e6139d56c4015d5402351bcbe5e69402c72 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 24 Jan 2020 08:48:16 +0000 Subject: [PATCH 5/6] Bug fixes for RAPIController. #309 --- src/Controller/RAPIController.php | 45 ++++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Controller/RAPIController.php b/src/Controller/RAPIController.php index abbc833b..51033004 100644 --- a/src/Controller/RAPIController.php +++ b/src/Controller/RAPIController.php @@ -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(); From 3eb7c2c42693b91bbc0a1eac34e0fbca672c2f7e Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Sat, 25 Jan 2020 01:31:18 +0000 Subject: [PATCH 6/6] Update RAPIController.php --- src/Controller/RAPIController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controller/RAPIController.php b/src/Controller/RAPIController.php index 51033004..2e16f58d 100644 --- a/src/Controller/RAPIController.php +++ b/src/Controller/RAPIController.php @@ -934,7 +934,8 @@ class RAPIController extends Controller protected function updateVehicleBattery(JobOrder $jo) { // check if new battery - if ($jo->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW) + if (($jo->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW) || + ($jo->getServiceType() != CMBServiceType::BATTERY_REPLACEMENT_NEW)) return; // customer vehicle