Add support for coolant and non-coolant overheat service #162
This commit is contained in:
parent
69e96d5aec
commit
3ad32605fe
4 changed files with 54 additions and 9 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue