Merge branch '162-phase-2-changes' into 'master'

Add support for coolant and non-coolant overheat service #162

Closes #162

See merge request jankstudio/resq!186
This commit is contained in:
Kendrick Chan 2018-09-06 19:30:31 +00:00
commit e1365e7721
4 changed files with 54 additions and 9 deletions

View file

@ -409,6 +409,7 @@ class RAPIController extends Controller
'promo' => $promo_data, 'promo' => $promo_data,
// TODO: load the actual // TODO: load the actual
'has_warranty_doc' => false, 'has_warranty_doc' => false,
'flag_coolant' => $jo->hasCoolant(),
] ]
]; ];
} }
@ -778,6 +779,11 @@ class RAPIController extends Controller
if ($or_num != null) if ($or_num != null)
$jo->setORNum($or_num); $jo->setORNum($or_num);
// coolant
$flag_coolant = $req->request->get('flag_coolant', 0);
if ($flag_coolant)
$jo->setHasCoolant($flag_coolant);
// check battery id // check battery id
$batt_id = $req->request->get('batt_id', null); $batt_id = $req->request->get('batt_id', null);
// no battery // no battery
@ -810,6 +816,7 @@ class RAPIController extends Controller
$crit = new InvoiceCriteria(); $crit = new InvoiceCriteria();
$crit->setServiceType($stype_id); $crit->setServiceType($stype_id);
$crit->setCustomerVehicle($jo->getCustomerVehicle()); $crit->setCustomerVehicle($jo->getCustomerVehicle());
$crit->setHasCoolant($jo->hasCoolant());
if ($promo != null) if ($promo != null)
$crit->addPromo($promo); $crit->addPromo($promo);

View file

@ -243,6 +243,12 @@ class JobOrder
*/ */
protected $flag_rider_rating; protected $flag_rider_rating;
// only for overheat service, if it requires coolant or not
/**
* @ORM\Column(type="boolean")
*/
protected $flag_coolant;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -259,6 +265,7 @@ class JobOrder
$this->events = new ArrayCollection(); $this->events = new ArrayCollection();
$this->trade_in_type = null; $this->trade_in_type = null;
$this->flag_rider_rating = false; $this->flag_rider_rating = false;
$this->flag_coolant = false;
} }
public function getID() public function getID()
@ -707,4 +714,16 @@ class JobOrder
return $this->flag_rider_rating; return $this->flag_rider_rating;
} }
public function setHasCoolant($flag = true)
{
$this->flag_coolant = $flag;
return $this;
}
public function hasCoolant()
{
return $this->flag_coolant;
}
} }

View file

@ -11,6 +11,7 @@ class InvoiceCriteria
protected $stype; protected $stype;
protected $promos; protected $promos;
protected $cv; protected $cv;
protected $flag_coolant;
// entries are battery and trade-in combos // entries are battery and trade-in combos
protected $entries; protected $entries;
@ -21,6 +22,7 @@ class InvoiceCriteria
$this->promos = []; $this->promos = [];
$this->entries = []; $this->entries = [];
$this->cv = null; $this->cv = null;
$this->flag_coolant = false;
} }
public function setServiceType($stype) public function setServiceType($stype)
@ -112,4 +114,15 @@ class InvoiceCriteria
{ {
return $this->cv; return $this->cv;
} }
public function setHasCoolant($flag = true)
{
$this->flag_coolant = $flag;
return $this;
}
public function hasCoolant()
{
return $this->flag_coolant;
}
} }

View file

@ -271,7 +271,7 @@ class InvoiceCreator
$total['total_price'] = 200.00; $total['total_price'] = 200.00;
} }
public function processOverheat(&$total, $invoice, $cv) public function processOverheat(&$total, $invoice, $cv, $has_coolant)
{ {
// free if they have a motolite battery // free if they have a motolite battery
if ($cv->hasMotoliteBattery()) if ($cv->hasMotoliteBattery())
@ -286,14 +286,19 @@ class InvoiceCreator
->setPrice($fee); ->setPrice($fee);
$invoice->addItem($item); $invoice->addItem($item);
$coolant = new InvoiceItem(); $total_price = $fee;
$coolant->setInvoice($invoice)
->setTitle('4L Coolant')
->setQuantity(1)
->setPrice(1600);
$invoice->addItem($coolant);
$total_price = $fee + 1600; if ($has_coolant)
{
$coolant = new InvoiceItem();
$coolant->setInvoice($invoice)
->setTitle('4L Coolant')
->setQuantity(1)
->setPrice(1600);
$invoice->addItem($coolant);
$total_price += 1600;
}
$vat = round($total_price * self::VAT_RATE, 2); $vat = round($total_price * self::VAT_RATE, 2);
$total['total_price'] = $total_price; $total['total_price'] = $total_price;
@ -395,6 +400,7 @@ class InvoiceCreator
$stype = $criteria->getServiceType(); $stype = $criteria->getServiceType();
$cv = $criteria->getCustomerVehicle(); $cv = $criteria->getCustomerVehicle();
$has_coolant = $criteria->hasCoolant();
// error_log($stype); // error_log($stype);
switch ($stype) switch ($stype)
{ {
@ -427,7 +433,7 @@ class InvoiceCreator
// $this->processOtherServices($total, $invoice, $stype); // $this->processOtherServices($total, $invoice, $stype);
break; break;
case ServiceType::OVERHEAT_ASSISTANCE: case ServiceType::OVERHEAT_ASSISTANCE:
$this->processOverheat($total, $invoice, $cv); $this->processOverheat($total, $invoice, $cv, $has_coolant);
break; break;
case ServiceType::EMERGENCY_REFUEL: case ServiceType::EMERGENCY_REFUEL:
error_log('processing refuel'); error_log('processing refuel');