From 09655b9f88c54bba81649d450f69a9810a8a6eca Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 16 Feb 2019 00:26:29 +0000 Subject: [PATCH 1/7] Fix nil values in on_hand column --- app/models/product_import/entry_validator.rb | 1 + spec/models/product_importer_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index 7582330a0a..a1e2d5b91b 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -254,6 +254,7 @@ module ProductImport new_product = Spree::Product.new new_product.assign_attributes(entry.attributes.except('id')) new_product.supplier_id = entry.producer_id + entry.on_hand = 0 if entry.on_hand.nil? if new_product.valid? entry.validates_as = 'new_product' unless entry.errors? diff --git a/spec/models/product_importer_spec.rb b/spec/models/product_importer_spec.rb index 7a259f53fe..5e21507afa 100644 --- a/spec/models/product_importer_spec.rb +++ b/spec/models/product_importer_spec.rb @@ -50,7 +50,7 @@ describe ProductImport::ProductImporter do csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "2", "kg", "", ""] csv << ["Pea Soup", "User Enterprise", "Vegetables", "8", "5.50", "750", "ml", "", "0"] csv << ["Salad", "User Enterprise", "Vegetables", "7", "4.50", "1", "", "bags", ""] - csv << ["Hot Cross Buns", "User Enterprise", "Cake", "7", "3.50", "1", "", "buns", "1"] + csv << ["Hot Cross Buns", "User Enterprise", "Cake", nil, "3.50", "1", "", "buns", "1"] end File.write('/tmp/test-m.csv', csv_data) file = File.new('/tmp/test-m.csv') @@ -122,7 +122,8 @@ describe ProductImport::ProductImporter do buns = Spree::Product.find_by_name('Hot Cross Buns') expect(buns.supplier).to eq enterprise - # buns.on_hand).to eq Infinity + expect(buns.on_hand).to eq Float::INFINITY + expect(buns.count_on_hand).to eq 0 expect(buns.price).to eq 3.50 expect(buns.unit_value).to eq 1 expect(buns.variant_unit).to eq 'items' From 9d4589632bfcee6116735d46920e592a1b1ba879 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 26 Mar 2019 16:13:50 +1100 Subject: [PATCH 2/7] Test inventory report to use variant overrides --- .../products_and_inventory_report_spec.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/lib/open_food_network/products_and_inventory_report_spec.rb b/spec/lib/open_food_network/products_and_inventory_report_spec.rb index 80bdaebcf7..4a992a2607 100644 --- a/spec/lib/open_food_network/products_and_inventory_report_spec.rb +++ b/spec/lib/open_food_network/products_and_inventory_report_spec.rb @@ -134,6 +134,32 @@ module OpenFoodNetwork subject.stub(:params).and_return(distributor_id: distributor.id) subject.filter(variants).should == [product2.variants.first] end + + it "ignores variant overrides without filter" do + distributor = create(:distributor_enterprise) + product = create(:simple_product, supplier: supplier, price: 5) + variant = product.variants.first + order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product.variants.first]) + create(:variant_override, hub: distributor, variant: variant, price: 2) + + result = subject.filter(variants) + + expect(result.first.price).to eq 5 + end + + it "considers variant overrides with distributor" do + distributor = create(:distributor_enterprise) + product = create(:simple_product, supplier: supplier, price: 5) + variant = product.variants.first + order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product.variants.first]) + create(:variant_override, hub: distributor, variant: variant, price: 2) + + allow(subject).to receive(:params).and_return(distributor_id: distributor.id) + result = subject.filter(variants) + + expect(result.first.price).to eq 2 + end + it "filters to a specific order cycle" do distributor = create(:distributor_enterprise) product1 = create(:simple_product, supplier: supplier) From 0f7ef2671f5ad6ebfd10685e73d2f60445f2c408 Mon Sep 17 00:00:00 2001 From: sdbowen Date: Wed, 27 Mar 2019 19:57:38 -0600 Subject: [PATCH 3/7] Add shipping method name to orders detail report Added column allows users to see the shipping method of each order. --- .rubocop_todo.yml | 1 - lib/open_food_network/order_and_distributor_report.rb | 8 ++++++-- .../order_and_distributor_report_spec.rb | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3df9808e33..55c8044723 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -20,7 +20,6 @@ Layout/AlignArray: Exclude: - 'lib/open_food_network/bulk_coop_report.rb' - 'lib/open_food_network/customers_report.rb' - - 'lib/open_food_network/order_and_distributor_report.rb' - 'lib/open_food_network/orders_and_fulfillments_report.rb' - 'lib/open_food_network/packing_report.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' diff --git a/lib/open_food_network/order_and_distributor_report.rb b/lib/open_food_network/order_and_distributor_report.rb index 1663d483a4..29b9772c96 100644 --- a/lib/open_food_network/order_and_distributor_report.rb +++ b/lib/open_food_network/order_and_distributor_report.rb @@ -10,7 +10,8 @@ module OpenFoodNetwork end def header - [I18n.t(:report_header_order_date), + [ + I18n.t(:report_header_order_date), I18n.t(:report_header_order_id), I18n.t(:report_header_customer_name), I18n.t(:report_header_customer_email), @@ -28,7 +29,9 @@ module OpenFoodNetwork I18n.t(:report_header_distributor_address), I18n.t(:report_header_distributor_city), I18n.t(:report_header_distributor_postcode), - I18n.t(:report_header_shipping_instructions)] + I18n.t(:report_header_shipping_method), + I18n.t(:report_header_shipping_instructions) + ] end def search @@ -95,6 +98,7 @@ module OpenFoodNetwork order.distributor.address.address1, order.distributor.address.city, order.distributor.address.zipcode, + order.shipping_method.name, order.special_instructions ] end diff --git a/spec/lib/open_food_network/order_and_distributor_report_spec.rb b/spec/lib/open_food_network/order_and_distributor_report_spec.rb index 4cd03de91c..614640c0e2 100644 --- a/spec/lib/open_food_network/order_and_distributor_report_spec.rb +++ b/spec/lib/open_food_network/order_and_distributor_report_spec.rb @@ -11,15 +11,16 @@ module OpenFoodNetwork 'Customer Name', 'Customer Email', 'Customer Phone', 'Customer City', 'SKU', 'Item name', 'Variant', 'Quantity', 'Max Quantity', 'Cost', 'Shipping Cost', 'Payment Method', - 'Distributor', 'Distributor address', 'Distributor city', 'Distributor postcode', 'Shipping instructions']) + 'Distributor', 'Distributor address', 'Distributor city', 'Distributor postcode', 'Shipping Method', 'Shipping instructions']) end context 'with completed order' do let(:bill_address) { create(:address) } let(:distributor) { create(:distributor_enterprise) } let(:product) { create(:product) } + let(:shipping_method) { create(:shipping_method) } let(:shipping_instructions) { 'pick up on thursday please!' } - let(:order) { create(:order, state: 'complete', completed_at: Time.zone.now, distributor: distributor, bill_address: bill_address, special_instructions: shipping_instructions) } + let(:order) { create(:order, state: 'complete', completed_at: Time.zone.now, distributor: distributor, bill_address: bill_address, shipping_method: shipping_method, special_instructions: shipping_instructions) } let(:payment_method) { create(:payment_method, distributors: [distributor]) } let(:payment) { create(:payment, payment_method: payment_method, order: order) } let(:line_item) { create(:line_item, product: product, order: order) } @@ -53,6 +54,7 @@ module OpenFoodNetwork distributor.address.address1, distributor.address.city, distributor.address.zipcode, + shipping_method.name, shipping_instructions ]) end From 29f32604f24812644a437c3e51995e014b219544 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 29 Mar 2019 13:40:51 +1100 Subject: [PATCH 4/7] Relax stripe version requirement We are using the latest version of the `stripe` gem. We don't depend on any particular version. I'm proposing to drop our dependency declaration on a particular version and just track the current used version in Gemfile.lock. That means fewer code changes when updating, which happens quite frequently with this gem. --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index bbf20b4196..374f59ac6a 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'spree_auth_devise', github: 'openfoodfoundation/spree_auth_devise', branch: # - Change type of password from string to password to hide it in the form gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "spree-upgrade-intermediate" #gem 'spree_paypal_express', github: "spree-contrib/better_spree_paypal_express", branch: "1-3-stable" -gem 'stripe', '~> 4.11.0' +gem 'stripe' # We need at least this version to have Digicert's root certificate # which is needed for Pin Payments (and possibly others). gem 'activemerchant', '~> 1.78' diff --git a/Gemfile.lock b/Gemfile.lock index 7b0b7b88e1..d2498638ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -865,7 +865,7 @@ DEPENDENCIES spree_paypal_express! spring (= 1.7.2) spring-commands-rspec - stripe (~> 4.11.0) + stripe therubyracer (= 0.12.0) timecop truncate_html From 8b6561addd0d2bc9048f8a79e8ce24ab457a782b Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 2 Apr 2019 17:47:36 +1100 Subject: [PATCH 5/7] Add missing translation for order form in v2 I saw the following error on the 2-0-stable branch: translation missing: en.spree.line_item_adjustments In a pending PR I change all three translations in the view file to use lazy lookup. This commit backports the addition to the locale so that it can be translated via Transifex before we release v2. --- config/locales/en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 68c49b8bc8..eed0881ba6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3003,6 +3003,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using title: "Distribution" distributor: "Distributor:" order_cycle: "Order cycle:" + line_item_adjustments: "Line Item Adjustments" + order_adjustments: "Order Adjustments" + order_total: "Order Total" overview: products: active_products: From 7522594b85fef6ec8faae9bce2ed5339afb75a22 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 4 Apr 2019 11:54:11 +0100 Subject: [PATCH 6/7] Fix outdated db2fog initializer --- .gitignore | 1 - config/initializers/0_depricated_db2fog.rb | 15 --------------- config/initializers/db2fog.rb | 7 +++++++ 3 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 config/initializers/0_depricated_db2fog.rb create mode 100644 config/initializers/db2fog.rb diff --git a/.gitignore b/.gitignore index 21ff15e147..88a12db1be 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ public/images public/spree config/abr.yml config/initializers/feature_toggle.rb -config/initializers/db2fog.rb NERD_tree* coverage libpeerconnection.log diff --git a/config/initializers/0_depricated_db2fog.rb b/config/initializers/0_depricated_db2fog.rb deleted file mode 100644 index f2a2e76bc9..0000000000 --- a/config/initializers/0_depricated_db2fog.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Depricated: this initializer contains an invalid bucket name. -# Users of DB2fog should be able to configure DB2fog without changing the code. -# -# Name your configuration file `db2fog.rb`. It will be ignored by git. -# And it will overwrite this depricated configuration. -# -# See: https://github.com/yob/db2fog -# -# TODO: Remove this file in a future release. -DB2Fog.config = { - :aws_access_key_id => Spree::Config[:s3_access_key], - :aws_secret_access_key => Spree::Config[:s3_secret], - :directory => "db-backup_#{Spree::Config[:s3_bucket]}", - :provider => 'AWS' -} diff --git a/config/initializers/db2fog.rb b/config/initializers/db2fog.rb new file mode 100644 index 0000000000..84a1d4098d --- /dev/null +++ b/config/initializers/db2fog.rb @@ -0,0 +1,7 @@ +# See: https://github.com/yob/db2fog +DB2Fog.config = { + :aws_access_key_id => Spree::Config[:s3_access_key], + :aws_secret_access_key => Spree::Config[:s3_secret], + :directory => Spree::Config[:s3_backups_bucket], + :provider => 'AWS' +} From 9b45269cbb63d1b4c96c99513ecf58d42d18d8cd Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 4 Apr 2019 13:06:05 +0100 Subject: [PATCH 7/7] Fix name of Spree::Config preference --- config/initializers/db2fog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/db2fog.rb b/config/initializers/db2fog.rb index 84a1d4098d..7c7a2d6d39 100644 --- a/config/initializers/db2fog.rb +++ b/config/initializers/db2fog.rb @@ -2,6 +2,6 @@ DB2Fog.config = { :aws_access_key_id => Spree::Config[:s3_access_key], :aws_secret_access_key => Spree::Config[:s3_secret], - :directory => Spree::Config[:s3_backups_bucket], + :directory => Spree::Config[:s3_bucket], :provider => 'AWS' }