class SunatBooks::Pdf::Page
Attributes
bi_sum[RW]
data[RW]
igv_sum[RW]
length[RW]
non_taxable[RW]
total_sum[RW]
Public Class Methods
new(page_number, length)
click to toggle source
# 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
Public Instance Methods
update_data_buys(ticket)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
available?(field, source)
click to toggle source
# File lib/sunat_books/pdf/page.rb, line 44 def available?(field, source) respond_to?("#{field}=") && source.respond_to?(field) end