Class: Between

Inherits:
Prawn::Document
  • Object
show all
Defined in:
lib/models/between.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, cash, from, to) ⇒ Between

Returns a new instance of Between.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/models/between.rb', line 4

def initialize(date,cash,from,to)
  super( top_margin: 35, page_layout: :landscape)
  @date = Vfwcash.set_date(date).beginning_of_month
  @from = Vfwcash.set_date(from)
  @to = Vfwcash.set_date(to)

  @m = Vfwcash.yyyymm(@date)
  @cash = cash
  @cash.get_fund_balances(@from,@to)
  @results = cash.balances
  @config = @cash.config
  # reset_balance
  make_pdf
  number_pages "#{Date.today}   -   Page <page> of <total>", { :start_count_at => 0, :page_filter => :all, :at => [bounds.right - 100, 0], :align => :right, :size => 6 }
end

Instance Attribute Details

#cashObject

Returns the value of attribute cash.



2
3
4
# File 'lib/models/between.rb', line 2

def cash
  @cash
end

#cwidthsObject

Returns the value of attribute cwidths.



2
3
4
# File 'lib/models/between.rb', line 2

def cwidths
  @cwidths
end

#dateObject

Returns the value of attribute date.



2
3
4
# File 'lib/models/between.rb', line 2

def date
  @date
end

Instance Method Details

#build_tableObject



75
76
77
78
79
80
81
# File 'lib/models/between.rb', line 75

def build_table
  @rows = [header]
  @rows << checking_row
  @rows += fund_rows
  @rows << savings_row
  @rows << curr_assets_row
end

#checking_rowObject



24
25
26
27
28
29
30
31
32
# File 'lib/models/between.rb', line 24

def checking_row
  arr = ["Checking"]
  arr << {content: money(@results[:checking][:bbalance]), align: :right}
  arr << {content: money(@results[:checking][:debits]), align: :right}
  arr << {content: money(@results[:checking][:credits]), align: :right}
  arr << {content: money(@results[:checking][:diff]), align: :right}
  arr << {content: money(@results[:checking][:ebalance]), align: :right}
  arr
end

#curr_assets_rowObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/models/between.rb', line 58

def curr_assets_row
  arr = ["Curr Assets"]
  arr << {content: money(@results[:checking][:bbalance] + @results[:savings][:bbalance]), align: :right}
  arr << {content: money(@results[:checking][:debits] + @results[:savings][:debits]), align: :right}
  arr << {content: money(@results[:checking][:credits] + @results[:savings][:credits]), align: :right}
  arr << {content: money(@results[:checking][:diff] + @results[:savings][:diff]), align: :right}
  arr << {content: money(@results[:checking][:ebalance] + @results[:savings][:ebalance]), align: :right}
  arr

end

#draw_tableObject



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/models/between.rb', line 83

def draw_table
  text "#{@config[:post][:post]} General Ledger Balances Between #{@from} and #{@to}", style: :bold, align: :center
  move_down(2)
  e = make_table @rows,row_colors: ["F8F8F8", "FFFFFF"],:cell_style => {:padding => [1, 2, 2, 1],border_color:"E0E0E0"}, 
    :column_widths => [60,60,60,60,60,60], header:true do
    
    row(0).font_style = :bold
    row(0).align = :center
    column(0).font_style = :bold
  end
  e.draw
end

#fund_rowsObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/models/between.rb', line 44

def fund_rows
  farr = []
  @cash.checking_funds.each do |f|
    arr = [f]
    arr << {content: money(@results[f][:bbalance]), align: :right}
    arr << {content: money(@results[f][:debits]), align: :right}
    arr << {content: money(@results[f][:credits]), align: :right}
    arr << {content: money(@results[f][:diff]), align: :right}
    arr << {content: money(@results[f][:ebalance]), align: :right}
    farr << arr
  end
  farr
end

#headerObject



20
21
22
# File 'lib/models/between.rb', line 20

def header
  arr = %w(Fund BeginBal Debits Credits P/L EndBal)
end

#make_pdfObject



69
70
71
72
73
# File 'lib/models/between.rb', line 69

def make_pdf
  font_size 9
  build_table
  draw_table
end

#money(int) ⇒ Object



96
97
98
# File 'lib/models/between.rb', line 96

def money(int)
  Vfwcash.money(int)
end

#savings_rowObject



34
35
36
37
38
39
40
41
42
# File 'lib/models/between.rb', line 34

def savings_row
  arr = ["Savings"]
  arr << {content: money(@results[:savings][:bbalance]), align: :right}
  arr << {content: money(@results[:savings][:debits]), align: :right}
  arr << {content: money(@results[:savings][:credits]), align: :right}
  arr << {content: money(@results[:savings][:diff]), align: :right}
  arr << {content: money(@results[:savings][:ebalance]), align: :right}
  arr
end