diff --git a/app/assets/stylesheets/admin/accounts_and_billing_settings.css.scss b/app/assets/stylesheets/admin/accounts_and_billing_settings.css.scss deleted file mode 100644 index 775e50cd90..0000000000 --- a/app/assets/stylesheets/admin/accounts_and_billing_settings.css.scss +++ /dev/null @@ -1,10 +0,0 @@ -.step { - a.explain:hover { - cursor: pointer; - } - - p.explanation { - margin-top: 20px; - display: none; - } -} diff --git a/app/controllers/admin/accounts_and_billing_settings_controller.rb b/app/controllers/admin/accounts_and_billing_settings_controller.rb index 259b20027c..e479952e0f 100644 --- a/app/controllers/admin/accounts_and_billing_settings_controller.rb +++ b/app/controllers/admin/accounts_and_billing_settings_controller.rb @@ -14,7 +14,7 @@ class Admin::AccountsAndBillingSettingsController < Spree::Admin::BaseController end def start_job - if @update_billable_periods_job || @update_user_invoices_job || @finalize_user_invoices_job + if @update_user_invoices_job || @finalize_user_invoices_job flash[:error] = "A task is already running, please wait until it has finished" else new_job = "#{params[:job][:name]}".camelize.constantize.new @@ -43,7 +43,7 @@ class Admin::AccountsAndBillingSettingsController < Spree::Admin::BaseController end def known_jobs - ['update_billable_periods', 'update_user_invoices', 'finalize_user_invoices'] + ['update_user_invoices', 'finalize_user_invoices'] end def require_known_job @@ -68,7 +68,6 @@ class Admin::AccountsAndBillingSettingsController < Spree::Admin::BaseController end def load_jobs - @update_billable_periods_job = Delayed::Job.where("handler LIKE (?)", "%Struct::UpdateBillablePeriods%").last @update_user_invoices_job = Delayed::Job.where("handler LIKE (?)", "%Struct::UpdateUserInvoices%").last @finalize_user_invoices_job = Delayed::Job.where("handler LIKE (?)", "%Struct::FinalizeUserInvoices%").last end diff --git a/app/views/admin/accounts_and_billing_settings/edit.html.haml b/app/views/admin/accounts_and_billing_settings/edit.html.haml index 3b02a76a67..fbb6b9b89f 100644 --- a/app/views/admin/accounts_and_billing_settings/edit.html.haml +++ b/app/views/admin/accounts_and_billing_settings/edit.html.haml @@ -23,40 +23,10 @@ .form-buttons{"data-hook" => "buttons"} = button t(:update), 'icon-refresh', value: "update" -.row - .four.columns.alpha.step.text-center - %fieldset.no-border-bottom - %legend Step 1 - - = form_for :job, url: main_app.start_job_admin_accounts_and_billing_settings_path, method: :post do |f| - = f.hidden_field :name, value: "update_billable_periods" - -# = f.select :start, options_for_select(month_options), {}, class: "fullwidth select2" - .form-buttons{"data-hook" => "buttons"} - = button "Calculate Bill Totals", "icon-bar-chart button fullwidth", :submit, disabled: @update_billable_periods_job.present? - - %br - - - if @update_billable_periods_job - %p.text-center - - if @update_billable_periods_job.run_at < Time.now - %strong In Progress - %br - Started at: - - else - %strong Queued - %br - Scheduled for: - = @update_billable_periods_job.run_at - - else - %a.explain What is this? - - %p.explanation - Use this button to immediately calculate the billable total for the month to date for each enterprise in the system. Do this before generating invoices on the right. This task is run automatically every night. - - - .four.columns.step.text-center - %fieldset.no-border-bottom - %legend Step 2 +%fieldset.no-border-bottom + %legend Manually Run Tasks + .row + .six.columns.alpha.step.text-center = form_for :job, url: main_app.start_job_admin_accounts_and_billing_settings_path, method: :post do |f| = f.hidden_field :name, value: "update_user_invoices" @@ -78,16 +48,11 @@ Scheduled for: = @update_user_invoices_job.run_at - else - %a.explain What is this? - - %p.explanation - Use this button to immediately update invoices for the month to date for each enterprise user in the system. Do this after calculating totals on the left. This task is run automatically every night. + %p.explanation + Use this button to immediately update invoices for the month to date for each enterprise user in the system. This task can be set up to run automatically every night. - .four.columns.omega.step.text-center - %fieldset.no-border-bottom - %legend Step 3 - + .six.columns.omega.step.text-center = form_for :job, url: main_app.start_job_admin_accounts_and_billing_settings_path, method: :post do |f| = f.hidden_field :name, value: "finalize_user_invoices" -# = f.select :start, options_for_select(month_options), {}, class: "fullwidth select2" @@ -108,12 +73,5 @@ Scheduled for: = @finalize_user_invoices_job.run_at - else - %a.explain What is this? - - %p.explanation - Use this button to finalize all invoices in the system for the pervious calendar month. Do this after steps one and two. This task is automatically run once a month. - - -:coffee - $('a.explain').click -> - $(this).siblings('.explanation').slideToggle(200) + %p.explanation + Use this button to finalize all invoices in the system for the previous calendar month. This task can be set up to run automatically once a month. diff --git a/spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb b/spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb index 1e6e096525..d0e1fadbf6 100644 --- a/spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb +++ b/spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb @@ -149,35 +149,6 @@ describe Admin::AccountsAndBillingSettingsController, type: :controller do end end - context "and job_name is update_billable_periods" do - let!(:params) { { job: { name: "update_billable_periods" } } } - - context "and no jobs are currently running" do - before do - allow(controller).to receive(:load_jobs) - end - - it "runs the job" do - expect{spree_post :start_job, params}.to enqueue_job UpdateBillablePeriods - expect(flash[:success]).to eq "Task Queued" - expect(response).to redirect_to edit_admin_accounts_and_billing_settings_path - end - end - - context "and there are jobs currently running" do - before do - allow(controller).to receive(:load_jobs) - controller.instance_variable_set("@update_billing_periods_job", double(:update_billing_periods_job)) - end - - it "does not run the job" do - expect{spree_post :start_job, params}.to_not enqueue_job UpdateBillablePeriods - expect(flash[:error]).to eq "A task is already running, please wait until it has finished" - expect(response).to redirect_to edit_admin_accounts_and_billing_settings_path - end - end - end - context "and job_name is update_user_invoices" do let!(:params) { { job: { name: "update_user_invoices" } } }