Class: Report::AccountsReceivableCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::AccountsReceivableCommand
- Defined in:
- app/services/report/accounts_receivable_command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#customer_count ⇒ Object
Summary totals computed from results.
- #execute ⇒ Object
- #success? ⇒ Boolean
- #total_amount ⇒ Object
- #total_current ⇒ Object
- #total_days30 ⇒ Object
- #total_days60 ⇒ Object
- #total_days90 ⇒ Object
- #total_over90 ⇒ Object
Class Method Details
.company_options ⇒ Object
25 26 27 |
# File 'app/services/report/accounts_receivable_command.rb', line 25 def self. Company. end |
Instance Method Details
#customer_count ⇒ Object
Summary totals computed from results
30 31 32 |
# File 'app/services/report/accounts_receivable_command.rb', line 30 def customer_count @results&.map { |a| a[:customers] }&.uniq&.count || 0 end |
#execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/report/accounts_receivable_command.rb', line 6 def execute return unless valid? results = ActiveRecord::Base.connection.execute(report_sql) @results = results.map do |r| { co: r["co"], bill_id: r["bill_id"], customers: r["customers"], terms: r["terms"], hold: r["hold"], bg: r["bg"], total_amount: r["total_amount"], current_amount: r["current_amount"], days30: r["days30"], days60: r["days60"], days90: r["days90"], over_90: r["over_90"] } end end |
#success? ⇒ Boolean
21 22 23 |
# File 'app/services/report/accounts_receivable_command.rb', line 21 def success? valid? && @results.present? end |
#total_amount ⇒ Object
34 35 36 |
# File 'app/services/report/accounts_receivable_command.rb', line 34 def total_amount @results&.sum { |a| a[:total_amount].to_f } || 0 end |
#total_current ⇒ Object
38 39 40 |
# File 'app/services/report/accounts_receivable_command.rb', line 38 def total_current @results&.sum { |a| a[:current_amount].to_f } || 0 end |
#total_days30 ⇒ Object
42 43 44 |
# File 'app/services/report/accounts_receivable_command.rb', line 42 def total_days30 @results&.sum { |a| a[:days30].to_f } || 0 end |
#total_days60 ⇒ Object
46 47 48 |
# File 'app/services/report/accounts_receivable_command.rb', line 46 def total_days60 @results&.sum { |a| a[:days60].to_f } || 0 end |
#total_days90 ⇒ Object
50 51 52 |
# File 'app/services/report/accounts_receivable_command.rb', line 50 def total_days90 @results&.sum { |a| a[:days90].to_f } || 0 end |
#total_over90 ⇒ Object
54 55 56 |
# File 'app/services/report/accounts_receivable_command.rb', line 54 def total_over90 @results&.sum { |a| a[:over_90].to_f } || 0 end |