Add warranty creation when JO is fulfilled to ResqJobOrderHandler. #305
This commit is contained in:
parent
8727c227e4
commit
d569c666e3
1 changed files with 42 additions and 1 deletions
|
|
@ -38,6 +38,7 @@ use App\Ramcar\JORejectionReason;
|
||||||
|
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\JobOrderHandlerInterface;
|
use App\Service\JobOrderHandlerInterface;
|
||||||
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
|
|
@ -59,12 +60,14 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
protected $validator;
|
protected $validator;
|
||||||
protected $translator;
|
protected $translator;
|
||||||
protected $country_code;
|
protected $country_code;
|
||||||
|
protected $wh;
|
||||||
|
|
||||||
protected $template_hash;
|
protected $template_hash;
|
||||||
|
|
||||||
public function __construct(Security $security, EntityManagerInterface $em,
|
public function __construct(Security $security, EntityManagerInterface $em,
|
||||||
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
||||||
TranslatorInterface $translator, string $country_code)
|
TranslatorInterface $translator, string $country_code,
|
||||||
|
WarrantyHandler $wh)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -72,6 +75,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->country_code = $country_code;
|
$this->country_code = $country_code;
|
||||||
|
$this->wh = $wh;
|
||||||
|
|
||||||
$this->loadTemplates();
|
$this->loadTemplates();
|
||||||
}
|
}
|
||||||
|
|
@ -703,6 +707,43 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// create the warranty if new battery only
|
||||||
|
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 = $this->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue