Merge branch '305-cmb-add-warranty-creation-when-jo-is-fulfilled-to-resqjoborderhandler' into '270-final-cmb-fixes'
Resolve "CMB - Add warranty creation when JO is fulfilled to ResqJobOrderHandler" See merge request jankstudio/resq!346
This commit is contained in:
commit
39adfe1958
2 changed files with 58 additions and 9 deletions
|
|
@ -164,22 +164,30 @@ services:
|
||||||
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
|
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
|
||||||
|
|
||||||
# job order generator
|
# job order generator
|
||||||
App\Service\JobOrderHandler\ResqJobOrderHandler:
|
#App\Service\JobOrderHandler\ResqJobOrderHandler:
|
||||||
|
# arguments:
|
||||||
|
# $country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
|
||||||
|
App\Service\JobOrderHandler\CMBJobOrderHandler:
|
||||||
arguments:
|
arguments:
|
||||||
$country_code: "%env(COUNTRY_CODE)%"
|
$country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
|
||||||
#job order generator interface
|
#job order generator interface
|
||||||
#App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
|
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
|
||||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
#App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
||||||
|
|
||||||
# customer generator
|
# customer generator
|
||||||
App\Service\CustomerHandler\ResqCustomerHandler:
|
App\Service\CustomerHandler\CMBCustomerHandler:
|
||||||
arguments:
|
arguments:
|
||||||
$country_code: "%env(COUNTRY_CODE)%"
|
$country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
|
||||||
|
#App\Service\CustomerHandler\ResqCustomerHandler:
|
||||||
|
# arguments:
|
||||||
|
# $country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
|
||||||
# customer generator interface
|
# customer generator interface
|
||||||
#App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\CMBCustomerHandler"
|
App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\CMBCustomerHandler"
|
||||||
App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\ResqCustomerHandler"
|
#App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\ResqCustomerHandler"
|
||||||
|
|
||||||
# rider assignment
|
# rider assignment
|
||||||
App\Service\RiderAssignmentHandler\CMBRiderAssignmentHandler: ~
|
App\Service\RiderAssignmentHandler\CMBRiderAssignmentHandler: ~
|
||||||
|
|
|
||||||
|
|
@ -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