diff --git a/app/operations/documents/append_1095a_documents.rb b/app/operations/documents/append_1095a_documents.rb index 27a911d..ec86b43 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