Контроллер настроен на парсер, готово к PR
This commit is contained in:
@@ -15,11 +15,26 @@ class FileProcessorJob
|
||||
|
||||
download_inn(inn, temp_dir.to_s)
|
||||
|
||||
# Найти или создать организацию по ИНН
|
||||
organization = Organization.find_or_create_by!(inn: inn)
|
||||
|
||||
Dir.glob("#{temp_dir}/**/*").select { |f| File.file?(f) }.each do |file_path|
|
||||
# Прикрепляем файл к Report (обратная совместимость)
|
||||
report.files.attach(
|
||||
io: File.open(file_path),
|
||||
filename: File.basename(file_path)
|
||||
)
|
||||
|
||||
# Создаём YearlyFile и прикрепляем xlsx
|
||||
yearly_file = organization.yearly_files.build(year: 0)
|
||||
yearly_file.file.attach(
|
||||
io: File.open(file_path),
|
||||
filename: File.basename(file_path)
|
||||
)
|
||||
yearly_file.save!
|
||||
|
||||
# Парсим данные из xlsx
|
||||
ReportParser.new(yearly_file).call
|
||||
end
|
||||
|
||||
# Удали временные файлы
|
||||
@@ -69,4 +84,4 @@ class FileProcessorJob
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user