Module: ModelExt::Restaurants::CreditCard
- Extended by:
- ActiveSupport::Concern
- Included in:
- Restaurant
- Defined in:
- lib/model_ext/restaurants/credit_card.rb
Overview
attribute for charge immediately =
-
min_party_size_to_charge
-
charge_pricing_type
-
adult_cc_immediate_charge_amount
-
kids_cc_immediate_charge_amount
attribute for on hold charge
-
cc_min_party_size
-
on_hold_pricing_type
Instance Attribute Summary collapse
-
#cc_hold_amount ⇒ Object
readonly
cc_hold_amount is the amount that will be charged to the credit card (in cents).
-
#cc_immediate_charge_amount ⇒ Object
readonly
Returns the value of attribute cc_immediate_charge_amount.
Instance Method Summary collapse
- #adult_cc_hold_amount=(amount) ⇒ Object
- #adult_cc_immediate_charge_amount=(amount) ⇒ Object
- #assert_charge_immediately? ⇒ Boolean
- #assert_on_hold_charge? ⇒ Boolean
- #kids_cc_hold_amount=(amount) ⇒ Object
- #kids_cc_immediate_charge_amount=(amount) ⇒ Object
- #party_require_credit_card?(party_size, channel_type) ⇒ Boolean
- #require_credit_card? ⇒ Boolean
Instance Attribute Details
#cc_hold_amount ⇒ Object (readonly)
cc_hold_amount is the amount that will be charged to the credit card (in cents)
72 73 74 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 72 def cc_hold_amount @cc_hold_amount end |
#cc_immediate_charge_amount ⇒ Object (readonly)
Returns the value of attribute cc_immediate_charge_amount.
18 19 20 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 18 def cc_immediate_charge_amount @cc_immediate_charge_amount end |
Instance Method Details
#adult_cc_hold_amount=(amount) ⇒ Object
87 88 89 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 87 def adult_cc_hold_amount=(amount) self[:adult_cc_hold_amount] = units_to_subunits(amount.to_d) end |
#adult_cc_immediate_charge_amount=(amount) ⇒ Object
106 107 108 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 106 def adult_cc_immediate_charge_amount=(amount) self[:adult_cc_immediate_charge_amount] = units_to_subunits(amount.to_d) end |
#assert_charge_immediately? ⇒ Boolean
110 111 112 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 110 def assert_charge_immediately? min_party_size_to_charge.to_i.positive? && cc_immediate_charge_amount.present? end |
#assert_on_hold_charge? ⇒ Boolean
114 115 116 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 114 def assert_on_hold_charge? cc_min_party_size.to_i.positive? && cc_hold_amount.present? end |
#kids_cc_hold_amount=(amount) ⇒ Object
83 84 85 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 83 def kids_cc_hold_amount=(amount) self[:kids_cc_hold_amount] = units_to_subunits(amount.to_d) end |
#kids_cc_immediate_charge_amount=(amount) ⇒ Object
102 103 104 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 102 def kids_cc_immediate_charge_amount=(amount) self[:kids_cc_immediate_charge_amount] = units_to_subunits(amount.to_d) end |
#party_require_credit_card?(party_size, channel_type) ⇒ Boolean
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 59 def party_require_credit_card?(party_size, channel_type) if party_size >= cc_min_party_size.to_i && channel_type == ::Channel::HOLD_CC true elsif party_size >= min_party_size_to_charge.to_i && channel_type == ::Channel::CHARGE_CC_DIRECTLY true else false end end |
#require_credit_card? ⇒ Boolean
55 56 57 |
# File 'lib/model_ext/restaurants/credit_card.rb', line 55 def require_credit_card? cc_min_party_size.to_i.positive? || min_party_size_to_charge.to_i.positive? end |