mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove Spree::Config[:shipment_inc_vat]
This is now done per ShippingMethod instead of globally
This commit is contained in:
@@ -14,10 +14,7 @@ module Spree
|
||||
private
|
||||
|
||||
def preferences_params
|
||||
params.require(:preferences).permit(
|
||||
:products_require_tax_category,
|
||||
:shipment_inc_vat
|
||||
)
|
||||
params.require(:preferences).permit(:products_require_tax_category)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,7 +58,6 @@ module Spree
|
||||
preference :products_per_page, :integer, default: 12
|
||||
preference :redirect_https_to_http, :boolean, default: false
|
||||
preference :require_master_price, :boolean, default: true
|
||||
preference :shipment_inc_vat, :boolean, default: false
|
||||
# Request instructions/info for shipping
|
||||
preference :shipping_instructions, :boolean, default: false
|
||||
# Displays variant full price or difference with product price.
|
||||
|
||||
@@ -24,13 +24,7 @@ module Spree
|
||||
delegate :name, to: :shipping_method
|
||||
|
||||
def display_price
|
||||
price = if Spree::Config[:shipment_inc_vat]
|
||||
(1 + Spree::TaxRate.default) * cost
|
||||
else
|
||||
cost
|
||||
end
|
||||
|
||||
Spree::Money.new(price, { currency: currency })
|
||||
Spree::Money.new(cost, { currency: currency })
|
||||
end
|
||||
|
||||
alias_method :display_cost, :display_price
|
||||
|
||||
@@ -10,10 +10,5 @@
|
||||
= check_box_tag 'preferences[products_require_tax_category]', '1', Spree::Config[:products_require_tax_category]
|
||||
= label_tag nil, t(:products_require_tax_category)
|
||||
|
||||
.field.align-center{"data-hook" => "shipment_vat"}
|
||||
= hidden_field_tag 'preferences[shipment_inc_vat]', '0'
|
||||
= check_box_tag 'preferences[shipment_inc_vat]', '1', Spree::Config[:shipment_inc_vat]
|
||||
= label_tag nil, t(:shipment_inc_vat)
|
||||
|
||||
.form-buttons{"data-hook" => "buttons"}
|
||||
= button t(:update), 'icon-refresh'
|
||||
|
||||
@@ -4,14 +4,7 @@ require 'spec_helper'
|
||||
|
||||
describe Spree::Admin::TaxSettingsController, type: :controller do
|
||||
describe "#update" do
|
||||
let(:params) {
|
||||
{
|
||||
preferences: {
|
||||
products_require_tax_category: "1",
|
||||
shipment_inc_vat: "0",
|
||||
}
|
||||
}
|
||||
}
|
||||
let(:params) { { preferences: { products_require_tax_category: "1" } } }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:spree_current_user) { create(:admin_user) }
|
||||
@@ -20,17 +13,7 @@ describe Spree::Admin::TaxSettingsController, type: :controller do
|
||||
it "changes Tax settings" do
|
||||
expect {
|
||||
spree_post :update, params
|
||||
}.to change {
|
||||
[
|
||||
Spree::Config[:products_require_tax_category],
|
||||
Spree::Config[:shipment_inc_vat],
|
||||
]
|
||||
}.to(
|
||||
[
|
||||
true,
|
||||
false,
|
||||
]
|
||||
)
|
||||
}.to change { Spree::Config[:products_require_tax_category] }.to(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,10 +8,7 @@ feature 'Account and Billing Settings' do
|
||||
|
||||
describe "updating" do
|
||||
before do
|
||||
Spree::Config.set(
|
||||
products_require_tax_category: false,
|
||||
shipment_inc_vat: false,
|
||||
)
|
||||
Spree::Config.set(products_require_tax_category: false)
|
||||
end
|
||||
|
||||
context "as an admin user" do
|
||||
@@ -20,19 +17,16 @@ feature 'Account and Billing Settings' do
|
||||
click_link "Tax Settings"
|
||||
|
||||
expect(page).to have_unchecked_field 'preferences_products_require_tax_category'
|
||||
expect(page).to have_unchecked_field 'preferences_shipment_inc_vat'
|
||||
end
|
||||
|
||||
it "attributes can be changed" do
|
||||
login_as_admin_and_visit spree.edit_admin_tax_settings_path
|
||||
|
||||
check 'preferences_products_require_tax_category'
|
||||
check 'preferences_shipment_inc_vat'
|
||||
|
||||
click_button "Update"
|
||||
|
||||
expect(Spree::Config.products_require_tax_category).to be true
|
||||
expect(Spree::Config.shipment_inc_vat).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,21 +10,10 @@ describe Spree::ShippingRate do
|
||||
shipping_method: shipping_method,
|
||||
cost: 10.55)
|
||||
}
|
||||
before { allow(Spree::TaxRate).to receive_messages(default: 0.05) }
|
||||
|
||||
context "#display_price" do
|
||||
context "when shipment includes VAT" do
|
||||
before { Spree::Config[:shipment_inc_vat] = true }
|
||||
it "displays the correct price" do
|
||||
expect(shipping_rate.display_price.to_s).to eq "$11.08" # $10.55 * 1.05 == $11.08
|
||||
end
|
||||
end
|
||||
|
||||
context "when shipment does not include VAT" do
|
||||
before { Spree::Config[:shipment_inc_vat] = false }
|
||||
it "displays the correct price" do
|
||||
expect(shipping_rate.display_price.to_s).to eq "$10.55"
|
||||
end
|
||||
it "displays the shipping price" do
|
||||
expect(shipping_rate.display_price.to_s).to eq "$10.55"
|
||||
end
|
||||
|
||||
context "when the currency is JPY" do
|
||||
|
||||
Reference in New Issue
Block a user