Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions app/operations/documents/append_1095a_documents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ def call(params)

private

def upload_to_s3_enabled?
PolypressRegistry.feature_enabled?(:upload_paper_notices_to_s3)
end

def base_folder_path
if upload_to_s3_enabled?
Rails.root.join('tmp/irs_1095a')
else
Rails.root.join('..', IRS_LOCAL_1095A_FOLDER)
end
end

def create_folder
Success(FileUtils.mkdir_p(Rails.root.join('..', IRS_LOCAL_1095A_FOLDER)))
Success(FileUtils.mkdir_p(base_folder_path))
end

def process(family_hash)
Expand Down Expand Up @@ -67,7 +79,7 @@ def generate_pdf(tax_household:, insurance_agreement:, insurance_policy:)
)
irs_report.process

@folder_path = Rails.root.join('..', IRS_LOCAL_1095A_FOLDER, @family_hbx_id.to_s)
@folder_path = File.join(base_folder_path, @family_hbx_id.to_s)
FileUtils.mkdir_p @folder_path
@absolute_file_path = "#{@folder_path}/#{@family_hbx_id}_#{DateTime.now.strftime('%Y%m%d%H%M%S%L')}.pdf"

Expand All @@ -89,7 +101,7 @@ def combine_tax_documents
end
end

@path = Rails.root.join('..', IRS_LOCAL_1095A_FOLDER, "#{@recipient[:person][:hbx_id]}_1095A_#{DateTime.now.strftime('%Y%m%d%H%M%S')}.pdf")
@path = File.join(base_folder_path, "#{@recipient[:person][:hbx_id]}_1095A_#{DateTime.now.strftime('%Y%m%d%H%M%S')}.pdf")
if pdf.save(@path)
Success(@path)
else
Expand Down
Loading