Class: Query::CustomerStatementOfAccount

Inherits:
Object
  • Object
show all
Defined in:
app/services/query/customer_statement_of_account.rb

Overview

Builds the live statement-of-account row set (invoices, credit memos, unapplied receipts)
for a party over a rolling date window.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(party_id) ⇒ CustomerStatementOfAccount

Returns a new instance of CustomerStatementOfAccount.



10
11
12
# File 'app/services/query/customer_statement_of_account.rb', line 10

def initialize(party_id)
  @party_id = party_id
end

Class Method Details

.call(party_id) ⇒ Object



6
7
8
# File 'app/services/query/customer_statement_of_account.rb', line 6

def self.call(party_id)
  new(party_id).call
end

Instance Method Details

#callObject



14
15
16
17
18
# File 'app/services/query/customer_statement_of_account.rb', line 14

def call
  start_date = Date.current - 4.years
  end_date = Date.current + 1.year
  rows(start_date, end_date).sort_by { |a| [a.due_date.to_s] }
end