No available units

Created on 18 December 2023, about 1 year ago
Updated 30 December 2023, 12 months ago

Maybe i'm doing something wrong, but now i can only booking in the rooms that has the same unit id, but not in the others. This unit id seems to has defined in the node settings. For example in my config/sync i have this config in my node type:

  bee:
    bee:
      bookable: 1
      bookable_type: hourly
      availability: available
      payment: 0
      payment_default_value: 0
      type_id: '8'

I've tried to remove the type_id and make a config import, but doesn't work neither.

This is because this code in getAvailableUnits() in bee/src/Form/AddReservationForm.php

    $bee_settings = $node_type->getThirdPartySetting('bee', 'bee');

    $units_ids = [];
    foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
      if ($unit->entity) {
        $units_ids[] = $unit->entity->id();
      }
    }

    if ($bee_settings['bookable_type'] == 'daily') {
      $start_date = new \DateTime($start_date);
      $end_date = new \DateTime($end_date);
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_daily_available'], [$bee_settings['type_id']], 'availability_daily');
    }
    else {
      $start_date = new \DateTime($start_date->format('Y-m-d H:i'));
      $end_date = new \DateTime($end_date->format('Y-m-d H:i'));
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_hourly_available'], [$bee_settings['type_id']], 'availability_hourly');
    }

For some reason i don't know this get a config from the node with the type id. But in every room can be a diferent type id.

I've made this changes to support this:

    $bee_settings = $node_type->getThirdPartySetting('bee', 'bee');

    $units_ids = [];
    $type_ids = [];
    foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
      if ($unit->entity) {
        $units_ids[] = $unit->entity->id();
        $type_ids[] = $unit->entity->unit_type_id->target_id;
      }
    }

    if ($bee_settings['bookable_type'] == 'daily') {
      $start_date = new \DateTime($start_date);
      $end_date = new \DateTime($end_date);
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_daily_available'], $type_ids, 'availability_daily');
    }
    else {
      $start_date = new \DateTime($start_date->format('Y-m-d H:i'));
      $end_date = new \DateTime($end_date->format('Y-m-d H:i'));
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_hourly_available'], $type_ids, 'availability_hourly');
    }
🐛 Bug report
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

🇪🇸Spain Carlitus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024