Module: Api::Vendor::V1::Concerns::ReservationUtils
- Extended by:
- ActiveSupport::Concern
- Included in:
- CreateReservation, Dianping::ReservationsController, Getyourguide::Concerns::Helpers, Getyourguide::ReservesController, GoogleReserve::Concerns::ErrorResponses, Klook::BookingsController, Klook::Concerns::ErrorResponses, Klook::Concerns::SerializerUtils, RestaurantsController, VendorReservationsController, ReservationService::Form::HungryHub
- Defined in:
- app/controllers/api/vendor/v1/concerns/reservation_utils.rb
Overview
typed: ignore frozen_string_literal: true
Constant Summary collapse
- HH_RESERVATION_INVENTORY_ERRORS =
[ 'Restaurant is closed', 'Package is not available at selected time', I18n.t('inventory.seat_is_full'), I18n.t('inventory.not_available'), ].freeze
Instance Method Summary collapse
-
#calculate_package_qty(rest_pack, adult, kids) ⇒ Integer
need to adjust package qty if vendor do not let customers select package qty for per_pack type packages such vendor list is saved in ::Channel.adjust_package_qty_for_vendor?.
-
#calculate_pax_qty(restaurant_package_id, adult, kids) ⇒ Array<Integer>
need to adjust adult/kids qty to block restaurant inventory, since vendor lets customer selects package qty only such vendor list is saved in ::Channel.adjust_pax_to_max_per_pack_qty?.
- #hh_reservation_inventory_errors ⇒ Object
Instance Method Details
#calculate_package_qty(rest_pack, adult, kids) ⇒ Integer
need to adjust package qty if vendor do not let customers select package qty for per_pack type packages such vendor list is saved in ::Channel.adjust_package_qty_for_vendor?
24 25 26 27 28 29 30 31 |
# File 'app/controllers/api/vendor/v1/concerns/reservation_utils.rb', line 24 def calculate_package_qty(rest_pack, adult, kids) total_count = 1 # for per_person packages, we send package qty as 1 in reservation params if rest_pack&.package&.dynamic_price_pricing_model&.to_sym == :per_pack per_pack_qty = rest_pack&.package&.dynamic_pricings&.first&.per_pack total_count = (adult.to_i + kids.to_i).fdiv(per_pack_qty).ceil if per_pack_qty.present? end total_count end |
#calculate_pax_qty(restaurant_package_id, adult, kids) ⇒ Array<Integer>
need to adjust adult/kids qty to block restaurant inventory, since vendor lets customer selects package qty only such vendor list is saved in ::Channel.adjust_pax_to_max_per_pack_qty?
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/api/vendor/v1/concerns/reservation_utils.rb', line 40 def calculate_pax_qty(restaurant_package_id, adult, kids) rest_pack = HhPackage::RestaurantPackage.find_by(id: restaurant_package_id) if rest_pack&.package&.dynamic_price_pricing_model&.to_sym == :per_pack per_pack_qty = rest_pack&.package&.dynamic_pricings&.first&.per_pack if per_pack_qty adult = per_pack_qty kids = 0 end end [adult.to_i, kids.to_i] end |
#hh_reservation_inventory_errors ⇒ Object
55 56 57 |
# File 'app/controllers/api/vendor/v1/concerns/reservation_utils.rb', line 55 def hh_reservation_inventory_errors HH_RESERVATION_INVENTORY_ERRORS end |