Exemplo n.º 1
0
 /**
  * @param \DDD\Domain\Booking\BookingTicket $data
  * @param array $formData
  *
  * @return array
  */
 public function prepareData($data, $formData)
 {
     /**
      * @var ReviewBooking $review
      * @var \DDD\Service\Reservation\PartnerSpecific $partnerSpecificService
      * @var \DDD\Service\Booking\Charge $bookingChargeService
      * @var \DDD\Dao\Booking\Booking $bookingDao
      */
     $partnerSpecificService = $this->getServiceLocator()->get('service_reservation_partner_specific');
     $daoReview = new \DDD\Dao\Accommodation\Review($this->getServiceLocator(), 'DDD\\Domain\\Review\\ReviewBooking');
     $bookingChargeService = $this->getServiceLocator()->get('service_booking_charge');
     $cityService = $this->getServiceLocator()->get('service_location');
     $bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
     $bookingDao->setEntity(new \DDD\Domain\Booking\PrepareData());
     $dataOther = [];
     $reservationId = $data->getId();
     $startDate = $data->getDate_from();
     $endDate = $data->getDate_to();
     $review_res_number = $data->getResNumber();
     $review = $daoReview->fetchOne(['res_number' => $review_res_number]);
     if ($review) {
         $data->setHas_review(true);
     } else {
         $data->setHas_review(false);
     }
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $dataOther['credit_card_view'] = false;
     if ($auth->hasRole(Roles::ROLE_CREDIT_CARD)) {
         $dataOther['credit_card_view'] = true;
         $dataOther['secure_url'] = "https://" . DomainConstants::WS_SECURE_DOMAIN_NAME . "/booking/update-cc-details?code=" . $formData['data']->getProvideCcPageHash();
     }
     if ($auth->hasRole(Roles::ROLE_RESERVATIONS)) {
         $dataOther['reservation_role'] = true;
     } else {
         $bookingService = $this->getServiceLocator()->get('service_booking');
         $part = $bookingService->getPartnerById($data->getPartnerId());
         $dataOther['affiliate'] = $part->getPartnerName();
     }
     $keyPageStatus = '';
     if (!Helper::checkDatesByDaysCount(1, $data->getDate_to())) {
         $keyPageStatus = "Expired";
     } elseif ($data->getKiPageStatus() == 1) {
         $kiPageHash = $data->getKiPageHash();
         $keyPageStatus = "<a target='_blank'  href='https://" . DomainConstants::WS_SECURE_DOMAIN_NAME . '/key?view=0&code=' . $kiPageHash . "' >Key Entry Link</a>";
     } elseif (!$data->getKiPageStatus()) {
         $keyPageStatus = "Not set yet";
     }
     $is_penalty_applied = $this->isPenaltyApplied($data->getDate_from(), $data->getIsRefundable(), $data->getRefundableBeforeHours());
     $penalty_period = $this->calculateCancelationPeriod($data->getStatus(), $data->getCancelation_date(), $data->getDate_to(), $is_penalty_applied);
     $dataOther['keyPageStatus'] = $keyPageStatus;
     $dataOther['penalty_period'] = $penalty_period;
     $penalty_val = number_format(str_replace(",", ".", $data->getPenalty_val()), 2, '.', '');
     $penalty = number_format(str_replace(",", ".", $data->getPenalty()), 2, '.', '');
     if (Rate::APARTMENT_RATE_REFUNDABLE == $data->getIsRefundable()) {
         if ($data->getRefundableBeforeHours() > 48) {
             $dataOther['cancellation'] = "This deal can be canceled for FREE up to " . $data->getRefundableBeforeHours() / 24 . " days before arrival";
         } else {
             $dataOther['cancellation'] = "This deal can be canceled for FREE up to " . $data->getRefundableBeforeHours() . " hours before arrival";
         }
     } else {
         $dataOther['cancellation'] = 'Non refundable';
     }
     $dataOther['panelty_type'] = Helper::getPenalty($penalty, $penalty_val, $data->getApartmentCurrencyCode());
     foreach ($formData['options']['statuses'] as $row) {
         if ($row->getId() == $data->getStatus()) {
             $dataOther['status_name'] = $row->getName();
             break;
         }
     }
     foreach ($formData['options']['partners'] as $row) {
         if ($row->getGid() == $data->getPartnerId()) {
             $dataOther['partner_name'] = $row->getPartnerName();
             $dataOther['partner_id'] = $data->getPartnerId();
             break;
         }
     }
     $customerReservations = $bookingDao->getCustomerReservationsStatuses($data->getGuestEmail());
     $bookedReservationsCount = 0;
     $cancelledReservationsCount = 0;
     $hasDebtBalance = false;
     foreach ($customerReservations as $customerReservation) {
         if (!$hasDebtBalance && $customerReservation->getBalance() < 0 && $data->getResNumber() != $customerReservation->getResNumber()) {
             $hasDebtBalance = true;
         }
         if ($customerReservation->getStatus() == BookingService::BOOKING_STATUS_BOOKED) {
             $bookedReservationsCount++;
         } else {
             $cancelledReservationsCount++;
         }
     }
     $dataOther['pendingCreditCardInQueue'] = false;
     $pendingCreditCardInQueue = $bookingDao->getPendingInQueueCardsByReservationId($reservationId);
     if ($pendingCreditCardInQueue->count()) {
         $dataOther['pendingCreditCardInQueue'] = true;
     }
     /**
      * @var \DDD\Service\Fraud $fraudService
      */
     $fraudService = $this->getServiceLocator()->get('service_fraud');
     $fraud = $fraudService->getFraudForReservation($reservationId);
     $dataOther['terminals'] = Objects::getTerminalList();
     $dataOther['addons'] = $formData['options']['addons'];
     $dataOther['addons_array'] = $formData['options']['addons_array'];
     $dataOther['fraud'] = $fraud;
     $dataOther['psp'] = [];
     $dataOther['curencyRate'] = $formData['options']['curencyRate'];
     $dataOther['charges'] = $formData['options']['charges'];
     $dataOther['charged'] = $formData['options']['charged'];
     $dataOther['chargeType'] = $formData['options']['chargeType'];
     $dataOther['transactions'] = $formData['options']['transactions'];
     $dataOther['ginosiCollectChargesSummaryInApartmentCurrency'] = $formData['options']['balances_and_summaries']['ginosiCollectChargesSummaryInApartmentCurrency'];
     $dataOther['ginosiCollectChargesSummaryInCustomerCurrency'] = $formData['options']['balances_and_summaries']['ginosiCollectChargesSummaryInCustomerCurrency'];
     $dataOther['partnerCollectChargesSummaryInApartmentCurrency'] = $formData['options']['balances_and_summaries']['partnerCollectChargesSummaryInApartmentCurrency'];
     $dataOther['partnerCollectChargesSummaryInCustomerCurrency'] = $formData['options']['balances_and_summaries']['partnerCollectChargesSummaryInCustomerCurrency'];
     $dataOther['ginosiCollectTransactionsSummaryInApartmentCurrency'] = $formData['options']['balances_and_summaries']['ginosiCollectTransactionsSummaryInApartmentCurrency'];
     $dataOther['ginosiCollectTransactionsSummaryInCustomerCurrency'] = $formData['options']['balances_and_summaries']['ginosiCollectTransactionsSummaryInCustomerCurrency'];
     $dataOther['partnerCollectTransactionsSummaryInApartmentCurrency'] = $formData['options']['balances_and_summaries']['partnerCollectTransactionsSummaryInApartmentCurrency'];
     $dataOther['partnerCollectTransactionsSummaryInCustomerCurrency'] = $formData['options']['balances_and_summaries']['partnerCollectTransactionsSummaryInCustomerCurrency'];
     $dataOther['chargesSummaryInApartmentCurrency'] = $formData['options']['balances_and_summaries']['chargesSummaryInApartmentCurrency'];
     $dataOther['chargesSummaryInCustomerCurrency'] = $formData['options']['balances_and_summaries']['chargesSummaryInCustomerCurrency'];
     $dataOther['transactionsSummaryInApartmentCurrency'] = $formData['options']['balances_and_summaries']['transactionsSummaryInApartmentCurrency'];
     $dataOther['transactionsSummaryInCustomerCurrency'] = $formData['options']['balances_and_summaries']['transactionsSummaryInCustomerCurrency'];
     $dataOther['ginosiBalanceInApartmentCurrency'] = $formData['options']['balances_and_summaries']['ginosiBalanceInApartmentCurrency'];
     $dataOther['ginosiBalanceInCustomerCurrency'] = $formData['options']['balances_and_summaries']['ginosiBalanceInCustomerCurrency'];
     $dataOther['partnerBalanceInApartmentCurrency'] = $formData['options']['balances_and_summaries']['partnerBalanceInApartmentCurrency'];
     $dataOther['partnerBalanceInCustomerCurrency'] = $formData['options']['balances_and_summaries']['partnerBalanceInCustomerCurrency'];
     $dataOther['resCount'] = $bookedReservationsCount;
     $dataOther['cancelCount'] = $cancelledReservationsCount;
     $dataOther['hasDebtBalance'] = $hasDebtBalance;
     $dataOther['hasPayableRole'] = $formData['options']['hasPayableRole'];
     $dataOther['hasTransactionVerifierRole'] = $formData['options']['hasTransactionVerifierRole'];
     $dataOther['creditCardsForAuthorization'] = $formData['options']['credit_cards_for_authorization'];
     //Calculate Taxes
     $nightCount = Helper::getDaysFromTwoDate($data->getDate_to(), $data->getDate_from());
     /** @var \DDD\Service\Taxes $taxesService */
     $taxesService = $this->getServiceLocator()->get('service_taxes');
     $taxesParams = ['tot' => $data->getTot(), 'tot_type' => $data->getTotType(), 'tot_included' => $data->getTotIncluded(), 'tot_additional' => $data->getTotAdditional(), 'tot_max_duration' => $data->getTotMaxDuration(), 'vat' => $data->getVat(), 'vat_type' => $data->getVatType(), 'vat_included' => $data->getVatIncluded(), 'vat_additional' => $data->getVatAdditional(), 'vat_max_duration' => $data->getVatMaxDuration(), 'city_tax' => $data->getCity_tax(), 'city_tax_type' => $data->getCityTaxType(), 'city_tax_included' => $data->getCityTaxIncluded(), 'city_tax_additional' => $data->getCityTaxAdditional(), 'city_tax_max_duration' => $data->getCityTaxMaxDuration(), 'sales_tax' => $data->getSales_tax(), 'sales_tax_type' => $data->getSalesTaxType(), 'sales_tax_included' => $data->getSalesTaxIncluded(), 'sales_tax_additional' => $data->getSalesTaxAdditional(), 'sales_tax_max_duration' => $data->getSalesTaxMaxDuration(), 'apartment_currency' => $data->getApartmentCurrencyCode(), 'customer_currency' => $data->getGuestCurrencyCode(), 'country_currency' => $data->getCountryCurrecny(), 'night_count' => $nightCount, 'rate_capacity' => $data->getRateCapacity(), 'occupancy' => $data->getOccupancy()];
     $taxesData = $taxesService->getTaxesForCharge($taxesParams);
     $dataOther += $taxesData;
     /**
      * @var \DDD\Service\Booking\ReservationIssues $reservationIssuesService
      */
     $reservationIssuesService = $this->getServiceLocator()->get('service_booking_reservation_issues');
     $issuesData = $reservationIssuesService->getReservationIssues($reservationId);
     $dataOther['hasIssues'] = false;
     $dataOther['hasIssuesText'] = '';
     if (count($issuesData) > 0) {
         $dataOther['hasIssuesText'] .= '<p>' . TextConstants::ISSUE_DETECTED_FOLLOWING . ':<br>';
         foreach ($issuesData as $issue) {
             $dataOther['hasIssuesText'] .= '<li>' . $issue->getTitle() . '</li>';
         }
         $dataOther['hasIssuesText'] .= '</p>';
         $dataOther['hasIssues'] = true;
     }
     /**
      * @var Card $cardService
      */
     $cardService = $this->getServiceLocator()->get('service_card');
     $customerCreditCards = $cardService->getCustomerCreditCardsForReservationTicket($data->getCustomerId());
     $creditCardsMerge = $customerCreditCards;
     $dataOther['hasValidCard'] = $creditCardsMerge['hasValidCard'];
     foreach ($formData['options']['psp'] as $psp) {
         array_push($dataOther['psp'], $psp);
     }
     /**
      * @var \DDD\Dao\MoneyAccount\MoneyAccount $moneyAccountDao
      */
     $moneyAccountDao = $this->getServiceLocator()->get('dao_money_account_money_account');
     $moneyAccountList = $moneyAccountDao->getActiveBankList();
     $dataOther['money_account_list'] = $moneyAccountList;
     $dataOther['person_account_list'] = $moneyAccountDao->getActivePersonList();
     /**
      * @var \DDD\Dao\Booking\ReservationNightly $reservationNightlyDao
      * @var \DDD\Dao\Apartment\Rate $apartmentRateDao
      */
     $reservationNightlyDao = $this->getServiceLocator()->get('dao_booking_reservation_nightly');
     $apartmentRateDao = $this->getServiceLocator()->get('dao_apartment_rate');
     // get nightly data
     $nightsData = $reservationNightlyDao->getNightsDateWithCharge($reservationId);
     $nightsParse = $dates = $ratesPriceByDateParse = [];
     foreach ($nightsData as $night) {
         $dates[] = $night['date'];
         // if partner specific get specific price
         $priceForNight = $partnerSpecificService->getPartnerDeductedPrice($data->getPartnerId(), $night['price'], $data->getApartmentIdAssigned());
         $nightsParse["_" . $night['id']] = ['reservation_nightly_id' => $night['id'], 'apartment_id' => $night['apartment_id'], 'rate_id' => $night['rate_id'], 'rate_name' => $night['rate_name'], 'price' => $priceForNight, 'date' => $night['date']];
         if ($night['charge_id']) {
             $ratesPriceByDateParse[$night['date']][] = ['id' => $night['rate_id'], 'rate_name' => $night['rate_name'] . ' *', 'price' => $night['price'], 'date' => $night['date']];
         }
     }
     // check is apartel
     $apartel = $bookingDao->checkIsApartel($reservationId);
     // get rate data by date
     if ($apartel) {
         /** @var \DDD\Dao\Apartel\Rate $apartelRateDao */
         $apartelRateDao = $this->getServiceLocator()->get('dao_apartel_rate');
         $ratesPriceByDate = $apartelRateDao->getRatesPriceByDate($data->getRoom_id(), $dates);
     } else {
         $ratesPriceByDate = $apartmentRateDao->getRatesPriceByDate($data->getApartmentIdAssigned(), $dates);
     }
     foreach ($ratesPriceByDate as $rate) {
         $ratesPriceByDateParse[$rate['date']][] = ['id' => $rate['id'], 'rate_name' => $rate['rate_name'], 'price' => $rate['price'], 'date' => $rate['date']];
     }
     // date list
     $current = strtotime($data->getDate_from());
     $last = strtotime($data->getDate_to());
     $dateList = [];
     $k = 1;
     while ($current < $last) {
         $dateList[$k] = date('Y-m-d', $current);
         $current = strtotime('+1 day', $current);
         $k++;
     }
     $dataOther['dateList'] = json_encode($dateList);
     // get near reservation dates
     $usedFrom = $data->getDate_from();
     $usedTo = $data->getDate_to();
     /**
      * @var \DDD\Dao\Apartment\Inventory $inventoryDao
      */
     $beforeDate = date('Y-m-d', strtotime('-10 day', strtotime($usedFrom)));
     $afterDate = date('Y-m-d', strtotime('+10 day', strtotime($usedTo)));
     $inventoryDao = $this->getServiceLocator()->get('dao_apartment_inventory');
     $dateAvListBeforeAfterReservation = $inventoryDao->getDateAvListBeforeAfterReservation($data->getApartmentIdAssigned(), $beforeDate, $afterDate);
     $dateListParseCheckIn = $dateListParseCheckOut = [];
     $classHighlight = '';
     foreach ($dateAvListBeforeAfterReservation as $row) {
         if ($row['availability'] == 1) {
             $classHighlight = 'date-open';
         } else {
             $classHighlight = 'date-closed';
         }
         if ($row['date'] >= $usedFrom && $row['date'] <= $usedTo) {
             $classHighlight = 'date-open date-used';
         }
         $dateListParseCheckIn[$row['date']] = ['date' => $row['date'], 'class' => $classHighlight, 'availability' => $row['availability']];
     }
     foreach ($dateListParseCheckIn as $row) {
         $dateForCheckout = date('Y-m-d', strtotime('-1 day', strtotime($row['date'])));
         if (!isset($dateListParseCheckIn[$dateForCheckout]['availability'])) {
             continue;
         }
         if ($dateListParseCheckIn[$dateForCheckout]['availability'] == 1) {
             $classHighlight = 'date-open';
         } else {
             $classHighlight = 'date-closed';
         }
         if ($dateForCheckout >= $usedFrom && $dateForCheckout < $usedTo) {
             $classHighlight = 'date-open';
         }
         if ($row['date'] >= $usedFrom && $row['date'] <= $usedTo) {
             $classHighlight .= ' date-used';
         }
         $dateListParseCheckOut[$dateForCheckout] = ['date' => $row['date'], 'class' => $classHighlight];
     }
     $dataOther['dateForHighlightsCheckIn'] = json_encode($dateListParseCheckIn);
     $dataOther['dateForHighlightsCheckOut'] = json_encode($dateListParseCheckOut);
     // calculate total apartment and taxes
     $totalApartmentView = [];
     $totalChargeType = [BookingAddon::ADDON_TYPE_ACC, BookingAddon::ADDON_TYPE_TAX_TOT, BookingAddon::ADDON_TYPE_TAX_VAT, BookingAddon::ADDON_TYPE_CITY_TAX, BookingAddon::ADDON_TYPE_SALES_TAX, BookingAddon::ADDON_TYPE_DISCOUNT, BookingAddon::ADDON_TYPE_PARKING];
     $value = '';
     $hasReversedCharges = false;
     /** @var \DDD\Domain\Booking\Charge $row */
     foreach ($dataOther['charged'] as $row) {
         if ($row->getStatus() == ChargesServices::CHARGE_STATUS_DELETED) {
             $hasReversedCharges = true;
         }
         if (in_array($row->getAddons_type(), $totalChargeType) && $row->getAddons_type() != BookingAddon::ADDON_TYPE_PARKING && $row->getStatus() == ChargesServices::CHARGE_STATUS_NORMAL && (int) $row->getReservationNightlyId()) {
             if (($row->getAddons_type() == BookingAddon::ADDON_TYPE_ACC || $row->getAddons_type() == BookingAddon::ADDON_TYPE_ACC) && $row->getRateName()) {
                 $value = $row->getRateName();
             } elseif ($row->getAddons_value() > 0) {
                 $value = $row->getAddons_value();
                 if ($row->getTaxType() == TaxesServices::TAXES_TYPE_PERCENT) {
                     $value .= ' %';
                 } elseif ($row->getTaxType() == TaxesServices::TAXES_TYPE_PER_NIGHT) {
                     $value .= ' p/n';
                 } elseif ($row->getTaxType() == TaxesServices::TAXES_TYPE_PER_PERSON) {
                     $value .= ' p/p';
                 }
             }
             if (!isset($totalApartmentView[$row->getAddons_type()])) {
                 $totalApartmentView[$row->getAddons_type()] = ['name' => $row->getAddon(), 'dateMin' => $row->getReservationNightlyDate(), 'dateMax' => $row->getReservationNightlyDate(), 'value' => $value, 'price' => $row->getAcc_amount(), 'collection' => ChargesServices::$moneyDirectionOptions[$row->getMoneyDirection()], 'commission' => $row->getCommission()];
             } else {
                 $totalApartmentView[$row->getAddons_type()]['price'] += $row->getAcc_amount();
                 if ($totalApartmentView[$row->getAddons_type()]['dateMin'] > $row->getReservationNightlyDate()) {
                     $totalApartmentView[$row->getAddons_type()]['dateMin'] = $row->getReservationNightlyDate();
                 }
                 if ($totalApartmentView[$row->getAddons_type()]['dateMax'] < $row->getReservationNightlyDate()) {
                     $totalApartmentView[$row->getAddons_type()]['dateMax'] = $row->getReservationNightlyDate();
                 }
             }
         }
     }
     //creating an array where spot names are keys
     //and values are arrays with all dates
     //Example :
     //            [spot1] => Array
     //            (
     //                  [0] => 2015-07-22
     //                  [1] => 2015-07-23
     //                  [2] => 2015-07-25
     //                  [3] => 2015-07-26
     //                  [4] => 2015-07-27
     //                  [5] => 2015-07-28
     //                  [6] => 2015-07-29
     //                  [7] => 2015-07-30
     //                  [8] => 2015-07-31
     //                  [9] => 2015-08-01
     //            )
     //             [spot2] => Array
     //            (
     //                  [0] => 2015-07-22
     //                  [1] => 2015-07-23
     //                  [2] => 2015-07-24
     //                  [3] => 2015-08-01
     //            )
     $AllParkingSpotDatesArray = [];
     foreach ($dataOther['charged'] as $row) {
         if ($row->getAddons_type() == BookingAddon::ADDON_TYPE_PARKING && $row->getStatus() == ChargesServices::CHARGE_STATUS_NORMAL && (int) $row->getReservationNightlyId()) {
             if (!isset($AllParkingSpotDatesArray[$row->getRateName()])) {
                 $AllParkingSpotDatesArray[$row->getRateName()] = [];
             }
             array_push($AllParkingSpotDatesArray[$row->getRateName()], $row->getReservationNightlyDate());
         }
     }
     //sorting spot level arrays by date
     foreach ($AllParkingSpotDatesArray as &$singleSpotDatesForSort) {
         sort($singleSpotDatesForSort);
     }
     //creating an array where keys are spot names
     //and the values are array containing arrays of date ranges
     //Example:
     //    [spot1] => Array
     //    (
     //        [0] => Array
     //        (
     //            [0] => 2015-07-22
     //            [1] => 2015-07-23
     //         )
     //        [1] => Array
     //         (
     //            [0] => 2015-07-25
     //            [1] => 2015-07-26
     //            [2] => 2015-07-27
     //            [3] => 2015-07-28
     //            [4] => 2015-07-29
     //            [5] => 2015-07-30
     //            [6] => 2015-07-31
     //            [7] => 2015-08-01
     //          )
     //    )
     //    [spot2] => Array
     //    (
     //        [0] => Array
     //        (
     //            [0] => 2015-07-22
     //            [1] => 2015-07-23
     //            [2] => 2015-07-24
     //        )
     //        [1] => Array
     //        (
     //            [0] => 2015-08-01
     //        )
     //    )
     $allParkingSpotDatesArrayByDateRanges = [];
     $secondsInOneDay = 86400;
     foreach ($AllParkingSpotDatesArray as $rowKey => $singleSpotDates) {
         $i = 0;
         $k = 0;
         $allParkingSpotDatesArrayByDateRanges[$rowKey] = [];
         foreach ($singleSpotDates as $date) {
             if ($i == 0) {
                 $allParkingSpotDatesArrayByDateRanges[$rowKey][$k] = [$date];
             } else {
                 $differenceBetweenDatesInSeconds = strtotime($date) - strtotime($singleSpotDates[$i - 1]);
                 if ($differenceBetweenDatesInSeconds != $secondsInOneDay) {
                     $k++;
                 }
                 if (!isset($allParkingSpotDatesArrayByDateRanges[$rowKey][$k])) {
                     $allParkingSpotDatesArrayByDateRanges[$rowKey][$k] = [];
                 }
                 array_push($allParkingSpotDatesArrayByDateRanges[$rowKey][$k], $date);
             }
             $i++;
         }
     }
     $combinedArray = [];
     foreach ($allParkingSpotDatesArrayByDateRanges as $spotName => $parkingSpotDateRangeItem) {
         foreach ($parkingSpotDateRangeItem as $dateRanges) {
             array_push($combinedArray, ['spot' => $spotName, 'dateStart' => min($dateRanges), 'dateEnd' => max($dateRanges)]);
         }
     }
     foreach ($dataOther['charged'] as $row) {
         if ($row->getAddons_type() == BookingAddon::ADDON_TYPE_PARKING && $row->getStatus() == ChargesServices::CHARGE_STATUS_NORMAL && (int) $row->getReservationNightlyId()) {
             foreach ($combinedArray as &$item) {
                 if ($row->getRateName() == $item['spot'] && $row->getReservationNightlyDate() >= $item['dateStart'] && $row->getReservationNightlyDate() <= $item['dateEnd']) {
                     if (!isset($item['price'])) {
                         $item['price'] = 0;
                     }
                     $item['price'] += $row->getAcc_amount();
                     $item['collection'] = ChargesServices::$moneyDirectionOptions[$row->getMoneyDirection()];
                     $item['commission'] = $row->getCommission();
                     $item['value'] = $item['spot'];
                     $item['name'] = 'Parking';
                     break;
                 }
             }
         }
     }
     foreach ($combinedArray as &$it) {
         $it['date'] = date(Constants::GLOBAL_DATE_WO_YEAR, strtotime($it['dateStart'])) . ' - ' . date(Constants::GLOBAL_DATE_WO_YEAR, strtotime($it['dateEnd'] . ' + 1 day'));
     }
     $dataOther['totalChargeView'] = $totalApartmentView;
     array_push($dataOther['totalChargeView'], $combinedArray);
     $dataOther['totalChargeType'] = $totalChargeType;
     $dataOther['hasReversedCharges'] = $hasReversedCharges;
     $dataOther['penaltyPrice'] = 0;
     if (array_key_exists(0, $dataOther['totalChargeView']) && !$data->getCheckCharged()) {
         $refundLimitDay = $data->getRefundableBeforeHours() / 24;
         $currentCityDate = $cityService->getCurrentDateCity($data->getApartmentCityId());
         $accomodationPrice = $data->getBooker_price();
         $dataOther['penaltyPrice'] = number_format($accomodationPrice, 2, '.', '');
         if ((strtotime($data->getDate_from()) - strtotime(date('Y-m-d', strtotime($currentCityDate)))) / 86400 > $refundLimitDay) {
             $penaltyPercent = $data->getPenalty_val() * 0.01;
             $penaltyPrice = round($data->getBooker_price() * $penaltyPercent, 2);
             $dataOther['penaltyPrice'] = number_format($penaltyPrice, 2, '.', '');
         }
     }
     if (array_key_exists(BookingAddon::ADDON_TYPE_ACC, $dataOther['totalChargeView'])) {
         $accomodationPrice = number_format($dataOther['totalChargeView'][BookingAddon::ADDON_TYPE_ACC]['price'], 2, '.', '');
         $dataOther['penaltyPrice'] = $accomodationPrice;
         if ($data->getPenalty()) {
             $penaltyPrice = $accomodationPrice - $bookingChargeService->recalculatePenalty($reservationId, $accomodationPrice);
             $dataOther['penaltyPrice'] = number_format($penaltyPrice, 2, '.', '');
             $refundLimitDay = $data->getRefundableBeforeHours() / 24;
             $currentCityDate = $cityService->getCurrentDateCity($data->getApartmentCityId());
             if ((strtotime($data->getDate_from()) - strtotime(date('Y-m-d', strtotime($currentCityDate)))) / 86400 < $refundLimitDay) {
                 $dataOther['penaltyPrice'] = $accomodationPrice;
             }
         }
     }
     $bankTransactionList = [];
     $listTransactionType = [BankTransaction::BANK_TRANSACTION_TYPE_VALIDATION => Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_VALIDATION], BankTransaction::BANK_TRANSACTION_TYPE_CASH => Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_CASH], BankTransaction::BANK_TRANSACTION_TYPE_BANK_DEPOSIT => Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_BANK_DEPOSIT], BankTransaction::BANK_TRANSACTION_TYPE_DEDUCTED_SALARY => Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_DEDUCTED_SALARY]];
     // collect from card
     if ($dataOther['hasValidCard']) {
         $listTransactionType[BankTransaction::BANK_TRANSACTION_TYPE_COLLECT] = Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_COLLECT];
     }
     if ($dataOther['transactions']) {
         foreach ($dataOther['transactions'] as $bank) {
             if (in_array($bank->getStatus(), [BankTransaction::BANK_TRANSACTION_STATUS_APPROVED, BankTransaction::BANK_TRANSACTION_STATUS_PENDING])) {
                 $listTransactionType[BankTransaction::BANK_TRANSACTION_TYPE_CASH_REFUND] = Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_CASH_REFUND];
                 if ($bank->getType() == BankTransaction::BANK_TRANSACTION_TYPE_COLLECT) {
                     $listTransactionType[BankTransaction::BANK_TRANSACTION_TYPE_REFUND] = Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_REFUND];
                     $listTransactionType[BankTransaction::BANK_TRANSACTION_TYPE_CHARGEBACK_FRAUD] = Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_CHARGEBACK_FRAUD];
                     $listTransactionType[BankTransaction::BANK_TRANSACTION_TYPE_CHARGEBACK_OTHER] = Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_CHARGEBACK_OTHER];
                     $listTransactionType[BankTransaction::BANK_TRANSACTION_TYPE_CHARGEBACK_DISPUTE] = Objects::getChargeType()[BankTransaction::BANK_TRANSACTION_TYPE_CHARGEBACK_DISPUTE];
                 }
             }
             if ($bank->getMoneyAccountId() > 0 && in_array($bank->getStatus(), [BankTransaction::BANK_TRANSACTION_STATUS_APPROVED, BankTransaction::BANK_TRANSACTION_STATUS_PENDING])) {
                 $bankTransactionList[$bank->getMoneyAccountId()] = ['money_account_name' => $bank->getBank(), 'money_account_currency' => $bank->getMoneyAccountCurrency()];
             }
         }
     }
     asort($listTransactionType);
     $dataOther['listTransactionType'] = $listTransactionType;
     $dataOther['bank_transaction_list'] = $bankTransactionList;
     // partner commission for charge
     $dataOther['partner_commission_charge'] = $partnerSpecificService->getPartnerDeductedCommission($data->getPartnerId(), $data->getPartnerCommission());
     // get apartel reservations bulk if needed
     if ($data->getApartelId() && $data->getChannelResId()) {
         /** @var \DDD\Dao\ChannelManager\ReservationIdentificator $reservationIdentificatorDao */
         $reservationIdentificatorDao = $this->getServiceLocator()->get('dao_channel_manager_reservation_identificator');
         $apartelReservationsBulk = $reservationIdentificatorDao->getReservationsIdentificatorDataByChannelResId($data->getChannelResId(), $data->getId());
         if ($apartelReservationsBulk->count()) {
             $dataOther['apartel_reservations_bulk'] = $apartelReservationsBulk;
         }
     }
     return ['data' => $data, 'otherData' => $dataOther, 'creditCards' => $creditCardsMerge['card_list'], 'nightsData' => $nightsParse, 'ratesByDate' => $ratesPriceByDateParse];
 }