Add warranty creation after job order fulfillment. #304
This commit is contained in:
parent
1ca2823d51
commit
00816b4226
2 changed files with 41 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ use App\Service\MapTools;
|
|||
use App\Service\HubCounter;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
use App\Service\WarrantyHandler;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
|
@ -1404,7 +1405,8 @@ class JobOrderController extends Controller
|
|||
->setWarrantyExpiration($warr_date);
|
||||
}
|
||||
|
||||
public function fulfillmentSubmit(Request $req, ValidatorInterface $validator, MQTTClient $mclient, $id)
|
||||
public function fulfillmentSubmit(Request $req, ValidatorInterface $validator,
|
||||
MQTTClient $mclient, $id, WarrantyHandler $wh)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1480,6 +1482,42 @@ class JobOrderController extends Controller
|
|||
// save to customer vehicle battery record
|
||||
$this->updateVehicleBattery($obj);
|
||||
|
||||
// create warranty
|
||||
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 = $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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
}
|
||||
|
||||
// validated! save the entity
|
||||
$em->flush();
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ class WarrantyHandler
|
|||
->setFirstName($first_name)
|
||||
->setLastName($last_name)
|
||||
->setMobileNumber($mobile_number)
|
||||
->setDatePurchase($date_purchase);
|
||||
->setDatePurchase($date_purchase)
|
||||
->setWarrantyClass($warranty_class);
|
||||
|
||||
$this->em->persist($warranty);
|
||||
$this->em->flush();
|
||||
|
|
|
|||
Loading…
Reference in a new issue