Adding billing tasks to whenever schedule

This commit is contained in:
Rob Harrington
2015-07-09 09:54:40 +08:00
parent 204a3275ac
commit 448bd12e9f
3 changed files with 24 additions and 2 deletions

View File

@@ -25,13 +25,13 @@
%fieldset.no-border-bottom
%legend Update Invoices
= f.check_box :auto_update_invoices
= f.label :auto_update_invoices, "Auto-update invoices nightly at 2am"
= f.label :auto_update_invoices, "Auto-update invoices nightly at 1:00am"
.six.columns.omega
%fieldset.no-border-bottom
%legend Finalise Invoices
= f.check_box :auto_finalize_invoices
= f.label :auto_finalize_invoices, "Auto-finalise invoices monthly on the 2nd"
= f.label :auto_finalize_invoices, "Auto-finalise invoices monthly on the 2nd at 1:30am"
.row
.twelve.columns.alpha.omega.form-buttons{"data-hook" => "buttons"}

View File

@@ -18,3 +18,12 @@ end
every 4.hours do
rake 'db2fog:backup'
end
every 1.day, at: '1:00am' do
rake 'openfoodnetwork:billing:update_user_invoices'
end
# On the 2nd of every month at 1:30am
every '30 1 2 * *' do
rake 'openfoodnetwork:billing:finalize_user_invoices'
end

13
lib/tasks/billing.rake Normal file
View File

@@ -0,0 +1,13 @@
namespace :openfoodnetwork do
namespace :billing do
desc 'Update enterprise user invoices'
task update_user_invoices: :environment do
Delayed::Job.enqueue(UpdateUserInvoices.new) if Spree::Config[:auto_update_invoices]
end
desc 'Finalize enterprise user invoices'
task finalize_user_invoices: :environment do
Delayed::Job.enqueue(FinalizeUserInvoices.new) if Spree::Config[:auto_finalize_invoices]
end
end
end