* Fertigstellung Buchungsformular (#1321) (SternTours-CRM-API-Anbindung, Mailversand, Validierung, Dynamische Preisberechnung, Persistierung von Buchungsinformationen)
* Fehler bei der Preisberechnung behoben * Farbschema geändert (Kevin Adametz) git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3289 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
dde3b91724
commit
3a28866cd2
36 changed files with 2200 additions and 268 deletions
|
|
@ -67,7 +67,8 @@ class TravelPeriodPrice
|
|||
private $priceTypeId;
|
||||
|
||||
private $effectivePrice = null;
|
||||
private $effectiveDiscountPrice = null;
|
||||
private $effectiveChildPrice = null;
|
||||
private $effectiveComfortPrice = null;
|
||||
|
||||
/**
|
||||
* Set priceType
|
||||
|
|
@ -199,29 +200,28 @@ class TravelPeriodPrice
|
|||
return $this->period;
|
||||
}
|
||||
|
||||
public function getDiscountPrice()
|
||||
/**
|
||||
* Set priceTypeId
|
||||
*
|
||||
* @param integer $priceTypeId
|
||||
*
|
||||
* @return TravelPeriodPrice
|
||||
*/
|
||||
public function setPriceTypeId($priceTypeId)
|
||||
{
|
||||
if ($this->getPeriod() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// #TODO FIX! Discount calculation differs for period and program
|
||||
$price = $this->price; // #TODO Is the discount calculated for the effective price or for the original price?
|
||||
$newPrice = $price;
|
||||
foreach ($this->getPeriod()->getDiscounts() as $discount)
|
||||
{
|
||||
$newPrice -= $discount->getPercent()
|
||||
? round($newPrice * $discount->getValue() / 100, 2) // FIXME
|
||||
: $discount->getValue();
|
||||
}
|
||||
$program = $this->getPeriod()->getProgram();
|
||||
if ($program != null && $program->getDiscount() != null)
|
||||
{
|
||||
$newPrice -= $program->getDiscountIsPercentValue()
|
||||
? round($price * $program->getDiscount() / 100, 2) // FIXME
|
||||
: $program->getDiscount();
|
||||
}
|
||||
return $price == $newPrice ? null : $newPrice;
|
||||
$this->priceTypeId = $priceTypeId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get priceTypeId
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPriceTypeId()
|
||||
{
|
||||
return $this->priceTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -245,48 +245,92 @@ class TravelPeriodPrice
|
|||
$this->effectivePrice = $effectivePrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Probably getEffectiveDiscountPrice() is the method you are actually looking for.
|
||||
* @return float|null
|
||||
*/
|
||||
public function getDiscountPrice()
|
||||
{
|
||||
return $this->calculateDiscountPrice($this->price);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getEffectiveDiscountPrice()
|
||||
{
|
||||
if ($this->effectiveDiscountPrice === null)
|
||||
if ($this->effectivePrice === null)
|
||||
{
|
||||
throw new \Exception('Effective discount price must be set from outside before reading it.');
|
||||
throw new \Exception('Effective price must be set from outside before reading effective discount price.');
|
||||
}
|
||||
return $this->effectiveDiscountPrice;
|
||||
return $this->calculateDiscountPrice($this->effectivePrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $effectiveDiscountPrice
|
||||
* @return float
|
||||
* @throws \Exception
|
||||
*
|
||||
* @todo The child price will not be set yet. This is just a preparation for later
|
||||
*/
|
||||
public function setEffectiveDiscountPrice($effectiveDiscountPrice)
|
||||
public function getEffectiveChildPrice()
|
||||
{
|
||||
$this->effectiveDiscountPrice = $effectiveDiscountPrice;
|
||||
if ($this->effectiveChildPrice === null)
|
||||
{
|
||||
throw new \Exception('Effective child price must be set from outside before reading it.');
|
||||
}
|
||||
return $this->effectiveChildPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set priceTypeId
|
||||
*
|
||||
* @param integer $priceTypeId
|
||||
*
|
||||
* @return TravelPeriodPrice
|
||||
* @param null $effectiveChildPrice
|
||||
*/
|
||||
public function setPriceTypeId($priceTypeId)
|
||||
public function setEffectiveChildPrice($effectiveChildPrice)
|
||||
{
|
||||
$this->priceTypeId = $priceTypeId;
|
||||
|
||||
return $this;
|
||||
$this->effectiveChildPrice = $effectiveChildPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get priceTypeId
|
||||
*
|
||||
* @return integer
|
||||
* @return float|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getPriceTypeId()
|
||||
public function getEffectiveComfortPrice()
|
||||
{
|
||||
return $this->priceTypeId;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue