Add logging when creating warranty from command. #555

This commit is contained in:
Korina Cordero 2021-04-30 10:30:44 +00:00
parent e235667952
commit c0a877e398
2 changed files with 29 additions and 2 deletions

View file

@ -16,20 +16,25 @@ use App\Entity\JobOrder;
use App\Entity\Warranty;
use App\Entity\SAPBattery;
use App\Service\WarrantyAPILogger;
use App\Ramcar\ServiceType;
use App\Ramcar\WarrantyStatus;
use App\Ramcar\WarrantySource;
use DoctrineExtensions\Query\Mysql\DateFormat;
class GenerateWarrantyFromJobOrderCommand extends Command
{
protected $em;
protected $logger;
protected $sapbatt_hash;
protected $warranties_hash;
public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, WarrantyAPILogger $logger)
{
$this->em = $em;
$this->logger = $logger;
$this->loadSAPBatteries();
@ -209,7 +214,27 @@ class GenerateWarrantyFromJobOrderCommand extends Command
$sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,serial,warranty_class,plate_number,status,date_create,date_purchase,date_expire,date_claim,sap_bty_id,claim_id,first_name,last_name,mobile_number,flag_activated,warranty_privacy_policy) VALUES ' . $values . "\n";
echo $sql_statement;
echo $sql_statement;
$db = $this->em->getConnection();
$stmt = $db->prepare($sql_statement);
$stmt->execute();
// log warranty creation
$log_data = [
'battery_model_id' => $bty_model_id,
'battery_size_id' => $bty_size_id,
'warranty_class' => $warranty_class,
'plate_number' => $cleaned_plate_number,
'date_create' => $date_create,
'date_purchase' => $date_purchase,
'date_expire' => $date_expire,
'sap_code' => $sap_code,
'first_name' => $first_name,
'last_name' => $last_name,
'mobile_number' => $mobile_number,
];
$this->logger->logWarrantyInfo($log_data, '', 'internal', 'create', WarrantySource::COMMAND);
}
else

View file

@ -9,6 +9,7 @@ class WarrantySource extends NameValue
const ADMIN_PANEL = 'admin_panel';
const BULK_UPLOAD = 'bulk_upload';
const MOBILE = 'mobile';
const COMMAND = 'command';
const COLLECTION = [
'capi' => 'Third Party API',
@ -16,5 +17,6 @@ class WarrantySource extends NameValue
'admin_panel' => 'Admin Panel',
'bulk_upload' => 'Bulk Upload',
'mobile' => 'Mobile API',
'command' => 'Command',
];
}