Module: Api::Vendor::V1::Concerns::ChargeCalculatorHelper
- Extended by:
- ActiveSupport::Concern
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/controllers/api/vendor/v1/concerns/charge_calculator_helper.rb
Instance Method Summary collapse
-
#calculate_package_charge(restaurant_package:, reservation: nil, restaurant: nil, adult: nil, kids: nil, date: nil, quantity: 1, booking_channel: nil, support_dynamic_pricing: false) ⇒ Hash
Calculate package price using dynamic pricing calculator.
Instance Method Details
#calculate_package_charge(restaurant_package:, reservation: nil, restaurant: nil, adult: nil, kids: nil, date: nil, quantity: 1, booking_channel: nil, support_dynamic_pricing: false) ⇒ Hash
Calculate package price using dynamic pricing calculator
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/api/vendor/v1/concerns/charge_calculator_helper.rb', line 17 def calculate_package_charge(restaurant_package:, reservation: nil, restaurant: nil, adult: nil, kids: nil, date: nil, quantity: 1, booking_channel: nil, support_dynamic_pricing: false) # Extract data from reservation if provided if reservation.present? restaurant ||= reservation.restaurant adult ||= reservation.adult kids ||= reservation.kids date ||= reservation.date booking_channel ||= reservation.booking_channel end package = restaurant_package.package package_bought = [{ package: package, restaurant_package_id: restaurant_package.id, quantity: quantity, }] calculator = HhPackage::ReservationPackages::ChargeCalculator.new calculator.use_dynamic_pricing = booking_channel&.support_dynamic_pricing reservation_date = booking_channel&.support_dynamic_pricing || support_dynamic_pricing ? date : nil calculator.calculate(package_bought, adult, kids, 0.0, restaurant, reservation_date) end |