From c6b31569a61fa0e1d6a1bd3e663ccd0f3b3f06e3 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Sun, 13 Oct 2019 09:49:09 +0000 Subject: [PATCH] Create service types for CMB. #270 --- src/Ramcar/CMBServiceType.php | 16 ++++++ .../InvoiceGenerator/CMBInvoiceGenerator.php | 54 +++++++++---------- .../JobOrderHandler/CMBJobOrderHandler.php | 28 +++------- 3 files changed, 49 insertions(+), 49 deletions(-) create mode 100644 src/Ramcar/CMBServiceType.php diff --git a/src/Ramcar/CMBServiceType.php b/src/Ramcar/CMBServiceType.php new file mode 100644 index 00000000..63d18f96 --- /dev/null +++ b/src/Ramcar/CMBServiceType.php @@ -0,0 +1,16 @@ + 'Battery Sales', + 'battery_warranty' => 'Under Warranty', + 'jumpstart' => 'Jumpstart', + ]; +} diff --git a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php index 48d6011c..92950ff4 100644 --- a/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/CMBInvoiceGenerator.php @@ -11,7 +11,7 @@ use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceStatus; use App\Ramcar\CMBTradeInType; use App\Ramcar\DiscountApply; -use App\Ramcar\ServiceType; +use App\Ramcar\CMBServiceType; use App\Ramcar\FuelType; use App\Entity\Invoice; @@ -68,13 +68,13 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface $has_coolant = $criteria->hasCoolant(); switch ($stype) { - case ServiceType::JUMPSTART_TROUBLESHOOT: + case CMBServiceType::JUMPSTART: $this->processJumpstart($total, $invoice); break; - case ServiceType::JUMPSTART_WARRANTY: - $this->processJumpstartWarranty($total, $invoice); + //case ServiceType::JUMPSTART_WARRANTY: + // $this->processJumpstartWarranty($total, $invoice); - case ServiceType::BATTERY_REPLACEMENT_NEW: + case CMBServiceType::BATTERY_REPLACEMENT_NEW: $this->processEntries($total, $criteria, $invoice); /* $this->processBatteries($total, $criteria, $invoice); @@ -83,27 +83,27 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface $this->processDiscount($total, $criteria, $invoice); break; - case ServiceType::BATTERY_REPLACEMENT_WARRANTY: + case CMBServiceType::BATTERY_REPLACEMENT_WARRANTY: $this->processWarranty($total, $criteria, $invoice); break; - case ServiceType::POST_RECHARGED: - $this->processRecharge($total, $invoice); - break; - case ServiceType::POST_REPLACEMENT: - $this->processReplacement($total, $invoice); - break; - case ServiceType::TIRE_REPAIR: - $this->processTireRepair($total, $invoice, $cv); + //case ServiceType::POST_RECHARGED: + // $this->processRecharge($total, $invoice); + // break; + //case ServiceType::POST_REPLACEMENT: + // $this->processReplacement($total, $invoice); + // break; + //case ServiceType::TIRE_REPAIR: + // $this->processTireRepair($total, $invoice, $cv); // $this->processOtherServices($total, $invoice, $stype); - break; - case ServiceType::OVERHEAT_ASSISTANCE: - $this->processOverheat($total, $invoice, $cv, $has_coolant); - break; - case ServiceType::EMERGENCY_REFUEL: - error_log('processing refuel'); - $ftype = $criteria->getCustomerVehicle()->getFuelType(); - $this->processRefuel($total, $invoice, $cv); - break; + // break; + //case ServiceType::OVERHEAT_ASSISTANCE: + // $this->processOverheat($total, $invoice, $cv, $has_coolant); + // break; + //case ServiceType::EMERGENCY_REFUEL: + // error_log('processing refuel'); + // $ftype = $criteria->getCustomerVehicle()->getFuelType(); + // $this->processRefuel($total, $invoice, $cv); + // break; } // TODO: check if any promo is applied @@ -229,7 +229,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface // return error if there's a problem, false otherwise // check service type $stype = $criteria->getServiceType(); - if ($stype != ServiceType::BATTERY_REPLACEMENT_NEW) + if ($stype != CMBServiceType::BATTERY_REPLACEMENT_NEW) return null; @@ -252,7 +252,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface { // check service type $stype = $criteria->getServiceType(); - if ($stype != ServiceType::BATTERY_REPLACEMENT_NEW && $stype != ServiceType::BATTERY_REPLACEMENT_WARRANTY) + if ($stype != CMBServiceType::BATTERY_REPLACEMENT_NEW && $stype != CMBServiceType::BATTERY_REPLACEMENT_WARRANTY) return null; // return error if there's a problem, false otherwise @@ -500,7 +500,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface { $item = new InvoiceItem(); $item->setInvoice($invoice) - ->setTitle('Service - ' . ServiceType::getName($stype)) + ->setTitle('Service - ' . CMBServiceType::getName($stype)) ->setQuantity(1) ->setPrice(self::OTHER_SERVICES_FEE); $invoice->addItem($item); @@ -581,7 +581,7 @@ class CMBInvoiceGenerator implements InvoiceGeneratorInterface // service charge $item->setInvoice($invoice) - ->setTitle('Service - ' . ServiceType::getName(ServiceType::EMERGENCY_REFUEL)) + ->setTitle('Service - ' . CMBServiceType::getName(CMBServiceType::EMERGENCY_REFUEL)) ->setQuantity(1) ->setPrice($fee); $invoice->addItem($item); diff --git a/src/Service/JobOrderHandler/CMBJobOrderHandler.php b/src/Service/JobOrderHandler/CMBJobOrderHandler.php index cab5c489..73e75d84 100644 --- a/src/Service/JobOrderHandler/CMBJobOrderHandler.php +++ b/src/Service/JobOrderHandler/CMBJobOrderHandler.php @@ -25,7 +25,7 @@ use App\Entity\Rider; use App\Entity\JORejection; use App\Ramcar\InvoiceCriteria; -use App\Ramcar\ServiceType; +use App\Ramcar\CMBServiceType; use App\Ramcar\CMBTradeInType; use App\Ramcar\JOEventType; use App\Ramcar\JOStatus; @@ -145,7 +145,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $obj_rows = $query_obj->getResult(); $statuses = JOStatus::getCollection(); - $service_types = ServiceType::getCollection(); + $service_types = CMBServiceType::getCollection(); // process rows $rows = []; @@ -243,7 +243,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $job_orders = []; foreach ($obj_rows as $jo) { - $service_type = ServiceType::getName($jo[0]->getServiceType()); + $service_type = CMBServiceType::getName($jo[0]->getServiceType()); $job_orders[] = [ 'id' => $jo[0]->getID(), @@ -1866,7 +1866,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // insert invoice footer details $pdf->Cell($label_width, $line_height, 'Transaction Type:'); - $pdf->MultiCell($val_width, $line_height, ServiceType::getName($obj->getServiceType()), 0, 'L'); + $pdf->MultiCell($val_width, $line_height, CMBServiceType::getName($obj->getServiceType()), 0, 'L'); // get Y after left cell $y1 = $pdf->GetY(); @@ -1964,24 +1964,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $fac_hubs[$hub->getID()] = $hub->getName() . ' - ' . $hub->getBranch(); } - // get the first two service types for POC - $scount = 1; - $selected_stypes = []; - $stypes = ServiceType::getCollection(); - - foreach ($stypes as $key => $data) - { - if ($scount < 2) - $selected_stypes[$key] = $data; - else - break; - - $scount++; - } - // name values - //$params['service_types'] = ServiceType::getCollection(); - $params['service_types'] = $selected_stypes; + $params['service_types'] = CMBServiceType::getCollection(); $params['warranty_classes'] = WarrantyClass::getCollection(); $params['modes_of_payment'] = ModeOfPayment::getCollection(); $params['statuses'] = JOStatus::getCollection(); @@ -2129,7 +2113,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface protected function updateVehicleBattery(JobOrder $jo) { // check if new battery - if ($jo->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW) + if ($jo->getServiceType() != CMBServiceType::BATTERY_REPLACEMENT_NEW) return; // customer vehicle