Class: Search::InvoiceSummaryPresenter

Inherits:
BasePresenter
  • Object
show all
Defined in:
app/presenters/search/invoice_summary_presenter.rb

Overview

Footer summary presenter for the CRM invoice advanced search.

Aggregates line totals and consolidated amounts across a collection of
invoice search results.

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from BasePresenter

Instance Method Details

#profit_consolidatedString

Sum of consolidated profit formatted in USD.

Returns:

  • (String)


34
35
36
# File 'app/presenters/search/invoice_summary_presenter.rb', line 34

def profit_consolidated
  h.number_to_currency results.to_a.sum { |i| i.profit_consolidated || 0.00 }, unit: 'USD$ '
end

#revenueString

Sum of invoice line totals formatted as currency.

Returns:

  • (String)


13
14
15
# File 'app/presenters/search/invoice_summary_presenter.rb', line 13

def revenue
  h.number_to_currency(results.to_a.sum { |i| i.line_total || 0.00 })
end

#revenue_consolidatedString

Sum of consolidated revenue formatted in USD.

Returns:

  • (String)


27
28
29
# File 'app/presenters/search/invoice_summary_presenter.rb', line 27

def revenue_consolidated
  h.number_to_currency results.to_a.sum { |i| i.revenue_consolidated || 0.00 }, unit: 'USD$ '
end

#totalString

Sum of invoice grand totals formatted as currency.

Returns:

  • (String)


20
21
22
# File 'app/presenters/search/invoice_summary_presenter.rb', line 20

def total
  h.number_to_currency(results.to_a.sum { |i| i.total || 0.00 })
end