Sha256: 9ade244ff64470c560f0702158154c11cc08b0dfd6f035afba04eccee395ff1b

Contents?: true

Size: 1.07 KB

Versions: 38

Compression:

Stored size: 1.07 KB

Contents

module Xeroizer
  module Report
    class AgedReceivablesByContact < Base

      public

        def total
          @_total_cache ||= summary.cell(:Total).value 
        end

        def total_paid
          @_total_paid_cache ||= summary.cell(:Paid).value
        end

        def total_credited
          @_total_credited_cache ||= summary.cell(:Credited).value
        end

        def total_due
          @_total_due_cache ||= summary.cell(:Due).value
        end

        def total_overdue
          return @_total_due_cache if @_total_due_cache
          
          now = Time.now
          @_total_due_cache = sum(:Due) do | row | 
            due_date = row.cell('Due Date').value
            due_date && due_date < now
          end
        end

        def sum(column_name, &block)
          sections.first.rows.inject(BigDecimal.new('0')) do | sum, row |
            cell = row.cell(column_name)
            sum += row.cell(column_name).value if row.class == Xeroizer::Report::Row && (block.nil? || block.call(row))
            sum
          end
        end
      
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
xeroizer-2.16.5 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.16.4 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.16.3 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.16.1 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.16.0 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.15.9 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.15.8 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.15.7 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.15.6 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.5.2 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.5.1 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-2.15.5 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.16 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.15 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.14 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.13 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.12 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.11 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.10 lib/xeroizer/report/aged_receivables_by_contact.rb
xeroizer-float-2.15.3.9 lib/xeroizer/report/aged_receivables_by_contact.rb