Class: Report::AccountsPayableCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::AccountsPayableCommand
- Defined in:
- app/services/report/accounts_payable_command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#payee_count ⇒ Object
Summary totals computed from results.
- #success? ⇒ Boolean
- #total_current ⇒ Object
- #total_days30 ⇒ Object
- #total_days60 ⇒ Object
- #total_open ⇒ Object
- #total_original ⇒ Object
- #total_over60 ⇒ Object
Class Method Details
.company_options ⇒ Object
29 30 31 |
# File 'app/services/report/accounts_payable_command.rb', line 29 def self. Company. end |
Instance Method Details
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/report/accounts_payable_command.rb', line 5 def execute return unless valid? @results = VoucherItem .joins(joins_sql) .select(select_sql) .where( "V.state in ('unpaid','paid') " \ "AND (case when payment.amount is null then voucher_items.gross_amount " \ " else voucher_items.gross_amount - coalesce(payment.amount) end) <> 0 " \ "AND V.company_id = :company_id " \ "AND V.supplier_id <> 295241 " \ "AND (voucher_items.gl_offset_account_id in (19,20) OR voucher_items.gl_offset_account_id is null) " \ "AND V.gl_date::date <= :picked_date", company_id: company_id.to_i, picked_date: start_date ) .order(order_sql.sql_safe) end |
#payee_count ⇒ Object
Summary totals computed from results
34 35 36 |
# File 'app/services/report/accounts_payable_command.rb', line 34 def payee_count @results&.map { |a| a["payee"] }&.uniq&.count || 0 end |
#success? ⇒ Boolean
25 26 27 |
# File 'app/services/report/accounts_payable_command.rb', line 25 def success? valid? && @results.present? end |
#total_current ⇒ Object
38 39 40 |
# File 'app/services/report/accounts_payable_command.rb', line 38 def total_current @results&.sum { |a| a["current"].to_f } || 0 end |
#total_days30 ⇒ Object
42 43 44 |
# File 'app/services/report/accounts_payable_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_payable_command.rb', line 46 def total_days60 @results&.sum { |a| a["days60"].to_f } || 0 end |
#total_open ⇒ Object
58 59 60 |
# File 'app/services/report/accounts_payable_command.rb', line 58 def total_open @results&.sum { |a| a["open_amount"].to_f } || 0 end |
#total_original ⇒ Object
54 55 56 |
# File 'app/services/report/accounts_payable_command.rb', line 54 def total_original @results&.sum { |a| a["original_amount"].to_f } || 0 end |
#total_over60 ⇒ Object
50 51 52 |
# File 'app/services/report/accounts_payable_command.rb', line 50 def total_over60 @results&.sum { |a| a["over60"].to_f } || 0 end |