Add BankAccountConnector to implement bank import methods in plugins

This commit is contained in:
Patrick Gansterer 2020-02-24 14:22:58 +01:00
parent d476993321
commit 5d84156bd8
11 changed files with 281 additions and 22 deletions

View file

@ -67,11 +67,14 @@ namespace :foodsoft do
desc "Import and assign bank transactions"
task :import_and_assign_bank_transactions => :environment do
BankAccount.find_each do |ba|
import_method = ba.find_import_method
next unless import_method
import_count = import_method.call(ba)
importer = ba.find_connector
next unless importer
importer.load nil
ok = importer.import nil
next unless ok
importer.finish
assign_count = ba.assign_unlinked_transactions
rake_say "#{ba.name}: imported #{import_count}, assigned #{assign_count}"
rake_say "#{ba.name}: imported #{importer.count}, assigned #{assign_count}"
end
end
end