priceType = $priceType; return $this; } /** * Get priceType * * @return integer */ public function getPriceType() { return $this->priceType; } /** * Set available * * @param integer $available * * @return TravelPeriodPrice */ public function setAvailable($available) { $this->available = $available; return $this; } /** * Get available * * @return integer */ public function getAvailable() { return $this->available; } /** * Set priceChildren * * @param float $priceChildren * * @return TravelPeriodPrice */ public function setPriceChildren($priceChildren) { $this->priceChildren = $priceChildren; return $this; } /** * Get priceChildren * * @return float */ public function getPriceChildren() { return $this->priceChildren; } /** * Set price * * @param float $price * * @return TravelPeriodPrice */ public function setPrice($price) { $this->price = $price; return $this; } /** * Get price * * @return float */ public function getPrice() { return $this->price; } /** * Set priceComfort * * @param float $priceComfort * * @return TravelPeriodPrice */ public function setPriceComfort($priceComfort) { $this->priceComfort = $priceComfort; return $this; } /** * Get priceComfort * * @return float */ public function getPriceComfort() { return $this->priceComfort; } /** * Set extraPriceChildren * * @param float $extraPriceChildren * * @return TravelPeriodPrice */ public function setExtraPriceChildren($extraPriceChildren) { $this->extraPriceChildren = $extraPriceChildren; return $this; } /** * Get extraPriceChildren * * @return float */ public function getExtraPriceChildren() { return $this->extraPriceChildren; } /** * Set extraPrice * * @param float $extraPrice * * @return TravelPeriodPrice */ public function setExtraPrice($extraPrice) { $this->extraPrice = $extraPrice; return $this; } /** * Get extraPrice * * @return float */ public function getExtraPrice() { return $this->extraPrice; } /** * Set extraPriceComfort * * @param float $extraPriceComfort * * @return TravelPeriodPrice */ public function setExtraPriceComfort($extraPriceComfort) { $this->extraPriceComfort = $extraPriceComfort; return $this; } /** * Get extraPriceComfort * * @return float */ public function getExtraPriceComfort() { return $this->extraPriceComfort; } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set period * * @param \AppBundle\Entity\TravelPeriod $period * * @return TravelPeriodPrice */ public function setPeriod(\AppBundle\Entity\TravelPeriod $period = null) { $this->period = $period; return $this; } /** * Get period * * @return \AppBundle\Entity\TravelPeriod */ public function getPeriod() { return $this->period; } /** * Set priceTypeId * * @param integer $priceTypeId * * @return TravelPeriodPrice */ public function setPriceTypeId($priceTypeId) { $this->priceTypeId = $priceTypeId; return $this; } /** * Get priceTypeId * * @return integer */ public function getPriceTypeId() { return $this->priceTypeId; } /** * @return float * @throws \Exception */ public function getEffectivePrice() { if ($this->effectivePrice === null) { throw new \Exception('Effective price must be set from outside before reading it.'); } return $this->effectivePrice; } /** * @param float $effectivePrice */ public function setEffectivePrice($effectivePrice) { $this->effectivePrice = $effectivePrice; } /** * @return float * @throws \Exception */ public function getEffectiveExtraPrice() { if ($this->effectiveExtraPrice === null) { throw new \Exception('EffectiveExtra price must be set from outside before reading it.'); } return $this->effectiveExtraPrice; } /** * @param float $effectiveExtraPrice */ public function setEffectiveExtraPrice($effectiveExtraPrice) { $this->effectiveExtraPrice = $effectiveExtraPrice; } /** * Probably getEffectiveDiscountPrice() is the method you are actually looking for. * @return float|null */ public function getDiscountPrice() { return $this->calculateDiscountPrice($this->price); } /** * Probably getEffectiveDiscountPrice() is the method you are actually looking for. * @return float|null */ public function getChildDiscountPrice() { return $this->calculateDiscountPrice($this->priceChildren); } /** * @return float * @throws \Exception */ public function getEffectiveDiscountPrice() { if ($this->effectivePrice === null) { throw new \Exception('Effective price must be set from outside before reading effective discount price.'); } return $this->calculateDiscountPrice($this->effectivePrice); } /** * @return float * @throws \Exception */ public function getEffectiveChildDiscountPrice() { if ($this->effectiveChildPrice === null) { throw new \Exception('Effective price must be set from outside before reading effective discount price.'); } return $this->calculateDiscountPrice($this->effectiveChildPrice); } /** * @return float * @throws \Exception * * @todo The child price will not be set yet. This is just a preparation for later */ public function getEffectiveChildPrice() { if ($this->effectiveChildPrice === null) { throw new \Exception('Effective child price must be set from outside before reading it.'); } return $this->effectiveChildPrice; } /** * @param null $effectiveChildPrice */ public function setEffectiveChildPrice($effectiveChildPrice) { $this->effectiveChildPrice = $effectiveChildPrice; } /** * @return float * @throws \Exception * * @todo The child price will not be set yet. This is just a preparation for later */ public function getEffectiveExtraChildPrice() { if ($this->effectiveExtraChildPrice === null) { throw new \Exception('Effective Extra child price must be set from outside before reading it.'); } return $this->effectiveExtraChildPrice; } /** * @param null $effectiveChildPrice */ public function setEffectiveExtraChildPrice($effectiveExtraChildPrice) { $this->effectiveExtraChildPrice = $effectiveExtraChildPrice; } /** * @return float|null * @throws \Exception */ public function getEffectiveComfortPrice() { if ($this->effectiveComfortPrice === null) { throw new \Exception('Effective comfort price must be set from outside before reading it.'); } return $this->effectiveComfortPrice; } /** * @param float|null $effectiveComfortPrice */ public function setEffectiveComfortPrice($effectiveComfortPrice) { $this->effectiveComfortPrice = $effectiveComfortPrice; } /** * @return float|null * @throws \Exception */ public function getEffectiveExtraComfortPrice() { if ($this->effectiveExtraComfortPrice === null) { throw new \Exception('Effective Extra comfort price must be set from outside before reading it.'); } return $this->effectiveExtraComfortPrice; } /** * @param float|null $effectiveExtraComfortPrice */ public function setEffectiveExtraComfortPrice($effectiveExtraComfortPrice) { $this->effectiveExtraComfortPrice = $effectiveExtraComfortPrice; } private function calculateDiscountPrice($price) { if ($this->getPeriod() == null) { return null; } $newPrice = $price; foreach ($this->getPeriod()->getDiscounts() as $discount) { $newPrice -= $discount->getPercent() ? round($newPrice * $discount->getValue() / 100, 2) // #TODO FIXME : $discount->getValue(); } $program = $this->getPeriod()->getProgram(); if ($program != null && $program->getDiscount() != null) { $newPrice -= $program->getDiscountIsPercentValue() ? round($price * $program->getDiscount() / 100, 2) // #TODO FIXME : $program->getDiscount(); } return $price == $newPrice ? null : $newPrice; } }