diff --git a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php index cf96181d..fa416e27 100644 --- a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php @@ -30,6 +30,7 @@ use App\Entity\Promo; use App\Entity\Battery; use App\Entity\BatteryModel; use App\Entity\BatterySize; +use App\Entity\Warranty; use DateTime; @@ -537,25 +538,29 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface else $date_purchase = $jo->getDateFulfill(); - $plate_number = $this->wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber()); - - $batt_list = array(); - $invoice = $jo->getInvoice(); - if (!empty($invoice)) + // validate plate number + // $plate_number = $this->wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber()); + $plate_number = Warranty::cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber()); + if ($plate_number != false) { - // get battery - $invoice_items = $invoice->getItems(); - foreach ($invoice_items as $item) + $batt_list = array(); + $invoice = $jo->getInvoice(); + if (!empty($invoice)) { - $battery = $item->getBattery(); - if ($battery != null) + // get battery + $invoice_items = $invoice->getItems(); + foreach ($invoice_items as $item) { - $batt_list[] = $item->getBattery(); + $battery = $item->getBattery(); + if ($battery != null) + { + $batt_list[] = $item->getBattery(); + } } } - } - $this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class); + $this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class); + } } // send mqtt event (fulfilled)