From 8e613a43b1d3f7831af7eae60759c2f16655b594 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 24 Jan 2020 06:22:12 +0000 Subject: [PATCH 1/2] 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 2/2] 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();