Class: Form1095B

Inherits:
ApplicationRecord show all
Defined in:
app/models/form1095_b.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?

Instance Method Details

#pdf_fileObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/form1095_b.rb', line 33

def pdf_file
  pdftk = PdfForms.new(Settings.binaries.pdftk)

  tmp_file = Tempfile.new("1095B-#{SecureRandom.hex}.pdf")

  unless File.exist?(pdf_template_path)
    Rails.logger.error "1095-B template for year #{tax_year} does not exist."
    raise "1095-B for tax year #{tax_year} not supported"
  end

  generate_pdf(pdftk, tmp_file)
end

#txt_fileObject

methods



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/form1095_b.rb', line 18

def txt_file
  unless File.exist?(txt_template_path)
    Rails.logger.error "1095-B template for year #{tax_year} does not exist."
    raise "1095-B for tax year #{tax_year} not supported"
  end

  template_file = File.open(txt_template_path, 'r')

  rv = template_file.read % data.merge(txt_form_data)

  template_file.close

  rv
end