2 # This file is part of SMR.
4 # SMR is free software: you can redistribute it and/or modify it under the
5 # terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or (at your option) any later
9 # SMR is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # SMR. If not, see <http://www.gnu.org/licenses/>.
19 # Collection if helper methods used throught the application.
21 # Its meant for small workhorses that do generic things that can be useful at
22 # many places. Views, Controllers, Models, ...
24 # Such methods should NOT interact directly with the database, the session,
25 # etc... each should be working standalone, based on its parameters only.
27 # Use `include Smr::Extensions::HelperMethods` wherever they are useful.
29 module Smr::Extensions::HelperMethods
32 # mandatory type method: sums outstanding coupons/redemptions happening before
33 # end of year, returns absolute number.
34 # - see Security::MENDATORY_TYPE_METHODS - therefore this method exists
35 # - see Smr::CashflowStream on whats behind cashflows
36 def cashflow_this_year(date=Time.now)
38 cashflow(:start_date=>date, :end_date=>date.end_of_year).each{|i| cf += i.total}