Merge branch '162-phase-2-changes' into 'master'
Resolve "Phase 2 changes" Closes #162 See merge request jankstudio/resq!180
This commit is contained in:
commit
cc6c00ab02
3 changed files with 70 additions and 24 deletions
14
src/Ramcar/MobileOSType.php
Normal file
14
src/Ramcar/MobileOSType.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class MobileOSType extends NameValue
|
||||
{
|
||||
const ANDROID = 'ANDROID';
|
||||
const IOS = 'IOS';
|
||||
|
||||
const COLLECTION = [
|
||||
'IOS' => 'iOS',
|
||||
'ANDROID' => 'Android',
|
||||
];
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ namespace App\Service;
|
|||
|
||||
use Mosquitto\Client as MosquittoClient;
|
||||
use App\Entity\JobOrder;
|
||||
use App\Ramcar\MobileOSType;
|
||||
use Redis;
|
||||
|
||||
class APNSClient
|
||||
|
|
@ -43,6 +44,10 @@ class APNSClient
|
|||
|
||||
foreach ($sessions as $sess)
|
||||
{
|
||||
// check if mobile session is using an ios device
|
||||
if ($sess->getOSType() != MobileOSType::IOS)
|
||||
continue;
|
||||
|
||||
$push_id = $sess->getDevicePushID();
|
||||
if ($push_id != null && strlen(trim($push_id)) > 0)
|
||||
$this->push($push_id, $message);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use Doctrine\Common\Util\Debug;
|
|||
class InvoiceCreator
|
||||
{
|
||||
const VAT_RATE = 0.12;
|
||||
const SERVICE_FEE = 300;
|
||||
|
||||
// creates invoice based on the criteria sent
|
||||
public function __construct()
|
||||
|
|
@ -269,13 +270,19 @@ class InvoiceCreator
|
|||
$total['total_price'] = 200.00;
|
||||
}
|
||||
|
||||
public function processOverheat(&$total, $invoice)
|
||||
public function processOverheat(&$total, $invoice, $cv)
|
||||
{
|
||||
// free if they have a motolite battery
|
||||
if ($cv->hasMotoliteBattery())
|
||||
$fee = 0;
|
||||
else
|
||||
$fee = self::SERVICE_FEE;
|
||||
|
||||
$item = new InvoiceItem();
|
||||
$item->setInvoice($invoice)
|
||||
->setTitle('Service - Overheat Assitance')
|
||||
->setQuantity(1)
|
||||
->setPrice(200.00);
|
||||
->setPrice($fee);
|
||||
$invoice->addItem($item);
|
||||
|
||||
$coolant = new InvoiceItem();
|
||||
|
|
@ -285,39 +292,57 @@ class InvoiceCreator
|
|||
->setPrice(1600);
|
||||
$invoice->addItem($coolant);
|
||||
|
||||
$total['total_price'] = 1800;
|
||||
$total['vat_ex_price'] = 1584;
|
||||
$total['vat'] = 216;
|
||||
$total_price = $fee + 1600;
|
||||
|
||||
$vat = round($total_price * self::VAT_RATE, 2);
|
||||
$total['total_price'] = $total_price;
|
||||
$total['vat_ex_price'] = $total_price - $vat;
|
||||
$total['vat'] = $vat;
|
||||
}
|
||||
|
||||
public function processTireRepair(&$total, $invoice)
|
||||
public function processTireRepair(&$total, $invoice, $cv)
|
||||
{
|
||||
// free if they have a motolite battery
|
||||
if ($cv->hasMotoliteBattery())
|
||||
$fee = 0;
|
||||
else
|
||||
$fee = self::SERVICE_FEE;
|
||||
|
||||
$item = new InvoiceItem();
|
||||
$item->setInvoice($invoice)
|
||||
->setTitle('Service - Flat Tire')
|
||||
->setQuantity(1)
|
||||
->setPrice(200.00);
|
||||
->setPrice($fee);
|
||||
$invoice->addItem($item);
|
||||
$total_price = $fee;
|
||||
|
||||
$total['total_price'] = 200;
|
||||
$total['vat_ex_price'] = 176;
|
||||
$total['vat'] = 24;
|
||||
$vat = round($total_price * self::VAT_RATE, 2);
|
||||
$total['total_price'] = $total_price;
|
||||
$total['vat_ex_price'] = $total_price - $vat;
|
||||
$total['vat'] = $vat;
|
||||
}
|
||||
|
||||
public function processRefuel(&$total, $invoice, $ftype)
|
||||
public function processRefuel(&$total, $invoice, $cv)
|
||||
{
|
||||
// free if they have a motolite battery
|
||||
if ($cv->hasMotoliteBattery())
|
||||
$fee = 0;
|
||||
else
|
||||
$fee = self::SERVICE_FEE;
|
||||
|
||||
$ftype = $cv->getFuelType();
|
||||
$item = new InvoiceItem();
|
||||
|
||||
// service charge
|
||||
$item->setInvoice($invoice)
|
||||
->setTitle('Service - ' . ServiceType::getName(ServiceType::EMERGENCY_REFUEL))
|
||||
->setQuantity(1)
|
||||
->setPrice(200.00);
|
||||
->setPrice($fee);
|
||||
$invoice->addItem($item);
|
||||
$total['total_price'] = 200.00;
|
||||
$total_price = $fee;
|
||||
// $total['total_price'] = 200.00;
|
||||
|
||||
$fuel = new InvoiceItem();
|
||||
$sfee = new InvoiceItem();
|
||||
error_log('fuel type - ' . $ftype);
|
||||
switch ($ftype)
|
||||
{
|
||||
|
|
@ -327,30 +352,31 @@ class InvoiceCreator
|
|||
->setQuantity(1)
|
||||
->setPrice(240);
|
||||
$invoice->addItem($fuel);
|
||||
$total['total_price'] += 240.00;
|
||||
$total['vat'] = 52.80;
|
||||
$total['vat_ex_price'] = 387.20;
|
||||
$total_price += 240.00;
|
||||
break;
|
||||
case FuelType::DIESEL:
|
||||
$fuel->setInvoice($invoice)
|
||||
->setTitle('4L Fuel - Diesel')
|
||||
->setQuantity(1)
|
||||
->setPrice(200);
|
||||
$total['total_price'] += 200.00;
|
||||
$total['vat'] = 48.00;
|
||||
$total['vat_ex_price'] = 352.00;
|
||||
$total_price += 200.00;
|
||||
$invoice->addItem($fuel);
|
||||
break;
|
||||
default:
|
||||
// should never get to this point
|
||||
$fuel->setInvoice($invoice)
|
||||
->setTitle('Fuel - Unknown')
|
||||
->setQuantity(1)
|
||||
->setPrice(0);
|
||||
$total['total_price'] += 0.00;
|
||||
$total_price += 0.00;
|
||||
$invoice->addItem($fuel);
|
||||
break;
|
||||
}
|
||||
|
||||
$vat = round($total_price * self::VAT_RATE, 2);
|
||||
$total['total_price'] = $total_price;
|
||||
$total['vat_ex_price'] = $total_price - $vat;
|
||||
$total['vat'] = $vat;
|
||||
}
|
||||
|
||||
public function processCriteria(InvoiceCriteria $criteria)
|
||||
|
|
@ -367,6 +393,7 @@ class InvoiceCreator
|
|||
];
|
||||
|
||||
$stype = $criteria->getServiceType();
|
||||
$cv = $criteria->getCustomerVehicle();
|
||||
// error_log($stype);
|
||||
switch ($stype)
|
||||
{
|
||||
|
|
@ -395,16 +422,16 @@ class InvoiceCreator
|
|||
$this->processReplacement($total, $invoice);
|
||||
break;
|
||||
case ServiceType::TIRE_REPAIR:
|
||||
$this->processTireRepair($total, $invoice);
|
||||
$this->processTireRepair($total, $invoice, $cv);
|
||||
// $this->processOtherServices($total, $invoice, $stype);
|
||||
break;
|
||||
case ServiceType::OVERHEAT_ASSISTANCE:
|
||||
$this->processOverheat($total, $invoice);
|
||||
$this->processOverheat($total, $invoice, $cv);
|
||||
break;
|
||||
case ServiceType::EMERGENCY_REFUEL:
|
||||
error_log('processing refuel');
|
||||
$ftype = $criteria->getCustomerVehicle()->getFuelType();
|
||||
$this->processRefuel($total, $invoice, $ftype);
|
||||
$this->processRefuel($total, $invoice, $cv);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue