Class: Collection
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Collection
- Defined in:
- app/models/collection.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.collect! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/collection.rb', line 24 def self.collect! payments = Payment.uncollected.complete.all return false if payments.blank? self.transaction do collection = self.create!( :banknotes => Payment.merge_banknotes(payments), :payment_ids => payments.map(&:id) ) payments.each{|x| x.update_attribute :collection_id, collection.id} return collection end return false end |
Instance Method Details
#amount ⇒ Object
51 52 53 |
# File 'app/models/collection.rb', line 51 def amount banknotes.inject(0){|sum, (nominal, count)| sum + nominal.to_i*count.to_i } end |
#report ⇒ Object
47 48 49 |
# File 'app/models/collection.rb', line 47 def report Payments::CollectWorker.perform_async(id) end |
#title ⇒ Object
43 44 45 |
# File 'app/models/collection.rb', line 43 def title amount end |