Create bank statement export dir if not present

Fixes #1551
This commit is contained in:
Alex Sherman 2020-03-03 10:43:20 +02:00
parent 0efd35516c
commit 0c30e8b8ee

View file

@ -25,10 +25,16 @@ class BankStatement < ApplicationRecord
bank_transactions.build(bt_params)
end
prepare_dir
self.import_file_path = "#{ENV['bank_statement_import_dir']}/#{Time.zone.now.to_formatted_s(:number)}.txt"
File.open(import_file_path, 'w') { |f| f.write(th6_file.open.read) }
end
def prepare_dir
dirname = ENV['bank_statement_import_dir']
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
end
def parse_th6_row(row)
return parse_th6_header(row) if row[4, 3].strip == '000'
return if row[4, 3].strip == '999' # skip footer