Reorganising BMC edit view

This commit is contained in:
Rob Harrington
2015-10-15 14:14:21 +11:00
parent 044e423543
commit a40a03905f
2 changed files with 64 additions and 19 deletions

View File

@@ -1,57 +1,51 @@
= render :partial => 'spree/admin/shared/configuration_menu'
- content_for :page_title do
= t(:business_model_configuration)
%p
This page allows configuration of the rates at which shops will be charged for use of the Open Food Network.
%br
%p
Total monthly bill will be: Fixed Charge + (Turnover x Percentage), unless this value exceeds the Monthly Cap, in which case the Monthly Cap will be charged instead.
%h1.page-title= t(:business_model_configuration)
%a.with-tip{ 'data-powertip' => "Configure the rate at which shops will be charged each month for use of the Open Food Network." } What's this?
= render 'spree/shared/error_messages', target: @settings
%fieldset.no-border-bottom
%legend Settings
= form_for @settings, as: :enterprise_types, url: main_app.admin_business_model_configuration_path, :method => :put do |f|
%legend=t(:monthly_bill_calculation_settings)
= form_for @settings, as: :settings, url: main_app.admin_business_model_configuration_path, :method => :put do |f|
.row
.one.column.alpha
.field
= label :nothing, ""
%br
Bill   =
%h6 Bill   =
.two.columns
.field
= f.label :account_invoices_monthly_fixed, t(:fixed_amount)
%span.with-tip.icon-question-sign{'data-powertip' => "A fixed monthly charge for ALL enterprises who are set up as a shop."}
= f.label :account_invoices_monthly_fixed, t(:fixed_charge)
%span.with-tip.icon-question-sign{'data-powertip' => "A fixed monthly charge for ALL enterprises who are set up as a shop, regardless of how much produce they sell."}
%br
= f.number_field :account_invoices_monthly_fixed, min: 0.0, class: "fullwidth"
.one.column.text-center
.field
= label :nothing, ""
%br
= "+"
.two.columns.text-center
%h6 +
.two.columns
.field
= label :nothing, ""
%br
(  Turnover   x
%h6 (  Turnover   ×
.two.columns
.field
= f.label :account_invoices_monthly_rate, t(:percentage)
%span.with-tip.icon-question-sign{'data-powertip' => "A rate (0.0 - 1.0) that will be applied to the total turnover of each shop."}
%span.with-tip.icon-question-sign{'data-powertip' => "When greater than zero, this rate (0.0 - 1.0) will be applied to the total turnover of each shop and added to any fixed charges (to the left) to calculate the monthly bill."}
%br
= f.number_field :account_invoices_monthly_rate, min: 0.0, max: 1.0, step: 0.01, class: "fullwidth"
.one.column
.field
= label :nothing, ""
%br
)
%h6 )
.two.columns.omega
.field
= f.label :account_invoices_monthly_cap, t(:capped_at)
%span.with-tip.icon-question-sign{'data-powertip' => "A cap on the amount that shops will be charged each month."}
%span.with-tip.icon-question-sign{'data-powertip' => "When greater than zero, this value will be used as a cap on the amount that shops will be charged each month."}
%br
= f.number_field :account_invoices_monthly_cap, min: 0.0, class: "fullwidth"

View File

@@ -0,0 +1,51 @@
require 'spec_helper'
feature 'Business Model Configuration' do
include AuthenticationWorkflow
include WebHelper
describe "updating" do
let!(:admin) { create(:admin_user) }
before do
Spree::Config.set({
account_invoices_monthly_fixed: 5,
account_invoices_monthly_rate: 0.02,
account_invoices_monthly_cap: 50
})
end
before do
quick_login_as_admin
end
context "as an admin user", js: true do
# it "loads the page" do
# visit spree.admin_path
# click_link "Configuration"
# click_link "Accounts & Billing"
#
# expect(page).to have_select2 "settings_accounts_distributor_id"
# select2_select accounts_distributor.name, from: "settings_accounts_distributor_id"
# expect(page).to have_select "settings_default_accounts_payment_method_id"
# expect(page).to have_select "settings_default_accounts_shipping_method_id"
# expect(page).to have_link "Update User Invoices", href: start_job_admin_accounts_and_billing_settings_path(job: { name: 'update_account_invoices'})
# expect(page).to have_link "Finalise User Invoices", href: start_job_admin_accounts_and_billing_settings_path(job: { name: 'finalize_account_invoices'})
# end
it "attributes can be changed", js: true do
visit edit_admin_business_model_configuration_path
fill_in "settings_account_invoices_monthly_fixed", with: 10
fill_in "settings_account_invoices_monthly_rate", with: 0.05
fill_in "settings_account_invoices_monthly_cap", with: 30
click_button "Update"
expect(Spree::Config.account_invoices_monthly_fixed).to eq 10
expect(Spree::Config.account_invoices_monthly_rate).to eq 0.05
expect(Spree::Config.account_invoices_monthly_cap).to eq 30
end
end
end
end