Class: Report::AccountsReceivableCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::AccountsReceivableCommand
- Defined in:
- app/services/report/accounts_receivable_command.rb
Overview
Service object: accounts receivable command.
Class Method Summary collapse
-
.company_options ⇒ Object
Company options.
Instance Method Summary collapse
-
#customer_count ⇒ Object
Summary totals computed from results.
-
#execute ⇒ Object
Run the report with the given filters and store the result.
-
#success? ⇒ Boolean
Whether the command validated and ran successfully.
-
#total_amount ⇒ Object
Total amount.
-
#total_current ⇒ Object
Total current.
-
#total_days30 ⇒ Object
Total days30.
-
#total_days60 ⇒ Object
Total days60.
-
#total_days90 ⇒ Object
Total days90.
-
#total_over90 ⇒ Object
Total over90.
Class Method Details
.company_options ⇒ Object
Company options.
33 34 35 |
# File 'app/services/report/accounts_receivable_command.rb', line 33 def self. Company. end |
Instance Method Details
#customer_count ⇒ Object
Summary totals computed from results
38 39 40 |
# File 'app/services/report/accounts_receivable_command.rb', line 38 def customer_count @results&.pluck(:customers)&.uniq&.count || 0 end |
#execute ⇒ Object
Run the report with the given filters and store the result.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/report/accounts_receivable_command.rb', line 10 def execute return unless valid? results = ActiveRecord::Base.lease_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
Whether the command validated and ran successfully.
27 28 29 |
# File 'app/services/report/accounts_receivable_command.rb', line 27 def success? valid? && @results.present? end |
#total_amount ⇒ Object
Total amount.
44 45 46 |
# File 'app/services/report/accounts_receivable_command.rb', line 44 def total_amount @results&.sum { |a| a[:total_amount].to_f } || 0 end |
#total_current ⇒ Object
Total current.
50 51 52 |
# File 'app/services/report/accounts_receivable_command.rb', line 50 def total_current @results&.sum { |a| a[:current_amount].to_f } || 0 end |
#total_days30 ⇒ Object
Total days30.
56 57 58 |
# File 'app/services/report/accounts_receivable_command.rb', line 56 def total_days30 @results&.sum { |a| a[:days30].to_f } || 0 end |
#total_days60 ⇒ Object
Total days60.
62 63 64 |
# File 'app/services/report/accounts_receivable_command.rb', line 62 def total_days60 @results&.sum { |a| a[:days60].to_f } || 0 end |
#total_days90 ⇒ Object
Total days90.
68 69 70 |
# File 'app/services/report/accounts_receivable_command.rb', line 68 def total_days90 @results&.sum { |a| a[:days90].to_f } || 0 end |
#total_over90 ⇒ Object
Total over90.
74 75 76 |
# File 'app/services/report/accounts_receivable_command.rb', line 74 def total_over90 @results&.sum { |a| a[:over_90].to_f } || 0 end |