From 2e89b2770aa5fc70a99d2d612d03f96c4f62208c Mon Sep 17 00:00:00 2001 From: Sai Praveen Gudimetla Date: Thu, 19 Feb 2026 14:40:47 -0500 Subject: [PATCH] use tmp folder to generate 1095a pdfs instead of aws folder --- .../documents/append_1095a_documents.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/operations/documents/append_1095a_documents.rb b/app/operations/documents/append_1095a_documents.rb index 27a911d4..ec86b431 100644 --- a/app/operations/documents/append_1095a_documents.rb +++ b/app/operations/documents/append_1095a_documents.rb @@ -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) @@ -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" @@ -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