Class: Balance
- Inherits:
-
Prawn::Document
- Object
- Prawn::Document
- Balance
- Defined in:
- lib/models/balance.rb
Instance Attribute Summary collapse
-
#cash ⇒ Object
Returns the value of attribute cash.
-
#cwidths ⇒ Object
Returns the value of attribute cwidths.
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
- #build_table ⇒ Object
- #checking_row ⇒ Object
- #curr_assets_row ⇒ Object
- #draw_table ⇒ Object
- #fund_rows ⇒ Object
- #header ⇒ Object
-
#initialize(date, cash) ⇒ Balance
constructor
A new instance of Balance.
- #make_pdf ⇒ Object
- #money(int) ⇒ Object
- #savings_row ⇒ Object
Constructor Details
#initialize(date, cash) ⇒ Balance
Returns a new instance of Balance.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/models/balance.rb', line 4 def initialize(date,cash) super( top_margin: 35, page_layout: :landscape) @date = Vfwcash.set_date(date).beginning_of_month @m = Vfwcash.yyyymm(@date) @cash = cash cash.get_fund_balances(@date,@date.end_of_month) @config = @cash.config 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
#cash ⇒ Object
Returns the value of attribute cash.
2 3 4 |
# File 'lib/models/balance.rb', line 2 def cash @cash end |
#cwidths ⇒ Object
Returns the value of attribute cwidths.
2 3 4 |
# File 'lib/models/balance.rb', line 2 def cwidths @cwidths end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/models/balance.rb', line 2 def date @date end |
Instance Method Details
#build_table ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/models/balance.rb', line 70 def build_table @rows = [header] @rows << checking_row @rows += fund_rows @rows << savings_row @rows << curr_assets_row end |
#checking_row ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/models/balance.rb', line 19 def checking_row arr = ["Checking"] arr << {content: money(@cash.balances[:checking][:bbalance]), align: :right} arr << {content: money(@cash.balances[:checking][:debits]), align: :right} arr << {content: money(@cash.balances[:checking][:credits]), align: :right} arr << {content: money(@cash.balances[:checking][:diff]), align: :right} arr << {content: money(@cash.balances[:checking][:ebalance]), align: :right} arr end |
#curr_assets_row ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/models/balance.rb', line 53 def curr_assets_row arr = ["Curr Assets"] arr << {content: money(@cash.balances[:checking][:bbalance] + @cash.balances[:savings][:bbalance]), align: :right} arr << {content: money(@cash.balances[:checking][:debits] + @cash.balances[:savings][:debits]), align: :right} arr << {content: money(@cash.balances[:checking][:credits] + @cash.balances[:savings][:credits]), align: :right} arr << {content: money(@cash.balances[:checking][:diff] + @cash.balances[:savings][:diff]), align: :right} arr << {content: money(@cash.balances[:checking][:ebalance] + @cash.balances[:savings][:ebalance]), align: :right} arr end |
#draw_table ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/models/balance.rb', line 78 def draw_table text "#{@config[:post][:post]} General Ledger Month Balances #{@date}", 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_rows ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/models/balance.rb', line 39 def fund_rows farr = [] @cash.checking_funds.each do |f| arr = [f] arr << {content: money(@cash.balances[f][:bbalance]), align: :right} arr << {content: money(@cash.balances[f][:debits]), align: :right} arr << {content: money(@cash.balances[f][:credits]), align: :right} arr << {content: money(@cash.balances[f][:diff]), align: :right} arr << {content: money(@cash.balances[f][:ebalance]), align: :right} farr << arr end farr end |
#header ⇒ Object
15 16 17 |
# File 'lib/models/balance.rb', line 15 def header arr = %w(Fund BeginBal Debits Credits P/L EndBal) end |
#make_pdf ⇒ Object
64 65 66 67 68 |
# File 'lib/models/balance.rb', line 64 def make_pdf font_size 9 build_table draw_table end |
#money(int) ⇒ Object
91 92 93 |
# File 'lib/models/balance.rb', line 91 def money(int) Vfwcash.money(int) end |
#savings_row ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/models/balance.rb', line 29 def savings_row arr = ["Savings"] arr << {content: money(@cash.balances[:savings][:bbalance]), align: :right} arr << {content: money(@cash.balances[:savings][:debits]), align: :right} arr << {content: money(@cash.balances[:savings][:credits]), align: :right} arr << {content: money(@cash.balances[:savings][:diff]), align: :right} arr << {content: money(@cash.balances[:savings][:ebalance]), align: :right} arr end |