Exemple #1
0
 public function getBookingOptions($data)
 {
     /**
      * @var \DDD\Service\Booking\BookingAddon $bookingAddonService
      * @var \DDD\Dao\Partners\Partners $partnerDao
      * @var \DDD\Dao\Booking\Charge $chargeDao
      * @var \DDD\Dao\Booking\ChargeTransaction $bankTransactionDao
      * @var \DDD\Dao\ApartmentGroup\ApartmentGroup $apartmentGroupDao
      * @var ChargeAuthorizationService $chargeAuthorizationService
      * @var Psp $pspDao
      */
     $bookingAddonService = $this->getServiceLocator()->get('service_booking_booking_addon');
     $partnerDao = $this->getServiceLocator()->get('dao_partners_partners');
     $apartmentGroupDao = $this->getServiceLocator()->get('dao_apartment_group_apartment_group');
     $chargeDao = $this->getServiceLocator()->get('dao_booking_charge');
     $bankTransactionDao = $this->getServiceLocator()->get('dao_booking_change_transaction');
     $apartmentDao = $this->getServiceLocator()->get('dao_accommodation_accommodations');
     $curencyRateDao = new \DDD\Dao\Currency\Currency($this->getServiceLocator(), 'DDD\\Domain\\Booking\\Currency');
     $countryDao = new \DDD\Dao\Geolocation\Countries($this->getServiceLocator());
     $teamsDao = new \DDD\Dao\Team\Team($this->getServiceLocator());
     $statusDao = new \DDD\Dao\Booking\Statuses($this->getServiceLocator());
     $accDeailsDao = new \DDD\Dao\Apartment\Details($this->getServiceLocator(), 'ArrayObject');
     $apartmentDescriptionDao = new \DDD\Dao\Apartment\Description($this->getServiceLocator(), 'ArrayObject');
     $chargeAuthorizationService = $this->getServiceLocator()->get('service_reservation_charge_authorization');
     $detailsRow = $accDeailsDao->fetchOne(['apartment_id' => $data['apartmentIdAssigned']]);
     $accInfo = $apartmentDao->fetchOne(['id' => $data['apartmentIdAssigned']]);
     $apartmentDescription = $apartmentDescriptionDao->fetchOne(['apartment_id' => $data['apartmentIdAssigned']]);
     $result = [];
     $result['apartment']['check_in'] = $apartmentDescription['check_in'];
     $status = $data['status'];
     $countries = $countryDao->getAllActiveCountries();
     $result['countries'] = $countries;
     /**
      * @todo do not fetchAll
      * Fetch using usage service
      */
     $result['teams'] = $teamsDao->fetchAll(['usage_notifiable' => 1]);
     $affiliateID = $data['aff_id'];
     $partner = $partnerDao->getPartners($affiliateID);
     $result['partners'] = iterator_to_array($partner);
     $result['partner_data'] = $partnerDao->getPartnerModel($affiliateID);
     $statuses = $statusDao->getAllList($status);
     $result['statuses'] = iterator_to_array($statuses);
     $pspDao = $this->getServiceLocator()->get('dao_psp_psp');
     $pspList = $pspDao->getPspListForTransaction();
     $result['psp'] = iterator_to_array($pspList);
     $addonsList = $bookingAddonService->getAddons();
     $addonsArray = $bookingAddonService->getAddonsArray();
     $creditCardsForAuthorization = $chargeAuthorizationService->getCreditCardsForAuthorization($data['id']);
     $result['credit_cards_for_authorization'] = $creditCardsForAuthorization;
     if ($status == BookingService::BOOKING_STATUS_BOOKED) {
         unset($addonsArray[BookingAddon::ADDON_TYPE_PENALTY]);
     } else {
         unset($addonsArray[BookingAddon::ADDON_TYPE_ACC]);
         unset($addonsArray[BookingAddon::ADDON_TYPE_NIGHT]);
     }
     $result['addons'] = $addonsList;
     $result['addons_array'] = $addonsArray;
     $result['apartels'] = $apartmentGroupDao->getApartelsByApartmentId($data['apartmentIdAssigned']);
     $curencyRate = $curencyRateDao->fetchAll();
     $curencyRateArray = [];
     foreach ($curencyRate as $row) {
         if ($detailsRow) {
             if ((int) $detailsRow['cleaning_fee']) {
                 if ($row->getId() == $accInfo->getCurrencyId()) {
                     $cleaningFeeData = ['currency_id' => $row->getId(), 'cname' => $row->getCode(), 'currency_rate' => $row->getValue()];
                 }
             }
         }
         $curencyRateArray[] = ['code' => $row->getCode(), 'value' => $row->getValue()];
     }
     if ($detailsRow) {
         if ((int) $detailsRow['cleaning_fee']) {
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['value'] = $detailsRow['cleaning_fee'];
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['currency_id'] = $cleaningFeeData['currency_id'];
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['cname'] = $cleaningFeeData['cname'];
             $result['addons_array'][BookingAddon::ADDON_TYPE_CLEANING_FEE]['currency_rate'] = $cleaningFeeData['currency_rate'];
         }
     }
     $result['curencyRate'] = json_encode($curencyRateArray);
     $chargeType = Objects::getChargeType();
     $result['chargeType'] = $chargeType;
     $charges = $chargeDao->getChargesByReservationId($data['id'], 1);
     $result['charges'] = iterator_to_array($charges);
     $charged = $chargeDao->getChargesByReservationId($data['id'], 0);
     $result['charged'] = iterator_to_array($charged);
     $getSumAndBalance = $this->getSumAndBalanc($data['id']);
     $result['balances_and_summaries'] = $getSumAndBalance;
     $transactions = $bankTransactionDao->getReservationTransactions($data['id']);
     $result['transactions'] = $transactions->count() ? iterator_to_array($transactions) : false;
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $hasFinanceRole = $auth->hasRole(Roles::ROLE_RESERVATION_FINANCE);
     $hasPayableRole = $auth->hasRole(Roles::ROLE_BILLPAY);
     $hasTransactionVerifierRole = $auth->hasRole(Roles::ROLE_BOOKING_TRANSACTION_VERIFIER);
     $result['hasFinanceRole'] = $hasFinanceRole;
     $result['hasFinanceRole'] = $hasFinanceRole;
     $result['hasPayableRole'] = $hasPayableRole;
     $result['hasTransactionVerifierRole'] = $hasTransactionVerifierRole;
     if ($auth->hasRole(Roles::ROLE_CREDIT_CARD)) {
         $result['hasCreditCardViewer'] = true;
     }
     return $result;
 }
Exemple #2
0
 /**
  * @param $reservationsToCharge
  * @param array $params
  * @param bool $isGetInfo
  * @param bool $additionalCharges
  * @return array
  */
 public function chargeProcess($reservationsToCharge, $params = [], $isGetInfo = false, $additionalCharges = false)
 {
     /** @var \DDD\Dao\Booking\ReservationNightly $reservationNightlyDao */
     $reservationNightlyDao = $this->getServiceLocator()->get('dao_booking_reservation_nightly');
     /** @var \DDD\Service\Booking\BookingAddon $addonService */
     $addonService = $this->getServiceLocator()->get('service_booking_booking_addon');
     /** @var \DDD\Dao\Booking\Charge $chargeDao */
     $chargeDao = $this->getServiceLocator()->get('dao_booking_charge');
     /** @var \DDD\Service\Reservation\PartnerSpecific $partnerSpecificService */
     $partnerSpecificService = $this->getServiceLocator()->get('service_reservation_partner_specific');
     /** @var \DDD\Dao\Partners\Partners $partnerDao */
     $partnerDao = $this->getServiceLocator()->get('dao_partners_partners');
     /** @var \DDD\Dao\Accommodation\Accommodations $apartmentDao */
     $apartmentDao = $this->getServiceLocator()->get('dao_accommodation_accommodations');
     /** @var \DDD\Dao\Apartment\Spots $apartmentSpotsDao */
     $apartmentSpotsDao = $this->getServiceLocator()->get('dao_apartment_spots');
     $accDetailsDao = new \DDD\Dao\Apartment\Details($this->getServiceLocator(), 'ArrayObject');
     $forViewInfo = [];
     /**
      * @var int $key
      * @var \DDD\Domain\Booking\FirstCharge $reservation
      */
     foreach ($reservationsToCharge as $key => $reservation) {
         $parkingNights = $this->getParkingNightsFromRemarks($reservation->getRemarks());
         try {
             $reservationId = $reservation->getId();
             $charge = ['reservation_id' => $reservationId, 'date' => date('Y-m-d H:i:s'), 'user_id' => isset($params['user_id']) ? $params['user_id'] : Constants::DEFAULT_USER, 'acc_currency' => $reservation->getApartmentCurrencyCode(), 'apartment_id' => $reservation->getApartmentIdAssigned(), 'type' => 'n'];
             $partnerId = $reservation->getPartnerId();
             // set business model
             if ($reservation->getModel() == PartnerService::BUSINESS_MODEL_GINOSI_COLLECT) {
                 $charge['money_direction'] = Charge::CHARGE_MONEY_DIRECTION_GINOSI_COLLECT;
             } elseif (in_array($reservation->getModel(), PartnerService::partnerBusinessModel())) {
                 $charge['money_direction'] = Charge::CHARGE_MONEY_DIRECTION_PARTNER_COLLECT;
             }
             $total = $apartmentChargePrice = $apartmentAdditionalChargePrice = $chargeAddonsValue = $chargeAddonsAdditionalValue = $nightPrice = $taxTypeForCharge = 0;
             if ($isGetInfo) {
                 $nightData = [['price' => $params['price'], 'id' => 0, 'date' => '', 'rate_name' => '']];
             } elseif (isset($params['reservationNighId'])) {
                 // charge if date modified
                 $nightData = $reservationNightlyDao->fetchAll(['id' => $params['reservationNighId']], ['id', 'price', 'date', 'rate_name']);
             } else {
                 $nightData = $reservationNightlyDao->fetchAll(['reservation_id' => $reservationId, 'status' => ReservationMainService::STATUS_BOOKED], ['id', 'price', 'date', 'rate_name']);
             }
             // check partner specific commission
             $partnerCommission = $partnerSpecificService->getPartnerDeductedCommission($partnerId, $reservation->getPartnerCommission());
             $hasDiscount = false;
             // get partner discount
             $partnerInfo = $partnerDao->getPartnerById($partnerId);
             if ($partnerInfo && ceil($partnerInfo->getDiscount()) && !$reservation->getChannelName()) {
                 $hasDiscount = true;
             }
             // addon list (taxes, cleaning fee etc.)
             $addons = $addonService->getAddonsArray();
             $checkUpdateBooking = false;
             $nightlyArr = [];
             // In case of reservation modification we pass the current tax duration in params
             // In other cases we use the iterator for check.
             $taxCurrentDurations = ['tot' => isset($params['current_tot_duration']) ? $params['current_tot_duration'] : 0, 'vat' => isset($params['current_vat_duration']) ? $params['current_vat_duration'] : 0, 'city_tax' => isset($params['current_city_tax_duration']) ? $params['current_city_tax_duration'] : 0, 'sales_tax' => isset($params['current_sales_tax_duration']) ? $params['current_sales_tax_duration'] : 0];
             foreach ($nightData as $night) {
                 array_push($nightlyArr, $night);
                 $nightPrice = $night['price'];
                 if ($nightPrice > 0) {
                     // if partner specific get specific price
                     $nightPrice = $partnerSpecificService->getPartnerDeductedPrice($partnerId, $nightPrice, $reservation->getApartmentIdAssigned());
                     $rawNightPrice = $nightPrice;
                     if ($hasDiscount) {
                         $rawNightPrice = number_format($nightPrice * (100 - $partnerInfo->getDiscount()) * 0.01, 2, '.', '');
                     }
                     foreach ($addons as $addon) {
                         $taxTypeForCharge = 0;
                         if ($addon['id'] == BookingAddon::ADDON_TYPE_ACC) {
                             $apartmentChargePrice = $nightPrice;
                             $chargeAddonsValue = $chargeAddonsAdditionalValue = 0;
                         } elseif ($addon['location_join'] != '') {
                             $taxIncluded = $reservation->{'get' . ucfirst(str_replace('_t', 'T', $addon['location_join'])) . 'Included'}() == LocationService::TAX_INCLUDED;
                             $taxMaxDuration = $reservation->{'get' . ucfirst(str_replace('_t', 'T', $addon['location_join'])) . 'MaxDuration'}();
                             if (!$taxIncluded && (!$taxMaxDuration || $taxCurrentDurations[$addon['location_join']] < $taxMaxDuration)) {
                                 ++$taxCurrentDurations[$addon['location_join']];
                                 $chargeAddonsValue = $reservation->{'get' . ucfirst($addon['location_join'])}();
                                 $chargeAddonsAdditionalValue = $reservation->{'get' . ucfirst(str_replace('_t', 'T', $addon['location_join'])) . 'Additional'}();
                                 $taxType = $reservation->{'get' . ucfirst($addon['location_join']) . '_type'}();
                                 // In case we don't give commission to partner from charge additional value
                                 if ($chargeAddonsAdditionalValue && !$partnerInfo->hasAdditionalTaxCommission()) {
                                     $chargeAddonsValue += $chargeAddonsAdditionalValue;
                                     $chargeAddonsAdditionalValue = 0;
                                 }
                                 if ($taxType == Taxes::TAXES_TYPE_PERCENT) {
                                     $apartmentChargePrice = $chargeAddonsValue * $rawNightPrice / 100;
                                     $apartmentAdditionalChargePrice = $chargeAddonsAdditionalValue * $rawNightPrice / 100;
                                     $taxTypeForCharge = Taxes::TAXES_TYPE_PERCENT;
                                 } elseif ($taxType == Taxes::TAXES_TYPE_PER_NIGHT) {
                                     $apartmentChargePrice = $chargeAddonsValue;
                                     $apartmentAdditionalChargePrice = $chargeAddonsAdditionalValue;
                                     $taxTypeForCharge = Taxes::TAXES_TYPE_PER_NIGHT;
                                 } elseif ($taxType == Taxes::TAXES_TYPE_PER_PERSON) {
                                     $apartmentChargePrice = $chargeAddonsValue * $reservation->getOccupancy();
                                     $apartmentAdditionalChargePrice = $chargeAddonsAdditionalValue * $reservation->getOccupancy();
                                     $taxTypeForCharge = Taxes::TAXES_TYPE_PER_PERSON;
                                 } else {
                                     $chargeAddonsValue = 0;
                                 }
                                 $apartmentChargePrice = number_format($apartmentChargePrice, 2, '.', '');
                                 $apartmentAdditionalChargePrice = number_format($apartmentAdditionalChargePrice, 2, '.', '');
                             } else {
                                 continue;
                             }
                         } else {
                             continue;
                         }
                         if ($addon['location_join'] && $chargeAddonsValue > 0 || $addon['id'] == BookingAddon::ADDON_TYPE_ACC) {
                             $checkUpdateBooking = true;
                             $total += $apartmentChargePrice;
                             $charge['addons_type'] = $addon['id'];
                             $charge['acc_amount'] = $apartmentChargePrice;
                             $charge['addons_value'] = $chargeAddonsValue;
                             $charge['status'] = 0;
                             $charge['tax_type'] = $addon['id'] == BookingAddon::ADDON_TYPE_ACC ? 0 : $taxTypeForCharge;
                             $charge['reservation_nightly_id'] = $night['id'];
                             $charge['commission'] = $addon['default_commission'] ? $partnerCommission : 0;
                             if ($addon['id'] == BookingAddon::ADDON_TYPE_ACC) {
                                 $charge['rate_name'] = $night['rate_name'];
                             }
                             $charge['reservation_nightly_date'] = $night['date'];
                             if ($chargeAddonsAdditionalValue && $addon['location_join']) {
                                 $additionalTaxCharge = $charge;
                                 $additionalTaxCharge['acc_amount'] = $apartmentAdditionalChargePrice;
                                 $additionalTaxCharge['addons_value'] = $chargeAddonsAdditionalValue;
                                 $additionalTaxCharge['commission'] = $partnerCommission;
                             }
                             if ($isGetInfo) {
                                 if ($addon['id'] == BookingAddon::ADDON_TYPE_ACC) {
                                     $charge['rate_name'] = $params['rate_name'];
                                 }
                                 array_push($forViewInfo, $charge);
                                 if ($chargeAddonsAdditionalValue) {
                                     array_push($forViewInfo, $additionalTaxCharge);
                                 }
                             } else {
                                 $chargeDao->save($charge);
                                 if ($chargeAddonsAdditionalValue) {
                                     $chargeDao->save($additionalTaxCharge);
                                 }
                             }
                             $charge['rate_name'] = null;
                             $charge['tax_type'] = 0;
                             // Ginosik and partners Discount
                             if ($addon['id'] == BookingAddon::ADDON_TYPE_ACC) {
                                 $bookingThicketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
                                 $validDiscount = $bookingThicketService->validateAndCheckDiscountData(['email' => $reservation->getGuestEmail(), 'aff_id' => $partnerId]);
                                 if ($validDiscount['valid'] && ceil($validDiscount['discount_value'])) {
                                     $charge['addons_type'] = BookingAddon::ADDON_TYPE_DISCOUNT;
                                     $charge['acc_amount'] = -($apartmentChargePrice * $validDiscount['discount_value'] / 100);
                                     $charge['addons_value'] = $validDiscount['discount_value'];
                                     $charge['status'] = 0;
                                     $charge['tax_type'] = Taxes::TAXES_TYPE_PERCENT;
                                     $charge['commission'] = $addons[BookingAddon::ADDON_TYPE_DISCOUNT]['default_commission'] ? $partnerCommission : 0;
                                     $charge['rate_name'] = $validDiscount['discount_value'] . '%';
                                     if (!$isGetInfo) {
                                         $chargeDao->save($charge);
                                     } else {
                                         $charge['acc_amount'] = number_format(round($charge['acc_amount'], 2), 2, '.', '');
                                         $forViewInfo[] = $charge;
                                     }
                                     $charge['rate_name'] = null;
                                 }
                             }
                         }
                     }
                 }
             }
             $valueForCleaningFeeSpecification = 0;
             if (!$isGetInfo && in_array(BookingAddon::ADDON_TYPE_CLEANING_FEE, array_keys($addons)) && !isset($params['date_modify'])) {
                 $detailsRow = $accDetailsDao->fetchOne(['apartment_id' => $reservation->getApartmentIdAssigned()]);
                 if ($detailsRow && (int) $detailsRow['cleaning_fee']) {
                     $chargeAddonsValue = $detailsRow['cleaning_fee'];
                     $charge['addons_type'] = BookingAddon::ADDON_TYPE_CLEANING_FEE;
                     $charge['acc_amount'] = $chargeAddonsValue;
                     $charge['addons_value'] = $chargeAddonsValue;
                     $charge['status'] = 0;
                     $charge['tax_type'] = 0;
                     $charge['commission'] = $addons[BookingAddon::ADDON_TYPE_CLEANING_FEE]['default_commission'] ? $partnerCommission : 0;
                     $charge['reservation_nightly_id'] = 0;
                     $charge['reservation_nightly_date'] = null;
                     // cleaning fee specification
                     if ($partnerSpecificService->checkCleaningFeeSpecificationForCharge($partnerId)) {
                         $charge['commission'] = $addons[BookingAddon::ADDON_TYPE_CLEANING_FEE]['default_commission'] ? $reservation->getPartnerCommission() : 0;
                         $charge['money_direction'] = Charge::CHARGE_MONEY_DIRECTION_GINOSI_COLLECT;
                         $valueForCleaningFeeSpecification = $chargeAddonsValue;
                     }
                     $chargeDao->save($charge);
                     $total += $chargeAddonsValue;
                 }
             }
             if ($parkingNights && !$additionalCharges) {
                 $resStartDate = $reservation->getDate_from();
                 $resEndDate = $reservation->getDateTo();
                 $date1 = date_create($resStartDate);
                 $date2 = date_create($resEndDate);
                 $dateDiff = date_diff($date2, $date1)->d + 1;
                 //parking nights are more than reservation nights
                 /**
                  * @var \DDD\Service\Parking\Spot\Inventory $parkingInventoryService
                  * @var \DDD\Dao\Parking\Spot\Inventory $parkingInventoryDao
                  */
                 $parkingInventoryDao = $this->getServiceLocator()->get('dao_parking_spot_inventory');
                 $parkingStart = $reservation->getDate_from();
                 $parkingEnd = date('Y-m-j', strtotime($reservation->getDate_from() . '+' . $parkingNights . ' days'));
                 // $availableSpot           = $parkingInventoryService->getAvailableSpotForApartment($reservation->getApartmentIdAssigned(), $parkingStart, $parkingEnd);
                 $newApartmentPreferedSpotId = [];
                 $availableSpot = $selectedSpot = [];
                 $apartmentPreferSpots = $apartmentSpotsDao->getApartmentSpots($reservation->getApartmentIdAssigned());
                 if ($apartmentPreferSpots->count()) {
                     foreach ($apartmentPreferSpots as $apartmentPreferSpot) {
                         array_push($newApartmentPreferedSpotId, $apartmentPreferSpot['spot_id']);
                     }
                     $reservationApartmentId = $reservation->getApartmentIdAssigned();
                     $apartmentService = $this->getServiceLocator()->get('service_apartment_general');
                     $apartmentTimezone = $apartmentService->getApartmentTimezoneById($reservationApartmentId)['timezone'];
                     $datetime = new \DateTime('now');
                     $datetime->setTimezone(new \DateTimeZone($apartmentTimezone));
                     $dateToday = $datetime->format('Y-m-d');
                     $availableSpot = $apartmentDao->getAvailableSpotsInLotForApartmentForDateRangeByPriority($reservationApartmentId, $parkingStart, $parkingEnd, [], false, [], $dateToday, true, $newApartmentPreferedSpotId);
                     if (count($availableSpot)) {
                         foreach ($availableSpot as $row) {
                             $selectedSpot = $row;
                         }
                     }
                 }
                 if ($dateDiff < $parkingNights || !count($availableSpot)) {
                     $taskService = $this->getServiceLocator()->get('service_task');
                     $taskService->parkingIssueTask($reservationId, $reservation->getApartmentIdAssigned(), $resStartDate);
                 }
                 if ($dateDiff >= $parkingNights && count($availableSpot) && count($selectedSpot)) {
                     $parkingCharge = ['reservation_id' => $reservationId, 'date' => date('Y-m-d H:i:s'), 'user_id' => isset($params['user_id']) ? $params['user_id'] : Constants::DEFAULT_USER, 'acc_currency' => $reservation->getApartmentCurrencyCode(), 'apartment_id' => $reservation->getApartmentIdAssigned(), 'type' => 'n', 'addons_type' => BookingAddon::ADDON_TYPE_PARKING, 'acc_amount' => $selectedSpot['price'], 'rate_name' => $selectedSpot['unit'] . '(' . $selectedSpot['name'] . ')', 'status' => 0, 'addons_value' => 0, 'entity_id' => $selectedSpot['parking_spot_id'], 'tax_type' => 0, 'commission' => $addons[BookingAddon::ADDON_TYPE_PARKING]['default_commission'] ? $partnerCommission : 0, 'money_direction' => Charge::CHARGE_MONEY_DIRECTION_GINOSI_COLLECT];
                     for ($iterator = 0; $iterator < $parkingNights; $iterator++) {
                         if (!empty($nightlyArr[$iterator])) {
                             $parkingCharge['reservation_nightly_id'] = $nightlyArr[$iterator]['id'];
                             $parkingCharge['reservation_nightly_date'] = $nightlyArr[$iterator]['date'];
                             $chargeDao->save($parkingCharge);
                             $total += $selectedSpot['price'];
                             $parkingInventoryDao->save(['availability' => 0], ['spot_id' => $parkingCharge['entity_id'], 'date' => $parkingCharge['reservation_nightly_date']]);
                         }
                     }
                 }
             }
             // update guest balance or partner balance according to ticket model
             if (!$isGetInfo && $checkUpdateBooking) {
                 $this->updateBalance($reservationId, true);
             }
         } catch (\Exception $e) {
             $this->gr2logException($e, 'Charge Process fail', ['reservation_id' => $reservation->getId(), 'reservation_number' => $reservation->getReservationNumber()]);
         }
     }
     return $forViewInfo;
 }
Exemple #3
0
 /**
  * @param $bookingId
  * @param $itemId
  * @return array
  */
 public function getDataForFrontierCharge($bookingId, $itemId)
 {
     /**
      * @var \DDD\Service\Booking\BookingAddon $bookingAddonService
      * @var \DDD\Dao\Booking\Booking $bookingDao
      * @var \DDD\Service\Taxes $taxesService
      */
     $bookingTicketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
     $bookingAddonService = $this->getServiceLocator()->get('service_booking_booking_addon');
     $taxesService = $this->getServiceLocator()->get('service_taxes');
     $apartmentGroupDao = $this->getServiceLocator()->get('dao_apartment_group_apartment_group');
     $chargeDao = $this->getServiceLocator()->get('dao_booking_charge');
     $bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
     $accDetailsDao = new \DDD\Dao\Apartment\Details($this->getServiceLocator(), 'ArrayObject');
     $addonsArray = $bookingAddonService->getAddonsArray();
     $bookingData = $bookingDao->getBookingForFrontierCharge($bookingId);
     $detailsRow = $accDetailsDao->fetchOne(['apartment_id' => $bookingData['apartment_id_assigned']]);
     if ($detailsRow && (int) $detailsRow['cleaning_fee']) {
         foreach ($addonsArray as $key => $addon) {
             if ($addon['id'] == BookingAddon::ADDON_TYPE_CLEANING_FEE) {
                 $cleaningFee = $detailsRow['cleaning_fee'];
                 $addonsArray[$key]['cname'] = $bookingData['acc_currency_sign'];
                 $addonsArray[$key]['currency_rate'] = $bookingData['acc_currency_rate'];
                 $addonsArray[$key]['currency_id'] = $bookingData['acc_currency_id'];
                 $addonsArray[$key]['value'] = $cleaningFee;
             }
         }
     }
     $data = ['addons_array' => $addonsArray];
     $data['booking_data'] = $bookingData;
     $data['booking_data']['night_count'] = Helper::getDaysFromTwoDate($bookingData['date_to'], $bookingData['date_from']);
     // Taxes
     $nightCount = Helper::getDaysFromTwoDate($bookingData['date_to'], $bookingData['date_from']);
     $taxesParams = ['tot' => $bookingData['tot'], 'tot_type' => $bookingData['tot_type'], 'tot_included' => $bookingData['tot_included'], 'tot_max_duration' => $bookingData['tot_max_duration'], 'tot_additional' => $bookingData['tot_additional'], 'vat' => $bookingData['vat'], 'vat_type' => $bookingData['vat_type'], 'vat_included' => $bookingData['vat_included'], 'vat_additional' => $bookingData['vat_additional'], 'vat_max_duration' => $bookingData['vat_max_duration'], 'city_tax' => $bookingData['city_tax'], 'city_tax_type' => $bookingData['city_tax_type'], 'city_tax_included' => $bookingData['city_tax_included'], 'city_tax_additional' => $bookingData['city_tax_additional'], 'city_tax_max_duration' => $bookingData['city_tax_max_duration'], 'sales_tax' => $bookingData['sales_tax'], 'sales_tax_type' => $bookingData['sales_tax_type'], 'sales_tax_included' => $bookingData['sales_tax_included'], 'sales_tax_max_duration' => $bookingData['sales_tax_max_duration'], 'sales_tax_additional' => $bookingData['sales_tax_additional'], 'apartment_currency' => $bookingData['apartment_currency_code'], 'customer_currency' => $bookingData['guest_currency_code'], 'country_currency' => $bookingData['country_currency'], 'night_count' => $nightCount, 'rate_capacity' => $bookingData['rate_capacity'], 'occupancy' => $bookingData['occupancy']];
     $taxesData = $taxesService->getTaxesForCharge($taxesParams);
     $data += $taxesData;
     $apartmentGroup = $apartmentGroupDao->fetchOne(['id' => $itemId]);
     // Charges
     $charges = $chargeDao->getChargesByReservationId($bookingId, 1);
     $data['charges'] = $charges;
     $balances = $bookingTicketService->getSumAndBalanc($bookingId);
     $balance = number_format($balances['ginosiBalanceInApartmentCurrency'], 2, '.', '');
     $data['balance'] = $balance;
     $data['group_name'] = 'Group';
     if ($apartmentGroup) {
         $data['group_name'] = $apartmentGroup->getName();
     }
     return $data;
 }