Class: Comee::Core::Payment
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Comee::Core::Payment
- Defined in:
- app/models/comee/core/payment.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
15 16 17 |
# File 'app/models/comee/core/payment.rb', line 15 def self.ransackable_associations(_auth_object = nil) %w[payment_deposit invoice] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
11 12 13 |
# File 'app/models/comee/core/payment.rb', line 11 def self.ransackable_attributes(_auth_object = nil) %w[id created_at updated_at] end |
Instance Method Details
#calculate_amount_paid ⇒ Object
29 30 31 32 |
# File 'app/models/comee/core/payment.rb', line 29 def calculate_amount_paid invoice.amount_paid = invoice.calculate_amount_paid invoice.save! end |
#validate_amount ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/models/comee/core/payment.rb', line 19 def validate_amount return unless amount && payment_deposit running_total = payment_deposit.payments.sum(:amount) running_total -= amount_was if id remaining = payment_deposit.amount - running_total error = "Amount exceeded. The maximum amount you can set is #{remaining}" errors.add(:base, error) if amount > remaining end |