Class: Comee::Core::SupplierPayment
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Comee::Core::SupplierPayment
- Defined in:
- app/models/comee/core/supplier_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
14 15 16 |
# File 'app/models/comee/core/supplier_payment.rb', line 14 def self.ransackable_associations(_auth_object = nil) %w[payment_order supplier_invoice] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
10 11 12 |
# File 'app/models/comee/core/supplier_payment.rb', line 10 def self.ransackable_attributes(_auth_object = nil) %w[id created_at updated_at] end |
Instance Method Details
#validate_amount ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/models/comee/core/supplier_payment.rb', line 18 def validate_amount return unless amount && payment_order running_total = payment_order.supplier_payments.sum(:amount) running_total -= amount_was if id remaining = payment_order.amount - running_total error = "Amount exceeded. The maximum amount you can set is #{remaining}" errors.add(:base, error) if amount > remaining end |