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

View file

@ -243,6 +243,12 @@ class JobOrder
*/
protected $flag_rider_rating;
// only for overheat service, if it requires coolant or not
/**
* @ORM\Column(type="boolean")
*/
protected $flag_coolant;
public function __construct()
{
$this->date_create = new DateTime();
@ -259,6 +265,7 @@ class JobOrder
$this->events = new ArrayCollection();
$this->trade_in_type = null;
$this->flag_rider_rating = false;
$this->flag_coolant = false;
}
public function getID()
@ -707,4 +714,16 @@ class JobOrder
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 $promos;
protected $cv;
protected $flag_coolant;
// entries are battery and trade-in combos
protected $entries;
@ -21,6 +22,7 @@ class InvoiceCriteria
$this->promos = [];
$this->entries = [];
$this->cv = null;
$this->flag_coolant = false;
}
public function setServiceType($stype)
@ -112,4 +114,15 @@ class InvoiceCriteria
{
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;
}
public function processOverheat(&$total, $invoice, $cv)
public function processOverheat(&$total, $invoice, $cv, $has_coolant)
{
// free if they have a motolite battery
if ($cv->hasMotoliteBattery())
@ -286,14 +286,19 @@ class InvoiceCreator
->setPrice($fee);
$invoice->addItem($item);
$coolant = new InvoiceItem();
$coolant->setInvoice($invoice)
->setTitle('4L Coolant')
->setQuantity(1)
->setPrice(1600);
$invoice->addItem($coolant);
$total_price = $fee;
$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);
$total['total_price'] = $total_price;
@ -395,6 +400,7 @@ class InvoiceCreator
$stype = $criteria->getServiceType();
$cv = $criteria->getCustomerVehicle();
$has_coolant = $criteria->hasCoolant();
// error_log($stype);
switch ($stype)
{
@ -427,7 +433,7 @@ class InvoiceCreator
// $this->processOtherServices($total, $invoice, $stype);
break;
case ServiceType::OVERHEAT_ASSISTANCE:
$this->processOverheat($total, $invoice, $cv);
$this->processOverheat($total, $invoice, $cv, $has_coolant);
break;
case ServiceType::EMERGENCY_REFUEL:
error_log('processing refuel');