diff --git a/src/Command/CreateCustomerFromWarrantyCommand.php b/src/Command/CreateCustomerFromWarrantyCommand.php index e644fc06..91684217 100644 --- a/src/Command/CreateCustomerFromWarrantyCommand.php +++ b/src/Command/CreateCustomerFromWarrantyCommand.php @@ -313,17 +313,14 @@ class CreateCustomerFromWarrantyCommand extends Command protected function loadCustomers() { - error_log('starting query...'); // get all customers $customers = $this->em->getRepository(Customer::class)->findAll(); $cust_q = $this->em->createQuery('select c from App\Entity\Customer c'); $cust_iter = $q->iterate(); - error_log('looping through query...'); $this->cust_index = []; foreach ($cust_iter as $customer) { - error_log('here'); $mobile = trim($customer->getPhoneMobile()); if (!empty($mobile)) { diff --git a/src/Controller/HubController.php b/src/Controller/HubController.php index aeaaec7a..e1d41525 100644 --- a/src/Controller/HubController.php +++ b/src/Controller/HubController.php @@ -166,7 +166,7 @@ class HubController extends Controller { $this->denyAccessUnlessGranted('hub.add', null, 'No access.'); - error_log($req->request->get('time_open')); + //error_log($req->request->get('time_open')); // create new object $em = $this->getDoctrine()->getManager(); diff --git a/src/Controller/StaticContentController.php b/src/Controller/StaticContentController.php index 395736d4..44c77595 100644 --- a/src/Controller/StaticContentController.php +++ b/src/Controller/StaticContentController.php @@ -148,7 +148,6 @@ class StaticContentController extends Controller $result = $em->getRepository(StaticContent::class)->find($id); if ($result != null) { - error_log($id); $error_array['id'] = 'Duplicate ID exists.'; } @@ -226,7 +225,6 @@ class StaticContentController extends Controller $result = $em->getRepository(StaticContent::class)->find($id); if ($result != null) { - error_log($id); $error_array['id'] = 'Duplicate ID exists.'; } diff --git a/src/Controller/VehicleController.php b/src/Controller/VehicleController.php index 9fb93544..2df6ec74 100644 --- a/src/Controller/VehicleController.php +++ b/src/Controller/VehicleController.php @@ -243,7 +243,6 @@ class VehicleController extends Controller // get current batteries of vehicle to be updated $current_batteries = $row->getBatteries(); - error_log('count of current batteries ' . count($current_batteries)); // set and save values $row->setMake($req->request->get('make')) diff --git a/src/Controller/WarrantyController.php b/src/Controller/WarrantyController.php index 40afec1a..ae6da43f 100644 --- a/src/Controller/WarrantyController.php +++ b/src/Controller/WarrantyController.php @@ -567,7 +567,7 @@ class WarrantyController extends Controller { // call service to check if warranty details is incomplete and then update warranty // using details from csv file - error_log('Updating warranty for ' . $warr->getID()); + // error_log('Updating warranty for ' . $warr->getID()); $wh->updateWarranty($warr, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase); } } @@ -582,7 +582,7 @@ class WarrantyController extends Controller continue; } - error_log('Creating warranty for serial ' . $serial . ' and plate number ' . $plate_number); + // error_log('Creating warranty for serial ' . $serial . ' and plate number ' . $plate_number); $wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class); } diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index 72e196fe..c5e9c81c 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -594,7 +594,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface $diesel_price = self::REFUEL_FEE_DIESEL; $fuel = new InvoiceItem(); - error_log('fuel type - ' . $ftype); + //error_log('fuel type - ' . $ftype); switch ($ftype) { case FuelType::GAS: @@ -631,4 +631,77 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface $total['vat'] = $vat; } + public function processCriteria(InvoiceCriteria $criteria) + { + // initialize + $invoice = new Invoice(); + $total = [ + 'sell_price' => 0.0, + 'vat' => 0.0, + 'vat_ex_price' => 0.0, + 'ti_rate' => 0.0, + 'total_price' => 0.0, + 'discount' => 0.0, + ]; + + $stype = $criteria->getServiceType(); + $cv = $criteria->getCustomerVehicle(); + $has_coolant = $criteria->hasCoolant(); + // error_log($stype); + switch ($stype) + { + case ServiceType::JUMPSTART_TROUBLESHOOT: + $this->processJumpstart($total, $invoice); + break; + case ServiceType::JUMPSTART_WARRANTY: + $this->processJumpstartWarranty($total, $invoice); + + case ServiceType::BATTERY_REPLACEMENT_NEW: + $this->processEntries($total, $criteria, $invoice); + /* + $this->processBatteries($total, $criteria, $invoice); + $this->processTradeIns($total, $criteria, $invoice); + */ + $this->processDiscount($total, $criteria, $invoice); + break; + + case ServiceType::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); + // $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; + } + + // TODO: check if any promo is applied + // apply discounts + $promos = $criteria->getPromos(); + + $invoice->setTotalPrice($total['total_price']) + ->setVATExclusivePrice($total['vat_ex_price']) + ->setVAT($total['vat']) + ->setDiscount($total['discount']) + ->setTradeIn($total['ti_rate']); + + + // dump + //Debug::dump($invoice, 1); + + return $invoice; + } } diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php index 641658d7..281464bf 100644 --- a/src/Service/WarrantyHandler.php +++ b/src/Service/WarrantyHandler.php @@ -93,7 +93,7 @@ class WarrantyHandler public function updateCustomerVehicle($serial, $batteries, $plate_number, $date_expire) { // find customer vehicle using plate number - error_log('Finding customer vehicle with plate number ' . $plate_number); + // error_log('Finding customer vehicle with plate number ' . $plate_number); $cv_q = $this->em->createQuery('select count(cv) from App\Entity\CustomerVehicle cv where cv.plate_number = :plate_number') ->setParameter('plate_number', $plate_number); $cv_result = $cv_q->getSingleScalarResult(); @@ -288,7 +288,7 @@ class WarrantyHandler if (empty($warranty_class)) { - error_log('Warranty class is empty for warranty id ' . $warr->getID()); + //error_log('Warranty class is empty for warranty id ' . $warr->getID()); return null; } @@ -301,12 +301,12 @@ class WarrantyHandler { if ($batt_model == null) { - error_log('Battery model is null for warranty id ' . $warr->getID()); + //error_log('Battery model is null for warranty id ' . $warr->getID()); return null; } if ($batt_size == null) { - error_log('Battery size is null for warranty id ' . $warr->getID()); + //error_log('Battery size is null for warranty id ' . $warr->getID()); return null; }