mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Reorganising busines model config settings, moving account invoice tax rate in busines model config settings
This commit is contained in:
@@ -20,7 +20,8 @@ class Admin::BusinessModelConfigurationController < Spree::Admin::BaseController
|
||||
@settings = OpenFoodNetwork::BusinessModelConfigurationValidator.new(params[:settings] || {
|
||||
account_invoices_monthly_fixed: Spree::Config[:account_invoices_monthly_fixed],
|
||||
account_invoices_monthly_rate: Spree::Config[:account_invoices_monthly_rate],
|
||||
account_invoices_monthly_cap: Spree::Config[:account_invoices_monthly_cap]
|
||||
account_invoices_monthly_cap: Spree::Config[:account_invoices_monthly_cap],
|
||||
account_invoices_tax_rate: Spree::Config[:account_invoices_tax_rate]
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ module Admin
|
||||
if fixed_description.empty? && rate_description.empty?
|
||||
t(:free).upcase
|
||||
elsif monthly_bill_includes_cap? && monthly_bill_includes_rate? # only care about cap if there is a rate too
|
||||
"#{fixed_description}#{plus}#{rate_description}{joiner}#{cap_description} #{t(:per_month).upcase}"
|
||||
"#{fixed_description}#{plus}#{rate_description}{joiner}#{cap_description} #{t(:per_month).upcase}#{tax_description.upcase}"
|
||||
else
|
||||
"#{fixed_description}#{plus}#{rate_description} #{t(:per_month).upcase}"
|
||||
"#{fixed_description}#{plus}#{rate_description} #{t(:per_month).upcase}#{tax_description.upcase}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,6 +29,10 @@ module Admin
|
||||
monthly_bill_includes_cap? ? "#{t(:capped_at_cap, cap: cap_amount).upcase}" : ""
|
||||
end
|
||||
|
||||
def tax_description
|
||||
Spree::Config[:account_invoices_tax_rate] > 0 ? ", #{t(:plus_tax).upcase}" : ""
|
||||
end
|
||||
|
||||
def monthly_bill_includes_fixed?
|
||||
Spree::Config[:account_invoices_monthly_fixed] > 0
|
||||
end
|
||||
|
||||
@@ -15,16 +15,9 @@ class BillablePeriod < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def bill
|
||||
fixed = Spree::Config[:account_invoices_monthly_fixed]
|
||||
rate = Spree::Config[:account_invoices_monthly_rate]
|
||||
cap = Spree::Config[:account_invoices_monthly_cap]
|
||||
|
||||
return 0 if trial?
|
||||
return 0 unless ['own', 'any'].include?(sells)
|
||||
|
||||
bill = fixed + (turnover * rate).round(2)
|
||||
return bill unless cap > 0
|
||||
[bill, cap].min
|
||||
OpenFoodNetwork::BillCalculator.new(turnover: turnover).bill
|
||||
end
|
||||
|
||||
def label
|
||||
@@ -54,8 +47,8 @@ class BillablePeriod < ActiveRecord::Base
|
||||
self.adjustment = invoice.adjustments.new( adjustment_attrs, :without_protection => true )
|
||||
end
|
||||
|
||||
if Spree::Config.account_bill_inc_tax
|
||||
adjustment.set_included_tax! Spree::Config.account_bill_tax_rate
|
||||
if Spree::Config.account_invoices_tax_rate > 0
|
||||
adjustment.set_included_tax! Spree::Config.account_invoices_tax_rate
|
||||
else
|
||||
adjustment.set_included_tax! 0
|
||||
end
|
||||
|
||||
@@ -7,8 +7,6 @@ Spree::AppConfiguration.class_eval do
|
||||
# Tax Preferences
|
||||
preference :products_require_tax_category, :boolean, default: false
|
||||
preference :shipping_tax_rate, :decimal, default: 0
|
||||
preference :account_bill_inc_tax, :boolean, default: false
|
||||
preference :account_bill_tax_rate, :decimal, default: 0
|
||||
|
||||
# Accounts & Billing Preferences
|
||||
preference :accounts_distributor_id, :integer, default: nil
|
||||
@@ -21,4 +19,5 @@ Spree::AppConfiguration.class_eval do
|
||||
preference :account_invoices_monthly_fixed, :decimal, default: 0
|
||||
preference :account_invoices_monthly_rate, :decimal, default: 0
|
||||
preference :account_invoices_monthly_cap, :decimal, default: 0
|
||||
preference :account_invoices_tax_rate, :decimal, default: 0
|
||||
end
|
||||
|
||||
@@ -10,44 +10,31 @@
|
||||
%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
|
||||
%h6 Bill =
|
||||
.three.columns.alpha
|
||||
= 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."}
|
||||
.two.columns
|
||||
.field
|
||||
= 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
|
||||
%h6 +
|
||||
= f.number_field :account_invoices_monthly_fixed, min: 0.0, class: "fullwidth"
|
||||
.two.columns
|
||||
.field
|
||||
= label :nothing, ""
|
||||
%br
|
||||
%h6 ( Turnover ×
|
||||
.two.columns
|
||||
.field
|
||||
= f.label :account_invoices_monthly_rate, t(:percentage)
|
||||
%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 )
|
||||
|
||||
.three.columns
|
||||
= f.label :account_invoices_monthly_rate, t(:percentage_of_turnover)
|
||||
%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."}
|
||||
.two.columns.omega
|
||||
.field
|
||||
= f.label :account_invoices_monthly_cap, t(:capped_at)
|
||||
%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"
|
||||
= f.number_field :account_invoices_monthly_rate, min: 0.0, max: 1.0, step: 0.01, class: "fullwidth"
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :account_invoices_monthly_cap, t(:monthly_cap_excl_tax)
|
||||
%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."}
|
||||
.two.columns
|
||||
= f.number_field :account_invoices_monthly_cap, min: 0.0, class: "fullwidth"
|
||||
.two.columns
|
||||
|
||||
.three.columns
|
||||
= f.label :account_invoices_tax_rate, t(:tax_rate)
|
||||
%span.with-tip.icon-question-sign{'data-powertip' => "Tax rate that applies to the the monthly bill that enterprises are charged for using the system."}
|
||||
.two.columns.omega
|
||||
= f.number_field :account_invoices_tax_rate, min: 0.0, max: 1.0, step: 0.01, class: "fullwidth"
|
||||
|
||||
.row
|
||||
.twelve.columns.alpha.omega.form-buttons{"data-hook" => "buttons"}
|
||||
|
||||
@@ -19,14 +19,5 @@
|
||||
= number_field_tag "preferences[shipping_tax_rate]", Spree::Config[:shipping_tax_rate].to_f, in: 0.0..1.0, step: 0.01
|
||||
= label_tag nil, t(:shipping_tax_rate)
|
||||
|
||||
.field.align-center{"data-hook" => "billing_tax"}
|
||||
= hidden_field_tag 'preferences[account_bill_inc_tax]', '0'
|
||||
= check_box_tag 'preferences[account_bill_inc_tax]', '1', Spree::Config[:account_bill_inc_tax]
|
||||
= label_tag nil, t(:account_bill_inc_tax)
|
||||
|
||||
.field.align-center{ "data-hook" => "account_bill_tax_rate" }
|
||||
= number_field_tag "preferences[account_bill_tax_rate]", Spree::Config[:account_bill_tax_rate].to_f, in: 0.0..1.0, step: 0.01
|
||||
= label_tag nil, t(:account_bill_tax_rate)
|
||||
|
||||
.form-buttons{"data-hook" => "buttons"}
|
||||
= button t(:update), 'icon-refresh'
|
||||
|
||||
@@ -32,10 +32,12 @@ en:
|
||||
must_have_valid_business_number: "%{enterprise_name} must have a valid ABN before invoices can be sent."
|
||||
invoice: "Invoice"
|
||||
percentage_of_sales: "%{percentage} of sales"
|
||||
capped_at: "capped at"
|
||||
percentage_of_turnover: "Percentage of turnover"
|
||||
monthly_cap_excl_tax: "monthly cap (excl. GST)"
|
||||
capped_at_cap: "capped at %{cap}"
|
||||
per_month: "per month"
|
||||
free: "free"
|
||||
plus_tax: "plus GST"
|
||||
|
||||
sort_order_cycles_on_shopfront_by: "Sort Order Cycles On Shopfront By"
|
||||
|
||||
|
||||
20
lib/open_food_network/bill_calculator.rb
Normal file
20
lib/open_food_network/bill_calculator.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module OpenFoodNetwork
|
||||
class BulkCoopReport
|
||||
attr_accessor :turnover, :fixed, :rate, :cap, :trial
|
||||
|
||||
def initialize(opts={})
|
||||
@turnover = opts[:turnover] || 0
|
||||
@fixed = opts[:fixed] || Spree::Config[:account_invoices_monthly_fixed]
|
||||
@rate = opts[:rate] || Spree::Config[:account_invoices_monthly_rate]
|
||||
@cap = opts[:cap] || Spree::Config[:account_invoices_monthly_cap]
|
||||
@tax_rate = Spree::Config[:account_bill_tax_rate]
|
||||
end
|
||||
|
||||
def bill
|
||||
bill = fixed + (turnover * rate)
|
||||
bill = bill * (1 + tax_rate)
|
||||
return bill unless cap > 0
|
||||
[bill, cap].min
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,11 +5,12 @@ module OpenFoodNetwork
|
||||
class BusinessModelConfigurationValidator
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_accessor :account_invoices_monthly_fixed, :account_invoices_monthly_rate, :account_invoices_monthly_cap
|
||||
attr_accessor :account_invoices_monthly_fixed, :account_invoices_monthly_rate, :account_invoices_monthly_cap, :account_invoices_tax_rate
|
||||
|
||||
validates :account_invoices_monthly_fixed, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
||||
validates :account_invoices_monthly_rate, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1 }
|
||||
validates :account_invoices_monthly_cap, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
||||
validates :account_invoices_tax_rate, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1 }
|
||||
|
||||
def initialize(attr, button=nil)
|
||||
attr.each { |k,v| instance_variable_set("@#{k}", v) }
|
||||
|
||||
@@ -8,7 +8,8 @@ describe Admin::BusinessModelConfigurationController, type: :controller do
|
||||
Spree::Config.set({
|
||||
account_invoices_monthly_fixed: 5,
|
||||
account_invoices_monthly_rate: 0.02,
|
||||
account_invoices_monthly_cap: 50
|
||||
account_invoices_monthly_cap: 50,
|
||||
account_invoices_tax_rate: 0.1
|
||||
})
|
||||
end
|
||||
|
||||
@@ -51,6 +52,7 @@ describe Admin::BusinessModelConfigurationController, type: :controller do
|
||||
params[:settings][:account_invoices_monthly_fixed] = ''
|
||||
params[:settings][:account_invoices_monthly_rate] = '2'
|
||||
params[:settings][:account_invoices_monthly_cap] = '-1'
|
||||
params[:settings][:account_invoices_tax_rate] = '4'
|
||||
spree_get :update, params
|
||||
end
|
||||
|
||||
@@ -60,6 +62,7 @@ describe Admin::BusinessModelConfigurationController, type: :controller do
|
||||
expect(Spree::Config.account_invoices_monthly_fixed).to eq 5
|
||||
expect(Spree::Config.account_invoices_monthly_rate).to eq 0.02
|
||||
expect(Spree::Config.account_invoices_monthly_cap).to eq 50
|
||||
expect(Spree::Config.account_invoices_tax_rate).to eq 0.1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,6 +71,7 @@ describe Admin::BusinessModelConfigurationController, type: :controller do
|
||||
params[:settings][:account_invoices_monthly_fixed] = '10'
|
||||
params[:settings][:account_invoices_monthly_rate] = '0.05'
|
||||
params[:settings][:account_invoices_monthly_cap] = '30'
|
||||
params[:settings][:account_invoices_tax_rate] = '0.15'
|
||||
end
|
||||
|
||||
it "sets global config to the specified values" do
|
||||
@@ -76,6 +80,7 @@ describe Admin::BusinessModelConfigurationController, type: :controller do
|
||||
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
|
||||
expect(Spree::Config.account_invoices_tax_rate).to eq 0.15
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,7 @@ feature 'Business Model Configuration' do
|
||||
account_invoices_monthly_fixed: 5,
|
||||
account_invoices_monthly_rate: 0.02,
|
||||
account_invoices_monthly_cap: 50
|
||||
account_invoices_tax_rate: 0.1
|
||||
})
|
||||
end
|
||||
|
||||
@@ -28,6 +29,7 @@ feature 'Business Model Configuration' do
|
||||
expect(page).to have_field "settings_account_invoices_monthly_fixed", with: 5.0
|
||||
expect(page).to have_field "settings_account_invoices_monthly_rate", with: 0.02
|
||||
expect(page).to have_field "settings_account_invoices_monthly_cap", with: 50.0
|
||||
expect(page).to have_field "settings_account_invoices_tax_rate", with: 0.1
|
||||
end
|
||||
|
||||
it "attributes can be changed", js: true do
|
||||
@@ -36,12 +38,14 @@ feature 'Business Model Configuration' do
|
||||
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
|
||||
fill_in "settings_account_invoices_tax_rate", with: 0.15
|
||||
|
||||
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
|
||||
expect(Spree::Config.settings_account_invoices_tax_rate).to eq 0.15
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,9 +11,7 @@ feature 'Account and Billing Settings' do
|
||||
Spree::Config.set({
|
||||
products_require_tax_category: false,
|
||||
shipment_inc_vat: false,
|
||||
shipping_tax_rate: 0,
|
||||
account_bill_inc_tax: false,
|
||||
account_bill_tax_rate: 0
|
||||
shipping_tax_rate: 0
|
||||
})
|
||||
end
|
||||
|
||||
@@ -30,8 +28,6 @@ feature 'Account and Billing Settings' do
|
||||
expect(page).to have_unchecked_field 'preferences_products_require_tax_category'
|
||||
expect(page).to have_unchecked_field 'preferences_shipment_inc_vat'
|
||||
expect(page).to have_field 'preferences_shipping_tax_rate'
|
||||
expect(page).to have_unchecked_field 'preferences_account_bill_inc_tax'
|
||||
expect(page).to have_field 'preferences_account_bill_tax_rate'
|
||||
end
|
||||
|
||||
it "attributes can be changed" do
|
||||
@@ -40,16 +36,12 @@ feature 'Account and Billing Settings' do
|
||||
check 'preferences_products_require_tax_category'
|
||||
check 'preferences_shipment_inc_vat'
|
||||
fill_in 'preferences_shipping_tax_rate', with: '0.12'
|
||||
check 'preferences_account_bill_inc_tax'
|
||||
fill_in 'preferences_account_bill_tax_rate', with: '0.05'
|
||||
|
||||
click_button "Update"
|
||||
|
||||
expect(Spree::Config.products_require_tax_category).to be true
|
||||
expect(Spree::Config.shipment_inc_vat).to be true
|
||||
expect(Spree::Config.shipping_tax_rate).to eq 0.12
|
||||
expect(Spree::Config.account_bill_inc_tax).to be true
|
||||
expect(Spree::Config.account_bill_tax_rate).to eq 0.05
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,66 +2,136 @@ require 'spec_helper'
|
||||
|
||||
describe Admin::BusinessModelConfigurationHelper do
|
||||
describe "describing monthly bills for enterprises" do
|
||||
context "when a fixed cost is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_fixed, 10) }
|
||||
context "when tax is applied to the service change" do
|
||||
before { Spree::Config.set(:account_invoices_tax_rate, 0.1) }
|
||||
context "when a fixed cost is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_fixed, 10) }
|
||||
|
||||
context "when a percentage of turnover is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0.05) }
|
||||
context "when a percentage of turnover is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0.05) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 + 5.0% OF SALES{joiner}CAPPED AT $20 PER MONTH" }
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 + 5.0% OF SALES{joiner}CAPPED AT $20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 + 5.0% OF SALES PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 + 5.0% OF SALES PER MONTH" }
|
||||
context "when a percentage of turnover is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a percentage of turnover is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0) }
|
||||
context "when a fixed cost is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_fixed, 0) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 PER MONTH" }
|
||||
context "when a percentage of turnover is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0.05) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES{joiner}CAPPED AT $20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 PER MONTH" }
|
||||
context "when a percentage of turnover is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE" }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a fixed cost is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_fixed, 0) }
|
||||
context "when tax is applied to the service change" do
|
||||
before { Spree::Config.set(:account_invoices_tax_rate, 0.0) }
|
||||
context "when a fixed cost is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_fixed, 10) }
|
||||
|
||||
context "when a percentage of turnover is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0.05) }
|
||||
context "when a percentage of turnover is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0.05) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES{joiner}CAPPED AT $20 PER MONTH" }
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 + 5.0% OF SALES{joiner}CAPPED AT $20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 + 5.0% OF SALES PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES PER MONTH" }
|
||||
context "when a percentage of turnover is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "$10 PER MONTH" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a percentage of turnover is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0) }
|
||||
context "when a fixed cost is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_fixed, 0) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE" }
|
||||
context "when a percentage of turnover is included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0.05) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES{joiner}CAPPED AT $20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE" }
|
||||
context "when a percentage of turnover is not included" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_rate, 0) }
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE" }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,8 +13,7 @@ describe BillablePeriod, type: :model do
|
||||
before do
|
||||
allow(subject).to receive(:bill) { 99 }
|
||||
allow(subject).to receive(:adjustment_label) { "Label for adjustment" }
|
||||
Spree::Config.set({ account_bill_inc_tax: true })
|
||||
Spree::Config.set({ account_bill_tax_rate: 0.1 })
|
||||
Spree::Config.set({ account_invoices_tax_rate: 0.1 })
|
||||
end
|
||||
|
||||
context "when no adjustment currently exists" do
|
||||
|
||||
Reference in New Issue
Block a user