Changeset View
Changeset View
Standalone View
Standalone View
src/app/PlanPackage.php
Show All 34 Lines | protected $casts = [ | ||||
'qty' => 'integer', | 'qty' => 'integer', | ||||
'qty_max' => 'integer', | 'qty_max' => 'integer', | ||||
'qty_min' => 'integer', | 'qty_min' => 'integer', | ||||
'discount_qty' => 'integer', | 'discount_qty' => 'integer', | ||||
'discount_rate' => 'integer' | 'discount_rate' => 'integer' | ||||
]; | ]; | ||||
/** | /** | ||||
* Calculate the costs for this plan. | * Calculate the costs for this package. | ||||
* | * | ||||
* @return integer | * @return int The costs in cents | ||||
*/ | */ | ||||
public function cost() | public function cost() | ||||
{ | { | ||||
$costs = 0; | $costs = 0; | ||||
// TODO: consider discount_qty/discount_rate here? | |||||
if ($this->qty_min > 0) { | if ($this->qty_min > 0) { | ||||
$costs += $this->package->cost() * $this->qty_min; | $costs += $this->package->cost() * $this->qty_min; | ||||
} elseif ($this->qty > 0) { | } elseif ($this->qty > 0) { | ||||
$costs += $this->package->cost() * $this->qty; | $costs += $this->package->cost() * $this->qty; | ||||
} | } | ||||
return $costs; | return $costs; | ||||
} | } | ||||
Show All 21 Lines |