Move warranty creation out of the RiderAPIHandler. #331

This commit is contained in:
Korina Cordero 2020-02-21 02:29:39 +00:00
parent 8a328bf441
commit 7dd9911e22
4 changed files with 8 additions and 24 deletions

View file

@ -24,7 +24,6 @@ use App\Entity\Hub;
use App\Entity\Promo; use App\Entity\Promo;
use App\Entity\Rider; use App\Entity\Rider;
use App\Entity\JORejection; use App\Entity\JORejection;
use App\Entity\Warranty;
use App\Entity\Customer; use App\Entity\Customer;
use App\Entity\ServiceCharge; use App\Entity\ServiceCharge;
@ -44,7 +43,6 @@ use App\Service\InvoiceGeneratorInterface;
use App\Service\JobOrderHandlerInterface; use App\Service\JobOrderHandlerInterface;
use App\Service\RiderAssignmentHandlerInterface; use App\Service\RiderAssignmentHandlerInterface;
use App\Service\CustomerHandlerInterface; use App\Service\CustomerHandlerInterface;
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;
@ -67,7 +65,6 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
protected $translator; protected $translator;
protected $rah; protected $rah;
protected $country_code; protected $country_code;
protected $wh;
protected $cust_handler; protected $cust_handler;
protected $template_hash; protected $template_hash;
@ -75,8 +72,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
public function __construct(Security $security, EntityManagerInterface $em, public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator, InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah, TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
string $country_code, WarrantyHandler $wh, string $country_code, CustomerHandlerInterface $cust_handler)
CustomerHandlerInterface $cust_handler)
{ {
$this->em = $em; $this->em = $em;
$this->ic = $ic; $this->ic = $ic;
@ -85,7 +81,6 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->translator = $translator; $this->translator = $translator;
$this->rah = $rah; $this->rah = $rah;
$this->country_code = $country_code; $this->country_code = $country_code;
$this->wh = $wh;
$this->cust_handler = $cust_handler; $this->cust_handler = $cust_handler;
$this->loadTemplates(); $this->loadTemplates();

View file

@ -23,7 +23,6 @@ use App\Entity\Hub;
use App\Entity\Promo; use App\Entity\Promo;
use App\Entity\Rider; use App\Entity\Rider;
use App\Entity\JORejection; use App\Entity\JORejection;
use App\Entity\Warranty;
use App\Entity\Customer; use App\Entity\Customer;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
@ -41,7 +40,6 @@ use App\Ramcar\JORejectionReason;
use App\Service\InvoiceGeneratorInterface; use App\Service\InvoiceGeneratorInterface;
use App\Service\JobOrderHandlerInterface; use App\Service\JobOrderHandlerInterface;
use App\Service\RiderAssignmentHandlerInterface; use App\Service\RiderAssignmentHandlerInterface;
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;
@ -64,14 +62,13 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
protected $translator; protected $translator;
protected $rah; protected $rah;
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, RiderAssignmentHandlerInterface $rah, TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
string $country_code, WarrantyHandler $wh) string $country_code)
{ {
$this->em = $em; $this->em = $em;
$this->ic = $ic; $this->ic = $ic;
@ -80,7 +77,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->translator = $translator; $this->translator = $translator;
$this->rah = $rah; $this->rah = $rah;
$this->country_code = $country_code; $this->country_code = $country_code;
$this->wh = $wh;
$this->loadTemplates(); $this->loadTemplates();
} }

View file

@ -18,7 +18,6 @@ use App\Service\RiderAPIHandlerInterface;
use App\Service\RedisClientProvider; use App\Service\RedisClientProvider;
use App\Service\RiderCache; use App\Service\RiderCache;
use App\Service\MQTTClient; use App\Service\MQTTClient;
use App\Service\WarrantyHandler;
use App\Service\JobOrderHandlerInterface; use App\Service\JobOrderHandlerInterface;
use App\Service\InvoiceGeneratorInterface; use App\Service\InvoiceGeneratorInterface;
@ -30,7 +29,6 @@ use App\Entity\Promo;
use App\Entity\Battery; use App\Entity\Battery;
use App\Entity\BatteryModel; use App\Entity\BatteryModel;
use App\Entity\BatterySize; use App\Entity\BatterySize;
use App\Entity\Warranty;
use DateTime; use DateTime;
@ -42,7 +40,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
protected $rcache; protected $rcache;
protected $country_code; protected $country_code;
protected $mclient; protected $mclient;
protected $wh;
protected $jo_handler; protected $jo_handler;
protected $ic; protected $ic;
protected $session; protected $session;
@ -50,8 +47,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis, public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
EncoderFactoryInterface $ef, RiderCache $rcache, EncoderFactoryInterface $ef, RiderCache $rcache,
string $country_code, MQTTClient $mclient, string $country_code, MQTTClient $mclient,
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler, JobOrderHandlerInterface $jo_handler, InvoiceGeneratorInterface $ic)
InvoiceGeneratorInterface $ic)
{ {
$this->em = $em; $this->em = $em;
$this->redis = $redis; $this->redis = $redis;
@ -59,7 +55,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->rcache = $rcache; $this->rcache = $rcache;
$this->country_code = $country_code; $this->country_code = $country_code;
$this->mclient = $mclient; $this->mclient = $mclient;
$this->wh = $wh;
$this->jo_handler = $jo_handler; $this->jo_handler = $jo_handler;
$this->ic = $ic; $this->ic = $ic;
@ -523,6 +518,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->em->flush(); $this->em->flush();
/*
// create warranty // create warranty
if($this->jo_handler->checkIfNewBattery($jo)) if($this->jo_handler->checkIfNewBattery($jo))
{ {
@ -561,7 +557,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$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) // send mqtt event (fulfilled)
$rider = $this->session->getRider(); $rider = $this->session->getRider();

View file

@ -18,7 +18,6 @@ use App\Service\RiderAPIHandlerInterface;
use App\Service\RedisClientProvider; use App\Service\RedisClientProvider;
use App\Service\RiderCache; use App\Service\RiderCache;
use App\Service\MQTTClient; use App\Service\MQTTClient;
use App\Service\WarrantyHandler;
use App\Service\JobOrderHandlerInterface; use App\Service\JobOrderHandlerInterface;
use App\Service\InvoiceGeneratorInterface; use App\Service\InvoiceGeneratorInterface;
@ -41,7 +40,6 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
protected $rcache; protected $rcache;
protected $country_code; protected $country_code;
protected $mclient; protected $mclient;
protected $wh;
protected $jo_handler; protected $jo_handler;
protected $ic; protected $ic;
protected $session; protected $session;
@ -49,8 +47,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis, public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
EncoderFactoryInterface $ef, RiderCache $rcache, EncoderFactoryInterface $ef, RiderCache $rcache,
string $country_code, MQTTClient $mclient, string $country_code, MQTTClient $mclient,
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler, JobOrderHandlerInterface $jo_handler, InvoiceGeneratorInterface $ic)
InvoiceGeneratorInterface $ic)
{ {
$this->em = $em; $this->em = $em;
$this->redis = $redis; $this->redis = $redis;
@ -58,7 +55,6 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
$this->rcache = $rcache; $this->rcache = $rcache;
$this->country_code = $country_code; $this->country_code = $country_code;
$this->mclient = $mclient; $this->mclient = $mclient;
$this->wh = $wh;
$this->jo_handler = $jo_handler; $this->jo_handler = $jo_handler;
$this->ic = $ic; $this->ic = $ic;
@ -522,6 +518,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
$this->em->flush(); $this->em->flush();
/*
// create warranty // create warranty
if($this->jo_handler->checkIfNewBattery($jo)) if($this->jo_handler->checkIfNewBattery($jo))
{ {
@ -556,7 +553,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
} }
$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) // send mqtt event (fulfilled)
$rider = $this->session->getRider(); $rider = $this->session->getRider();