Esempio n. 1
0
 /**
  * @param int $productRateId
  * @param array $dates
  * @param int $roomCount
  * @param float $price
  * @see \DDD\Service\ChannelManager::getDates()
  * @return array
  * <pre>
  * array(
  *    'cancel' => $cancel,
  *    'penalty' => $penalty,
  *    'currency_rate' => $currencyRate,
  *    'penalty_fixed_amount' => $penaltyAmount,
  *    'refundable_before_hours' => $refBeforeHours,
  *    'penalty_val' => $penaltyValue,
  * )
  * </pre>
  */
 public function getPenalty($productRateId, $dates, $roomCount, $price, $resNumber = false)
 {
     if ($resNumber) {
         // for charging
         $bookingDao = new BookingForPenalty($this->getServiceLocator(), 'DDD\\Domain\\Apartment\\ProductRate\\Penalty');
         $productRateDomain = $bookingDao->getRateDataForReservation($resNumber);
     } else {
         // for reservation
         /** @var \DDD\Dao\Apartment\Rate  $productRateDao */
         $productRateDao = $this->getServiceLocator()->get('dao_apartment_rate');
         $productRateDomain = $productRateDao->getRateById($productRateId);
     }
     $dayCount = $this->dateDiff($dates['date_from'], $dates['date_to']);
     $penaltyValue = $this->getPenaltyValue($productRateDomain, $dayCount);
     if ($productRateDomain->getPenaltyType() == Rate::APARTMENT_RATE_NON_REFUNDABLE) {
         $penaltyValue *= $roomCount;
     } else {
     }
     return ['is_refundable' => $productRateDomain->getIsRefundable(), 'penalty' => $productRateDomain->getPenaltyType(), 'penalty_fixed_amount' => $productRateDomain->getIsRefundable() == Rate::APARTMENT_RATE_NON_REFUNDABLE ? $price : $this->calculatePenalty($productRateDomain, $dayCount, $price, $roomCount), 'refundable_before_hours' => $productRateDomain->getIsRefundable() == Rate::APARTMENT_RATE_REFUNDABLE ? $productRateDomain->getRefundableBeforeHours() : 0, 'penalty_val' => $penaltyValue];
 }