Class: RegisterPdf
- Inherits:
-
Prawn::Document
- Object
- Prawn::Document
- RegisterPdf
- Defined in:
- lib/models/register_pdf.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #balance_row ⇒ Object
- #build_table ⇒ Object
- #draw_table ⇒ Object
- #header ⇒ Object
-
#initialize(date, cash) ⇒ RegisterPdf
constructor
A new instance of RegisterPdf.
- #make_pdf ⇒ Object
- #money(int) ⇒ Object
Constructor Details
#initialize(date, cash) ⇒ RegisterPdf
Returns a new instance of RegisterPdf.
4 5 6 7 8 9 10 11 12 |
# File 'lib/models/register_pdf.rb', line 4 def initialize(date,cash) super( top_margin: 35) @date = Vfwcash.set_date(date).beginning_of_month @config = cash.config cash.get_fund_balances(@date,@date.end_of_month) @response = cash.split_ledger_api(@date) 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
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/models/register_pdf.rb', line 2 def date @date end |
#response ⇒ Object
Returns the value of attribute response.
2 3 4 |
# File 'lib/models/register_pdf.rb', line 2 def response @response end |
Instance Method Details
#balance_row ⇒ Object
18 19 20 |
# File 'lib/models/register_pdf.rb', line 18 def balance_row [{content:'',colspan: 2},"Beginning Balance",nil,nil,nil,nil,{content: money(@response[:balances][:checking][:bbalance]),align: :right}] end |
#build_table ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/models/register_pdf.rb', line 28 def build_table @rows = [header] @rows << balance_row @response[:rows].each do |row| arr = [row[:date],row[:num],row[:desc],row[:memo],row[:r]] arr << (row[:checking][:db].zero? ? nil : {content: money(row[:checking][:db]), align: :right}) arr << (row[:checking][:cr].zero? ? nil : {content: money(row[:checking][:cr]), align: :right}) arr << (row[:balance].zero? ? nil : {content: money(row[:balance]), align: :right}) @rows << arr end end |
#draw_table ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/models/register_pdf.rb', line 40 def draw_table text "#{@config[:post][:post]} Checkbook Register - #{@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 => [40, 24, 150,110,10,40,40,40,40], header:true do row(0).font_style = :bold end e.draw end |
#header ⇒ Object
14 15 16 |
# File 'lib/models/register_pdf.rb', line 14 def header arr = ["Date", "Num","Description","Account","R","Debits","Credits", "Balance"] end |
#make_pdf ⇒ Object
22 23 24 25 26 |
# File 'lib/models/register_pdf.rb', line 22 def make_pdf font_size 7 build_table draw_table end |