Class: Dorsale::BillingMachine::Invoice::Statistics

Inherits:
Object
  • Object
show all
Defined in:
app/services/dorsale/billing_machine/invoice/statistics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(invoices) ⇒ Statistics

Returns a new instance of Statistics.



4
5
6
# File 'app/services/dorsale/billing_machine/invoice/statistics.rb', line 4

def initialize(invoices)
  @invoices = invoices
end

Instance Attribute Details

#invoiceObject

Returns the value of attribute invoice.



2
3
4
# File 'app/services/dorsale/billing_machine/invoice/statistics.rb', line 2

def invoice
  @invoice
end

Instance Method Details

#t(*args) ⇒ Object



29
30
31
# File 'app/services/dorsale/billing_machine/invoice/statistics.rb', line 29

def t(*args)
  ::Dorsale::BillingMachine::Invoice.t(*args)
end

#total_excluding_taxesObject



8
9
10
11
12
13
# File 'app/services/dorsale/billing_machine/invoice/statistics.rb', line 8

def total_excluding_taxes
  @total_excluding_taxes ||= @invoices
    .pluck(:total_excluding_taxes)
    .delete_if(&:blank?)
    .sum
end

#total_including_taxesObject



22
23
24
25
26
27
# File 'app/services/dorsale/billing_machine/invoice/statistics.rb', line 22

def total_including_taxes
  @total_including_taxes ||= @invoices
    .pluck(:total_including_taxes)
    .delete_if(&:blank?)
    .sum
end

#vat_amountObject



15
16
17
18
19
20
# File 'app/services/dorsale/billing_machine/invoice/statistics.rb', line 15

def vat_amount
  @vat_amount ||= @invoices
    .pluck(:vat_amount)
    .delete_if(&:blank?)
    .sum
end