Add rake task to import bank_transactions

This commit is contained in:
Patrick Gansterer 2017-01-17 23:12:31 +01:00
parent d4ab0a055f
commit 9fc51bdce8
2 changed files with 16 additions and 0 deletions

View file

@ -7,6 +7,11 @@ every :day, :at => '7:20 am' do
rake "multicoops:run TASK=foodsoft:notify_users_of_weekly_task" rake "multicoops:run TASK=foodsoft:notify_users_of_weekly_task"
end end
# Import and assign bank transactions
every :weekday, :at => %w(5:56am 6:04pm) do
rake "multicoops:run TASK=foodsoft:import_and_assign_bank_transactions"
end
# Weekly taks # Weekly taks
every :sunday, :at => '7:14 am' do every :sunday, :at => '7:14 am' do
rake "multicoops:run TASK=foodsoft:create_upcoming_periodic_tasks" rake "multicoops:run TASK=foodsoft:create_upcoming_periodic_tasks"

View file

@ -63,6 +63,17 @@ namespace :foodsoft do
server.start server.start
server.join server.join
end end
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)
assign_count = ba.assign_unlinked_transactions
rake_say "#{ba.name}: imported #{import_count}, assigned #{assign_count}"
end
end
end end
# Helper # Helper