Ejemplo n.º 1
0
 public function sendApplicantRejectionsAction()
 {
     /**
      * @var \DDD\Service\Queue\EmailQueue $emailQueueService
      * @var \Mailer\Service\Email $mailer
      */
     $emailQueueService = $this->getServiceLocator()->get('service_queue_email_queue');
     $list = $emailQueueService->fetch(EmailQueue::TYPE_APPLICANT_REJECTION);
     if ($list && $list->count()) {
         /**
          * @var \DDD\Service\Textline $textlineService
          */
         $textlineService = $this->getServiceLocator()->get('service_textline');
         foreach ($list as $item) {
             //Don't send an email if applicant is not rejected anymore
             if (Applicant::APPLICANT_STATUS_REJECT != $item['status']) {
                 $emailQueueService->delete($item['id']);
                 continue;
             }
             $mailer = $this->getServiceLocator()->get('Mailer\\Email');
             $emailValidator = new EmailAddress();
             if (!$emailValidator->isValid($item['email'])) {
                 $this->outputMessage('[error] Applicant email is not valid: ' . $item['email'] . ' Removing from queue.');
                 $this->gr2err("Applicant rejection mail wasn't sent", ['applicant_id' => $item['entity_id'], 'applicant_name' => $item['applicant_name']]);
                 continue;
             }
             $mailer->send('applicant-rejection', ['to' => $item['email'], 'bcc' => EmailAliases::HR_EMAIL, 'to_name' => $item['applicant_name'], 'replyTo' => EmailAliases::HR_EMAIL, 'from_address' => EmailAliases::HR_EMAIL, 'from_name' => 'Ginosi Apartments', 'subject' => $textlineService->getUniversalTextline(1608, true), 'msg' => Helper::evaluateTextline($textlineService->getUniversalTextline(1607), ['{{APPLICANT_NAME}}' => $item['applicant_name'], '{{POSITION_TITLE}}' => $item['position_title']])]);
             $emailQueueService->delete($item['id']);
             $this->outputMessage("Rejection email to {$item['applicant_name']} sent. ");
         }
     } else {
         $this->outputMessage("Queue is empty. ");
     }
     $this->outputMessage("Done. ");
 }
Ejemplo n.º 2
0
 /**
  * @param $reservationId
  * @return array
  */
 public function getAlreadyChargedItems($reservationId)
 {
     /**
      * @var \DDD\Dao\Booking\Charge $chargeDao
      * @var \DDD\Service\Textline $textlineService
      */
     $chargeDao = $this->getServiceLocator()->get('dao_booking_charge');
     $textlineService = $this->getServiceLocator()->get('service_textline');
     $charges = $chargeDao->getChargesForView($reservationId);
     $chargesList = [];
     $totalPrice = 0;
     $currencySymbol = '';
     foreach ($charges as $charge) {
         $totalPrice += $charge->getAmount();
         switch ($charge->getAddonsType()) {
             case BookingAddon::ADDON_TYPE_ACC:
                 array_push($chargesList, ['label' => Helper::evaluateTextline($textlineService->getUniversalTextline(1585), ['{{NIGHT_COUNT}}' => date(Constants::GLOBAL_DATE_FORMAT, strtotime($charge->getNightlyDate()))]), 'price_view' => $charge->getCurrencySymbol() . ' ' . number_format($charge->getAmount(), 2, '.', ' '), 'price' => $charge->getAmount(), 'percent' => 0, 'type' => 'night', 'class' => '', 'description' => '', 'tax_included' => '']);
                 $currencySymbol = $charge->getCurrencySymbol();
                 break;
             case BookingAddon::ADDON_TYPE_TAX_TOT:
             case BookingAddon::ADDON_TYPE_TAX_VAT:
             case BookingAddon::ADDON_TYPE_CITY_TAX:
             case BookingAddon::ADDON_TYPE_SALES_TAX:
                 $labelTextLineId = 0;
                 $descriptionTextLineId = 0;
                 if ($charge->getAddonsType() == BookingAddon::ADDON_TYPE_TAX_TOT) {
                     $descriptionTextLineId = 1429;
                     $labelTextLineId = 1259;
                 } elseif ($charge->getAddonsType() == BookingAddon::ADDON_TYPE_TAX_VAT) {
                     $descriptionTextLineId = 1430;
                     $labelTextLineId = 1260;
                 } elseif ($charge->getAddonsType() == BookingAddon::ADDON_TYPE_SALES_TAX) {
                     $descriptionTextLineId = 1431;
                     $labelTextLineId = 1261;
                 } elseif ($charge->getAddonsType() == BookingAddon::ADDON_TYPE_CITY_TAX) {
                     $descriptionTextLineId = 1432;
                     $labelTextLineId = 1262;
                 }
                 if ($charge->getTaxType() == Taxes::TAXES_TYPE_PERCENT) {
                     $taxValue = $charge->getAddonsValue() . ' %';
                 } else {
                     $taxNameTextline = 1473;
                     if ($charge->getTaxType() == BookingAddon::ADDON_TYPE_CITY_TAX && $charge->getTaxType() == Taxes::TAXES_TYPE_PER_PERSON) {
                         $taxNameTextline = 1493;
                     }
                     $taxValue = $charge->getCurrencySymbol() . ' ' . number_format($charge->getAddonsValue(), 2, '.', ' ') . ' ' . $textlineService->getUniversalTextline($taxNameTextline);
                 }
                 array_push($chargesList, ['label' => $textlineService->getUniversalTextline($labelTextLineId) . ' (' . $taxValue . ') ', 'price_view' => $charge->getCurrencySymbol() . ' ' . number_format($charge->getAmount(), 2, '.', ' '), 'price' => $charge->getAmount(), 'percent' => 0, 'type' => 'tax', 'class' => '', 'description' => $textlineService->getUniversalTextline($descriptionTextLineId), 'tax_included' => '', 'date' => $charge->getNightlyDate(), 'type_id' => $charge->getAddonsType()]);
                 break;
             case BookingAddon::ADDON_TYPE_DISCOUNT:
                 array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1503), 'price_view' => $charge->getCurrencySymbol() . ' ' . number_format($charge->getAmount(), 2, '.', ' '), 'price' => $charge->getAmount(), 'percent' => 0, 'type' => 'discount', 'class' => 'text-danger', 'description' => '', 'tax_included' => '']);
                 break;
             case BookingAddon::ADDON_TYPE_CLEANING_FEE:
                 array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1497), 'price_view' => $charge->getCurrencySymbol() . ' ' . number_format($charge->getAmount(), 2, '.', ' '), 'price' => $charge->getAmount(), 'percent' => 0, 'type' => 'fee', 'class' => 'text-danger', 'description' => $textlineService->getUniversalTextline(1498), 'tax_included' => '']);
                 break;
         }
     }
     // Total
     array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1305), 'price_view' => $currencySymbol . ' ' . number_format($totalPrice, 2, '.', ' '), 'price' => $totalPrice, 'percent' => 0, 'type' => 'total', 'class' => '', 'description' => '', 'tax_included' => '']);
     return $chargesList;
 }
Ejemplo n.º 3
0
 /**
  * @return ViewModel
  */
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Textline $textlineService
      * @var \DDD\Service\Lock\General $lockService
      */
     $textlineService = $this->getServiceLocator()->get('service_textline');
     $lockService = $this->getServiceLocator()->get('service_lock_general');
     $keyCode = $this->params()->fromQuery('code');
     $view = $this->params()->fromQuery('view');
     $godMode = $this->params()->fromQuery('bo', false) ?: false;
     if ($keyCode === null || !ClassicValidator::validateAlnum($keyCode)) {
         return $this->redirect()->toRoute('home')->setStatusCode('301');
     }
     /**
      * if have not key code in query...
      * OR not finded thicket...
      * OR "arrival date" NOT MORE than "5"
      * OR "depart date" NOT LESS than "-3"
      * redirect() -> Home
      */
     $bookingData = $this->getBookingData($keyCode);
     if (!$bookingData || !Helper::checkDatesByDaysCount(1, $bookingData->getDateTo())) {
         return $this->redirect()->toRoute('home')->setStatusCode('301');
     }
     $session = new SessionContainer('visitor');
     $parkingTextline = '';
     if ($bookingData->hasParking()) {
         $parkingTextline = $textlineService->getUniversalTextline($bookingData->getParkingTextlineId());
     }
     /**
      * @var \DDD\Service\Website\Textline $textlineService
      */
     $textlineService = $this->getServiceLocator()->get('service_website_textline');
     $keyDirectEntryTextline = Helper::evaluateTextline($textlineService->getApartmentDirectKeyInstructionTextline($bookingData->getApartmentId()), ['{{PARKING_TEXTLINE}}' => $parkingTextline]);
     $keyReceptionEntryTextline = Helper::evaluateTextline($textlineService->getApartmentReceptionKeyInstructionTextline($bookingData->getApartmentId()), ['{{PARKING_TEXTLINE}}' => $parkingTextline]);
     /* @var $customerService \DDD\Service\Customer */
     $customerService = $this->getServiceLocator()->get('service_customer');
     /**
      * If NOT HAVE flag from BO (view=0)...
      * Specify that looked & save the date view
      */
     if ($view !== '0' && $bookingData->isKiViewed() !== '1' && !$customerService->isBot($session)) {
         /**
          * @var \DDD\Service\Website\Booking $bookingService
          */
         $bookingService = $this->getServiceLocator()->get('service_website_booking');
         $bookingService->updateData($bookingData->getId(), ['ki_viewed' => '1', 'ki_viewed_date' => date('Y-m-d H:i:s')]);
     }
     $lockDatas = $lockService->getLockByReservationApartmentId($bookingData->getApartmentIdAssigned(), $bookingData->getPin(), [LockService::USAGE_APARTMENT_TYPE, LockService::USAGE_BUILDING_TYPE, LockService::USAGE_PARKING_TYPE], true);
     foreach ($lockDatas as $key => $lockData) {
         switch ($key) {
             case LockService::USAGE_APARTMENT_TYPE:
                 $bookingData->setPin($lockData['code']);
                 break;
             case LockService::USAGE_BUILDING_TYPE:
                 $bookingData->setOutsideDoorCode($lockData['code']);
                 break;
             case LockService::USAGE_PARKING_TYPE:
                 // TODO: to be or not to be, this is the question.
                 break;
         }
     }
     // get Office Address
     $officeAddress = false;
     if ($bookingData->getKiPageType() == Building::KI_PAGE_TYPE_RECEPTION) {
         /**
          * @var \DDD\Service\Office $officeService
          */
         $officeService = $this->getServiceLocator()->get('service_office');
         $officeManagement = $officeService->getData($bookingData->getOfficeId());
         /**
          * @var \DDD\Domain\Office\OfficeManager $officeData
          */
         $officeData = $officeManagement['office'];
         $officeAddress = $officeData->getAddress();
     }
     if ($view !== '0') {
         $this->checkCustomerIdentityData($bookingData);
     }
     $this->layout()->setTemplate('layout/layout-ki');
     $this->layout()->userTrackingInfo = ['res_number' => $bookingData->getResNumber(), 'partner_id' => $bookingData->getPartnerId()];
     $this->layout()->godMode = $godMode === substr(md5($keyCode), 12, 5);
     $this->layout()->keyData = $bookingData;
     $this->layout()->keyCode = $keyCode;
     $this->layout()->directEntryTextline = $keyDirectEntryTextline;
     $this->layout()->receptionEntryTextline = $keyReceptionEntryTextline;
     return new ViewModel(['keyData' => $bookingData, 'keyCode' => $keyCode, 'directEntryTextline' => $keyDirectEntryTextline, 'receptionEntryTextline' => $keyReceptionEntryTextline, 'godMode' => $godMode === substr(md5($keyCode), 12, 5), 'isGuest' => $view !== '0', 'officeAddress' => $officeAddress]);
 }
Ejemplo n.º 4
0
 /**
  *
  * @param int $totalCount
  * @param int $currentPage
  * @param int $viewCount
  * @return string
  */
 private function paginationViewItem($totalCount, $currentPage, $viewCount)
 {
     if ($totalCount <= $viewCount) {
         return '';
     }
     $viewFirst = $currentPage == 1 ? 1 : ($currentPage - 1) * $viewCount;
     $viewSecnd = $currentPage * $viewCount <= $totalCount ? $currentPage * $viewCount : $totalCount;
     return Helper::evaluateTextline($this->getTextLineSite(1215), ['{{PAGE_COUNT}}' => "{$viewFirst}-{$viewSecnd}", '{{ITEM_COUNT}}' => $totalCount]);
 }
Ejemplo n.º 5
0
 /**
  *
  * @param array $data
  * @return array
  */
 public function cancelationPolicy($data)
 {
     $result = ['type' => '', 'description' => ''];
     if (isset($data['is_refundable']) && $data['is_refundable'] == 2) {
         //None refundable
         $result['type'] = $this->getTextLineSite(845);
         $result['description'] .= $this->getTextLineSite(861);
     } elseif (isset($data['is_refundable']) && $data['is_refundable'] == 1) {
         //Refundable
         $result['type'] = $this->getTextLineSite(846);
         $time = (int) $data['refundable_before_hours'];
         if ($time > 48) {
             $time = $time / 24 . ' ' . $this->getTextLineSite(977);
         } else {
             $time = $time . ' ' . $this->getTextLineSite(976);
         }
         //penalty
         $pen_val = '';
         switch ($data['penalty_type']) {
             case 1:
                 $pen_val = $data['penalty_percent'] . "%";
                 break;
             case 2:
                 $pen_val = $data['penalty_fixed_amount'] . ' ' . $data['code'];
                 break;
             case 3:
                 $night = $data['night_count'];
                 if ($night < $data['penalty_nights']) {
                     $pen_val = $night;
                 } else {
                     $pen_val = $data['penalty_nights'];
                 }
                 $pen_val .= ' ' . $this->getTextLineSite(862);
                 break;
         }
         $description = Helper::evaluateTextline($this->getTextLineSite(859), ['{{CXL_TIME}}' => $time, '{{CXL_PENALTY}}' => $pen_val]);
         $result['description'] .= $description;
     }
     return $result;
 }
Ejemplo n.º 6
0
 public function sendReceiptAction()
 {
     /**
      * @var \DDD\Service\Booking\BookingTicket $bookingService
      */
     try {
         $serviceLocator = $this->getServiceLocator();
         $mailer = $serviceLocator->get('Mailer\\Email');
         $bookingService = $serviceLocator->get('service_booking_booking_ticket');
         $reservationId = $this->id;
         if (!$reservationId) {
             $this->gr2err("Reservation ID missing", ['reason' => 'Reservation Id not found']);
             return false;
         }
         $receiptData = $bookingService->getReceiptData($reservationId);
         $reservation = $receiptData['reservation'];
         $emailValidator = new EmailAddress();
         $email = $reservation['guest_email'];
         if ($this->getRequest()->getParam('email')) {
             $email = $this->getRequest()->getParam('email');
         }
         if ($receiptData['status'] != 'success' || !$emailValidator->isValid($email)) {
             $this->gr2err('Receipt status or mail is not correct', ['reservation_id' => $reservationId, 'reservation_number' => $reservation['res_number']]);
             return false;
         }
         /**
          * @var \DDD\Service\Textline $textlineService
          */
         $textlineService = $this->getServiceLocator()->get('service_textline');
         $mailSubject = 'Receipt for Transaction: ' . $reservation['res_number'];
         $title = 'Receipt';
         $reservationDetails = 'Reservation Details';
         $financeDetails = 'Finance Details';
         $receiptThankYou = TextConstants::RECEIPT_THANK_YOU;
         // added by me
         $reservationId = $reservation['id'];
         $reservationNumber = $reservation['res_number'];
         $receiptIssueDate = $receiptData['today'];
         $customerName = $reservation['guest_first_name'] . ' ' . $reservation['guest_last_name'];
         $customerAddress = $reservation['guest_address'];
         $checkInDate = date(Constants::GLOBAL_DATE_TIME_WO_SEC_FORMAT, strtotime($reservation['date_from'] . $reservation['check_in']));
         $checkOutDate = date(Constants::GLOBAL_DATE_TIME_WO_SEC_FORMAT, strtotime($reservation['date_to'] . $reservation['check_out']));
         $apartmentName = $reservation['apartment_name'];
         $apartmentAddress = $reservation['apartment_address'];
         $totalAmountToPay = 0;
         $nightsCount = 0;
         $taxes = [];
         if ($receiptData['charges'] && $receiptData['charges']) {
             foreach ($receiptData['charges'] as $charge) {
                 // calculate taxes
                 if ($charge['addon']) {
                     if ($charge['addons_type'] == 1) {
                         $chargeKey = ucfirst($textlineService->getUniversalTextline(669));
                         $nightsCount++;
                     } else {
                         $chargeKey = $charge['addon'];
                     }
                 } elseif ($charge['type'] == 'p') {
                     $chargeKey = 'Penalty';
                 } elseif ($charge['type'] == 'g') {
                     $chargeKey = 'Penalty Ginosi';
                 } else {
                     $chargeKey = 'Other';
                 }
                 if ($charge['addons_value'] > 0 && $charge['location_join'] != '') {
                     $chargeKey .= ' ' . $charge['addons_value'];
                     if ($charge['tax_type'] == Taxes::TAXES_TYPE_PERCENT) {
                         $chargeKey .= ' %';
                     } elseif ($charge['tax_type'] == Taxes::TAXES_TYPE_PER_NIGHT) {
                         $chargeKey .= ' p/n';
                     } elseif ($charge['tax_type'] == Taxes::TAXES_TYPE_PER_PERSON) {
                         $chargeKey .= ' p/p';
                     }
                 }
                 if (isset($taxes[$chargeKey])) {
                     $taxes[$chargeKey] += $charge['acc_amount'];
                 } else {
                     $taxes[$chargeKey] = $charge['acc_amount'];
                 }
                 // calculate all amount to pay
                 $totalAmountToPay += $charge['acc_amount'];
             }
         }
         $totalAmountToPaid = 0;
         if ($receiptData['transactions'] && $receiptData['transactions']->count()) {
             foreach ($receiptData['transactions'] as $key => $transaction) {
                 $totalAmountToPaid += $transaction['acc_amount'];
             }
         }
         $totalAmountPaid = $totalAmountToPaid;
         $balance = number_format($totalAmountToPay - $totalAmountToPaid, 2, '.', '');
         // analytics image
         $analyticsCode = $this->getAnalyticsCode();
         $analyticsImage = Helper::evaluateTextline($textlineService->getUniversalTextline(1681), ['{{ANALYTICS_CODE}}' => $analyticsCode, '{{ANALYTICS_RES_NUMBER}}' => $reservationNumber, '{{ANALYTICS_TEMPLATE}}' => 'receipt', '{{ANALYTICS_PARTNER_ID}}' => $reservation['partner_id']]);
         $analyticsQuery = Helper::evaluateTextline($textlineService->getUniversalTextline(1682), ['{{ANALYTICS_TEMPLATE}}' => 'key-instruction']);
         $mailer->send('receipt', array('layout' => 'layout-new', 'analyticsQuery' => $analyticsQuery, 'to' => $email, 'to_name' => $reservation['guest_first_name'] . ' ' . $reservation['guest_last_name'], 'replyTo' => EmailAliases::RT_RESERVATION, 'from_address' => EmailAliases::FROM_MAIN_MAIL, 'from_name' => 'Ginosi Apartments', 'subject' => $mailSubject, 'title' => $title, 'reservationDetails' => $reservationDetails, 'financeDetails' => $financeDetails, 'receiptThankYou' => $receiptThankYou, 'data' => $receiptData, 'reservationId' => $reservationId, 'reservationNumber' => $reservationNumber, 'reservationSymbol' => $reservation['symbol'], 'receiptIssueDate' => $receiptIssueDate, 'customerName' => $customerName, 'customerAddress' => $customerAddress, 'checkInDate' => $checkInDate, 'checkOutDate' => $checkOutDate, 'apartmentName' => $apartmentName, 'apartmentAddress' => $apartmentAddress, 'nightsCount' => $nightsCount, 'taxes' => $taxes, 'totalAmountPaid' => $totalAmountPaid, 'balance' => $balance, 'phone1' => $reservation['phone1'], 'phone2' => $reservation['phone2'], 'analyticsImage' => $analyticsImage));
         $this->gr2info('Sending Customer Receipt mail', ['reservation_number' => $reservation['res_number']]);
         return true;
     } catch (\Exception $e) {
         $msg = "[error]Error: Receipt mail wasn't sent";
         $this->gr2logException($e, "Receipt mail wasn't sent", ['reservation_number' => isset($reservation) ? $reservation['res_number'] : '', 'reservation_id' => isset($reservationId) ? $reservationId : '']);
         $this->outputMessage($msg . ' ' . $e->getMessage());
         return false;
     }
 }
Ejemplo n.º 7
0
 /**
  * Testing GetToBeChargedItems method
  */
 public function testGetToBeChargedItems()
 {
     // get any reservation
     $isBookerPrice = false;
     /**
      * @var \DDD\Dao\Booking\Booking $reservationDao
      */
     $reservationDao = $this->getApplicationServiceLocator()->get('dao_booking_booking');
     //        $reservation    = $reservationDao->fetchOne(function(Select $select) {
     //            $select->order('id DESC');
     //        });
     $getReservationWithChargesAndBookedStatusQuery = new Select();
     $getReservationWithChargesAndBookedStatusQuery->join([DbTables::TBL_CHARGE => 'charges'], 'charges.reservation_id = ' . DbTables::TBL_BOOKINGS . '.id', ['charge_id' => 'id'], Select::JOIN_INNER);
     $getReservationWithChargesAndBookedStatusQuery->where->isNotNull('charge_id');
     $getReservationWithChargesAndBookedStatusQuery->where->equalTo(DbTables::TBL_BOOKINGS . '.status', Booking::BOOKING_STATUS_BOOKED);
     $getReservationWithChargesAndBookedStatusQuery->order([DbTables::TBL_BOOKINGS . '.id' => 'DESC']);
     $reservation = $reservationDao->fetchOne($getReservationWithChargesAndBookedStatusQuery);
     $this->assertNotNull($reservation);
     // get textvine service
     /**
      * @var \DDD\Service\Textline $textlineService
      */
     $textlineService = $this->getApplicationServiceLocator()->get('service_textline');
     // check chargeProcess domain
     $reservation = $reservationDao->getDataForToBeCharged($reservation->getId());
     $this->assertInstanceOf('\\DDD\\Domain\\Booking\\ChargeProcess', $reservation);
     // check booking ticket
     $bookingTicketService = $this->getApplicationServiceLocator()->get('service_booking_booking_ticket');
     $this->assertInstanceOf('\\DDD\\Service\\Booking\\BookingTicket', $bookingTicketService);
     // check discount getters
     $this->assertTrue(method_exists($reservation, 'getPartnerId'), 'Class does not have method getPartnerId');
     $this->assertTrue(method_exists($reservation, 'getGuestEmail'), 'Class does not have method getGuestEmail');
     $discountParams = [];
     if ($reservation->getPartnerId()) {
         $discountParams = ['aff_id' => $reservation->getPartnerId(), 'email' => $reservation->getGuestEmail()];
     }
     // check price getters
     $this->assertTrue(method_exists($reservation, 'getBookerPrice'), 'Booking Object does not have method getBookerPrice');
     $this->assertTrue(method_exists($reservation, 'getPrice'), 'Booking Object does not have method getPrice');
     if ($isBookerPrice) {
         $totalPrice = $reservation->getBookerPrice();
         $price = $reservation->getBookerPrice();
     } else {
         $totalPrice = $reservation->getPrice();
         $price = $reservation->getPrice();
     }
     $nightCount = Helper::getDaysFromTwoDate($reservation->getDateTo(), $reservation->getDateFrom());
     $currencySymbol = $reservation->getCurrencySymbol();
     // check night count
     $this->assertLessThan($nightCount, 0);
     // Night Charges
     $chargesList = [['label' => Helper::evaluateTextline($textlineService->getUniversalTextline(1580), ['{{NIGHT_COUNT}}' => $nightCount]), 'price_view' => $currencySymbol . number_format($totalPrice, 2, '.', ' '), 'price' => $totalPrice, 'percent' => 0, 'type' => 'night', 'class' => '', 'description' => '', 'tax_included' => '']];
     /********************************************************************************************************/
     /********************************* Check discount charges ***********************************************/
     /********************************************************************************************************/
     $discountValidator = $bookingTicketService->validateAndCheckDiscountData($discountParams, false);
     $discounted = false;
     if (isset($discountValidator['discount_value']) && $discountValidator['valid'] && isset($discountValidator['discount_value']) && ceil($discountValidator['discount_value'])) {
         $discountValue = $totalPrice * $discountValidator['discount_value'] / 100;
         $price = $totalPrice - $discountValue;
         $discounted = true;
         $totalPrice = $totalPrice - $discountValue;
         array_push($chargesList, ['label' => (isset($discountValidator['partner_name']) ? $discountValidator['partner_name'] : '') . ' ' . $textlineService->getUniversalTextline(1503), 'price_view' => '- ' . $currencySymbol . number_format($discountValue, 2, '.', ' '), 'price' => $discountValue, 'percent' => 0, 'type' => 'discount', 'class' => 'text-danger', 'description' => '', 'tax_included' => '']);
     }
     /********************************************************************************************************/
     /************************************** Check Tax Charges ***********************************************/
     /********************************************************************************************************/
     $currencyService = $this->getApplicationServiceLocator()->get('service_currency_currency');
     $this->assertInstanceOf('\\DDD\\Service\\Currency\\Currency', $currencyService);
     $currencyRate = 1;
     $this->assertTrue(method_exists($reservation, 'getGuestCurrency'), 'Booking Object does not have method getGuestCurrency');
     $this->assertTrue(method_exists($reservation, 'getApartmentCurrency'), 'Booking Object does not have method getApartmentCurrency');
     $this->assertTrue(method_exists($currencyService, 'getCurrencyConversionRate'), 'Booking Object does not have method getCurrencyConversionRate');
     if ($reservation->getGuestCurrency() != $reservation->getApartmentCurrency() && $isBookerPrice) {
         $currencyRate = $currencyService->getCurrencyConversionRate($reservation->getGuestCurrency(), $reservation->getApartmentCurrency());
     }
     $this->assertTrue(method_exists($reservation, 'getCityTotType'), 'Booking Object does not have method getCityTotType');
     $this->assertTrue(method_exists($reservation, 'getCityTot'), 'Booking Object does not have method getCityTot');
     $this->assertTrue(method_exists($reservation, 'getTotIncluded'), 'Booking Object does not have method getTotIncluded');
     if ($reservation->getCityTotType() > 0 && $reservation->getCityTot() > 0) {
         $taxDiscounted = false;
         $totDuration = $reservation->getTotMaxDuration() ? min($reservation->getTotMaxDuration(), $nightCount) : $nightCount;
         $totValue = $reservation->getCityTot() + $reservation->getTotAdditional();
         if ($reservation->getCityTotType() == Taxes::TAXES_TYPE_PERCENT) {
             $cityTot = $price / 100 * $totValue * $totDuration / $nightCount;
             $taxValue = $totValue . ' %';
             if ($discounted) {
                 $taxDiscounted = true;
             }
             $percent = $totValue;
         } else {
             $cityTot = $totDuration * $totValue * $currencyRate;
             $taxValue = $currencySymbol . ' ' . number_format($totValue * $currencyRate, 2, '.', ' ') . ' ' . $textlineService->getUniversalTextline(1473);
             $percent = 0;
         }
         array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1259) . ' (' . $taxValue . ($reservation->getTotIncluded() == 1 ? ', ' . $textlineService->getUniversalTextline(1472) : '') . ') ' . ($taxDiscounted ? $textlineService->getUniversalTextline(1633) : ''), 'price_view' => $currencySymbol . number_format($cityTot, 2, '.', ' '), 'price' => $cityTot, 'percent' => $percent, 'duration' => $totDuration, 'type' => 'tax', 'class' => 'text-primary', 'description' => $textlineService->getUniversalTextline(1429), 'tax_included' => $reservation->getTotIncluded() == 1 ?: '']);
         if ($reservation->getTotIncluded() != 1) {
             $totalPrice += $cityTot;
         }
     }
     $this->assertTrue(method_exists($reservation, 'getCityVatType'), 'Booking Object does not have method getCityVatType');
     $this->assertTrue(method_exists($reservation, 'getCityVat'), 'Booking Object does not have method getCityVat');
     $this->assertTrue(method_exists($reservation, 'getVatIncluded'), 'Booking Object does not have method getVatIncluded');
     if ($reservation->getCityVatType() > 0 && $reservation->getCityVat() > 0) {
         $taxDiscounted = false;
         $vatValue = $reservation->getCityVat();
         $vatDuration = $reservation->getVatMaxDuration() ? min($reservation->getVatMaxDuration(), $nightCount) : $nightCount;
         if ($reservation->getCityVatType() == Taxes::TAXES_TYPE_PERCENT) {
             $cityVat = $price / 100 * $vatValue * $vatDuration / $nightCount;
             $taxValue = $vatValue . ' %';
             if ($discounted) {
                 $taxDiscounted = true;
             }
             $percent = $vatValue;
         } else {
             $cityVat = $vatDuration * $vatValue * $currencyRate;
             $taxValue = $currencySymbol . number_format($vatValue * $currencyRate, 2, '.', ' ') . ' ' . $textlineService->getUniversalTextline(1473);
             $percent = 0;
         }
         array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1260) . ' (' . $taxValue . ($reservation->getVatIncluded() == 1 ? ', ' . $textlineService->getUniversalTextline(1472) : '') . ') ' . ($taxDiscounted ? $textlineService->getUniversalTextline(1633) : ''), 'price_view' => $currencySymbol . number_format($cityVat, 2, '.', ' '), 'price' => $cityVat, 'percent' => $percent, 'duration' => $vatDuration, 'type' => 'tax', 'class' => 'text-primary', 'description' => $textlineService->getUniversalTextline(1430), 'tax_included' => $reservation->getVatIncluded() == 1 ?: '']);
         if ($reservation->getVatIncluded() != 1) {
             $totalPrice += $cityVat;
         }
     }
     $this->assertTrue(method_exists($reservation, 'getCitySalesTaxType'), 'Booking Object does not have method getCitySalesTaxType');
     $this->assertTrue(method_exists($reservation, 'getCitySalesTax'), 'Booking Object does not have method getCitySalesTax');
     $this->assertTrue(method_exists($reservation, 'getCitySalesTaxType'), 'Booking Object does not have method getCitySalesTaxType');
     $this->assertTrue(method_exists($reservation, 'getSalesTaxIncluded'), 'Booking Object does not have method getSalesTaxIncluded');
     if ($reservation->getCitySalesTaxType() > 0 && $reservation->getCitySalesTax() > 0) {
         $taxDiscounted = false;
         $salesTaxValue = $reservation->getCitySalesTax();
         $salesTaxDuration = $reservation->getSalesTaxMaxDuration() ? min($reservation->getSalesTaxMaxDuration(), $nightCount) : $nightCount;
         if ($reservation->getCitySalesTaxType() == Taxes::TAXES_TYPE_PERCENT) {
             $citySalesTax = $price / 100 * $salesTaxValue * $salesTaxDuration / $nightCount;
             $taxValue = $salesTaxValue . ' %';
             if ($discounted) {
                 $taxDiscounted = true;
             }
             $percent = $salesTaxValue;
         } else {
             $citySalesTax = $salesTaxDuration * $salesTaxValue * $currencyRate;
             $taxValue = $currencySymbol . ' ' . number_format($salesTaxValue * $currencyRate, 2, '.', ' ') . ' ' . $textlineService->getUniversalTextline(1473);
             $percent = 0;
         }
         array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1261) . ' (' . $taxValue . ($reservation->getSalesTaxIncluded() == 1 ? ', ' . $textlineService->getUniversalTextline(1472) : '') . ') ' . ($taxDiscounted ? $textlineService->getUniversalTextline(1633) : ''), 'price_view' => $currencySymbol . number_format($citySalesTax, 2, '.', ' '), 'price' => $citySalesTax, 'percent' => $percent, 'duration' => $salesTaxDuration, 'type' => 'tax', 'class' => 'text-primary', 'description' => $textlineService->getUniversalTextline(1431), 'tax_included' => $reservation->getSalesTaxIncluded() == 1 ?: '']);
         if ($reservation->getSalesTaxIncluded() != 1) {
             $totalPrice += $citySalesTax;
         }
     }
     $this->assertTrue(method_exists($reservation, 'getCityTaxType'), 'Booking Object does not have method getCityTaxType');
     $this->assertTrue(method_exists($reservation, 'getCityTax'), 'Booking Object does not have method getCityTax');
     $this->assertTrue(method_exists($reservation, 'getCityTaxType'), 'Booking Object does not have method getCityTaxType');
     $this->assertTrue(method_exists($reservation, 'getCityTaxIncluded'), 'Booking Object does not have method getCityTaxIncluded');
     if ($reservation->getCityTaxType() > 0 && $reservation->getCityTax() > 0) {
         $taxDiscounted = false;
         $cityTaxValue = $reservation->getCityTax();
         $cityTaxDuration = $reservation->getCityTaxMaxDuration() ? min($reservation->getCityTaxMaxDuration(), $nightCount) : $nightCount;
         if ($reservation->getCityTaxType() == Taxes::TAXES_TYPE_PERCENT) {
             $cityTax = $price / 100 * $cityTaxValue * $cityTaxDuration / $nightCount;
             $taxValue = $cityTaxValue . ' %';
             if ($discounted) {
                 $taxDiscounted = true;
             }
             $percent = $cityTaxValue;
         } elseif ($reservation->getCityTaxType() == Taxes::TAXES_TYPE_PER_PERSON) {
             $cityTax = $cityTaxDuration * $cityTaxValue * $currencyRate * $reservation->getOccupancy();
             $taxValue = $currencySymbol . ' ' . number_format($cityTaxValue * $currencyRate, 2, '.', ' ') . ' ' . $textlineService->getUniversalTextline(1493);
             $percent = 0;
         } else {
             $cityTax = $cityTaxDuration * $cityTaxValue * $currencyRate;
             $taxValue = $currencySymbol . ' ' . number_format($cityTaxValue * $currencyRate, 2, '.', ' ') . ' ' . $textlineService->getUniversalTextline(1473);
             $percent = 0;
         }
         array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1262) . ' (' . $taxValue . ($reservation->getCityTaxIncluded() == 1 ? ', ' . $textlineService->getUniversalTextline(1472) : '') . ') ' . ($taxDiscounted ? $textlineService->getUniversalTextline(1633) : ''), 'price_view' => $currencySymbol . number_format($cityTax, 2, '.', ' '), 'price' => $cityTax, 'percent' => $percent, 'duration' => $cityTaxDuration, 'type' => 'tax', 'class' => 'text-primary', 'description' => $textlineService->getUniversalTextline(1432), 'tax_included' => $reservation->getCityTaxIncluded() == 1 ?: '']);
         if ($reservation->getCityTaxIncluded() != 1) {
             $totalPrice += $cityTax;
         }
     }
     /********************************************************************************************************/
     /************************************** Check Parking taxes *********************************************/
     /********************************************************************************************************/
     $matches = [];
     $parkingNights = false;
     if (preg_match('/Parking space \\(per night: (?P<nights>\\d+)n\\)/', $reservation->getRemarks(), $matches)) {
         if (!empty($matches['nights'])) {
             $parkingNights = $matches['nights'];
         }
     }
     $accommodationDao = $this->getApplicationServiceLocator()->get('dao_accommodation_accommodations');
     $this->assertInstanceOf('\\DDD\\Dao\\Accommodation\\Accommodations', $accommodationDao);
     $apartmentSpotsDao = $this->getApplicationServiceLocator()->get('dao_apartment_spots');
     $this->assertInstanceOf('\\DDD\\Dao\\Apartment\\Spots', $apartmentSpotsDao);
     $reservationNightlyDao = $this->getApplicationServiceLocator()->get('dao_booking_reservation_nightly');
     $this->assertInstanceOf('\\DDD\\Dao\\Booking\\ReservationNightly', $reservationNightlyDao);
     $apartmentGeneralService = $this->getApplicationServiceLocator()->get('service_apartment_general');
     $this->assertInstanceOf('\\DDD\\Service\\Apartment\\General', $apartmentGeneralService);
     $this->assertTrue(method_exists($reservation, 'getDateFrom'), 'Booking Object does not have method getDateFrom');
     $this->assertTrue(method_exists($reservation, 'getDateTo'), 'Booking Object does not have method getDateTo');
     $this->assertTrue(method_exists($reservation, 'getApartmentIdAssigned'), 'Booking Object does not have method getApartmentIdAssigned');
     $this->assertTrue(method_exists($apartmentSpotsDao, 'getApartmentSpots'), 'ApartmentSpotsDao Object does not have method getApartmentSpots');
     $this->assertTrue(method_exists($apartmentGeneralService, 'getApartmentTimezoneById'), 'ApartmentGeneralService Object does not have method getApartmentTimezoneById');
     $this->assertTrue(method_exists($accommodationDao, 'getAvailableSpotsInLotForApartmentForDateRangeByPriority'), 'AccommodationDao Object does not have method getAvailableSpotsInLotForApartmentForDateRangeByPriority');
     if ($parkingNights) {
         $resStartDate = $reservation->getDateFrom();
         $resEndDate = $reservation->getDateTo();
         $date1 = date_create($resStartDate);
         $date2 = date_create($resEndDate);
         $dateDiff = date_diff($date2, $date1)->d + 1;
         $nightData = $reservationNightlyDao->fetchAll(['reservation_id' => $reservation->getId()], ['id', 'price', 'date', 'rate_name']);
         $nightlyArr = [];
         foreach ($nightData as $night) {
             array_push($nightlyArr, $night);
         }
         $parkingStart = $reservation->getDateFrom();
         $parkingEnd = date('Y-m-j', strtotime($reservation->getDateFrom() . '+' . $parkingNights . ' days'));
         $newApartmentPreferedSpotId = [];
         $availableSpot = [];
         $selectedSpot = [];
         $apartmentPreferSpots = $apartmentSpotsDao->getApartmentSpots($reservation->getApartmentIdAssigned());
         if ($apartmentPreferSpots->count()) {
             foreach ($apartmentPreferSpots as $apartmentPreferSpot) {
                 array_push($newApartmentPreferedSpotId, $apartmentPreferSpot['spot_id']);
             }
             $reservationApartmentId = $reservation->getApartmentIdAssigned();
             $apartmentTimezone = $apartmentGeneralService->getApartmentTimezoneById($reservationApartmentId)['timezone'];
             $datetime = new \DateTime('now');
             $datetime->setTimezone(new \DateTimeZone($apartmentTimezone));
             $dateToday = $datetime->format('Y-m-d');
             $availableSpot = $accommodationDao->getAvailableSpotsInLotForApartmentForDateRangeByPriority($reservationApartmentId, $parkingStart, $parkingEnd, [], false, [], $dateToday, true, $newApartmentPreferedSpotId);
             if (count($availableSpot)) {
                 foreach ($availableSpot as $row) {
                     $selectedSpot = $row;
                 }
             }
         }
         $parkingTotal = 0;
         if ($dateDiff >= $parkingNights && count($availableSpot) && count($selectedSpot)) {
             for ($iterator = 0; $iterator < $parkingNights; $iterator++) {
                 $parkingTotal += $selectedSpot['price'];
             }
         }
         if ($parkingTotal > 0) {
             $parkingTotal = $currencyRate * $parkingTotal;
             $totalPrice += $parkingTotal;
             array_push($chargesList, ['label' => 'Parking', 'price_view' => $currencySymbol . number_format($parkingTotal, 2, '.', ' '), 'price' => $parkingTotal, 'percent' => 0, 'type' => 'tax', 'class' => 'text-primary', 'description' => $textlineService->getUniversalTextline(1430), 'tax_included' => $reservation->getVatIncluded() == 1 ?: '']);
         }
     }
     /********************************************************************************************************/
     /************************************** Check Cleaning Fee **********************************************/
     /********************************************************************************************************/
     $apartmentMainService = $this->getApplicationServiceLocator()->get('service_apartment_main');
     $this->assertInstanceOf('\\DDD\\Service\\Apartment\\Main', $apartmentMainService);
     $cleaningFee = $apartmentMainService->getApartmentCleaningFeeInGuestCurrency($reservation->getApartmentId(), $reservation->getApartmentCurrency(), $reservation->getGuestCurrency(), $reservation->getCheckCurrency());
     if ($cleaningFee) {
         $cleaningFee = $cleaningFee * $currencyRate;
         $totalPrice += $cleaningFee;
         array_push($chargesList, ['label' => $textlineService->getUniversalTextline(1497), 'price_view' => $currencySymbol . number_format($cleaningFee, 2, '.', ' '), 'price' => $cleaningFee, 'percent' => 0, 'type' => 'fee', 'class' => 'text-primary', 'description' => $textlineService->getUniversalTextline(1498), 'tax_included' => '']);
     }
     $testTotal = 0;
     foreach ($chargesList as $charge) {
         if (!is_bool($charge['tax_included']) || !$charge['tax_included']) {
             if ($charge['type'] == 'discount') {
                 $testTotal -= $charge['price'];
             } else {
                 $testTotal += $charge['price'];
             }
         }
     }
     $this->assertEquals($testTotal, $totalPrice);
 }