Module: LucaBook::Accumulator
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(klass) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #credit_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
- #credit_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
- #debit_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
- #debit_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
- #each_month ⇒ Object
- #gross_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
- #gross_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
- #net_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/luca_book/accumulator.rb', line 9 def self.included(klass) #:nodoc: klass.extend ClassMethods end |
Instance Method Details
#credit_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
225 226 227 |
# File 'lib/luca_book/accumulator.rb', line 225 def credit_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) gross_amount(code, start_year, start_month, end_year, end_month, recursive: recursive)[1] end |
#credit_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
242 243 244 |
# File 'lib/luca_book/accumulator.rb', line 242 def credit_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) gross_count(code, start_year, start_month, end_year, end_month, recursive: recursive)[1] end |
#debit_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
221 222 223 |
# File 'lib/luca_book/accumulator.rb', line 221 def debit_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) gross_amount(code, start_year, start_month, end_year, end_month, recursive: recursive)[0] end |
#debit_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
238 239 240 |
# File 'lib/luca_book/accumulator.rb', line 238 def debit_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) gross_count(code, start_year, start_month, end_year, end_month, recursive: recursive)[0] end |
#each_month ⇒ Object
255 256 257 |
# File 'lib/luca_book/accumulator.rb', line 255 def each_month yield end |
#gross_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
229 230 231 232 233 234 235 236 |
# File 'lib/luca_book/accumulator.rb', line 229 def gross_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) start_year ||= @cursor_start&.year || @start_date.year start_month ||= @cursor_start&.month || @start_date.month end_year ||= @cursor_end&.year || @end_date.year end_month ||= @cursor_end&.month || @end_date.month g = self.class.gross(start_year, start_month, end_year, end_month, code: code, recursive: recursive) [g[:debit][code], g[:credit][code]] end |
#gross_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
246 247 248 249 250 251 252 253 |
# File 'lib/luca_book/accumulator.rb', line 246 def gross_count(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) start_year ||= @cursor_start&.year || @start_date.year start_month ||= @cursor_start&.month || @start_date.month end_year ||= @cursor_end&.year || @end_date.year end_month ||= @cursor_end&.month || @end_date.month g = self.class.gross(start_year, start_month, end_year, end_month, code: code, recursive: recursive) [g[:debit_count][code], g[:credit_count][code]] end |
#net_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) ⇒ Object
213 214 215 216 217 218 219 |
# File 'lib/luca_book/accumulator.rb', line 213 def net_amount(code, start_year = nil, start_month = nil, end_year = nil, end_month = nil, recursive: true) start_year ||= @cursor_start&.year || @start_date.year start_month ||= @cursor_start&.month || @start_date.month end_year ||= @cursor_end&.year || @end_date.year end_month ||= @cursor_end&.month || @end_date.month self.class.net(start_year, start_month, end_year, end_month, code: code, recursive: recursive)[0][code] end |