Module: ReservationService::Form::Validators
- Included in:
- HungryHub
- Defined in:
- app/services/reservation_service/form/validators.rb
Instance Method Summary collapse
- #accept_refund_guarantee_param ⇒ Object
- #alipay? ⇒ Boolean
- #check_skip_prepayment? ⇒ Boolean
- #created_by_admin? ⇒ Boolean
- #eligible_to_use_refund_guarantee? ⇒ Boolean
- #shopee_pay? ⇒ Boolean
- #true_wallet? ⇒ Boolean
- #wechat_pay? ⇒ Boolean
Instance Method Details
#accept_refund_guarantee_param ⇒ Object
65 66 67 |
# File 'app/services/reservation_service/form/validators.rb', line 65 def accept_refund_guarantee_param params[:accept_refund_guarantee].to_s == 'true' end |
#alipay? ⇒ Boolean
14 15 16 |
# File 'app/services/reservation_service/form/validators.rb', line 14 def alipay? params[:omise_payment_type].to_s == 'alipay_plus' end |
#check_skip_prepayment? ⇒ Boolean
22 23 24 25 26 27 28 29 |
# File 'app/services/reservation_service/form/validators.rb', line 22 def check_skip_prepayment? return false if voucher_param.blank? voucher_result = voucher_form.calculate service_type = reservation_params[:service_type].to_s delivery_fee = service_type == 'delivery' ? voucher_result[:delivery_fee] : 0 voucher_result[:charge_price].to_i.zero? && voucher_result[:total_price].to_i.zero? && delivery_fee.to_i.zero? end |
#created_by_admin? ⇒ Boolean
2 3 4 |
# File 'app/services/reservation_service/form/validators.rb', line 2 def created_by_admin? created_by_params == :admin end |
#eligible_to_use_refund_guarantee? ⇒ Boolean
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/services/reservation_service/form/validators.rb', line 31 def eligible_to_use_refund_guarantee? return true unless accept_refund_guarantee_param # Check if all selected packages have refund guarantee restaurant_packages = params[:restaurant_packages] if restaurant_packages.present? restaurant_packages.each do |rp_param| restaurant_package = HhPackage::RestaurantPackage.find_by(id: rp_param[:id]) next if restaurant_package.blank? package = restaurant_package.package unless package&.package_attr&.accept_refund_guarantee? return false end end end # Check if all selected add-ons have refund guarantee restaurant_add_ons = params[:restaurant_add_ons] if restaurant_add_ons.present? restaurant_add_ons.each do |rao_param| restaurant_add_on = AddOns::Restaurant.find_by(id: rao_param[:id]) next if restaurant_add_on.blank? add_on = restaurant_add_on.add_on unless add_on&.accept_refund_guarantee? return false end end end true end |
#shopee_pay? ⇒ Boolean
10 11 12 |
# File 'app/services/reservation_service/form/validators.rb', line 10 def shopee_pay? payment_type_param.to_s == 'shopee_pay' end |
#true_wallet? ⇒ Boolean
6 7 8 |
# File 'app/services/reservation_service/form/validators.rb', line 6 def true_wallet? payment_type_param.to_s == 'true_wallet' end |
#wechat_pay? ⇒ Boolean
18 19 20 |
# File 'app/services/reservation_service/form/validators.rb', line 18 def wechat_pay? params[:omise_payment_type].to_s == 'wechat_pay' end |