Class: ReservationService::UserAdjustedPoints

Inherits:
Object
  • Object
show all
Defined in:
app/services/reservation_service/user_adjusted_points.rb

Overview

This class is used to calculate how many points for each user they can redeem user will be shown user_adjusted_points in reservation checkout page, The admin can set the limit on this page /admin/limit_points_adjustments

Instance Method Summary collapse

Constructor Details

#initialize(user, booking_amount, country_code = ApiV5::Constants::COUNTRY_CODE_TH) ⇒ UserAdjustedPoints

Returns a new instance of UserAdjustedPoints.



8
9
10
11
12
# File 'app/services/reservation_service/user_adjusted_points.rb', line 8

def initialize(user, booking_amount, country_code = ApiV5::Constants::COUNTRY_CODE_TH)
  @user = user
  @booking_amount = booking_amount
  @country = Country.find_by(alpha3: country_code)
end

Instance Method Details

#calculateObject



14
15
16
# File 'app/services/reservation_service/user_adjusted_points.rb', line 14

def calculate
  [user_remaining_limit_points, booking_limit_points, booking_limit_spend_points, user_credits].compact.min
end