From b5c6ecb45a745fa27485109b6c3bd7d01d729f49 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 7 Nov 2018 16:50:24 +0000 Subject: [PATCH 01/24] Explicitly use UTF-8 encoding when opening spreadsheet files --- app/models/product_import/product_importer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index 3bc66fa815..62879d9785 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -205,7 +205,7 @@ module ProductImport def open_spreadsheet if accepted_mimetype - Roo::Spreadsheet.open(@file, extension: accepted_mimetype) + Roo::Spreadsheet.open(@file, extension: accepted_mimetype, encoding: Encoding::UTF_8) else errors.add(:importer, I18n.t(:product_importer_spreadsheet_error)) delete_uploaded_file From 9011f5d9a2c7467a99d2bbec7021be6cf1683dac Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 7 Nov 2018 17:12:19 +0000 Subject: [PATCH 02/24] Rescue ArgumentError and give user feedback --- app/controllers/admin/product_import_controller.rb | 9 ++++++--- app/models/product_import/product_importer.rb | 8 ++++++++ config/locales/en.yml | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/product_import_controller.rb b/app/controllers/admin/product_import_controller.rb index aa55fac115..201d57033f 100644 --- a/app/controllers/admin/product_import_controller.rb +++ b/app/controllers/admin/product_import_controller.rb @@ -16,8 +16,7 @@ module Admin @original_filename = params[:file].try(:original_filename) @non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields - check_file_errors @importer - check_spreadsheet_has_data @importer + return if contains_errors? @importer @ams_data = ams_data end @@ -63,15 +62,19 @@ module Admin true end - def check_file_errors(importer) + def contains_errors?(importer) if importer.errors.present? redirect_to '/admin/product_import', notice: @importer.errors.full_messages.to_sentence + return true end + + check_spreadsheet_has_data importer end def check_spreadsheet_has_data(importer) unless importer.item_count redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice) + true end end diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index 62879d9785..26a07fd6d2 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -226,6 +226,14 @@ module ProductImport (2..@sheet.last_row).map do |i| @sheet.row(i) end + rescue ArgumentError => e + if e.message.include? 'invalid byte sequence' + errors.add(:importer, I18n.t('admin.product_import.model.encoding_error')) + else + errors.add(:importer, I18n.t('admin.product_import.model.unexpected_error', + error_message: e.message)) + end + [] end def build_entries_in_range diff --git a/config/locales/en.yml b/config/locales/en.yml index 34d4584439..523d7f7823 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -524,6 +524,8 @@ en: inventory_no_permission: you do not have permission to create inventory for this producer none_saved: did not save any products successfully line_number: "Line %{number}:" + encoding_error: "Please check the language setting of your source file and ensure it is saved with UTF-8 encoding" + unexpected_error: "Product Import encountered an unexpected error whilst opening the file: %{error_message}" index: select_file: Select a spreadsheet to upload spreadsheet: Spreadsheet From c33ca508f717d81417e5e32359f92d49c8fd5f6a Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 4 Dec 2018 10:59:18 +0000 Subject: [PATCH 03/24] Add guard clause on variant overrides filter in case hub id is not present in the hubPermissions --- .../variant_overrides/filters/hub_permissions_filter.js.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/admin/variant_overrides/filters/hub_permissions_filter.js.coffee b/app/assets/javascripts/admin/variant_overrides/filters/hub_permissions_filter.js.coffee index 39b5e77839..b1434fb21e 100644 --- a/app/assets/javascripts/admin/variant_overrides/filters/hub_permissions_filter.js.coffee +++ b/app/assets/javascripts/admin/variant_overrides/filters/hub_permissions_filter.js.coffee @@ -1,4 +1,5 @@ angular.module("admin.variantOverrides").filter "hubPermissions", ($filter) -> return (products, hubPermissions, hub_id) -> return [] if !hub_id + return [] if !hubPermissions[hub_id] return $filter('filter')(products, ((product) -> hubPermissions[hub_id].indexOf(product.producer_id) > -1), true) From 38ff99717a6a2013ec1d7863bbff1f3b0c3ddcd3 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sat, 17 Nov 2018 12:43:55 +0000 Subject: [PATCH 04/24] Fix bug on calculator_decorator line_items_for where input is line_item with an nil order. Adapted line_items_for so that weight_calculator.line_items_for could be removed. --- app/models/calculator/weight.rb | 14 ----------- app/models/spree/calculator_decorator.rb | 8 ++++--- .../enterprise_fee_calculator_spec.rb | 1 + spec/models/calculator/weight_spec.rb | 24 +++++++++---------- .../flat_percent_item_total_spec.rb | 2 +- .../spree/calculator/flexi_rate_spec.rb | 2 +- spec/models/spree/calculator/per_item_spec.rb | 2 +- 7 files changed, 21 insertions(+), 32 deletions(-) diff --git a/app/models/calculator/weight.rb b/app/models/calculator/weight.rb index ae65026a46..410a53b2f8 100644 --- a/app/models/calculator/weight.rb +++ b/app/models/calculator/weight.rb @@ -12,19 +12,5 @@ module Calculator total_weight = line_items.sum { |li| ((li.variant.andand.weight || 0) * li.quantity) } total_weight * preferred_per_kg end - - private - - def line_items_for(object) - if object.respond_to? :order - object.order.line_items - elsif object.respond_to? :line_items - object.line_items - elsif object.respond_to?(:variant) && object.respond_to?(:quantity) - [object] - else - raise "Unknown object type: #{object.inspect}" - end - end end end diff --git a/app/models/spree/calculator_decorator.rb b/app/models/spree/calculator_decorator.rb index f8be4d00ef..29db0a5c0d 100644 --- a/app/models/spree/calculator_decorator.rb +++ b/app/models/spree/calculator_decorator.rb @@ -1,18 +1,20 @@ module Spree Calculator.class_eval do - private # Given an object which might be an Order or a LineItem (amongst # others), return a collection of line items. def line_items_for(object) - if object.respond_to? :line_items + if object.is_a?(Spree::LineItem) + [object] + elsif object.respond_to? :line_items object.line_items + elsif object.order.present? + object.order.line_items else [object] end end - end end diff --git a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb index 01b97346f7..ae79303b8d 100644 --- a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb +++ b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb @@ -1,3 +1,4 @@ +require 'spec_helper' require 'open_food_network/enterprise_fee_calculator' module OpenFoodNetwork diff --git a/spec/models/calculator/weight_spec.rb b/spec/models/calculator/weight_spec.rb index dee2f3d067..c45da8850a 100644 --- a/spec/models/calculator/weight_spec.rb +++ b/spec/models/calculator/weight_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' describe Calculator::Weight do it "computes shipping cost for an order by total weight" do - variant1 = double(:variant, weight: 10) - variant2 = double(:variant, weight: 20) - variant3 = double(:variant, weight: nil) + variant1 = build(:variant, weight: 10) + variant2 = build(:variant, weight: 20) + variant3 = build(:variant, weight: nil) - line_item1 = double(:line_item, variant: variant1, quantity: 1) - line_item2 = double(:line_item, variant: variant2, quantity: 3) - line_item3 = double(:line_item, variant: variant3, quantity: 5) + line_item1 = build(:line_item, variant: variant1, quantity: 1) + line_item2 = build(:line_item, variant: variant2, quantity: 3) + line_item3 = build(:line_item, variant: variant3, quantity: 5) order = double(:order, line_items: [line_item1, line_item2, line_item3]) @@ -17,20 +17,20 @@ describe Calculator::Weight do end it "computes shipping cost for a line item" do - variant = double(:variant, weight: 10) + variant = build(:variant, weight: 10) - line_item = double(:line_item, variant: variant, quantity: 2) + line_item = build(:line_item, variant: variant, quantity: 2) subject.set_preference(:per_kg, 10) expect(subject.compute(line_item)).to eq(10 * 2 * 10) end it "computes shipping cost for an object with an order" do - variant1 = double(:variant, weight: 10) - variant2 = double(:variant, weight: 5) + variant1 = build(:variant, weight: 10) + variant2 = build(:variant, weight: 5) - line_item1 = double(:line_item, variant: variant1, quantity: 1) - line_item2 = double(:line_item, variant: variant2, quantity: 2) + line_item1 = build(:line_item, variant: variant1, quantity: 1) + line_item2 = build(:line_item, variant: variant2, quantity: 2) order = double(:order, line_items: [line_item1, line_item2]) object_with_order = double(:object_with_order, order: order) diff --git a/spec/models/spree/calculator/flat_percent_item_total_spec.rb b/spec/models/spree/calculator/flat_percent_item_total_spec.rb index 998b5fca2a..72fe29d9d1 100644 --- a/spec/models/spree/calculator/flat_percent_item_total_spec.rb +++ b/spec/models/spree/calculator/flat_percent_item_total_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Spree::Calculator::FlatPercentItemTotal do let(:calculator) { Spree::Calculator::FlatPercentItemTotal.new } - let(:line_item) { instance_double(Spree::LineItem, amount: 10) } + let(:line_item) { build(:line_item, price: 10, quantity: 1) } before { calculator.stub :preferred_flat_percent => 10 } diff --git a/spec/models/spree/calculator/flexi_rate_spec.rb b/spec/models/spree/calculator/flexi_rate_spec.rb index 6659da86fd..b821f4fc74 100644 --- a/spec/models/spree/calculator/flexi_rate_spec.rb +++ b/spec/models/spree/calculator/flexi_rate_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Spree::Calculator::FlexiRate do - let(:line_item) { instance_double(Spree::LineItem, amount: 10, quantity: quantity) } + let(:line_item) { build(:line_item, quantity: quantity) } let(:calculator) do Spree::Calculator::FlexiRate.new( preferred_first_item: 2, diff --git a/spec/models/spree/calculator/per_item_spec.rb b/spec/models/spree/calculator/per_item_spec.rb index 7f483372d5..a50c5264b3 100644 --- a/spec/models/spree/calculator/per_item_spec.rb +++ b/spec/models/spree/calculator/per_item_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Spree::Calculator::PerItem do let(:calculator) { Spree::Calculator::PerItem.new(preferred_amount: 10) } let(:shipping_calculable) { double(:calculable) } - let(:line_item) { double(:line_item, quantity: 5, product: double(:product)) } + let(:line_item) { build(:line_item, quantity: 5) } it "correctly calculates on a single line item object" do calculator.stub(calculable: shipping_calculable) From a341561446c0bc67ccfba599ded6bd51855b2c13 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 18 Dec 2018 17:30:36 +1100 Subject: [PATCH 05/24] Move tax rate finding into service and spec it The `#tax_rates` method is actually not present in Spree. We encapsulate the logic in this commit and enable better unit testing. The new tests cover a current bug: https://github.com/openfoodfoundation/openfoodnetwork/issues/3127 --- app/models/spree/adjustment_decorator.rb | 24 +------- app/services/tax_rate_finder.rb | 33 +++++++++++ spec/models/spree/adjustment_spec.rb | 15 ----- spec/services/tax_rate_finder_spec.rb | 73 ++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 38 deletions(-) create mode 100644 app/services/tax_rate_finder.rb create mode 100644 spec/services/tax_rate_finder_spec.rb diff --git a/app/models/spree/adjustment_decorator.rb b/app/models/spree/adjustment_decorator.rb index bca08752da..61e968d844 100644 --- a/app/models/spree/adjustment_decorator.rb +++ b/app/models/spree/adjustment_decorator.rb @@ -42,29 +42,7 @@ module Spree # @return [Array] def tax_rates - case originator - when Spree::TaxRate - [originator] - when EnterpriseFee - case source - when Spree::LineItem - tax_category = originator.inherits_tax_category? ? source.product.tax_category : originator.tax_category - return tax_category ? tax_category.tax_rates.match(source.order) : [] - when Spree::Order - return originator.tax_category ? originator.tax_category.tax_rates.match(source) : [] - end - else - find_closest_tax_rates_from_included_tax - end - end - - # shipping fees and adjustments created from the admin panel have - # taxes set at creation in the included_tax field without relation - # to the corresponding TaxRate, so we look for the closest one - def find_closest_tax_rates_from_included_tax - approximation = (included_tax / (amount - included_tax)) - return [] if approximation.infinite? or approximation.zero? - [Spree::TaxRate.order("ABS(amount - #{approximation})").first] + TaxRateFinder.new.tax_rates(originator, source, amount, included_tax) end def self.without_callbacks diff --git a/app/services/tax_rate_finder.rb b/app/services/tax_rate_finder.rb new file mode 100644 index 0000000000..b0a5c65446 --- /dev/null +++ b/app/services/tax_rate_finder.rb @@ -0,0 +1,33 @@ +# Finds tax rates on which an adjustment is based on. +# For example a packaging fee may contain VAT. This service finds the VAT rate +# for the tax included in the packaging fee. +class TaxRateFinder + # @return [Array] + def tax_rates(originator, source, amount, included_tax) + case originator + when Spree::TaxRate + [originator] + when EnterpriseFee + case source + when Spree::LineItem + tax_category = originator.inherits_tax_category? ? source.product.tax_category : originator.tax_category + tax_category ? tax_category.tax_rates.match(source.order) : [] + when Spree::Order + originator.tax_category ? originator.tax_category.tax_rates.match(source) : [] + end + else + find_closest_tax_rates_from_included_tax(amount, included_tax) + end + end + + private + + # shipping fees and adjustments created from the admin panel have + # taxes set at creation in the included_tax field without relation + # to the corresponding TaxRate, so we look for the closest one + def find_closest_tax_rates_from_included_tax(amount, included_tax) + approximation = (included_tax / (amount - included_tax)) + return [] if approximation.infinite? || approximation.zero? + [Spree::TaxRate.order("ABS(amount - #{approximation})").first] + end +end diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index fa24de3122..f6466ec0d1 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -281,21 +281,6 @@ module Spree adjustment.included_tax.should == 10.00 end end - - describe "getting the corresponding tax rate" do - let!(:adjustment_with_tax) { create(:adjustment, amount: 50, included_tax: 10) } - let!(:adjustment_without_tax) { create(:adjustment, amount: 50, included_tax: 0) } - let!(:tax_rate) { create(:tax_rate, calculator: Spree::Calculator::DefaultTax.new, amount: 0.25) } - let!(:other_tax_rate) { create(:tax_rate, calculator: Spree::Calculator::DefaultTax.new, amount: 0.3) } - - it "returns [] if there is no included tax" do - adjustment_without_tax.find_closest_tax_rates_from_included_tax.should == [] - end - - it "returns the most accurate tax rate" do - adjustment_with_tax.find_closest_tax_rates_from_included_tax.should == [tax_rate] - end - end end context "extends LocalizedNumber" do diff --git a/spec/services/tax_rate_finder_spec.rb b/spec/services/tax_rate_finder_spec.rb new file mode 100644 index 0000000000..7debe8d154 --- /dev/null +++ b/spec/services/tax_rate_finder_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +describe TaxRateFinder do + describe "getting the corresponding tax rate" do + let(:amount) { BigDecimal(100) } + let(:included_tax) { BigDecimal(20) } + let(:tax_rate) { create_rate(0.2) } + let(:close_tax_rate) { create_rate(0.25) } + let(:other_tax_rate) { create_rate(0.3) } + let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) } + # This zone is used by :order_with_taxes and needs to match it + let(:zone) { create(:zone, name: "GlobalZone") } + let(:shipment) { create(:shipment) } + let(:enterprise_fee) { create(:enterprise_fee, tax_category: tax_category) } + let(:order) { create(:order_with_taxes) } + + it "finds the tax rate of a shipping fee" do + rates = TaxRateFinder.new.tax_rates( + tax_rate, + shipment, + amount, + included_tax + ) + expect(rates).to eq [tax_rate] + end + + it "finds a close match" do + close_tax_rate + other_tax_rate + + rates = TaxRateFinder.new.tax_rates( + nil, + shipment, + amount, + included_tax + ) + + expect(rates).to eq [close_tax_rate] + end + + it "finds the tax rate of an enterprise fee" do + rates = TaxRateFinder.new.tax_rates( + enterprise_fee, + order, + amount, + included_tax + ) + expect(rates).to eq [tax_rate] + end + + # There is a bug that leaves orphan adjustments on an order after + # associated line items have been removed. + # https://github.com/openfoodfoundation/openfoodnetwork/issues/3127 + pending "deals with a missing line item" do + rates = TaxRateFinder.new.tax_rates( + enterprise_fee, + nil, + amount, + included_tax + ) + expect(rates).to eq [tax_rate] + end + + def create_rate(amount) + create( + :tax_rate, + amount: amount, + calculator: Spree::Calculator::DefaultTax.new, + zone: zone + ) + end + end +end From 3169a384ba94b1cf860021efbd7995698ed91d37 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 18 Dec 2018 17:45:12 +1100 Subject: [PATCH 06/24] Find approximate tax rate if no other is found There are several cases in which a tax rate is not associated with an adjustment. We find the closest one for reporting here. It is not a good solution, but a workaround introduced for reporting: https://github.com/openfoodfoundation/openfoodnetwork/pull/1496 --- app/services/tax_rate_finder.rb | 11 +++++++---- spec/services/tax_rate_finder_spec.rb | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/services/tax_rate_finder.rb b/app/services/tax_rate_finder.rb index b0a5c65446..ede2e1c629 100644 --- a/app/services/tax_rate_finder.rb +++ b/app/services/tax_rate_finder.rb @@ -4,6 +4,13 @@ class TaxRateFinder # @return [Array] def tax_rates(originator, source, amount, included_tax) + find_associated_tax_rate(originator, source) || + find_closest_tax_rates_from_included_tax(amount, included_tax) + end + + private + + def find_associated_tax_rate(originator, source) case originator when Spree::TaxRate [originator] @@ -15,13 +22,9 @@ class TaxRateFinder when Spree::Order originator.tax_category ? originator.tax_category.tax_rates.match(source) : [] end - else - find_closest_tax_rates_from_included_tax(amount, included_tax) end end - private - # shipping fees and adjustments created from the admin panel have # taxes set at creation in the included_tax field without relation # to the corresponding TaxRate, so we look for the closest one diff --git a/spec/services/tax_rate_finder_spec.rb b/spec/services/tax_rate_finder_spec.rb index 7debe8d154..4b3790d4ae 100644 --- a/spec/services/tax_rate_finder_spec.rb +++ b/spec/services/tax_rate_finder_spec.rb @@ -51,7 +51,7 @@ describe TaxRateFinder do # There is a bug that leaves orphan adjustments on an order after # associated line items have been removed. # https://github.com/openfoodfoundation/openfoodnetwork/issues/3127 - pending "deals with a missing line item" do + it "deals with a missing line item" do rates = TaxRateFinder.new.tax_rates( enterprise_fee, nil, From fc1b18227574130ac0c82c626b630ddd1c9c39ed Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Dec 2018 14:09:48 +1100 Subject: [PATCH 07/24] Simplify method complexity and comply with rubocop --- app/services/tax_rate_finder.rb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/app/services/tax_rate_finder.rb b/app/services/tax_rate_finder.rb index ede2e1c629..2ce475fc5a 100644 --- a/app/services/tax_rate_finder.rb +++ b/app/services/tax_rate_finder.rb @@ -15,13 +15,25 @@ class TaxRateFinder when Spree::TaxRate [originator] when EnterpriseFee - case source - when Spree::LineItem - tax_category = originator.inherits_tax_category? ? source.product.tax_category : originator.tax_category - tax_category ? tax_category.tax_rates.match(source.order) : [] - when Spree::Order - originator.tax_category ? originator.tax_category.tax_rates.match(source) : [] - end + enterprise_fee_tax_rates(originator, source) + end + end + + def enterprise_fee_tax_rates(enterprise_fee, source) + case source + when Spree::LineItem + tax_category = line_item_tax_category(enterprise_fee, source) + tax_category ? tax_category.tax_rates.match(source.order) : [] + when Spree::Order + enterprise_fee.tax_category ? enterprise_fee.tax_category.tax_rates.match(source) : [] + end + end + + def line_item_tax_category(enterprise_fee, line_item) + if enterprise_fee.inherits_tax_category? + line_item.product.tax_category + else + enterprise_fee.tax_category end end From a978e992bfa7dbd2f2c70f04b78a41c2ab96a158 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Dec 2018 14:42:38 +1100 Subject: [PATCH 08/24] Remove `tax_rates` shortcut from adjustment Becoming less dependent on Spree, using our own namespace, keeping decorators small. --- app/helpers/checkout_helper.rb | 2 +- app/models/spree/adjustment_decorator.rb | 5 ----- app/models/spree/order_decorator.rb | 2 +- app/services/tax_rate_finder.rb | 10 ++++++++++ lib/open_food_network/enterprise_fee_applicator.rb | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index bc885bd5dc..4d64735cfc 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -54,7 +54,7 @@ module CheckoutHelper end def display_adjustment_tax_rates(adjustment) - tax_rates = adjustment.tax_rates + tax_rates = TaxRateFinder.tax_rates_of(adjustment) tax_rates.map { |tr| number_to_percentage(tr.amount * 100, :precision => 1) }.join(", ") end diff --git a/app/models/spree/adjustment_decorator.rb b/app/models/spree/adjustment_decorator.rb index 61e968d844..e7ffcf41f0 100644 --- a/app/models/spree/adjustment_decorator.rb +++ b/app/models/spree/adjustment_decorator.rb @@ -40,11 +40,6 @@ module Spree included_tax > 0 end - # @return [Array] - def tax_rates - TaxRateFinder.new.tax_rates(originator, source, amount, included_tax) - end - def self.without_callbacks skip_callback :save, :after, :update_adjustable skip_callback :destroy, :after, :update_adjustable diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb index 5baf95fa1c..be6fcd8fa1 100644 --- a/app/models/spree/order_decorator.rb +++ b/app/models/spree/order_decorator.rb @@ -293,7 +293,7 @@ Spree::Order.class_eval do def tax_adjustment_totals tax_adjustments.each_with_object(Hash.new) do |adjustment, hash| - tax_rates = adjustment.tax_rates + tax_rates = TaxRateFinder.tax_rates_of(adjustment) tax_rates_hash = Hash[tax_rates.collect do |tax_rate| tax_amount = tax_rates.one? ? adjustment.included_tax : tax_rate.compute_tax(adjustment.amount) [tax_rate, tax_amount] diff --git a/app/services/tax_rate_finder.rb b/app/services/tax_rate_finder.rb index 2ce475fc5a..dc6bdd83a2 100644 --- a/app/services/tax_rate_finder.rb +++ b/app/services/tax_rate_finder.rb @@ -2,6 +2,16 @@ # For example a packaging fee may contain VAT. This service finds the VAT rate # for the tax included in the packaging fee. class TaxRateFinder + # @return [Array] + def self.tax_rates_of(adjustment) + new.tax_rates( + adjustment.originator, + adjustment.source, + adjustment.amount, + adjustment.included_tax + ) + end + # @return [Array] def tax_rates(originator, source, amount, included_tax) find_associated_tax_rate(originator, source) || diff --git a/lib/open_food_network/enterprise_fee_applicator.rb b/lib/open_food_network/enterprise_fee_applicator.rb index e213204047..cafe67ea7b 100644 --- a/lib/open_food_network/enterprise_fee_applicator.rb +++ b/lib/open_food_network/enterprise_fee_applicator.rb @@ -32,7 +32,7 @@ module OpenFoodNetwork end def adjustment_tax(adjustable, adjustment) - tax_rates = adjustment.tax_rates + tax_rates = TaxRateFinder.tax_rates_of(adjustment) tax_rates.select(&:included_in_price).sum do |rate| rate.compute_tax adjustment.amount From aac8706f9a1ebf36a1667f24c08a728d060e8dd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 20 Dec 2018 08:35:01 +0000 Subject: [PATCH 09/24] Bump blockenspiel from 0.4.5 to 0.5.0 Bumps [blockenspiel](https://github.com/dazuma/blockenspiel) from 0.4.5 to 0.5.0. - [Release notes](https://github.com/dazuma/blockenspiel/releases) - [Changelog](https://github.com/dazuma/blockenspiel/blob/master/History.rdoc) - [Commits](https://github.com/dazuma/blockenspiel/commits/v0.5.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 01a6d4aa12..eaefbb57f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -201,7 +201,7 @@ GEM bcrypt (3.1.11) bcrypt-ruby (3.1.5) bcrypt (>= 3.1.3) - blockenspiel (0.4.5) + blockenspiel (0.5.0) bugsnag (4.1.0) builder (3.0.4) byebug (9.0.6) From 4eaaeb37c9cc1bf10f0f4c26157f414c16c10c0e Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 26 Dec 2018 13:07:52 +0000 Subject: [PATCH 10/24] Reverting to therubyracer because mini racer is causing trouble to some developers using osx. We will probably be able to move back to the faster mini racer when we upgrade to newer rails versions --- Gemfile | 5 +---- Gemfile.lock | 13 +++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index c2762a6aa9..f332520e61 100644 --- a/Gemfile +++ b/Gemfile @@ -88,10 +88,7 @@ group :assets do gem 'compass-rails' gem 'coffee-rails', '~> 3.2.1' - gem 'mini_racer' - # We found that the following version of libv8 breaks the compilation of mini_racer. - # Nothing else depends on libv8. - gem 'libv8', '!= 6.7.288.46.1' + gem 'therubyracer', '=0.12.0' gem 'uglifier', '>= 1.0.3' diff --git a/Gemfile.lock b/Gemfile.lock index b7abc02c6a..384dbd1b20 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -511,7 +511,7 @@ GEM addressable (~> 2.3) letter_opener (1.6.0) launchy (~> 2.2) - libv8 (6.3.292.48.1) + libv8 (3.16.14.19) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -523,8 +523,6 @@ GEM mime-types (1.25.1) mini_mime (1.0.1) mini_portile2 (2.1.0) - mini_racer (0.1.15) - libv8 (~> 6.3) momentjs-rails (2.20.1) railties (>= 3.1) money (5.1.0) @@ -627,6 +625,7 @@ GEM rdoc (3.12.2) json (~> 1.4) redcarpet (3.2.3) + ref (2.0.0) roadie (3.4.0) css_parser (~> 1.4) nokogiri (~> 1.5) @@ -705,6 +704,9 @@ GEM stringex (1.3.3) stripe (3.3.2) faraday (~> 0.9) + therubyracer (0.12.0) + libv8 (~> 3.16.14.0) + ref thor (0.20.3) tilt (1.4.1) timecop (0.9.1) @@ -802,9 +804,7 @@ DEPENDENCIES jwt (~> 1.5) knapsack letter_opener (>= 1.4.1) - libv8 (!= 6.7.288.46.1) listen (= 3.0.8) - mini_racer momentjs-rails nokogiri (>= 1.6.7.1) oauth2 (~> 1.2.0) @@ -840,6 +840,7 @@ DEPENDENCIES spree_i18n! spree_paypal_express! stripe (~> 3.3.2) + therubyracer (= 0.12.0) timecop truncate_html turbo-sprockets-rails3 @@ -856,4 +857,4 @@ RUBY VERSION ruby 2.1.5p273 BUNDLED WITH - 1.16.4 + 1.17.2 From 6dccbeca703b7a95d5670e50bdfa9b791c4ed3c5 Mon Sep 17 00:00:00 2001 From: Alvaro Chalar Date: Mon, 17 Dec 2018 09:19:46 +0100 Subject: [PATCH 11/24] Add custom footer message in reports section --- app/views/spree/admin/reports/_table.html.haml | 2 +- app/views/spree/admin/reports/bulk_coop.html.haml | 2 +- app/views/spree/admin/reports/customers.html.haml | 4 ++-- .../admin/reports/order_cycle_management.html.haml | 2 +- .../admin/reports/orders_and_distributors.html.haml | 2 +- .../admin/reports/orders_and_fulfillment.html.haml | 2 +- app/views/spree/admin/reports/packing.html.haml | 2 +- app/views/spree/admin/reports/payments.html.haml | 2 +- .../admin/reports/products_and_inventory.html.haml | 4 ++-- app/views/spree/admin/reports/sales_tax.html.haml | 2 +- .../admin/reports/users_and_enterprises.html.haml | 2 +- app/views/spree/admin/reports/xero_invoices.html.haml | 2 +- config/locales/en.yml | 2 +- spec/features/admin/reports_spec.rb | 10 +++++----- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/views/spree/admin/reports/_table.html.haml b/app/views/spree/admin/reports/_table.html.haml index 7cc612a82d..d1927aaf55 100644 --- a/app/views/spree/admin/reports/_table.html.haml +++ b/app/views/spree/admin/reports/_table.html.haml @@ -20,4 +20,4 @@ %td{colspan: @header.count}= t(:none) - else %p.report__message - = t(".select_and_search") + = t(".select_and_search", option: msg_option.upcase) diff --git a/app/views/spree/admin/reports/bulk_coop.html.haml b/app/views/spree/admin/reports/bulk_coop.html.haml index a3a3b8e367..c644e8dd6e 100644 --- a/app/views/spree/admin/reports/bulk_coop.html.haml +++ b/app/views/spree/admin/reports/bulk_coop.html.haml @@ -16,4 +16,4 @@ %br = button t(:search) -= render "table", id: "listing_orders" += render "table", id: "listing_orders", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/customers.html.haml b/app/views/spree/admin/reports/customers.html.haml index 63d084f016..8f58149ae7 100644 --- a/app/views/spree/admin/reports/customers.html.haml +++ b/app/views/spree/admin/reports/customers.html.haml @@ -27,6 +27,6 @@ = check_box_tag :csv = label_tag :csv, t(:report_customers_csv) %br - = button t(:search) + = button t(:go) -= render "table", id: "listing_customers" += render "table", id: "listing_customers", msg_option: t(:go) diff --git a/app/views/spree/admin/reports/order_cycle_management.html.haml b/app/views/spree/admin/reports/order_cycle_management.html.haml index 54d9eca68a..746aa4e282 100644 --- a/app/views/spree/admin/reports/order_cycle_management.html.haml +++ b/app/views/spree/admin/reports/order_cycle_management.html.haml @@ -29,4 +29,4 @@ .row = button t(:search) -= render "table", id: "listing_ocm_orders" += render "table", id: "listing_ocm_orders", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/orders_and_distributors.html.haml b/app/views/spree/admin/reports/orders_and_distributors.html.haml index 2279438c25..efd7ebbd07 100644 --- a/app/views/spree/admin/reports/orders_and_distributors.html.haml +++ b/app/views/spree/admin/reports/orders_and_distributors.html.haml @@ -6,4 +6,4 @@ %br = button t(:search) -= render "table", id: "listing_orders" += render "table", id: "listing_orders", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/orders_and_fulfillment.html.haml b/app/views/spree/admin/reports/orders_and_fulfillment.html.haml index 9bf5b6bd24..91921959ec 100644 --- a/app/views/spree/admin/reports/orders_and_fulfillment.html.haml +++ b/app/views/spree/admin/reports/orders_and_fulfillment.html.haml @@ -25,4 +25,4 @@ .row = button t(:search) -= render "table", id: "listing_orders" += render "table", id: "listing_orders", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/packing.html.haml b/app/views/spree/admin/reports/packing.html.haml index 742520d715..d8b881c6cd 100644 --- a/app/views/spree/admin/reports/packing.html.haml +++ b/app/views/spree/admin/reports/packing.html.haml @@ -25,4 +25,4 @@ .row = button t(:search) -= render "table", id: "listing_orders" += render "table", id: "listing_orders", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/payments.html.haml b/app/views/spree/admin/reports/payments.html.haml index 23b046e7c0..5da46d8d5e 100644 --- a/app/views/spree/admin/reports/payments.html.haml +++ b/app/views/spree/admin/reports/payments.html.haml @@ -16,4 +16,4 @@ %br = button t(:search) -= render "table", id: "listing_orders" += render "table", id: "listing_orders", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/products_and_inventory.html.haml b/app/views/spree/admin/reports/products_and_inventory.html.haml index 3d552b81be..73d31a6990 100644 --- a/app/views/spree/admin/reports/products_and_inventory.html.haml +++ b/app/views/spree/admin/reports/products_and_inventory.html.haml @@ -30,5 +30,5 @@ = check_box_tag :csv = label_tag :csv, t(:report_customers_csv) %br - = button t(:search) -= render "table", id: "listing_products" + = button t(:go) += render "table", id: "listing_products", msg_option: t(:go) diff --git a/app/views/spree/admin/reports/sales_tax.html.haml b/app/views/spree/admin/reports/sales_tax.html.haml index d64f73ec4d..1482d27266 100644 --- a/app/views/spree/admin/reports/sales_tax.html.haml +++ b/app/views/spree/admin/reports/sales_tax.html.haml @@ -16,4 +16,4 @@ %br = button t(:search) -= render "table", id: "listing_orders", column_partials: {0 => "link_order"} += render "table", id: "listing_orders", column_partials: {0 => "link_order"}, msg_option: t(:search) diff --git a/app/views/spree/admin/reports/users_and_enterprises.html.haml b/app/views/spree/admin/reports/users_and_enterprises.html.haml index 4c74a79e0d..03f255820b 100644 --- a/app/views/spree/admin/reports/users_and_enterprises.html.haml +++ b/app/views/spree/admin/reports/users_and_enterprises.html.haml @@ -18,4 +18,4 @@ .row = button t(:search) -= render "table", id: "users_and_enterprises" += render "table", id: "users_and_enterprises", msg_option: t(:search) diff --git a/app/views/spree/admin/reports/xero_invoices.html.haml b/app/views/spree/admin/reports/xero_invoices.html.haml index 0139b42a68..bdbea6b13e 100644 --- a/app/views/spree/admin/reports/xero_invoices.html.haml +++ b/app/views/spree/admin/reports/xero_invoices.html.haml @@ -32,4 +32,4 @@ .four.columns.alpha= button t(:search) -= render "table", id: "listing_invoices" += render "table", id: "listing_invoices", msg_option: t(:search) diff --git a/config/locales/en.yml b/config/locales/en.yml index 6fc4f61cbe..8856c10235 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2772,7 +2772,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using display_as: Display As reports: table: - select_and_search: "Select filters and click on SEARCH to access your data." + select_and_search: "Select filters and click on %{option} to access your data." bulk_coop: bulk_coop_supplier_report: 'Bulk Co-op - Totals by Supplier' bulk_coop_allocation: 'Bulk Co-op - Allocation' diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 6e2f310175..a552786618 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -40,8 +40,8 @@ feature %q{ scenario "customers report" do click_link "Mailing List" expect(page).to have_select('report_type', selected: 'Mailing List') - expect(page).to have_content "click on SEARCH" - click_button "Search" + expect(page).to have_content "click on GO" + click_button "Go" rows = find("table#listing_customers").all("thead tr") table = rows.map { |r| r.all("th").map { |c| c.text.strip } } @@ -54,7 +54,7 @@ feature %q{ click_link "Addresses" expect(page).to have_select('report_type', selected: 'Addresses') - click_button "Search" + click_button "Go" rows = find("table#listing_customers").all("thead tr") table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ @@ -323,7 +323,7 @@ feature %q{ expect(page).to have_content "All products" expect(page).to have_content "Inventory (on hand)" click_link 'Products & Inventory' - click_button "Search" + click_button "Go" expect(page).to have_content "Supplier" expect(page).to have_table_row ["Supplier", "Producer Suburb", "Product", "Product Properties", "Taxons", "Variant Value", "Price", "Group Buy Unit Quantity", "Amount", "SKU"].map(&:upcase) expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city, "Product Name", product1.properties.map(&:presentation).join(", "), product1.primary_taxon.name, "Test", "100.0", product1.group_buy_unit_size.to_s, "", "sku1"] @@ -335,7 +335,7 @@ feature %q{ quick_login_as_admin visit spree.admin_reports_path click_link 'LettuceShare' - click_button "Search" + click_button "Go" expect(page).to have_table_row ['PRODUCT', 'Description', 'Qty', 'Pack Size', 'Unit', 'Unit Price', 'Total', 'GST incl.', 'Grower and growing method', 'Taxon'].map(&:upcase) expect(page).to have_table_row ['Product 2', '100g', '', '100', 'g', '99.0', '', '0', 'Supplier Name (Organic - NASAA 12345)', 'Taxon Name'] From cca15e75a6ccc79d207443ee709305871746eea8 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Fri, 28 Dec 2018 20:40:32 +0100 Subject: [PATCH 12/24] Refactor to reveal how we load enterprises in shop By sticking to Rails conventions we make it more obvious how (badly) we are loading enterprises in EnterprisesController#shop and shed some light on the obscure InjectionHelper. This will also make it easier to improve its performance in the future as it's among the top offenders. See https://www.skylight.io/app/applications/ibo3NOqCYMnq/1545851520/1d/endpoints/EnterprisesController%23shop?responseType=html --- app/controllers/enterprises_controller.rb | 27 ++++++++++++++++++++++- app/helpers/injection_helper.rb | 9 -------- app/views/enterprises/shop.html.haml | 2 +- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 00af18d701..6a817a47d7 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -7,13 +7,28 @@ class EnterprisesController < BaseController # These prepended filters are in the reverse order of execution prepend_before_filter :set_order_cycles, :require_distributor_chosen, :reset_order, only: :shop - before_filter :check_stock_levels, :set_noindex_meta_tag, only: :shop before_filter :clean_permalink, only: :check_permalink before_filter :enable_embedded_shopfront respond_to :js, only: :permalink_checker + def shop + check_stock_levels + set_noindex_meta_tag + + order_cycles = if current_order_cycle + [current_order_cycle] + else + OrderCycle.not_closed.with_distributor(current_distributor) + end + + enterprises = current_distributor.plus_relatives_and_oc_producers(order_cycles).activated.includes(address: :state).all + enterprises = inject_json_ams('enterprises', enterprises) + + render locals: { enterprises: enterprises } + end + def relatives set_enterprise @@ -88,4 +103,14 @@ class EnterprisesController < BaseController def set_noindex_meta_tag @noindex_meta_tag = true unless current_distributor.visible? end + + def inject_json_ams(name, object) + options = { + each_serializer: Api::EnterpriseSerializer, + data: OpenFoodNetwork::EnterpriseInjectionData.new + } + serializer_instance = ActiveModel::ArraySerializer.new(object, options) + + { name: name, json: serializer_instance.to_json } + end end diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index dfcf2bb6ff..52d178cb74 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -14,15 +14,6 @@ module InjectionHelper inject_json_ams "enterprises", current_distributor.relatives_including_self.activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data end - def inject_shop_enterprises - ocs = if current_order_cycle - [current_order_cycle] - else - OrderCycle.not_closed.with_distributor(current_distributor) - end - inject_json_ams "enterprises", current_distributor.plus_relatives_and_oc_producers(ocs).activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data - end - def inject_group_enterprises inject_json_ams "group_enterprises", @group.enterprises.activated.all, Api::EnterpriseSerializer, enterprise_injection_data end diff --git a/app/views/enterprises/shop.html.haml b/app/views/enterprises/shop.html.haml index f05ac115f3..041c8be07b 100644 --- a/app/views/enterprises/shop.html.haml +++ b/app/views/enterprises/shop.html.haml @@ -5,7 +5,7 @@ - content_for(:image) do = current_distributor.logo.url -= inject_shop_enterprises += render partial: 'json/injection_ams', locals: enterprises %shop.darkswarm - if @shopfront_layout == 'embedded' From 46760ce28c98ec4a9da1b724713f4968691ae54a Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Sun, 30 Dec 2018 11:42:37 +0100 Subject: [PATCH 13/24] Do not double-render when there is no stock --- app/controllers/enterprises_controller.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 6a817a47d7..83f8ae93cf 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -14,7 +14,7 @@ class EnterprisesController < BaseController respond_to :js, only: :permalink_checker def shop - check_stock_levels + return redirect_to spree.cart_path unless enough_stock? set_noindex_meta_tag order_cycles = if current_order_cycle @@ -63,10 +63,8 @@ class EnterprisesController < BaseController params[:permalink] = params[:permalink].parameterize end - def check_stock_levels - if current_order(true).insufficient_stock_lines.present? - redirect_to spree.cart_path - end + def enough_stock? + current_order(true).insufficient_stock_lines.blank? end def reset_order From 51da607ab1868ed64815194a660703b7728a2de2 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 2 Jan 2019 13:07:52 +0100 Subject: [PATCH 14/24] Fix too long line --- app/controllers/enterprises_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 83f8ae93cf..35100ff6b9 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -23,7 +23,11 @@ class EnterprisesController < BaseController OrderCycle.not_closed.with_distributor(current_distributor) end - enterprises = current_distributor.plus_relatives_and_oc_producers(order_cycles).activated.includes(address: :state).all + enterprises = current_distributor + .plus_relatives_and_oc_producers(order_cycles) + .activated + .includes(address: :state) + .all enterprises = inject_json_ams('enterprises', enterprises) render locals: { enterprises: enterprises } From e3edb51d3e974128e433b3cd6c0df82771cc4148 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 2 Jan 2019 13:46:24 +0100 Subject: [PATCH 15/24] Update rubocop_todo --- .rubocop_todo.yml | 142 ++++++++++++++-------------------------------- 1 file changed, 43 insertions(+), 99 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e8b203c9d6..38fa7f623d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 1400` -# on 2018-10-25 13:57:32 +1100 using RuboCop version 0.57.2. +# on 2019-01-02 13:44:41 +0100 using RuboCop version 0.57.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -27,7 +27,7 @@ Layout/AlignArray: - 'spec/lib/open_food_network/order_grouper_spec.rb' - 'spec/services/cart_service_spec.rb' -# Offense count: 121 +# Offense count: 122 # Cop supports --auto-correct. # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table @@ -56,8 +56,9 @@ Layout/AlignHash: - 'spec/models/order_cycle_spec.rb' - 'spec/models/spree/shipping_method_spec.rb' - 'spec/models/spree/variant_spec.rb' + - 'spec/models/variant_override_spec.rb' -# Offense count: 60 +# Offense count: 49 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_parameter, with_fixed_indentation @@ -68,7 +69,6 @@ Layout/AlignParameters: - 'app/models/enterprise_group.rb' - 'app/models/enterprise_relationship.rb' - 'app/serializers/api/address_serializer.rb' - - 'app/serializers/api/enterprise_serializer.rb' - 'app/serializers/api/shipping_method_serializer.rb' - 'lib/spree/product_filters.rb' - 'spec/controllers/enterprises_controller_spec.rb' @@ -94,11 +94,12 @@ Layout/BlockAlignment: - 'spec/models/spree/line_item_spec.rb' - 'spec/models/spree/product_spec.rb' -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. Layout/BlockEndNewline: Exclude: - 'spec/features/consumer/shopping/cart_spec.rb' + - 'spec/models/variant_override_spec.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -124,7 +125,7 @@ Layout/ElseAlignment: - 'app/serializers/api/admin/order_cycle_serializer.rb' - 'lib/open_food_network/sales_tax_report.rb' -# Offense count: 197 +# Offense count: 187 # Cop supports --auto-correct. Layout/EmptyLines: Exclude: @@ -137,7 +138,6 @@ Layout/EmptyLines: - 'app/controllers/spree/admin/adjustments_controller_decorator.rb' - 'app/controllers/spree/admin/base_controller_decorator.rb' - 'app/controllers/spree/admin/general_settings_controller_decorator.rb' - - 'app/controllers/spree/admin/orders_controller_decorator.rb' - 'app/controllers/spree/admin/payments_controller_decorator.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/admin/variants_controller_decorator.rb' @@ -148,10 +148,8 @@ Layout/EmptyLines: - 'app/jobs/finalize_account_invoices.rb' - 'app/jobs/products_cache_integrity_checker_job.rb' - 'app/jobs/refresh_products_cache_job.rb' - - 'app/mailers/producer_mailer.rb' - 'app/models/coordinator_fee.rb' - 'app/models/enterprise_fee.rb' - - 'app/models/enterprise_relationship.rb' - 'app/models/exchange.rb' - 'app/models/exchange_fee.rb' - 'app/models/inventory_item.rb' @@ -176,7 +174,6 @@ Layout/EmptyLines: - 'app/models/spree/shipping_method_decorator.rb' - 'app/models/spree/tax_rate_decorator.rb' - 'app/models/spree/taxon_decorator.rb' - - 'app/serializers/api/enterprise_serializer.rb' - 'lib/open_food_network/cached_products_renderer.rb' - 'lib/open_food_network/enterprise_fee_applicator.rb' - 'lib/open_food_network/enterprise_issue_validator.rb' @@ -188,7 +185,6 @@ Layout/EmptyLines: - 'lib/open_food_network/products_cache.rb' - 'lib/open_food_network/products_cache_integrity_checker.rb' - 'lib/open_food_network/products_renderer.rb' - - 'lib/open_food_network/property_merge.rb' - 'lib/open_food_network/reports/bulk_coop_report.rb' - 'lib/open_food_network/sales_tax_report.rb' - 'lib/open_food_network/scope_product_to_hub.rb' @@ -246,7 +242,6 @@ Layout/EmptyLines: - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/shipping_method_spec.rb' - 'spec/models/spree/variant_spec.rb' - - 'spec/models/variant_override_spec.rb' - 'spec/serializers/admin/exchange_serializer_spec.rb' - 'spec/serializers/admin/for_order_cycle/enterprise_serializer_spec.rb' - 'spec/serializers/admin/for_order_cycle/supplied_product_serializer_spec.rb' @@ -261,15 +256,13 @@ Layout/EmptyLinesAroundArguments: Exclude: - 'spec/archive/features/consumer/checkout_spec.rb' -# Offense count: 59 +# Offense count: 51 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines Layout/EmptyLinesAroundBlockBody: Exclude: - - 'app/controllers/spree/admin/orders_controller_decorator.rb' - 'app/controllers/spree/api/orders_controller_decorator.rb' - - 'app/controllers/spree/api/products_controller_decorator.rb' - 'app/controllers/spree/checkout_controller_decorator.rb' - 'app/models/spree/calculator/default_tax_decorator.rb' - 'app/models/spree/calculator_decorator.rb' @@ -279,21 +272,17 @@ Layout/EmptyLinesAroundBlockBody: - 'lib/spree/money_decorator.rb' - 'spec/controllers/admin/order_cycles_controller_spec.rb' - 'spec/controllers/admin/tag_rules_controller_spec.rb' - - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/controllers/spree/admin/reports_controller_spec.rb' - 'spec/controllers/spree/api/orders_controller_spec.rb' - 'spec/controllers/spree/orders_controller_spec.rb' - 'spec/controllers/user_confirmations_controller_spec.rb' - - 'spec/controllers/user_registrations_controller_spec.rb' - 'spec/features/admin/caching_spec.rb' - 'spec/features/admin/orders_spec.rb' - 'spec/features/admin/reports_spec.rb' - - 'spec/features/admin/variant_overrides_spec.rb' - 'spec/features/consumer/cookies_spec.rb' - 'spec/features/consumer/shopping/embedded_groups_spec.rb' - 'spec/features/consumer/shopping/embedded_shopfronts_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' - - 'spec/features/consumer/shopping/variant_overrides_spec.rb' - 'spec/helpers/admin/business_model_configuration_helper_spec.rb' - 'spec/helpers/shared_helper_spec.rb' - 'spec/helpers/shop_helper_spec.rb' @@ -317,7 +306,7 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/support/matchers/select2_matchers.rb' - 'spec/support/matchers/table_matchers.rb' -# Offense count: 24 +# Offense count: 23 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only @@ -331,7 +320,6 @@ Layout/EmptyLinesAroundClassBody: - 'app/controllers/api/enterprises_controller.rb' - 'app/controllers/application_controller.rb' - 'app/controllers/home_controller.rb' - - 'app/mailers/producer_mailer.rb' - 'app/models/coordinator_fee.rb' - 'app/models/producer_property.rb' - 'app/models/spree/preferences/file_configuration.rb' @@ -358,7 +346,7 @@ Layout/EndAlignment: - 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb' - 'app/serializers/api/admin/order_cycle_serializer.rb' -# Offense count: 47 +# Offense count: 45 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. Layout/ExtraSpacing: @@ -368,7 +356,6 @@ Layout/ExtraSpacing: - 'app/helpers/admin/injection_helper.rb' - 'app/models/enterprise.rb' - 'app/models/spree/classification_decorator.rb' - - 'app/serializers/api/enterprise_serializer.rb' - 'config.ru' - 'lib/open_food_network/bulk_coop_report.rb' - 'lib/open_food_network/option_value_namer.rb' @@ -453,7 +440,7 @@ Layout/IndentationWidth: - 'spec/models/enterprise_spec.rb' - 'spec/models/spree/calculator/flexi_rate_spec.rb' -# Offense count: 44 +# Offense count: 43 # Cop supports --auto-correct. Layout/LeadingCommentSpace: Exclude: @@ -463,7 +450,6 @@ Layout/LeadingCommentSpace: - 'app/models/spree/inventory_unit_decorator.rb' - 'app/models/spree/taxon_decorator.rb' - 'app/serializers/api/address_serializer.rb' - - 'app/serializers/api/enterprise_serializer.rb' - 'app/serializers/api/product_serializer.rb' - 'spec/archive/features/consumer/checkout_spec.rb' - 'spec/controllers/spree/api/line_items_controller_spec.rb' @@ -479,7 +465,7 @@ Layout/LeadingCommentSpace: - 'spec/support/matchers/select2_matchers.rb' - 'spec/support/request/authentication_workflow.rb' -# Offense count: 44 +# Offense count: 45 # Cop supports --auto-correct. Layout/MultilineBlockLayout: Exclude: @@ -499,6 +485,7 @@ Layout/MultilineBlockLayout: - 'spec/models/order_cycle_spec.rb' - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/variant_spec.rb' + - 'spec/models/variant_override_spec.rb' - 'spec/serializers/enterprise_serializer_spec.rb' # Offense count: 4 @@ -645,7 +632,7 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'spec/support/request/distribution_helper.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 55 +# Offense count: 50 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. Layout/SpaceAroundOperators: @@ -656,7 +643,6 @@ Layout/SpaceAroundOperators: - 'app/overrides/remove_search_bar.rb' - 'app/overrides/remove_side_bar.rb' - 'app/overrides/replace_shipping_address_form_with_distributor_details.rb' - - 'app/serializers/api/enterprise_serializer.rb' - 'lib/open_food_network/xero_invoices_report.rb' - 'lib/spree/product_filters.rb' - 'spec/controllers/admin/enterprises_controller_spec.rb' @@ -721,7 +707,7 @@ Layout/SpaceInsideArrayLiteralBrackets: - 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb' - 'spec/models/spree/order_spec.rb' -# Offense count: 194 +# Offense count: 192 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -774,7 +760,7 @@ Layout/SpaceInsideBlockBraces: - 'spec/spec_helper.rb' - 'spec/support/cancan_helper.rb' -# Offense count: 728 +# Offense count: 702 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -922,7 +908,7 @@ Layout/TrailingBlankLines: Exclude: - 'spec/controllers/cart_controller_spec.rb' -# Offense count: 60 +# Offense count: 57 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: @@ -938,7 +924,6 @@ Layout/TrailingWhitespace: - 'app/views/json/partials/_producer.rabl' - 'spec/controllers/admin/column_preferences_controller_spec.rb' - 'spec/features/admin/customers_spec.rb' - - 'spec/features/admin/variant_overrides_spec.rb' - 'spec/features/consumer/cookies_spec.rb' - 'spec/helpers/enterprises_helper_spec.rb' - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' @@ -951,9 +936,10 @@ Layout/TrailingWhitespace: - 'spec/serializers/enterprise_serializer_spec.rb' - 'spec/support/request/menu_helper.rb' -# Offense count: 1 +# Offense count: 2 Lint/AmbiguousOperator: Exclude: + - 'spec/controllers/api/enterprise_fees_controller_spec.rb' - 'spec/controllers/spree/admin/payments_controller_spec.rb' # Offense count: 4 @@ -962,14 +948,13 @@ Lint/DuplicateMethods: - 'lib/discourse/single_sign_on.rb' - 'lib/open_food_network/subscription_summary.rb' -# Offense count: 16 +# Offense count: 15 Lint/IneffectiveAccessModifier: Exclude: - 'app/models/column_preference.rb' - 'app/models/variant_override.rb' - 'lib/open_food_network/feature_toggle.rb' - 'lib/open_food_network/products_cache.rb' - - 'lib/open_food_network/property_merge.rb' - 'spec/lib/open_food_network/reports/report_spec.rb' # Offense count: 2 @@ -1069,18 +1054,17 @@ Lint/UnusedMethodArgument: - 'lib/open_food_network/paperclippable.rb' - 'lib/open_food_network/rack_request_blocker.rb' -# Offense count: 6 +# Offense count: 5 # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'app/models/column_preference.rb' - 'lib/open_food_network/feature_toggle.rb' - 'lib/open_food_network/products_cache.rb' - - 'lib/open_food_network/property_merge.rb' - 'lib/open_food_network/reports/bulk_coop_report.rb' - 'spec/lib/open_food_network/reports/report_spec.rb' -# Offense count: 242 +# Offense count: 240 # Configuration parameters: CheckForMethodsWithNoSideEffects. Lint/Void: Exclude: @@ -1091,7 +1075,6 @@ Lint/Void: - 'spec/controllers/enterprises_controller_spec.rb' - 'spec/controllers/shop_controller_spec.rb' - 'spec/controllers/spree/admin/adjustments_controller_spec.rb' - - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/controllers/spree/admin/variants_controller_spec.rb' - 'spec/controllers/spree/api/products_controller_spec.rb' - 'spec/controllers/spree/api/variants_controller_spec.rb' @@ -1135,53 +1118,26 @@ Lint/Void: - 'spec/serializers/enterprise_serializer_spec.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 192 -Metrics/AbcSize: - Max: 293 - -# Offense count: 1039 +# Offense count: 110 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: Max: 787 # Offense count: 1 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 4 - -# Offense count: 23 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 331 + Max: 117 -# Offense count: 36 -Metrics/CyclomaticComplexity: - Max: 23 - -# Offense count: 2717 +# Offense count: 1 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Max: 619 + Max: 141 -# Offense count: 161 +# Offense count: 1 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 95 - -# Offense count: 27 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 633 - -# Offense count: 6 -# Configuration parameters: CountKeywordArgs. -Metrics/ParameterLists: - Max: 8 - -# Offense count: 28 -Metrics/PerceivedComplexity: - Max: 21 + Max: 14 # Offense count: 7 Naming/AccessorMethodName: @@ -1236,7 +1192,7 @@ Naming/PredicateName: - 'lib/open_food_network/packing_report.rb' - 'lib/tasks/data.rake' -# Offense count: 13 +# Offense count: 12 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: io, id, to, by, on, in, at Naming/UncommunicativeMethodParamName: @@ -1246,7 +1202,6 @@ Naming/UncommunicativeMethodParamName: - 'app/helpers/spree/base_helper_decorator.rb' - 'app/models/exchange.rb' - 'app/services/subscription_validator.rb' - - 'lib/open_food_network/property_merge.rb' - 'lib/open_food_network/reports/bulk_coop_report.rb' - 'lib/open_food_network/xero_invoices_report.rb' - 'spec/lib/open_food_network/reports/report_spec.rb' @@ -1259,7 +1214,7 @@ Naming/VariableName: Exclude: - 'app/helpers/admin/injection_helper.rb' -# Offense count: 16 +# Offense count: 10 # Configuration parameters: EnforcedStyle. # SupportedStyles: snake_case, normalcase, non_integer Naming/VariableNumber: @@ -1417,7 +1372,7 @@ Rails/HasManyOrHasOneDependent: - 'app/models/spree/variant_decorator.rb' - 'app/models/subscription.rb' -# Offense count: 45 +# Offense count: 46 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: numeric, symbolic @@ -1426,13 +1381,13 @@ Rails/HttpStatus: - 'app/controllers/admin/bulk_line_items_controller.rb' - 'app/controllers/admin/column_preferences_controller.rb' - 'app/controllers/admin/customers_controller.rb' - - 'app/controllers/admin/enterprise_fees_controller.rb' - 'app/controllers/admin/enterprise_relationships_controller.rb' - 'app/controllers/admin/enterprise_roles_controller.rb' - 'app/controllers/admin/manager_invitations_controller.rb' - 'app/controllers/admin/tag_rules_controller.rb' - 'app/controllers/admin/variant_overrides_controller.rb' - 'app/controllers/api/customers_controller.rb' + - 'app/controllers/api/enterprise_fees_controller.rb' - 'app/controllers/api/enterprises_controller.rb' - 'app/controllers/application_controller.rb' - 'app/controllers/cart_controller.rb' @@ -1473,12 +1428,11 @@ Rails/Presence: Exclude: - 'app/serializers/api/admin/customer_serializer.rb' -# Offense count: 4 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. Rails/Present: Exclude: - - 'app/controllers/spree/admin/orders_controller_decorator.rb' - 'app/models/producer_property.rb' - 'lib/open_food_network/products_and_inventory_report.rb' @@ -1655,7 +1609,7 @@ Style/CaseEquality: - 'app/helpers/angular_form_helper.rb' - 'spec/models/spree/payment_spec.rb' -# Offense count: 85 +# Offense count: 82 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: nested, compact @@ -1799,7 +1753,7 @@ Style/EmptyLiteral: - 'app/helpers/checkout_helper.rb' - 'app/models/spree/order_decorator.rb' -# Offense count: 6 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded @@ -1809,7 +1763,6 @@ Style/EmptyMethod: - 'app/controllers/home_controller.rb' - 'app/controllers/map_controller.rb' - 'app/controllers/producers_controller.rb' - - 'app/controllers/shops_controller.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' # Offense count: 2 @@ -1828,19 +1781,17 @@ Style/FormatStringToken: - 'lib/open_food_network/sales_tax_report.rb' - 'spec/models/enterprise_spec.rb' -# Offense count: 80 +# Offense count: 76 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - - 'app/controllers/admin/enterprise_fees_controller.rb' - 'app/controllers/admin/enterprises_controller.rb' - 'app/controllers/admin/order_cycles_controller.rb' - 'app/controllers/admin/product_import_controller.rb' - 'app/controllers/application_controller.rb' - 'app/controllers/base_controller.rb' - 'app/controllers/checkout_controller.rb' - - 'app/controllers/enterprises_controller.rb' - 'app/controllers/home_controller.rb' - 'app/controllers/spree/admin/adjustments_controller_decorator.rb' - 'app/controllers/spree/admin/base_controller_decorator.rb' @@ -1853,7 +1804,6 @@ Style/GuardClause: - 'app/jobs/products_cache_integrity_checker_job.rb' - 'app/jobs/update_account_invoices.rb' - 'app/jobs/update_billable_periods.rb' - - 'app/mailers/producer_mailer.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_group.rb' - 'app/models/producer_property.rb' @@ -1876,7 +1826,7 @@ Style/GuardClause: - 'spec/support/request/distribution_helper.rb' - 'spec/support/request/shop_workflow.rb' -# Offense count: 924 +# Offense count: 872 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -1908,7 +1858,6 @@ Style/HashSyntax: - 'app/helpers/spree/admin/navigation_helper_decorator.rb' - 'app/helpers/spree/admin/orders_helper_decorator.rb' - 'app/mailers/enterprise_mailer.rb' - - 'app/mailers/spree/order_mailer_decorator.rb' - 'app/mailers/spree/user_mailer_decorator.rb' - 'app/models/billable_period.rb' - 'app/models/calculator/flat_percent_per_item.rb' @@ -1947,7 +1896,6 @@ Style/HashSyntax: - 'app/overrides/set_auth_token_in_frontend.rb' - 'app/presenters/variant_presenter.rb' - 'app/serializers/api/admin/enterprise_fee_serializer.rb' - - 'app/serializers/api/enterprise_serializer.rb' - 'app/views/api/order_cycles/bulk_show.v1.rabl' - 'app/views/json/_order_cycle.rabl' - 'app/views/json/partials/_hub.rabl' @@ -1972,7 +1920,6 @@ Style/HashSyntax: - 'spec/controllers/api/order_cycles_controller_spec.rb' - 'spec/controllers/base_controller_spec.rb' - 'spec/controllers/cart_controller_spec.rb' - - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/controllers/spree/admin/payment_methods_controller_spec.rb' - 'spec/controllers/spree/admin/payments_controller_spec.rb' - 'spec/controllers/spree/api/products_controller_spec.rb' @@ -2161,7 +2108,7 @@ Style/NumericLiteralPrefix: Exclude: - 'spec/features/admin/order_cycles_spec.rb' -# Offense count: 13 +# Offense count: 12 # Cop supports --auto-correct. # Configuration parameters: Strict. Style/NumericLiterals: @@ -2198,14 +2145,13 @@ Style/ParenthesesAroundCondition: Exclude: - 'app/controllers/checkout_controller.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: short, verbose Style/PreferredHashMethods: Exclude: - 'app/controllers/spree/orders_controller_decorator.rb' - - 'spec/controllers/spree/admin/orders_controller_spec.rb' # Offense count: 18 # Cop supports --auto-correct. @@ -2263,7 +2209,7 @@ Style/RedundantReturn: - 'app/models/spree/classification_decorator.rb' - 'app/serializers/api/admin/enterprise_serializer.rb' -# Offense count: 96 +# Offense count: 95 # Cop supports --auto-correct. Style/RedundantSelf: Exclude: @@ -2310,15 +2256,14 @@ Style/RegexpLiteral: - 'spec/mailers/subscription_mailer_spec.rb' - 'spec/models/content_configuration_spec.rb' -# Offense count: 4 +# Offense count: 2 # Cop supports --auto-correct. Style/RescueModifier: Exclude: - 'app/controllers/application_controller.rb' - - 'app/controllers/spree/admin/orders_controller_decorator.rb' - 'lib/tasks/data.rake' -# Offense count: 268 +# Offense count: 266 Style/Send: Exclude: - 'spec/controllers/admin/subscriptions_controller_spec.rb' @@ -2394,7 +2339,7 @@ Style/StructInheritance: Exclude: - 'lib/open_food_network/enterprise_fee_applicator.rb' -# Offense count: 93 +# Offense count: 90 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. # IgnoredMethods: respond_to, define_method @@ -2418,7 +2363,6 @@ Style/SymbolProc: - 'lib/open_food_network/reports/bulk_coop_supplier_report.rb' - 'lib/spree/product_filters.rb' - 'spec/controllers/api/order_cycles_controller_spec.rb' - - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/controllers/spree/api/products_controller_spec.rb' - 'spec/controllers/spree/api/variants_controller_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' From ddf916814f02617310a4bac9fd9df5f720e1ebe4 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 3 Jan 2019 11:14:51 +0100 Subject: [PATCH 16/24] Reduce complexity of EnterprisesController#shop As asked by Rubocop. --- app/controllers/enterprises_controller.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 35100ff6b9..cfaab8de47 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -17,17 +17,12 @@ class EnterprisesController < BaseController return redirect_to spree.cart_path unless enough_stock? set_noindex_meta_tag - order_cycles = if current_order_cycle - [current_order_cycle] - else - OrderCycle.not_closed.with_distributor(current_distributor) - end - enterprises = current_distributor - .plus_relatives_and_oc_producers(order_cycles) + .plus_relatives_and_oc_producers(shop_order_cycles) .activated .includes(address: :state) .all + enterprises = inject_json_ams('enterprises', enterprises) render locals: { enterprises: enterprises } @@ -102,6 +97,14 @@ class EnterprisesController < BaseController order.order_cycle = order_cycle_options.first if order_cycle_options.count == 1 end + def shop_order_cycles + if current_order_cycle + [current_order_cycle] + else + OrderCycle.not_closed.with_distributor(current_distributor) + end + end + def set_noindex_meta_tag @noindex_meta_tag = true unless current_distributor.visible? end From edffbd72fe961efc3886055c230d3e9ed874dd4c Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 3 Jan 2019 11:15:52 +0100 Subject: [PATCH 17/24] Update rubocop_manual_todo --- .rubocop_manual_todo.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 390010ef06..71812eb60a 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -47,7 +47,6 @@ Metrics/LineLength: - app/controllers/base_controller.rb - app/controllers/cart_controller.rb - app/controllers/checkout_controller.rb - - app/controllers/enterprises_controller.rb - app/controllers/shop_controller.rb - app/controllers/spree/admin/adjustments_controller_decorator.rb - app/controllers/spree/admin/base_controller_decorator.rb @@ -435,7 +434,6 @@ Metrics/AbcSize: - app/controllers/cart_controller.rb - app/controllers/checkout_controller.rb - app/controllers/discourse_sso_controller.rb - - app/controllers/enterprises_controller.rb - app/controllers/spree/admin/adjustments_controller_decorator.rb - app/controllers/spree/admin/line_items_controller_decorator.rb - app/controllers/spree/admin/orders_controller_decorator.rb From a8ccb9b818433dde551600c961530d5366222719 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 4 Jan 2019 17:24:45 +1100 Subject: [PATCH 18/24] Explain why we look for the closest tax rate of a fee --- app/services/tax_rate_finder.rb | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app/services/tax_rate_finder.rb b/app/services/tax_rate_finder.rb index dc6bdd83a2..3f7397af94 100644 --- a/app/services/tax_rate_finder.rb +++ b/app/services/tax_rate_finder.rb @@ -47,9 +47,32 @@ class TaxRateFinder end end - # shipping fees and adjustments created from the admin panel have - # taxes set at creation in the included_tax field without relation - # to the corresponding TaxRate, so we look for the closest one + # There are two cases in which a line item is not associated to a tax rate. + # + # 1. Shipping fees and adjustments created from the admin panel have taxes set + # at creation in the included_tax field without relation to the + # corresponding TaxRate. + # 2. Removing line items from an order doesn't always remove the associated + # enterprise fees. These orphaned fees don't have a line item any more to + # find the item's tax rate. + # + # In these cases we try to find the used tax rate based on the included tax. + # For example, if the included tax is 10% of the adjustment, we look for a tax + # rate of 10%. Due to rounding errors, the included tax may be 9.9% of the + # adjustment. That's why we call it an approximation of the tax rate and look + # for the closest and hopefully find the 10% tax rate. + # + # This attempt can fail. + # + # - If an admin created an adjustment with a miscalculated included tax then + # we don't know which tax rate the admin intended to use. + # - An admin may also enter included tax that doesn't correspond to any tax + # rate in the system. They may enter a fee of $1.2 with tax of $0.2, but + # that doesn't mean that there is a 20% tax rate in the database. + # - The used tax rate may also have been deleted. Maybe the tax law changed. + # + # In either of these cases, we will find a tax rate that doesn't correspond + # to the included tax. def find_closest_tax_rates_from_included_tax(amount, included_tax) approximation = (included_tax / (amount - included_tax)) return [] if approximation.infinite? || approximation.zero? From d2ba305ce6663c7b01815702f7b86104d6b36677 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 4 Jan 2019 18:28:29 +1100 Subject: [PATCH 19/24] Fix context data for tax rate finder spec The spec was accidentally finding an exact tax rate match. The new test data provides only close matches to choose from. The naming of variables has been simplified as well. --- spec/services/tax_rate_finder_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/services/tax_rate_finder_spec.rb b/spec/services/tax_rate_finder_spec.rb index 4b3790d4ae..3f5daadfcf 100644 --- a/spec/services/tax_rate_finder_spec.rb +++ b/spec/services/tax_rate_finder_spec.rb @@ -2,11 +2,9 @@ require 'spec_helper' describe TaxRateFinder do describe "getting the corresponding tax rate" do - let(:amount) { BigDecimal(100) } + let(:amount) { BigDecimal(120) } let(:included_tax) { BigDecimal(20) } let(:tax_rate) { create_rate(0.2) } - let(:close_tax_rate) { create_rate(0.25) } - let(:other_tax_rate) { create_rate(0.3) } let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) } # This zone is used by :order_with_taxes and needs to match it let(:zone) { create(:zone, name: "GlobalZone") } @@ -25,8 +23,11 @@ describe TaxRateFinder do end it "finds a close match" do - close_tax_rate - other_tax_rate + tax_rate.destroy + close_tax_rate = create_rate(tax_rate.amount + 0.05) + # other tax rates, not as close to the real one + create_rate(tax_rate.amount + 0.06) + create_rate(tax_rate.amount - 0.06) rates = TaxRateFinder.new.tax_rates( nil, From 2893f1c141baf5c5d41e2c163c28244ce2f5f7df Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 24 Dec 2018 00:06:55 +0000 Subject: [PATCH 20/24] Add test to cover weight calculation bug #3072 --- spec/features/consumer/shopping/cart_spec.rb | 35 +++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index a319043c27..5790034fbf 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -48,7 +48,7 @@ feature "full-page cart", js: true do end describe "admin and handling flat fees" do - context 'when there are fees' do + context "when there are fees" do let(:handling_fee) { create(:enterprise_fee, calculator: Spree::Calculator::FlatRate.new(preferred_amount: 1), enterprise: order_cycle.coordinator, fee_type: 'admin') } @@ -58,7 +58,7 @@ feature "full-page cart", js: true do visit spree.cart_path end - it 'shows admin and handlings row' do + it "shows admin and handlings row" do expect(page).to have_selector('#cart-detail') expect(page).to have_content('Admin & Handling') expect(page).to have_selector '.cart-item-price', text: with_currency(0.86) @@ -68,13 +68,13 @@ feature "full-page cart", js: true do end end - context 'when there are no admin and handling fees' do + context "when there are no admin and handling fees" do before do add_product_to_cart order, product_fee, quantity: 2 visit spree.cart_path end - it 'hides admin and handlings row' do + it "hides admin and handlings row" do expect(page).to have_selector('#cart-detail') expect(page).to have_no_content('Admin & Handling') expect(page).to have_selector '.cart-item-price', text: with_currency(0.86) @@ -83,6 +83,33 @@ feature "full-page cart", js: true do end end + describe "admin weight calculated fees" do + context "order with 2 line items" do + let(:admin_fee) { create(:enterprise_fee, calculator: Calculator::Weight.new(preferred_per_kg: 1), + enterprise: order_cycle.coordinator, fee_type: 'admin') } + + before do + product_fee.variants.first.update_attributes(unit_value: '2000.0') + product_tax.variants.first.update_attributes(unit_value: '5000.0') + + add_enterprise_fee admin_fee + + cart_service = CartService.new(order) + cart_service.populate(variants: { product_fee.variants.first.id => 3, product_tax.variants.first.id => 3 }) + order.update_distribution_charge! + + visit spree.cart_path + end + + it "shows the correct weight calculations" do + expect(page).to have_selector('#cart-detail') + expect(page).to have_selector '.cart-item-price', text: with_currency(2.86) # price + 1 * 2kg + expect(page).to have_selector '.cart-item-price', text: with_currency(115.0) # price + 1 * 5kg + expect(page).to have_selector '.order-total.grand-total', text: with_currency(353.58) # above * 3 items + end + end + end + describe "tax" do before do add_enterprise_fee enterprise_fee From 364f9f9abd3666acc0772d7eea2327127659a4dd Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 7 Jan 2019 11:40:42 +0000 Subject: [PATCH 21/24] Improve variable names in cart spec --- spec/features/consumer/shopping/cart_spec.rb | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/spec/features/consumer/shopping/cart_spec.rb b/spec/features/consumer/shopping/cart_spec.rb index 5790034fbf..e0ce56cedc 100644 --- a/spec/features/consumer/shopping/cart_spec.rb +++ b/spec/features/consumer/shopping/cart_spec.rb @@ -10,10 +10,10 @@ feature "full-page cart", js: true do let!(:zone) { create(:zone_with_member) } let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true, charges_sales_tax: true) } let(:supplier) { create(:supplier_enterprise) } - let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product_tax.variants.first, product_fee.variants.first]) } - let(:enterprise_fee) { create(:enterprise_fee, amount: 11.00, tax_category: product_tax.tax_category) } - let(:product_tax) { create(:taxed_product, supplier: supplier, zone: zone, price: 110.00, tax_rate_amount: 0.1) } - let(:product_fee) { create(:simple_product, supplier: supplier, price: 0.86, on_hand: 100) } + let!(:order_cycle) { create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product_with_tax.variants.first, product_with_fee.variants.first]) } + let(:enterprise_fee) { create(:enterprise_fee, amount: 11.00, tax_category: product_with_tax.tax_category) } + let(:product_with_tax) { create(:taxed_product, supplier: supplier, zone: zone, price: 110.00, tax_rate_amount: 0.1) } + let(:product_with_fee) { create(:simple_product, supplier: supplier, price: 0.86, on_hand: 100) } let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) } before do @@ -22,7 +22,7 @@ feature "full-page cart", js: true do describe "product description" do it "does not link to the product page" do - add_product_to_cart order, product_fee, quantity: 2 + add_product_to_cart order, product_with_fee, quantity: 2 visit spree.cart_path expect(page).to have_no_selector '.item-thumb-image a' end @@ -33,7 +33,7 @@ feature "full-page cart", js: true do before do add_enterprise_fee percentage_fee - add_product_to_cart order, product_fee, quantity: 8 + add_product_to_cart order, product_with_fee, quantity: 8 visit spree.cart_path end @@ -54,7 +54,7 @@ feature "full-page cart", js: true do before do add_enterprise_fee handling_fee - add_product_to_cart order, product_fee, quantity: 3 + add_product_to_cart order, product_with_fee, quantity: 3 visit spree.cart_path end @@ -70,7 +70,7 @@ feature "full-page cart", js: true do context "when there are no admin and handling fees" do before do - add_product_to_cart order, product_fee, quantity: 2 + add_product_to_cart order, product_with_fee, quantity: 2 visit spree.cart_path end @@ -89,13 +89,13 @@ feature "full-page cart", js: true do enterprise: order_cycle.coordinator, fee_type: 'admin') } before do - product_fee.variants.first.update_attributes(unit_value: '2000.0') - product_tax.variants.first.update_attributes(unit_value: '5000.0') + product_with_fee.variants.first.update_attributes(unit_value: '2000.0') + product_with_tax.variants.first.update_attributes(unit_value: '5000.0') add_enterprise_fee admin_fee cart_service = CartService.new(order) - cart_service.populate(variants: { product_fee.variants.first.id => 3, product_tax.variants.first.id => 3 }) + cart_service.populate(variants: { product_with_fee.variants.first.id => 3, product_with_tax.variants.first.id => 3 }) order.update_distribution_charge! visit spree.cart_path @@ -103,8 +103,8 @@ feature "full-page cart", js: true do it "shows the correct weight calculations" do expect(page).to have_selector('#cart-detail') - expect(page).to have_selector '.cart-item-price', text: with_currency(2.86) # price + 1 * 2kg - expect(page).to have_selector '.cart-item-price', text: with_currency(115.0) # price + 1 * 5kg + expect(page).to have_selector '.cart-item-price', text: with_currency(2.86) # price + (1eur * 2kg) + expect(page).to have_selector '.cart-item-price', text: with_currency(115.0) # price + (1eur * 5kg) expect(page).to have_selector '.order-total.grand-total', text: with_currency(353.58) # above * 3 items end end @@ -113,7 +113,7 @@ feature "full-page cart", js: true do describe "tax" do before do add_enterprise_fee enterprise_fee - add_product_to_cart order, product_tax + add_product_to_cart order, product_with_tax visit spree.cart_path end @@ -124,10 +124,10 @@ feature "full-page cart", js: true do describe "updating quantities with insufficient stock available" do let(:li) { order.line_items(true).last } - let(:variant) { product_tax.variants.first } + let(:variant) { product_with_tax.variants.first } before do - add_product_to_cart order, product_tax + add_product_to_cart order, product_with_tax end around do |example| @@ -173,7 +173,7 @@ feature "full-page cart", js: true do order.save order.distributor.allow_order_changes = true order.distributor.save - add_product_to_cart order, product_tax + add_product_to_cart order, product_with_tax quick_login_as user visit spree.cart_path end From f1f1ab9dafbfc708a412eb530aaed1296117c030 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 8 Jan 2019 17:05:40 +0100 Subject: [PATCH 22/24] Update all locales with the latest Transifex translations --- config/locales/de_DE.yml | 11 +++- config/locales/en_BE.yml | 14 ++++- config/locales/en_GB.yml | 14 ++++- config/locales/es.yml | 51 +++++++++++++++++- config/locales/fr.yml | 4 +- config/locales/fr_BE.yml | 113 +++++++++++++++++++++------------------ config/locales/fr_CA.yml | 14 ++++- config/locales/it.yml | 15 +++++- config/locales/nb.yml | 30 +++++++++-- config/locales/pt.yml | 16 ++++-- config/locales/sv.yml | 14 ++++- 11 files changed, 223 insertions(+), 73 deletions(-) diff --git a/config/locales/de_DE.yml b/config/locales/de_DE.yml index 9ee5b8e1f2..7ef494a65a 100644 --- a/config/locales/de_DE.yml +++ b/config/locales/de_DE.yml @@ -1699,6 +1699,9 @@ de_DE: update_and_recalculate_fees: "Aktualisieren und Gebühren neu berechnen" registration: steps: + images: + back: "Zurück" + headline: "Dankeschön!" type: headline: "Letzter Schritt zum Hinzufügen von %{enterprise}!" question: "Sind Sie ein Produzent?" @@ -1833,8 +1836,6 @@ de_DE: registration_type_error: "Bitte wählen Sie: Sind Sie ein Produzent?" registration_type_producer_help: "Hersteller machen leckere Dinge zu essen und / oder zu trinken. Du bist ein Produzent, wenn du ihn anbaust, erziehst ihn, braue ihn, backe ihn, gähre ihn, melke ihn oder forme ihn." registration_type_no_producer_help: "Wenn Sie kein Produzent sind, sind Sie wahrscheinlich jemand, der Lebensmittel verkauft und verteilt. Sie könnten ein Hub, Coop, Einkaufsgruppe, Einzelhändler, Großhändler oder andere sein." - registration_images_headline: "Dankeschön!" - registration_images_description: "Lass uns ein paar schöne Bilder hochladen, damit dein Profil gut aussieht! :)" registration_detail_headline: "Lass uns anfangen" registration_detail_enterprise: "Woot! Zuerst müssen wir ein wenig über Ihr Unternehmen wissen:" registration_detail_producer: "Woot! Zuerst müssen wir ein wenig über Ihre Farm wissen:" @@ -2431,7 +2432,13 @@ de_DE: in Ihrem Warenkorb verringert. Das Folgende hat sich geändert: now_out_of_stock: ist jetzt ausverkauft. only_n_remainging: "Jetzt hat nur noch %{num} übrig." + variants: + on_demand: + 'yes': "Auf Anfrage" variant_overrides: + on_demand: + 'yes': "Ja" + 'no': "Nein" inventory_products: "Katalogprodukte" hidden_products: "Ausgeblendete Produkte" new_products: "Neue Produkte" diff --git a/config/locales/en_BE.yml b/config/locales/en_BE.yml index 02ef98adab..15c4dd2415 100644 --- a/config/locales/en_BE.yml +++ b/config/locales/en_BE.yml @@ -712,6 +712,7 @@ en_BE: close_date: Close Date social: twitter_placeholder: eg. @the_prof + facebook_placeholder: eg. www.facebook.com/PageNameHere stripe_connect: connect_with_stripe: "Connect with Stripe" stripe_connect_intro: "To accept payments using credit card, you will need to connect your stripe account to the Open Food Network. Use the button to the right to get started." @@ -1702,6 +1703,11 @@ en_BE: update_and_recalculate_fees: "Update And Recalculate Fees" registration: steps: + images: + continue: "Continue" + back: "Back" + headline: "Thanks!" + description: "Let's upload some pretty pictures so your profile looks great! :)" type: headline: "Last step to add %{enterprise}!" question: "Are you a producer?" @@ -1836,8 +1842,6 @@ en_BE: registration_type_error: "Please choose one. Are you are producer?" registration_type_producer_help: "Producers make yummy things to eat and/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it." registration_type_no_producer_help: "If you’re not a producer, you’re probably someone who sells and distributes food. You might be a hub, coop, buying group, retailer, wholesaler or other." - registration_images_headline: "Thanks!" - registration_images_description: "Let's upload some pretty pictures so your profile looks great! :)" registration_detail_headline: "Let's Get Started" registration_detail_enterprise: "Woot! First we need to know a little bit about your enterprise:" registration_detail_producer: "Woot! First we need to know a little bit about your farm:" @@ -2434,7 +2438,13 @@ en_BE: in your cart have reduced. Here's what's changed: now_out_of_stock: is now out of stock. only_n_remainging: "now only has %{num} remaining." + variants: + on_demand: + 'yes': "On demand" variant_overrides: + on_demand: + 'yes': "Yes" + 'no': "No" inventory_products: "Inventory Products" hidden_products: "Hidden Products" new_products: "New Products" diff --git a/config/locales/en_GB.yml b/config/locales/en_GB.yml index 5ea952bea7..59b748c4d4 100644 --- a/config/locales/en_GB.yml +++ b/config/locales/en_GB.yml @@ -715,6 +715,7 @@ en_GB: close_date: Close Date social: twitter_placeholder: eg. @the_prof + facebook_placeholder: eg. www.facebook.com/PageNameHere stripe_connect: connect_with_stripe: "Connect with Stripe" stripe_connect_intro: "To accept payments using credit card, you will need to connect your stripe account to the Open Food Network. Use the button to the right to get started." @@ -1705,6 +1706,11 @@ en_GB: update_and_recalculate_fees: "Update And Recalculate Fees" registration: steps: + images: + continue: "Continue" + back: "Back" + headline: "Thanks!" + description: "Let's upload some pictures so your profile looks great! :)" type: headline: "Last step to add %{enterprise}!" question: "Are you a producer?" @@ -1839,8 +1845,6 @@ en_GB: registration_type_error: "Please choose one. Are you are producer?" registration_type_producer_help: "Producers make things to eat and/or drink. You're a producer if you might grow it, raise it, brew it, bake it or ferment it." registration_type_no_producer_help: "If you’re not a producer, you’re probably someone who sells and distributes food. You might be a hub, coop, buying group, retailer, wholesaler or other." - registration_images_headline: "Thanks!" - registration_images_description: "Let's upload some pictures so your profile looks great! :)" registration_detail_headline: "Let's get started" registration_detail_enterprise: "First we need to know a little bit about your enterprise:" registration_detail_producer: "First we need to know a little bit about your farm:" @@ -2444,7 +2448,13 @@ en_GB: in your cart have reduced. Here's what's changed: now_out_of_stock: is now out of stock. only_n_remainging: "now only has %{num} remaining." + variants: + on_demand: + 'yes': "Unlimited" variant_overrides: + on_demand: + 'yes': "Yes" + 'no': "No" inventory_products: "Inventory Products" hidden_products: "Hidden Products" new_products: "New Products" diff --git a/config/locales/es.yml b/config/locales/es.yml index 773c965e41..61f0bf86ad 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -24,6 +24,11 @@ es: attributes: orders_close_at: after_orders_open_at: debe ser después de la fecha de apertura + variant_override: + count_on_hand: + using_producer_stock_settings_but_count_on_hand_set: "debe estar en blanco porque estás usando la configuración de estoc de la productora" + on_demand_but_count_on_hand_set: "debe estar en blanco si está bajo demanda" + limited_stock_but_no_count_on_hand: "se debe especificar porque se ha definido estoc limitado" activemodel: errors: models: @@ -195,6 +200,7 @@ es: admin_and_handling: Administración y Manejo profile: Perfil supplier_only: Sólo Proveedor + has_shopfront: Tiene tienda weight: Peso volume: Volumen items: Elementos @@ -216,6 +222,10 @@ es: quantity: Cantidad pick_up: Recogida copy: Copia + password_confirmation: Confirmación de contraseña + reset_password_token: token de restablecimiento de contraseña + expired: ha expirado, por favor solicite una nueva + back_to_payments_list: "Volver a la lista de pagos" actions: create_and_add_another: "Crear y agregar otro" admin: @@ -464,6 +474,7 @@ es: products_no_permission: no tienes permiso para administrar productos para esta organización inventory_no_permission: no tienes permiso para crear inventario para esta productora none_saved: No se guardó ningún producto con éxito + line_number: "Línea %{number}:" index: select_file: Selecciona una hoja de cálculo para subir spreadsheet: Hoja de cálculo @@ -497,6 +508,7 @@ es: no_permission: no tienes permiso para administrar esta organización not_found: no se pudo encontrar la organización en la base de datos no_name: Sin nombre + blank_enterprise: Algunos productos no tienen una organización definida. reset_absent?: Restablecer productos ausentes reset_absent_tip: Establezca el stock en cero para todos los productos existentes que no estén presentes en el archivo. overwrite_all: Sobrescribir todo @@ -567,6 +579,7 @@ es: tip: "Usa esta página para alterar la cantidad del producto en varios pedidos a la vez. Los productos pueden ser eliminados de los pedidos si es necesario. " shared: "¿Recurso compartido?" order_no: "Pedido Nº" + order_date: "Completado en" max: "Max" product_unit: "Producto: Unidad" weight_volume: "Peso/Volumen" @@ -709,6 +722,9 @@ es: close_date: Fecha de Finalización social: twitter_placeholder: 'ej: the_prof' + instagram_placeholder: p.ej. @mi_huerta + facebook_placeholder: eg. www.facebook.com/NombreDePáginaAquí + linkedin_placeholder: p.ej. www.linkedin.com/in/YourNameHere stripe_connect: connect_with_stripe: "Conectar con Stripe" stripe_connect_intro: "Para aceptar pagos con tarjeta de crédito, necesitarás conectar tu cuenta Stripe con Open Food Network. Usa el botón a la derecha para comenzar." @@ -1149,7 +1165,9 @@ es: menu_5_title: "Acerca de" menu_5_url: "http://katuma.org/" menu_6_title: "Conectar" + menu_6_url: " " menu_7_title: "Aprender" + menu_7_url: " " logo: "Logo (640x130)" logo_mobile: "Logo para móvil (75x26)" logo_mobile_svg: "Logo para móvil (SVG)" @@ -1697,6 +1715,11 @@ es: update_and_recalculate_fees: "Actualizar y recalcular tarifas" registration: steps: + images: + continue: "Continuar" + back: "Atrás" + headline: "¡Ya casi lo tenemos!" + description: "¡Sube algunas fotografías así el perfil se verá mucho mejor! :)" type: headline: "Último paso para añadir %{enterprise}!" question: "¿Eres una productora?" @@ -1831,8 +1854,6 @@ es: registration_type_error: "Escoja una. ¿Es una productora?" registration_type_producer_help: "Las productoras hacen cosas deliciosas para comer y/o beber. Eres una productora si lo cultivas, lo haces crecer, lo preparas, lo horneas, lo fermentas, lo ordeñas, ..." registration_type_no_producer_help: "Si no eres una productora, probablemente conozcas a alguien que venda o distribuya comida. También podrías convertirte en un grupo de consumo u otro tipo de organización." - registration_images_headline: "¡Ya casi lo tenemos!" - registration_images_description: "¡Sube algunas fotografías así el perfil se verá mucho mejor! :)" registration_detail_headline: "Empecemos..." registration_detail_enterprise: "¡Bien! Primero necesitamos saber un poco más sobre tu organización:" registration_detail_producer: "¡Bien! Primero necesitamos saber un poco más sobre tu productora:" @@ -2229,6 +2250,7 @@ es: validation_msg_relationship_already_established: "^Esta relación ya existe." validation_msg_at_least_one_hub: "^Al menos se debe seleccionar un grupo de consumo" validation_msg_product_category_cant_be_blank: "^La Categoría del Producto no puede estar en vacía" + validation_msg_tax: "^ Se requiere categoría de impuestos" validation_msg_tax_category_cant_be_blank: "^La Categoría del Impuesto no puede estar vacía" validation_msg_is_associated_with_an_exising_customer: "Está asociado con un consumidor existente" content_configuration_pricing_table: "(TODO: tabla de precios)" @@ -2418,6 +2440,9 @@ es: resolve: Resolver new_tag_rule_dialog: select_rule_type: "Selecciona un tipo de regla:" + orders: + index: + per_page: "%{results} por página" resend_user_email_confirmation: resend: "Reenviar" sending: "Reenviar..." @@ -2430,7 +2455,14 @@ es: de tu carrito se han reducido. Aquí está lo que ha cambiado: now_out_of_stock: está ahora fuera de stock. only_n_remainging: "Solo quedan %{num} ." + variants: + on_demand: + 'yes': "Bajo demanda" variant_overrides: + on_demand: + use_producer_settings: "Utilizar la configuración de estoc de la productora." + 'yes': "Sí" + 'no': "No" inventory_products: "Productos del Inventario" hidden_products: "Productos ocultos" new_products: "Nuevos productos" @@ -2511,6 +2543,8 @@ es: next: "Siguiente" loading: "Cargando" no_orders_found: "No se encontraron pedidos" + results_found: "%{number} Resultados encontrados." + viewing: "Viendo de %{start}a %{end}." invoice: issued_on: Emitido el tax_invoice: FACTURA DE IMPUESTOS @@ -2532,6 +2566,12 @@ es: other: "Tienes %{count} ciclos de pedido activos." manage_order_cycles: "GESTIONA LOS CICLOS DE PEDIDO" payment_methods: + new: + new_payment_method: "Nuevo método de pago" + back_to_payment_methods_list: "Volver a la lista de métodos de pago" + edit: + editing_payment_method: "Edición del método de pago" + back_to_payment_methods_list: "Volver a la lista de métodos de pago" stripe_connect: enterprise_select_placeholder: Escoge... loading_account_information_msg: Cargando la información de la cuenta de Stripe, espere un momento ... @@ -2592,14 +2632,21 @@ es: bulk_coop_customer_payments: 'Bulk Co-op - Pagos de las Consumidoras' users: index: + listing_users: "Listado de Usuarias" + new_user: "Nueva usuaria" user: "Usuaria" enterprise_limit: "Límite de la Organización" search: "Buscar" email: "Email" + edit: + editing_user: "Editando usuarias" + back_to_users_list: "Volver a la lista de usuarias" + general_settings: "Configuración general" form: email: "Email" roles: "Roles" enterprise_limit: "Límite de la Organización" + confirm_password: "Confirmar contraseña" password: "Contraseña" email_confirmation: confirmation_pending: "La confirmación por correo electrónico está pendiente. Hemos enviado un correo electrónico de confirmación a %{address}." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1fa30bd680..dd3116b7e2 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1987,7 +1987,7 @@ fr: spree_admin_overview_enterprises_header: "Mes entreprises" spree_admin_overview_enterprises_footer: "GÉRER MES ENTREPRISES" spree_admin_enterprises_hubs_name: "Nom" - spree_admin_enterprises_create_new: "CRÉER NOUVELLE" + spree_admin_enterprises_create_new: "CRÉER NOUVEAU" spree_admin_enterprises_shipping_methods: "Méthodes de livraison" spree_admin_enterprises_fees: "Marges et commissions" spree_admin_enterprises_none_create_a_new_enterprise: "CRÉER UNE NOUVELLE ENTREPRISE" @@ -2570,7 +2570,7 @@ fr: zero: "Vous n'avez aucun cycle de vente actif." one: "Vous avez un cycle de vente actif." other: "Vous avez %{count} cycles de vente actifs." - manage_order_cycles: "GERER LES CYCLES DE VENTE" + manage_order_cycles: "GÉRER LES CYCLES DE VENTE" payment_methods: new: new_payment_method: "Nouvelle méthode de paiement" diff --git a/config/locales/fr_BE.yml b/config/locales/fr_BE.yml index 97fb8d6710..7b9bbfeae4 100644 --- a/config/locales/fr_BE.yml +++ b/config/locales/fr_BE.yml @@ -246,7 +246,7 @@ fr_BE: schedule: Rythme d'abonnement shipping: Expédition shipping_method: Option d'expédition - shop: Boutique + shop: Comptoir sku: Référence produit status_state: Province tags: Tags @@ -302,8 +302,8 @@ fr_BE: default_payment_method: 'doit être défini si vous souhaitez générer des factures pour les utilisateurs entreprises. ' default_shipping_method: doit être défini si vous souhaitez générer des factures pour les utilisateurs entreprises. shopfront_settings: - embedded_shopfront_settings: "Paramètres Boutiques Intégrées" - enable_embedded_shopfronts: "Autoriser l'intégration des boutiques" + embedded_shopfront_settings: "Paramètres comptoir Intégrées" + enable_embedded_shopfronts: "Autoriser l'intégration des comptoirs" embedded_shopfronts_whitelist: "Liste blanche des Domaines Externes" number_localization: number_localization_settings: "Gestion localisation des nombres" @@ -396,7 +396,7 @@ fr_BE: search_by_email: "Recherche par email/code..." guest_label: 'Commande en mode invité' destroy: - has_associated_orders: 'Suppression impossible: des commandes sont associées à cet acheteur pour cette boutique' + has_associated_orders: 'Suppression impossible: des commandes sont associées à cet acheteur pour ce comptoir' contents: edit: title: Contenu @@ -552,7 +552,7 @@ fr_BE: add: Ajouter hide: Masquer import_date: Importé - select_a_shop: Choisir un magasin + select_a_shop: Choisir un comptoir review_now: Vérifier maintenant new_products_alert_message: Il y a %{new_product_count} nouveaux produits disponibles pouvant être ajoutés à votre catalogue. currently_empty: Votre catalogue est actuellement vide @@ -562,7 +562,7 @@ fr_BE: no_new_products: Pas de nouveaux produits à ajouter à ce catalogue no_matching_new_products: Pas de nouveaux produits répondant à la recherche inventory_powertip: Ceci est votre catalogue produits. Pour ajouter des produits à votre catalogue, sélectionnez "Nouveaux Produits" dans le menu déroulant. - hidden_powertip: Ces produits ont été masqués de votre catalogue, vous ne pourrez pas les proposer dans votre boutique. Vous pouvez cliquer sur "Ajouter" pour ajouter un produit à votre catalogue. + hidden_powertip: Ces produits ont été masqués de votre catalogue, vous ne pourrez pas les proposer dans votre comptoir. Vous pouvez cliquer sur "Ajouter" pour ajouter un produit à votre catalogue. new_powertip: Ces produits peuvent être ajoutés à votre catalogue. Cliquez sur "Ajouter" pour ajouter un produit à votre catalogue, ou 'Masquer" pour ne plus l'afficher. Vous pourrez changer d'avis plus tard! controls: back_to_my_inventory: Retour à mon catalogue magasin @@ -644,8 +644,8 @@ fr_BE: dans votre catalogue magasin avant qu'ils puissent être mis en vente dans votre magasin Si vous n'utilisez pas cet outil, choisissez l'option indiquant "recommandé" ci-dessous: - preferred_product_selection_from_inventory_only_yes: Les nouveaux produits des producteurs peuvent être ajoutés à mon magasin en ligne (recommandé) - preferred_product_selection_from_inventory_only_no: Les nouveaux produits des producteurs doivent être ajoutés à mon catalogue magasin avant de pouvoir être ajoutés à mon magasin en ligne + preferred_product_selection_from_inventory_only_yes: Les nouveaux produits des producteurs peuvent être ajoutés à mon comptoir en ligne (recommandé) + preferred_product_selection_from_inventory_only_no: Les nouveaux produits des producteurs doivent être ajoutés à mon catalogue comptoir avant de pouvoir être ajoutés à mon comptoir en ligne payment_methods: name: Nom applies: Active? @@ -672,9 +672,9 @@ fr_BE: visible: Visible not_visible: Invisible permalink: Nom pour URL (sans espace) - permalink_tip: "Ce nom permanent est utilisé pour créer l'url de votre magasin: %{link}ma-boutique/shop" - link_to_front: Lien URL du magasin - link_to_front_tip: C'est le lien qui permet d'accéder en direct à votre magasin sur Open Food Network. + permalink_tip: "Ce nom permanent est utilisé pour créer l'url de votre comptoir: %{link}ma-boutique/shop" + link_to_front: Lien URL du comptoir + link_to_front_tip: C'est le lien qui permet d'accéder en direct à votre comptoir sur Open Food Network. shipping_methods: name: Nom applies: Active? @@ -683,8 +683,8 @@ fr_BE: create_one_button: En créer une maintenant no_method_yet: Vous n'avez pas encore paramétré de méthode de livraison. shop_preferences: - shopfront_requires_login: "Magasin visible par tous?" - shopfront_requires_login_tip: "Choisissez si les acheteurs doivent être connectés pour voir le magasin ou si le magasin est visible par tout le monde." + shopfront_requires_login: "Comptoir visible par tous?" + shopfront_requires_login_tip: "Choisissez si les acheteurs doivent être connectés pour voir le magasin ou si le comptoir est visible par tout le monde." shopfront_requires_login_false: "Visible par tous" shopfront_requires_login_true: "Visible uniquement pour les acheteurs logués" recommend_require_login: "Nous recommandons de demander aux utilisateurs de se connecter si vous souhaitez leur permettre de modifier leur commande." @@ -700,20 +700,22 @@ fr_BE: enable_subscriptions_tip: "Activer la fonction abonnements?" enable_subscriptions_false: "Désactivé" enable_subscriptions_true: "Activé" - shopfront_message: Message d'accueil magasin ouvert + shopfront_message: Message d'accueil comptoir ouvert shopfront_message_placeholder: > - Vous pouvez ici expliquer à vos acheteurs comment votre magasin fonctionne. - Ce texte s'affiche dans votre magasin, au-dessus de la liste de produits. - shopfront_closed_message: Message d'accueil magasin fermé + Vous pouvez ici expliquer à vos acheteurs comment votre comptoir fonctionne. + Ce texte s'affiche dans votre comptoir, au-dessus de la liste de produits. + shopfront_closed_message: Message d'accueil comptoir fermé shopfront_closed_message_placeholder: > - Vous pouvez ici expliquer à vos acheteurs pourquoi votre magasin est + Vous pouvez ici expliquer à vos acheteurs pourquoi votre comptoir est fermé et/ou quand il ouvrira. Ce texte s'affiche uniquement quand il - n'y a pas de cycle de vente en cours (donc quand votre magasin est fermé). + n'y a pas de cycle de vente en cours (donc quand votre comptoir est + fermé). shopfront_category_ordering: Ordre d'affichage des catégories open_date: Date d'ouverture close_date: Date de fermeture social: twitter_placeholder: ex. @OpenFoodNet_fr + facebook_placeholder: 'ex: www.facebook.com/NomDeLaPage' stripe_connect: connect_with_stripe: "Connecter avec Stripe" stripe_connect_intro: "Pour accepter des paiements utilisant la carte bancaire, vous devez connecter votre compte Stripe à Open Food Network. Cliquez sur le bouton à droite pour commencer." @@ -775,19 +777,19 @@ fr_BE: connect_ofn: Gagnez en visibilité via OFFrance always_free: GRATUIT producer_description_text: Saisissez votre catalogue produits sur Open Food Network, ce qui permettra aux comptoirs utilisant la plateforme de les proposer dans leurs magasins (sur votre autorisation). - producer_shop: Magasin Producteur + producer_shop: Comptoir Producteur sell_your_produce: Vendez vos propres produits - producer_shop_description_text: Vendez vos produits en direct aux consommateurs via votre propre Magasin Producteur sur Open Food Network. + producer_shop_description_text: Vendez vos produits en direct aux consommateurs via votre propre Comptoir Producteur sur Open Food Network. producer_shop_description_text2: Un Magasin Producteur vous permet de vendre uniquement vos propres produits. Si vous voulez vendre d'autres produits, sélectionnez "Comptoir Producteur" producer_hub: Comptoir Producteur producer_hub_text: Vendez vos produits et ceux d'autres fournisseurs - producer_hub_description_text: Vous vendez non seulement vos produits, mais aussi des produits d'autres producteurs de votre région, artisans, ou distributeurs afin de proposer une offre complète dans votre magasin. Vous soutenez ainsi le développement de votre système alimentaire territorial ! + producer_hub_description_text: Vous vendez non seulement vos produits, mais aussi des produits d'autres producteurs de votre région, artisans, ou distributeurs afin de proposer une offre complète dans votre comptoir. Vous soutenez ainsi le développement de votre système alimentaire territorial ! profile: Profil uniquement get_listing: Référencez votre hub/point de vente profile_description_text: Les visiteurs peuvent vous trouver sur Open Food Network et vous contacter. Votre entreprise sera visible sur la carte. hub_shop: Magasin comptoir hub_shop_text: Vendez des produits de multiples fournisseurs différents - hub_shop_description_text: Vous proposez des produits de différents producteurs de votre région, artisans, ou distributeurs afin de proposer une offre complète dans votre magasin. Vous soutenez ainsi le développement de votre système alimentaire territorial ! + hub_shop_description_text: Vous proposez des produits de différents producteurs de votre région, artisans, ou distributeurs afin de proposer une offre complète dans votre comptoir. Vous soutenez ainsi le développement de votre système alimentaire territorial ! choose_option: Veuilliez choisir l'une des options ci-dessus. change_now: Changer enterprise_user_index: @@ -987,7 +989,7 @@ fr_BE: new: Nouvel abonnement create: Créer abonnement index: - please_select_a_shop: Veuillez choisir une boutique + please_select_a_shop: Veuillez choisir un comptoir edit_subscription: Mettre à jour Abonnement pause_subscription: Mettre en pause Abonnement unpause_subscription: Reprendre Abonnement @@ -995,8 +997,8 @@ fr_BE: setup_explanation: just_a_few_more_steps: 'Encore quelques étapes avant de pouvoir commencer:' enable_subscriptions: "Activez la fonction abonnements pour au moins une de vos comptoirs" - enable_subscriptions_step_1_html: 1. Allez à %{enterprises_link}, trouvez votre boutique, et cliquez sur "Gérer" - enable_subscriptions_step_2: 2. Sous "Préférences boutiques", activez la fonction Abonnements + enable_subscriptions_step_1_html: 1. Allez à %{enterprises_link}, trouvez votre comptoir, et cliquez sur "Gérer" + enable_subscriptions_step_2: 2. Sous "Préférences comptoir", activez la fonction Abonnements set_up_shipping_and_payment_methods_html: Paramétrez au moins une méthode d'%{shipping_link} et une méthode de %{payment_link} set_up_shipping_and_payment_methods_note_html: Notez bien que seules des méthodes de paiement de type "cash" ou "Stripe" pourront
être utilisées pour les Abonnements ensure_at_least_one_customer_html: Assurez-vous qu'au moins un %{customer_link} est enregistré dans votre liste d'acheteurs. @@ -1113,7 +1115,7 @@ fr_BE: login: "Se connecter" register: "s'inscrire" contact: "contacter" - require_customer_login: "La boutique est réservée aux membres." + require_customer_login: "Le comptoir est réservée aux membres." require_login_html: "Déjà inscrit? %{login}. Sinon, %{register} pour pouvoir faire vos achats." require_customer_html: "Veuillez %{contact} %{enterprise} pour devenir membre." card_could_not_be_updated: La carte bancaire n'a pas pu être mise à jour @@ -1143,7 +1145,7 @@ fr_BE: ticket_column_item: "Produit" ticket_column_unit_price: "Prix unitaire" ticket_column_total_price: "Prix total" - menu_1_title: "Comptoir" + menu_1_title: "Comptoirs" menu_1_url: "/shops" menu_2_title: "Carte" menu_2_url: "/map" @@ -1198,8 +1200,8 @@ fr_BE: no_shipping_or_payment: pas de méthode de livraison ou de paiement unconfirmed: non confirmé days: jours - label_shop: "Boutique" - label_shops: "Comptoir" + label_shop: "Comptoir" + label_shops: "Comptoirs" label_map: "Carte" label_producer: "Producteur" label_producers: "Producteurs" @@ -1430,7 +1432,7 @@ fr_BE: email_signup_confirmed_email: "Merci d'avoir confirmé votre email." email_signup_shop_html: "Vous pouvez maintenant vous connecter sur %{link}." email_signup_text: "Merci d'avoir rejoint le réseau. Si vous êtes un client, nous sommes impatients de vous faire découvrir de nombreux agriculteurs fantastiques, de merveilleux comptoirs et des plats délicieux! Si vous êtes un producteur ou autre entreprise alimentaire, nous sommes ravis de vous compter parmi les membres du réseau." - email_signup_help_html: "Vos questions et commentaire sont les bienvenus! Cliquez sur le bouton Envoyer un commentaire sur le site ou envoyez-nous un email à %{email}" + email_signup_help_html: "Vos questions et commentaires sont les bienvenus! Cliquez sur le bouton Envoyer un commentaire sur le site ou envoyez-nous un email à %{email}" invite_email: greeting: "Bonjour!" invited_to_manage: "Vous avez été invité(e) à gérer %{enterprise} sur %{instance}." @@ -1604,7 +1606,7 @@ fr_BE: orders_edit_title: Panier orders_edit_headline: Votre panier orders_edit_time: Commande prête pour - orders_edit_continue: Retour à la boutique + orders_edit_continue: Retour au comptoir orders_edit_checkout: Etape suivante (coordonnées) orders_form_empty_cart: "Vider le panier" orders_form_subtotal: Sous-total @@ -1704,6 +1706,11 @@ fr_BE: update_and_recalculate_fees: "Mettre à jour et recalculer les frais" registration: steps: + images: + continue: "Suivant" + back: "Retour" + headline: "Merci!" + description: "Ajoutez maintenant de jolies photos pour que votre profil soit attractif! :)" type: headline: "Dernière étape pour ajouter %{enterprise} !" question: "Etes-vous un producteur ?" @@ -1838,8 +1845,6 @@ fr_BE: registration_type_error: "Veuillez faire un choix. Etes vous un producteur?" registration_type_producer_help: "Un producteur fabrique de bonnes choses à boire et à manger. Vous êtes un producteur si vous les faites pousser, les élevez, les pétrissez, transformez, fermentez, les réduisez en grains, etc." registration_type_no_producer_help: "Si vous n'êtes pas un producteur, vous êtes probablement un revendeur ou distributeur alimentaire: un comptoir, une coopérative, un groupement d'achat, un revendeur, un grossiste, ou autre." - registration_images_headline: "Merci!" - registration_images_description: "Ajoutez maintenant de jolies photos pour que votre profil soit attractif! :)" registration_detail_headline: "Commençons" registration_detail_enterprise: "Woohoo! Dites-nous déjà quelques mots à propos de votre entreprise:" registration_detail_producer: "Woohoo! Dites-nous déjà quelques mots à propos de votre ferme:" @@ -1870,8 +1875,8 @@ fr_BE: shop_variant_quantity_min: "min" shop_variant_quantity_max: "max" follow: "Suivre" - shop_for_products_html: "Acheter les produits de %{enterprise} dans les boutiques suivantes:" - change_shop: "Changer de boutique pour:" + shop_for_products_html: "Acheter les produits de %{enterprise} dans les comptoirs suivants:" + change_shop: "Changer de comptoir pour:" shop_at: "Acheter maintenant :" price_breakdown: "Détail du prix:" admin_fee: "Frais de gestion admin" @@ -1979,7 +1984,7 @@ fr_BE: spree_admin_enterprises_fees: "Marges et commissions" spree_admin_enterprises_none_create_a_new_enterprise: "CRÉER UNE NOUVELLE ENTREPRISE" spree_admin_enterprises_none_text: "Vous n'avez pas encore d'entreprise" - spree_admin_enterprises_tabs_hubs: "COMPTOIR" + spree_admin_enterprises_tabs_hubs: "COMPTOIRS" spree_admin_enterprises_producers_manage_products: "GÉRER LES PRODUITS" spree_admin_enterprises_any_active_products_text: "Vous n'avez aucun produit actif." spree_admin_enterprises_create_new_product: "CRÉER UN NOUVEAU PRODUIT" @@ -2034,7 +2039,7 @@ fr_BE: admin_share_zipcode: "Code postal" admin_share_country: "Pays" admin_share_state: "Département" - hub_sidebar_hubs: "Comptoir" + hub_sidebar_hubs: "Comptoirs" hub_sidebar_none_available: "Aucun disponible" hub_sidebar_manage: "Gérer" hub_sidebar_at_least: "Sélectionnez un/des comptoir/s" @@ -2230,7 +2235,7 @@ fr_BE: payment_method_fee: "Frais de transaction" inventory_settings: "Catalogue boutique" tag_rules: "Règles de tag" - shop_preferences: "Préférences boutique" + shop_preferences: "Préférences comptoir" enterprise_fee_whole_order: Commande totale enterprise_fee_by: "%{type}marges/frais par %{role} %{enterprise_name}" validation_msg_relationship_already_established: "^Un lien est déjà établi entre ces entreprises." @@ -2300,7 +2305,7 @@ fr_BE: unavailable: Non disponible profile: Profil hub: Comptoir - shop: Boutique + shop: Comptoir choose: Choisir resolve_errors: Veuillez corriger les erreurs suivantes more_items: "+ %{count} en plus" @@ -2346,7 +2351,7 @@ fr_BE: hub_shop_text1: > Vous proposez des produits de différents producteurs de votre région, artisans, ou distributeurs afin de proposer une offre complète dans - votre boutique. Vous soutenez ainsi le développement de votre système + votre comptoir. Vous soutenez ainsi le développement de votre système alimentaire territorial ! hub_shop_text2: > Un comptoir n'a pas de modèle figé, il peut s'agir d'un groupement d'achat, @@ -2371,24 +2376,24 @@ fr_BE: profile_only_text2: > Si vous souhaitez vous concentrer sur votre activité de production, et laisser à d'autre le soin de distribuer vos produits, vous n'avez - pas besoin d'une boutique sur Open Food Network. + pas besoin d'un comptoir sur Open Food Network. profile_only_text3: > Saisissez votre catalogue produits sur Open Food Network, ce qui permettra aux comptoirs utilisant la plateforme de les proposer dans leurs boutiques (sur votre autorisation). - producer_shop: Boutique Producteur + producer_shop: Comptoir Producteur producer_shop_text1: > Vendez vos produits en direct aux mangeurs/restaurateurs/etc. via votre propre Boutique Producteur sur Open Food Network. producer_shop_text2: > - Une Boutique Producteur vous permet de vendre uniquement vos propres + Une Comptoir Producteur vous permet de vendre uniquement vos propres produits. Si vous voulez vendre d'autres produits, sélectionnez "Comptoir Producteur" producer_hub: Comptoir Producteur producer_hub_text1: > Vous vendez non seulement vos produits, mais aussi des produits d'autres producteurs de votre région, artisans, ou distributeurs afin de proposer - une offre complète dans votre boutique. Vous soutenez ainsi le développement + une offre complète dans votre comptoir. Vous soutenez ainsi le développement de votre système alimentaire territorial ! producer_hub_text2: > Un comptoir producteur peut prendre différentes formes, une boutique @@ -2413,7 +2418,7 @@ fr_BE: transformez, fermentez, les réduisez en grains, etc. producer_text2: > Un producteur peut aussi avoir d'autres rôles, comme par exemple stocker - et distribuer des produits d'autres producteurs à travers une boutique + et distribuer des produits d'autres producteurs à travers une comptoir sur Open Food Network. non_producer: Non-producteur non_producer_text1: > @@ -2450,7 +2455,13 @@ fr_BE: à votre demande. Voilà les modifications opérées: now_out_of_stock: est maintenant en rupture de stock. only_n_remainging: "plus que %{num} en stock." + variants: + on_demand: + 'yes': "A volonté" variant_overrides: + on_demand: + 'yes': "Oui" + 'no': "Non" inventory_products: "Produits du Catalogue Boutique" hidden_products: "Produits Masqués" new_products: "Nouveaux Produits" @@ -2465,10 +2476,10 @@ fr_BE: changing_on_hand_stock: Modification des niveaux de stock en cours... stock_reset: Les niveaux de stock ont été réinitiatlisés (valeurs par défaut) tag_rules: - show_hide_variants: 'Afficher ou Masquer les variantes dans ma boutique' + show_hide_variants: 'Afficher ou Masquer les variantes dans mon comptoir' show_hide_shipping: 'Afficher ou Montrer les méthodes de livraison lors de la finalisation de commande' show_hide_payment: 'Afficher ou Montrer les méthodes de paiement lors de la finalisation de commande' - show_hide_order_cycles: 'Afficher ou Masquer les cycles de vente de ma boutique' + show_hide_order_cycles: 'Afficher ou Masquer les cycles de vente de mon comptoir' visible: VISIBLE not_visible: INVISIBLE services: @@ -2494,7 +2505,7 @@ fr_BE: producer: "Producteur" non_producer: "Non-producteur" customers: - select_shop: 'Veuillez d''abord choisir une boutique' + select_shop: 'Veuillez d''abord choisir un comptoir' could_not_create: Oups ! Création impossible... subscriptions: closes: fermer @@ -2745,7 +2756,7 @@ fr_BE: until: Jusqu'à past_orders: order: Commandes à venir - shop: Boutique + shop: Comptoir completed_at: Date items: Produits total: Total @@ -2759,7 +2770,7 @@ fr_BE: authorised_shops_popover: Voilà la liste des comptoirs que vous avez autorisées à débiter votre carte de paiement par défaut dans le cadre de vos abonnements en cours (commandes récurrentes). Les informations concernant votre carte de paiement sont sécurisées et ne sont pas accessibles par le gérant de la boutique. Vous recevrez systématiquement une notification avant tout débit sur votre carte. saved_cards_popover: Voilà la liste des cartes de paiement que vous avez enregistrées. Votre carte par défaut sera automatiquement sélectionnée au moment de la finalisation d'une commande, et pourra être débitée par les comptoirs auxquels vous avez donné cette autorisation (voir à droite). authorised_shops: - shop_name: "Nom de la boutique" + shop_name: "Nom du comptoir" allow_charges?: "Autoriser les prélèvements ?" localized_number: invalid_format: n'est pas un format valide. Veuillez entrer un nombre. diff --git a/config/locales/fr_CA.yml b/config/locales/fr_CA.yml index c2a4733820..6d4a26aa40 100644 --- a/config/locales/fr_CA.yml +++ b/config/locales/fr_CA.yml @@ -702,6 +702,7 @@ fr_CA: close_date: Date de fermeture social: twitter_placeholder: ex. @OpenFoodNet_fr + facebook_placeholder: 'ex: www.facebook.com/NomDeLaPage' stripe_connect: connect_with_stripe: "Connecter avec Stripe" stripe_connect_intro: "Pour accepter des paiements utilisant la carte bancaire, vous devez connecter votre compte Stripe à Open Food Network. Cliquez sur le bouton à droite pour commencer." @@ -1689,6 +1690,11 @@ fr_CA: update_and_recalculate_fees: "Mettre à jour et recalculer les frais" registration: steps: + images: + continue: "Suivant" + back: "Retour" + headline: "Merci!" + description: "Ajoutez maintenant de jolies photos pour que votre profil soit attractif! :)" type: headline: "Dernière étape pour ajouter %{enterprise} !" question: "Etes-vous un producteur?" @@ -1823,8 +1829,6 @@ fr_CA: registration_type_error: "Veuillez faire un choix. Etes vous un producteur?" registration_type_producer_help: "Un producteur fabrique de bonnes choses à boire et à manger. Vous êtes un producteur si vous les faites pousser, les élevez, les pétrissez, transformez, fermentez, les réduisez en grains, etc." registration_type_no_producer_help: "Si vous n'êtes pas un producteur, vous êtes probablement un revendeur ou distributeur alimentaire: un \"hub\", une coopérative, un groupement d'achat, un revendeur, un grossiste, ou autre." - registration_images_headline: "Merci!" - registration_images_description: "Ajoutez maintenant de jolies photos pour que votre profil soit attractif! :)" registration_detail_headline: "Commençons" registration_detail_enterprise: "Woohoo! Dites-nous déjà quelques mots à propos de votre entreprise:" registration_detail_producer: "Woohoo! Dites-nous déjà quelques mots à propos de votre ferme:" @@ -2429,7 +2433,13 @@ fr_CA: à votre demande. Voilà les modifications opérées: now_out_of_stock: est maintenant en rupture de stock. only_n_remainging: "plus que %{num} en stock." + variants: + on_demand: + 'yes': "A volonté" variant_overrides: + on_demand: + 'yes': "Oui" + 'no': "Non" inventory_products: "Produits du Catalogue Boutique" hidden_products: "Produits Masqués" new_products: "Nouveaux Produits" diff --git a/config/locales/it.yml b/config/locales/it.yml index 9da5f3d19f..1e4e5b1d8d 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -577,6 +577,8 @@ it: shopfront_category_ordering: Categorie disponibili in Vetrina open_date: Data apertura close_date: Data chiusura + social: + facebook_placeholder: p.es. www.facebook.com/PageNameHere stripe_connect: confirm_modal: cancel: Annulla @@ -1373,6 +1375,11 @@ it: update_and_recalculate_fees: "Aggiorna e ricalcola tariffe" registration: steps: + images: + continue: "Continua" + back: "Indietro" + headline: "Grazie!" + description: "Carichiamo qualche immagine per rendere più bello il tuo profilo! :)" type: headline: "Ultimo passo per aggiungere %{enterprise}!" question: "Sei un produttore?" @@ -1498,8 +1505,6 @@ it: registration_type_error: "Per favore scegline uno. Sei un produttore?" registration_type_producer_help: "I produttori fanno cose buone da mangiare e/o bere. Sei un produttore se le coltivi, le allevi, le infondi, le cucini, le fai fermentare, le mungi o le modelli." registration_type_no_producer_help: "Se non sei un produttore, probabilmente sei qualcuno che vende e distribuisce cibo. potresti essere un hub, una cooperativa, un gruppo d'acquisto, un rivenditore al dettaglio o all'ingrosso, o altro." - registration_images_headline: "Grazie!" - registration_images_description: "Carichiamo qualche immagine per rendere più bello il tuo profilo! :)" registration_detail_headline: "Cominciamo" registration_detail_enterprise: "Wow! Prima abbiamo bisogno di saperne un po' di più della tua impresa:" registration_detail_producer: "Wow! Prima abbiamo bisogno di saperne un po' di più della tua azienda agricola:" @@ -1966,7 +1971,13 @@ it: nel tuo carrello sono diminuite. Ecco cosa è cambiato: now_out_of_stock: non è al momento disponibile only_n_remainging: "attualmente solo %{num} rimasto." + variants: + on_demand: + 'yes': "A richiesta" variant_overrides: + on_demand: + 'yes': "Sì" + 'no': "No" inventory_products: "Inventario Prodotti" hidden_products: "Prodotti Nascosti" new_products: "Nuovi Prodotti" diff --git a/config/locales/nb.yml b/config/locales/nb.yml index 16d1e57b3e..339132e9b6 100644 --- a/config/locales/nb.yml +++ b/config/locales/nb.yml @@ -24,6 +24,11 @@ nb: attributes: orders_close_at: after_orders_open_at: må være etter åpningsdato + variant_override: + count_on_hand: + using_producer_stock_settings_but_count_on_hand_set: "må være tomt fordi du bruker produsentens lagerinnstillinger" + on_demand_but_count_on_hand_set: "må være tom hvis på forespørsel" + limited_stock_but_no_count_on_hand: "må spesifiseres fordi det tvinger begrenset lager" activemodel: errors: models: @@ -715,6 +720,9 @@ nb: close_date: Stengedato social: twitter_placeholder: f.eks. @the_prof + instagram_placeholder: f.eks. the_prof + facebook_placeholder: f.eks. www.facebook.com/FirmaNavnHer + linkedin_placeholder: f.eks. www.linkedin.com/in/YourNameHere stripe_connect: connect_with_stripe: "Koble til Stripe" stripe_connect_intro: "For å akseptere betaling med kredittkort må du koble din Stripe konto til Open Food Network. Bruk knappen til høyre for å komme i gang." @@ -1264,7 +1272,7 @@ nb: cookie_stripe_desc: "Data samlet inn av betalingsprosessoren vår Stripe for svindeloppdagelse https://stripe.com/cookies-policy/legal. Ikke alle butikker bruker Stripe som betalingsmetode, men det er en god praksis å forhindre at svindel gjelder for alle sider. Stripe bygger sannsynligvis et bilde av hvilke av våre sider som til vanlig samhandler med API-en og deretter flagge alt uvanlig. Så å sette Stripe-cookien har en bredere funksjon enn bare å levere en betalingsmetode til en bruker. Fjerning av det kan påvirke sikkerheten til selve tjenesten. Du kan lære mer om Stripe og lese retningslinjene for personvern på https://stripe.com/privacy." statistics_cookies: "Statistikkkapsler" statistics_cookies_desc: "Følgende er ikke strengt nødvendige, men hjelper deg med å gi deg den beste brukeropplevelsen ved å tillate oss å analysere brukeradferd, identifisere hvilke funksjoner du bruker mest, eller ikke bruker, forstå brukeropplevelsesproblemer osv." - statistics_cookies_analytics_desc_html: "For å samle og analysere plattformbruksdata bruker vi Google Analytics, da det var standardtjenesten som var koblet til Spree (ehandel open source programvare som vi bygde på), men visjonen vår er å bytte til Matomo (ex Piwik, open source analyseverktøy som er GDPR-kompatibelt og beskytter ditt privatliv) så snart vi kan." + statistics_cookies_analytics_desc_html: "For å samle og analysere plattformbruksdata bruker vi Google Analytics, da det var standardtjenesten som var koblet til Spree (ehandel open source programvare som vi bygde på), men visjonen vår er å bytte til Matomo (ex Piwik, open source analyseverktøy som er GDPR-kompatibelt og beskytter ditt privatliv) så snart vi kan." statistics_cookies_matomo_desc_html: "For å samle og analysere plattformbruksdata bruker vi Matomo (ex Piwik), et åpen kildekodeanalyseverktøy som er kompatibelt med GDPR og beskytter personvernet ditt." statistics_cookies_matomo_optout: "Ønsker du å melde deg av Matomo analytics? Vi samler ikke inn personlige data, og Matomo hjelper oss med å forbedre vår tjeneste, men vi respekterer ditt valg :-)" cookie_analytics_utma_desc: "Brukes til å skille mellom brukere og økter. Kapselen er opprettet når javascriptbiblioteket utføres, og ingen eksisterende __utma-informasjonskapsler eksisterer. Cookien oppdateres hver gang data sendes til Google Analytics." @@ -1705,6 +1713,11 @@ nb: update_and_recalculate_fees: "Oppdater og regn avgifter på nytt" registration: steps: + images: + continue: "Fortsett" + back: "Tilbake" + headline: "Takk!" + description: "La oss laste opp noen fine bilder så profilen din ser flott ut! :)" type: headline: "Siste skritt for å legge til %{enterprise}!" question: "Er du en produsent?" @@ -1839,8 +1852,6 @@ nb: registration_type_error: "Vennligst velg en. Er du produsent?" registration_type_producer_help: "Produsenter lager deilige ting å spise og/eller drikke. Du er en produsent hvis du dyrker det, driver med det, brygger det, baker det, fermenterer det, melker det eller former det." registration_type_no_producer_help: "Hvis du ikke er en produsent, er du sannsynligvis noen som selger og distribuerer mat. Du kan være en hub, samvirke, kjøpegruppe, forhandler, grossist eller annet." - registration_images_headline: "Takk!" - registration_images_description: "La oss laste opp noen fine bilder så profilen din ser flott ut! :)" registration_detail_headline: "La oss komme i gang" registration_detail_enterprise: "Kult! Først må vi vite litt om bedriften:" registration_detail_producer: "Kult! Først må vi vite litt om gården din:" @@ -2438,7 +2449,14 @@ nb: i din handlekurv gått ned. Her er hva som er endret. now_out_of_stock: er nå ikke på lager. only_n_remainging: "har nå kun %{num} igjen." + variants: + on_demand: + 'yes': "Ved forespørsel" variant_overrides: + on_demand: + use_producer_settings: "Bruk produsentens lagerinnstillinger" + 'yes': "Ja" + 'no': "Nei" inventory_products: "Produkter i Varelager" hidden_products: "Skjulte Produkter" new_products: "Nye Produkter" @@ -2541,6 +2559,12 @@ nb: other: "Du har %{count} aktive bestillingssykluser." manage_order_cycles: "BEHANDLE BESTILLINGSRUNDER" payment_methods: + new: + new_payment_method: "Ny Betalingsmetode" + back_to_payment_methods_list: "Tilbake til listen over betalingsmetoder" + edit: + editing_payment_method: "Redigerer betalingsmetode" + back_to_payment_methods_list: "Tilbake til listen over betalingsmetoder" stripe_connect: enterprise_select_placeholder: Velg... loading_account_information_msg: Laster inn kontoinformasjon fra Stripe, vennligst vent ... diff --git a/config/locales/pt.yml b/config/locales/pt.yml index db55ac5385..fef04357df 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -73,7 +73,7 @@ pt: order_mailer: cancel_email: dear_customer: "Caro Consumidor," - instructions: "A sua encomenda foi cancelada. Por favor guarde está informação para seu registo." + instructions: "A sua encomenda foi cancelada. Por favor guarde esta informação para seu registo." order_summary_canceled: "Sumário de Encomenda [CANCELADA]" subject: "Cancelamento de Encomenda" subtotal: "Subtotal: %{subtotal}" @@ -692,6 +692,7 @@ pt: close_date: Data de fecho social: twitter_placeholder: 'ex: @o_prof' + facebook_placeholder: ex. www.facebook.com/asuapagina stripe_connect: connect_with_stripe: "Conectar com o Stripe" stripe_connect_intro: "Para aceitar pagamentos com cartão de crédito, vai ser necessário ligar a sua conta Stripe à Open Food Network. Use o botão à direita para começar." @@ -1607,6 +1608,11 @@ pt: update_and_recalculate_fees: "Actualizar e Recalcular Taxas" registration: steps: + images: + continue: "Continuar" + back: "Voltar" + headline: "Obrigado!" + description: "Vamos adicionar umas boas imagens para o seu perfil ficar impecável!" type: headline: "Último passo para adicionar %{enterprise}!" question: "É produtor/a?" @@ -1740,8 +1746,6 @@ pt: registration_type_error: "Por favor escolha uma opção. É produtor/a?" registration_type_producer_help: "Produtores/as são quem faz coisas deliciosas para comer e/ou beber. É produtor/a se planta, cria, fermenta, amassa, munge ou molda algo." registration_type_no_producer_help: "Se não é produtor/a, é provavelmente alguém que vende e distribui alimentos. Pode ser uma cooperativa, um grupo de consumo, um distribuidor, um retalhista, ou outro." - registration_images_headline: "Obrigado!" - registration_images_description: "Vamos adicionar umas boas imagens para o seu perfil ficar impecável!" registration_detail_headline: "Vamos Começar" registration_detail_enterprise: "Primeiro precisamos saber mais sobre a sua organização:" registration_detail_producer: "Primeiro precisamos saber mais sobre sua produção:" @@ -2334,7 +2338,13 @@ pt: carrinho baixou. Aqui está o que mudou: now_out_of_stock: está agora sem stock. only_n_remainging: "agora só tem %{num}restantes." + variants: + on_demand: + 'yes': "Sob encomenda" variant_overrides: + on_demand: + 'yes': "Sim" + 'no': "Não" inventory_products: "Produtos de Inventário" hidden_products: "Produtos Escondidos" new_products: "Novos Produtos" diff --git a/config/locales/sv.yml b/config/locales/sv.yml index bbc471eb27..f47c6fb424 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -441,6 +441,7 @@ sv: close_date: Stängningsdatum social: twitter_placeholder: t.ex. @the_prof + facebook_placeholder: eg. www.facebook.com/PageNameHere tag_rules: default_rules: by_default: Som standard @@ -1172,6 +1173,11 @@ sv: who_is_managing_enterprise: "Vem är ansvarig hos %{enterprise}?" registration: steps: + images: + continue: "Fortsätt" + back: "Backa" + headline: "Tack!" + description: "Låt oss ladda några säljande bilder så att din profil ser lockande ut! :)" type: headline: "Sista steget för att lägga till %{enterprise}!" question: "Är du en producent?" @@ -1257,8 +1263,6 @@ sv: registration_type_error: "Var vänlig välj en. Är du en producent?" registration_type_producer_help: "Producenter gör smakfulla rätter att äta och/eller dricka. Du är en producent om du odlar det, föder upp det, brygger det, bakar det behandlar det, förädlar det eller formar det." registration_type_no_producer_help: "Om du inte ät en producent är du antagligen någon som säljer och distribuerar mat. Du borde bli ett matställe, kooperation, inköpsgrupp, detaljhandlare,grossist eller annat. " - registration_images_headline: "Tack!" - registration_images_description: "Låt oss ladda några säljande bilder så att din profil ser lockande ut! :)" registration_detail_headline: "Låt oss börja" registration_detail_enterprise: "Hej! Först bejöver vi veta lite om ditt företag:" registration_detail_producer: "Hej! Först behöver vi veta lite om din gård:" @@ -1814,7 +1818,13 @@ sv: kundvagn minskat. Detta har ändrats: now_out_of_stock: Är nu slut only_n_remainging: "nu återstår endast %{num}" + variants: + on_demand: + 'yes': "På begäran " variant_overrides: + on_demand: + 'yes': "Ja" + 'no': "Nej" inventory_products: "Lagerstatus produkter" hidden_products: "Dolda produkter" new_products: "Nya produkter" From f05f4ce0b12e16e39b01652f64ed4643b02b4e14 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Wed, 9 Jan 2019 07:06:27 +1100 Subject: [PATCH 23/24] Updating translations for config/locales/en_GB.yml --- config/locales/en_GB.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/locales/en_GB.yml b/config/locales/en_GB.yml index 59b748c4d4..489e14db82 100644 --- a/config/locales/en_GB.yml +++ b/config/locales/en_GB.yml @@ -24,6 +24,11 @@ en_GB: attributes: orders_close_at: after_orders_open_at: must be after open date + variant_override: + count_on_hand: + using_producer_stock_settings_but_count_on_hand_set: "must be blank because using producer stock settings" + on_demand_but_count_on_hand_set: "must be blank if on demand" + limited_stock_but_no_count_on_hand: "must be specified because forcing limited stock" activemodel: errors: models: @@ -715,7 +720,9 @@ en_GB: close_date: Close Date social: twitter_placeholder: eg. @the_prof + instagram_placeholder: eg. the_prof facebook_placeholder: eg. www.facebook.com/PageNameHere + linkedin_placeholder: eg. www.linkedin.com/in/YourNameHere stripe_connect: connect_with_stripe: "Connect with Stripe" stripe_connect_intro: "To accept payments using credit card, you will need to connect your stripe account to the Open Food Network. Use the button to the right to get started." @@ -2453,6 +2460,7 @@ en_GB: 'yes': "Unlimited" variant_overrides: on_demand: + use_producer_settings: "Use producer stock settings" 'yes': "Yes" 'no': "No" inventory_products: "Inventory Products" @@ -2558,6 +2566,12 @@ en_GB: other: "You have %{count} active order cycles." manage_order_cycles: "MANAGE ORDER CYCLES" payment_methods: + new: + new_payment_method: "New Payment Method" + back_to_payment_methods_list: "Back To Payment Methods List" + edit: + editing_payment_method: "Editing Payment Method" + back_to_payment_methods_list: "Back To Payment Methods List" stripe_connect: enterprise_select_placeholder: Choose... loading_account_information_msg: Loading account information from stripe, please wait... From 15e197b3b0118cc3eb978854934f4d0ae2069893 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Thu, 10 Jan 2019 07:31:46 +1100 Subject: [PATCH 24/24] Updating translations for config/locales/en_GB.yml --- config/locales/en_GB.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/locales/en_GB.yml b/config/locales/en_GB.yml index 489e14db82..11fad53128 100644 --- a/config/locales/en_GB.yml +++ b/config/locales/en_GB.yml @@ -475,6 +475,8 @@ en_GB: inventory_no_permission: you do not have permission to create inventory for this producer none_saved: did not save any products successfully line_number: "Line %{number}:" + encoding_error: "Please check the language setting of your source file and ensure it is saved with UTF-8 encoding" + unexpected_error: "Product Import encountered an unexpected error whilst opening the file: %{error_message}" index: select_file: Select a spreadsheet to upload spreadsheet: Spreadsheet @@ -2624,7 +2626,7 @@ en_GB: display_as: Display As reports: table: - select_and_search: "Select filters and click on SEARCH to access your data." + select_and_search: "Select filters and click on %{option} to access your data." bulk_coop: bulk_coop_supplier_report: 'Bulk Co-op - Totals by Supplier' bulk_coop_allocation: 'Bulk Co-op - Allocation'