Add logging for warranty creation for rider API and JO fulfillment. #555
This commit is contained in:
parent
c1d54ec626
commit
e235667952
4 changed files with 42 additions and 5 deletions
|
|
@ -664,8 +664,12 @@ class WarrantyController extends Controller
|
|||
}
|
||||
|
||||
// error_log('Creating warranty for serial ' . $serial . ' and plate number ' . $plate_number);
|
||||
$user_id = $this->getUser()->getUsername();
|
||||
$source = WarrantySource::BULK_UPLOAD;
|
||||
|
||||
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class,
|
||||
$user_id, $source);
|
||||
|
||||
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ use App\Ramcar\CustomerNotWaitReason;
|
|||
use App\Ramcar\NoTradeInReason;
|
||||
use App\Ramcar\WillingToWaitContent;
|
||||
use App\Ramcar\HubCriteria;
|
||||
use App\Ramcar\WarrantySource;
|
||||
|
||||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
|
|
@ -1025,7 +1026,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
$user_id = $user->getUsername();
|
||||
$source = WarrantySource::ADMIN_PANEL;
|
||||
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class, $user_id, $source);
|
||||
}
|
||||
else
|
||||
error_log('Invalid plate number for warranty. Plate number = ' . $obj->getCustomerVehicle()->getPlateNumber());
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use App\Ramcar\JOEventType;
|
|||
use App\Ramcar\InvoiceStatus;
|
||||
use App\Ramcar\ModeOfPayment;
|
||||
use App\Ramcar\InvoiceCriteria;
|
||||
use App\Ramcar\WarrantySource;
|
||||
|
||||
use App\Service\RiderAPIHandlerInterface;
|
||||
use App\Service\RedisClientProvider;
|
||||
|
|
@ -598,7 +599,10 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
}
|
||||
}
|
||||
|
||||
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
// for riders, use rider session id
|
||||
$user_id = $this->session->getID();
|
||||
$source = WarrantySource::RAPI;
|
||||
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class, $user_id, $source);
|
||||
}
|
||||
|
||||
// send mqtt event (fulfilled)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ use App\Entity\SAPBattery;
|
|||
use App\Entity\BatteryModel;
|
||||
use App\Entity\CustomerVehicle;
|
||||
|
||||
use App\Service\WarrantyAPILogger;
|
||||
|
||||
use App\Ramcar\WarrantyClass;
|
||||
|
||||
use DateTime;
|
||||
|
|
@ -19,18 +21,23 @@ use DateInterval;
|
|||
class WarrantyHandler
|
||||
{
|
||||
protected $em;
|
||||
protected $logger;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
public function __construct(EntityManagerInterface $em, WarrantyAPILogger $logger)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number,
|
||||
$batt_list, DateTime $date_purchase, $warranty_class)
|
||||
$batt_list, DateTime $date_purchase, $warranty_class, $user_id, $source)
|
||||
{
|
||||
// new warranty
|
||||
$warranty = new Warranty();
|
||||
|
||||
$bmodel_name = '';
|
||||
$bsize_name ='';
|
||||
$sap_batt_id = '';
|
||||
foreach ($batt_list as $battery)
|
||||
{
|
||||
// get the battery model and battery size
|
||||
|
|
@ -43,10 +50,12 @@ class WarrantyHandler
|
|||
if ($bty_model != null)
|
||||
{
|
||||
$warranty->setBatteryModel($bty_model);
|
||||
$bmodel_name = $bty_model->getName();
|
||||
}
|
||||
if ($bty_size != null)
|
||||
{
|
||||
$warranty->setBatterySize($bty_size);
|
||||
$bsize_name = $bty_size->getName();
|
||||
}
|
||||
|
||||
$sap_code = $battery->getSAPCode();
|
||||
|
|
@ -57,6 +66,7 @@ class WarrantyHandler
|
|||
if ($sap_battery != null)
|
||||
{
|
||||
$warranty->setSAPBattery($sap_battery);
|
||||
$sap_batt_id = $sap_battery->getID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -87,6 +97,22 @@ class WarrantyHandler
|
|||
$this->em->persist($warranty);
|
||||
$this->em->flush();
|
||||
|
||||
// log warranty creation
|
||||
$action = 'create';
|
||||
$log_data = [
|
||||
'serial' => $serial,
|
||||
'warranty_class' => $warranty_class,
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'mobile_number' => $mobile_number,
|
||||
'date_purchase' => $date_purchase->format('d-M-y'),
|
||||
'date_expire' => $date_expire->format('d-M-y'),
|
||||
'battery_model' => $bmodel_name,
|
||||
'battery_size' => $bsize_name,
|
||||
'sap_battery' => $sap_batt_id,
|
||||
'plate_number' => $plate_number,
|
||||
];
|
||||
$this->logger->logWarrantyInfo($log_data, '', $user_id, $action, $source);
|
||||
// update customer vehicle with warranty info
|
||||
$this->updateCustomerVehicle($serial, $batt_list, $plate_number, $date_expire);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue