Class: Activity::ResourceList::InvoiceRetriever

Inherits:
ResourceRetriever show all
Defined in:
app/services/activity/resource_list.rb

Overview

Service object: invoice retriever.

Instance Attribute Summary

Attributes inherited from ResourceRetriever

#page, #party, #per_page, #query

Instance Method Summary collapse

Methods inherited from ResourceRetriever

build, #filter_results, #initialize, #total_count

Constructor Details

This class inherits a constructor from Activity::ResourceList::ResourceRetriever

Instance Method Details

#resourcesActiveRecord::Relation<Invoice>?

The party's invoices matching the query.

Returns:

  • (ActiveRecord::Relation<Invoice>, nil)


196
197
198
199
200
201
202
# File 'app/services/activity/resource_list.rb', line 196

def resources
  return unless party.respond_to?(:invoices)

  invoices = party.invoices
  invoices = invoices.where(Invoice[:reference_number].matches("%#{query}%")) if query.present?
  filter_results(Invoice, invoices)
end