156 lines
3 KiB
PHP
156 lines
3 KiB
PHP
<?php
|
|
|
|
namespace App\Ramcar;
|
|
|
|
use App\Entity\Battery;
|
|
use App\Entity\Promo;
|
|
use App\Entity\CustomerVehicle;
|
|
use App\Entity\ServiceCharge;
|
|
|
|
class InvoiceCriteria
|
|
{
|
|
protected $stype;
|
|
protected $promos;
|
|
protected $cv;
|
|
protected $flag_coolant;
|
|
protected $discount;
|
|
protected $service_charges;
|
|
|
|
// entries are battery and trade-in combos
|
|
protected $entries;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->stype = 0;
|
|
$this->promos = [];
|
|
$this->entries = [];
|
|
$this->cv = null;
|
|
$this->flag_coolant = false;
|
|
$this->discount = 0;
|
|
$this->service_charges = [];
|
|
}
|
|
|
|
public function setServiceType($stype)
|
|
{
|
|
// TODO: validate service type
|
|
$this->stype = $stype;
|
|
return $this;
|
|
}
|
|
|
|
public function getServiceType()
|
|
{
|
|
return $this->stype;
|
|
}
|
|
|
|
/*
|
|
public function addBattery(Battery $battery, $qty = 1)
|
|
{
|
|
for ($i = 0; $i < $qty; $i++)
|
|
$this->batteries[] = $battery;
|
|
return $this;
|
|
}
|
|
|
|
public function getBatteries()
|
|
{
|
|
return $this->batteries;
|
|
}
|
|
*/
|
|
|
|
public function addPromo(Promo $promo)
|
|
{
|
|
$this->promos[] = $promo;
|
|
return $this;
|
|
}
|
|
|
|
public function getPromos()
|
|
{
|
|
return $this->promos;
|
|
}
|
|
|
|
/*
|
|
public function addTradeIn($is_motolite, $qty = 1)
|
|
{
|
|
// NOTE: this asumes that all the rates for trade-ins are standardized
|
|
// for motolite and non-motolite trade-ins
|
|
|
|
for ($i = 0; $i < $qty; $i++)
|
|
{
|
|
if ($is_motolite)
|
|
$trade_in = 'motolite';
|
|
else
|
|
$trade_in = 'other';
|
|
|
|
$this->trade_ins[] = $trade_in;
|
|
}
|
|
return $this;
|
|
}
|
|
|
|
public function getTradeIns()
|
|
{
|
|
return $this->trade_ins;
|
|
}
|
|
*/
|
|
|
|
public function addEntry($battery, $trade_in, $qty)
|
|
{
|
|
// trade_in is null if no trade_in specified
|
|
|
|
$entry = [
|
|
'battery' => $battery,
|
|
'trade_in' => $trade_in,
|
|
'qty' => $qty
|
|
];
|
|
|
|
$this->entries[] = $entry;
|
|
}
|
|
|
|
public function getEntries()
|
|
{
|
|
return $this->entries;
|
|
}
|
|
|
|
public function setCustomerVehicle(CustomerVehicle $cv = null)
|
|
{
|
|
$this->cv = $cv;
|
|
return $this;
|
|
}
|
|
|
|
public function getCustomerVehicle()
|
|
{
|
|
return $this->cv;
|
|
}
|
|
|
|
public function setHasCoolant($flag = true)
|
|
{
|
|
$this->flag_coolant = $flag;
|
|
return $this;
|
|
}
|
|
|
|
public function hasCoolant()
|
|
{
|
|
return $this->flag_coolant;
|
|
}
|
|
|
|
public function setDiscount($discount)
|
|
{
|
|
$this->discount = $discount;
|
|
return $this;
|
|
}
|
|
|
|
public function getDiscount()
|
|
{
|
|
return $this->discount;
|
|
}
|
|
|
|
public function addServiceCharge(ServiceCharge $service_charge)
|
|
{
|
|
$this->service_charges[] = $service_charge;
|
|
return $this;
|
|
}
|
|
|
|
public function getServiceCharges()
|
|
{
|
|
return $this->service_charges;
|
|
}
|
|
|
|
}
|