Class: ReservationService::UserAdjustedPoints
- Inherits:
-
Object
- Object
- ReservationService::UserAdjustedPoints
- 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
- #calculate ⇒ Object
-
#initialize(user, booking_amount, country_code = ApiV5::Constants::COUNTRY_CODE_TH) ⇒ UserAdjustedPoints
constructor
A new instance of UserAdjustedPoints.
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
#calculate ⇒ Object
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 |