Class: SunatBooks::Pdf::Page

Inherits:
Base
  • Object
show all
Defined in:
lib/sunat_books/pdf/page.rb

Constant Summary

Constants included from Utils

Utils::MONTHS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#book_header, #book_title, #get_counts, #get_mother_counts, #get_value, #make_sub_table, #prawn_header, #sub_head, #sub_head_options, #sub_head_table, #table_body, #table_hash, #table_head

Methods included from Utils

#add_align, #add_widths, #field_value, #formated_number, #get_column_widths, #get_date, #get_period, #get_row_sums, #order_data_row, #parse_day, #sum_count, #txt, #zero

Methods included from CommonUtils

#available_value?

Constructor Details

#initialize(page_number, length) ⇒ Page

Returns a new instance of Page.



10
11
12
13
14
15
16
17
18
# File 'lib/sunat_books/pdf/page.rb', line 10

def initialize(page_number, length)
  @page_number = page_number
  @length = length
  @bi_sum = BigDecimal(0)
  @igv_sum = BigDecimal(0)
  @total_sum = BigDecimal(0)
  @non_taxable = BigDecimal(0)
  @data = []
end

Instance Attribute Details

#bi_sumObject

Returns the value of attribute bi_sum.



8
9
10
# File 'lib/sunat_books/pdf/page.rb', line 8

def bi_sum
  @bi_sum
end

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/sunat_books/pdf/page.rb', line 8

def data
  @data
end

#igv_sumObject

Returns the value of attribute igv_sum.



8
9
10
# File 'lib/sunat_books/pdf/page.rb', line 8

def igv_sum
  @igv_sum
end

#lengthObject

Returns the value of attribute length.



8
9
10
# File 'lib/sunat_books/pdf/page.rb', line 8

def length
  @length
end

#non_taxableObject

Returns the value of attribute non_taxable.



8
9
10
# File 'lib/sunat_books/pdf/page.rb', line 8

def non_taxable
  @non_taxable
end

#total_sumObject

Returns the value of attribute total_sum.



8
9
10
# File 'lib/sunat_books/pdf/page.rb', line 8

def total_sum
  @total_sum
end

Instance Method Details

#update_data_buys(ticket) ⇒ Object



20
21
22
23
24
25
# File 'lib/sunat_books/pdf/page.rb', line 20

def update_data_buys(ticket)
  @bi_sum += ticket.taxable_to_taxable_export_bi.round(2)
  @igv_sum += ticket.taxable_to_taxable_export_igv.round(2)
  @total_sum += ticket.total_operation_buys.round(2)
  @non_taxable += ticket.non_taxable unless ticket.non_taxable.nil?
end

#update_data_sales(ticket) ⇒ Object



27
28
29
30
31
# File 'lib/sunat_books/pdf/page.rb', line 27

def update_data_sales(ticket)
  @bi_sum += ticket.taxable_bi.round(2)
  @igv_sum += ticket.igv.round(2)
  @total_sum += ticket.total_operation_sales.round(2)
end

#update_fields(fields = nil, source = nil) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/sunat_books/pdf/page.rb', line 33

def update_fields(fields = nil, source = nil)
  # update fields from a given source
  return if source.nil?

  fields&.each do |field|
    send("#{field}=", source.send(field)) if available?(field, source)
  end
end