Class: Bookkeeper::Account
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Bookkeeper::Account
- Defined in:
- app/models/bookkeeper/account.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#rebuild_balance ⇒ Object
23 24 25 |
# File 'app/models/bookkeeper/account.rb', line 23 def rebuild_balance self.balance = self.initial_balance + self.incomings.sum(:amount) - self.outgoings.sum(:amount) end |
#update_balance ⇒ Object
18 19 20 21 |
# File 'app/models/bookkeeper/account.rb', line 18 def update_balance self.rebuild_balance self.save end |
#update_start_date ⇒ Object
27 28 29 |
# File 'app/models/bookkeeper/account.rb', line 27 def update_start_date self.update_attribute(:start_date, self.movements.first.created_at) end |