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 Mosquitto\Client as MosquittoClient;
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
|
use App\Ramcar\MobileOSType;
|
||||||
use Redis;
|
use Redis;
|
||||||
|
|
||||||
class APNSClient
|
class APNSClient
|
||||||
|
|
@ -43,6 +44,10 @@ class APNSClient
|
||||||
|
|
||||||
foreach ($sessions as $sess)
|
foreach ($sessions as $sess)
|
||||||
{
|
{
|
||||||
|
// check if mobile session is using an ios device
|
||||||
|
if ($sess->getOSType() != MobileOSType::IOS)
|
||||||
|
continue;
|
||||||
|
|
||||||
$push_id = $sess->getDevicePushID();
|
$push_id = $sess->getDevicePushID();
|
||||||
if ($push_id != null && strlen(trim($push_id)) > 0)
|
if ($push_id != null && strlen(trim($push_id)) > 0)
|
||||||
$this->push($push_id, $message);
|
$this->push($push_id, $message);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use Doctrine\Common\Util\Debug;
|
||||||
class InvoiceCreator
|
class InvoiceCreator
|
||||||
{
|
{
|
||||||
const VAT_RATE = 0.12;
|
const VAT_RATE = 0.12;
|
||||||
|
const SERVICE_FEE = 300;
|
||||||
|
|
||||||
// creates invoice based on the criteria sent
|
// creates invoice based on the criteria sent
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
|
@ -269,13 +270,19 @@ class InvoiceCreator
|
||||||
$total['total_price'] = 200.00;
|
$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 = new InvoiceItem();
|
||||||
$item->setInvoice($invoice)
|
$item->setInvoice($invoice)
|
||||||
->setTitle('Service - Overheat Assitance')
|
->setTitle('Service - Overheat Assitance')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(200.00);
|
->setPrice($fee);
|
||||||
$invoice->addItem($item);
|
$invoice->addItem($item);
|
||||||
|
|
||||||
$coolant = new InvoiceItem();
|
$coolant = new InvoiceItem();
|
||||||
|
|
@ -285,39 +292,57 @@ class InvoiceCreator
|
||||||
->setPrice(1600);
|
->setPrice(1600);
|
||||||
$invoice->addItem($coolant);
|
$invoice->addItem($coolant);
|
||||||
|
|
||||||
$total['total_price'] = 1800;
|
$total_price = $fee + 1600;
|
||||||
$total['vat_ex_price'] = 1584;
|
|
||||||
$total['vat'] = 216;
|
$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 = new InvoiceItem();
|
||||||
$item->setInvoice($invoice)
|
$item->setInvoice($invoice)
|
||||||
->setTitle('Service - Flat Tire')
|
->setTitle('Service - Flat Tire')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(200.00);
|
->setPrice($fee);
|
||||||
$invoice->addItem($item);
|
$invoice->addItem($item);
|
||||||
|
$total_price = $fee;
|
||||||
|
|
||||||
$total['total_price'] = 200;
|
$vat = round($total_price * self::VAT_RATE, 2);
|
||||||
$total['vat_ex_price'] = 176;
|
$total['total_price'] = $total_price;
|
||||||
$total['vat'] = 24;
|
$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();
|
$item = new InvoiceItem();
|
||||||
|
|
||||||
// service charge
|
// service charge
|
||||||
$item->setInvoice($invoice)
|
$item->setInvoice($invoice)
|
||||||
->setTitle('Service - ' . ServiceType::getName(ServiceType::EMERGENCY_REFUEL))
|
->setTitle('Service - ' . ServiceType::getName(ServiceType::EMERGENCY_REFUEL))
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(200.00);
|
->setPrice($fee);
|
||||||
$invoice->addItem($item);
|
$invoice->addItem($item);
|
||||||
$total['total_price'] = 200.00;
|
$total_price = $fee;
|
||||||
|
// $total['total_price'] = 200.00;
|
||||||
|
|
||||||
$fuel = new InvoiceItem();
|
$fuel = new InvoiceItem();
|
||||||
$sfee = new InvoiceItem();
|
|
||||||
error_log('fuel type - ' . $ftype);
|
error_log('fuel type - ' . $ftype);
|
||||||
switch ($ftype)
|
switch ($ftype)
|
||||||
{
|
{
|
||||||
|
|
@ -327,30 +352,31 @@ class InvoiceCreator
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(240);
|
->setPrice(240);
|
||||||
$invoice->addItem($fuel);
|
$invoice->addItem($fuel);
|
||||||
$total['total_price'] += 240.00;
|
$total_price += 240.00;
|
||||||
$total['vat'] = 52.80;
|
|
||||||
$total['vat_ex_price'] = 387.20;
|
|
||||||
break;
|
break;
|
||||||
case FuelType::DIESEL:
|
case FuelType::DIESEL:
|
||||||
$fuel->setInvoice($invoice)
|
$fuel->setInvoice($invoice)
|
||||||
->setTitle('4L Fuel - Diesel')
|
->setTitle('4L Fuel - Diesel')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(200);
|
->setPrice(200);
|
||||||
$total['total_price'] += 200.00;
|
$total_price += 200.00;
|
||||||
$total['vat'] = 48.00;
|
|
||||||
$total['vat_ex_price'] = 352.00;
|
|
||||||
$invoice->addItem($fuel);
|
$invoice->addItem($fuel);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
// should never get to this point
|
||||||
$fuel->setInvoice($invoice)
|
$fuel->setInvoice($invoice)
|
||||||
->setTitle('Fuel - Unknown')
|
->setTitle('Fuel - Unknown')
|
||||||
->setQuantity(1)
|
->setQuantity(1)
|
||||||
->setPrice(0);
|
->setPrice(0);
|
||||||
$total['total_price'] += 0.00;
|
$total_price += 0.00;
|
||||||
$invoice->addItem($fuel);
|
$invoice->addItem($fuel);
|
||||||
break;
|
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)
|
public function processCriteria(InvoiceCriteria $criteria)
|
||||||
|
|
@ -367,6 +393,7 @@ class InvoiceCreator
|
||||||
];
|
];
|
||||||
|
|
||||||
$stype = $criteria->getServiceType();
|
$stype = $criteria->getServiceType();
|
||||||
|
$cv = $criteria->getCustomerVehicle();
|
||||||
// error_log($stype);
|
// error_log($stype);
|
||||||
switch ($stype)
|
switch ($stype)
|
||||||
{
|
{
|
||||||
|
|
@ -395,16 +422,16 @@ class InvoiceCreator
|
||||||
$this->processReplacement($total, $invoice);
|
$this->processReplacement($total, $invoice);
|
||||||
break;
|
break;
|
||||||
case ServiceType::TIRE_REPAIR:
|
case ServiceType::TIRE_REPAIR:
|
||||||
$this->processTireRepair($total, $invoice);
|
$this->processTireRepair($total, $invoice, $cv);
|
||||||
// $this->processOtherServices($total, $invoice, $stype);
|
// $this->processOtherServices($total, $invoice, $stype);
|
||||||
break;
|
break;
|
||||||
case ServiceType::OVERHEAT_ASSISTANCE:
|
case ServiceType::OVERHEAT_ASSISTANCE:
|
||||||
$this->processOverheat($total, $invoice);
|
$this->processOverheat($total, $invoice, $cv);
|
||||||
break;
|
break;
|
||||||
case ServiceType::EMERGENCY_REFUEL:
|
case ServiceType::EMERGENCY_REFUEL:
|
||||||
error_log('processing refuel');
|
error_log('processing refuel');
|
||||||
$ftype = $criteria->getCustomerVehicle()->getFuelType();
|
$ftype = $criteria->getCustomerVehicle()->getFuelType();
|
||||||
$this->processRefuel($total, $invoice, $ftype);
|
$this->processRefuel($total, $invoice, $cv);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue