From 6c5aaef86e954f8a64200b4921a12f4605ed5e09 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 1 Apr 2016 19:42:09 +1100 Subject: [PATCH] Removing ability to create order discount rules Issue with application of tax to discounted items is yet to be resolved --- .../directives/new_rule_dialog.js.coffee | 2 +- app/models/tag_rule/discount_order.rb | 2 +- config/locales/en.yml | 6 +---- db/schema.rb | 2 +- spec/features/admin/tag_rules_spec.rb | 22 +++++++++---------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/admin/tag_rules/directives/new_rule_dialog.js.coffee b/app/assets/javascripts/admin/tag_rules/directives/new_rule_dialog.js.coffee index 888ec2b402..54e33006e4 100644 --- a/app/assets/javascripts/admin/tag_rules/directives/new_rule_dialog.js.coffee +++ b/app/assets/javascripts/admin/tag_rules/directives/new_rule_dialog.js.coffee @@ -6,7 +6,7 @@ angular.module("admin.tagRules").directive 'newTagRuleDialog', ($compile, $templ template = $compile($templateCache.get('admin/new_tag_rule_dialog.html'))(scope) scope.ruleTypes = [ - { id: "DiscountOrder", name: 'Apply a discount to orders' } + # { id: "DiscountOrder", name: 'Apply a discount to orders' } { id: "FilterShippingMethods", name: 'Show/Hide shipping methods' } ] diff --git a/app/models/tag_rule/discount_order.rb b/app/models/tag_rule/discount_order.rb index 9f293bfdaa..5984814289 100644 --- a/app/models/tag_rule/discount_order.rb +++ b/app/models/tag_rule/discount_order.rb @@ -5,7 +5,7 @@ class TagRule::DiscountOrder < TagRule # Warning: this should only EVER be called via TagRule#apply def apply! - create_adjustment(I18n.t("tag_rules.discount_order.discount"), subject, subject) + create_adjustment(I18n.t("discount"), subject, subject) end def subject_class_matches? diff --git a/config/locales/en.yml b/config/locales/en.yml index 4a9d8fe546..e38d3e3f6b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -137,11 +137,6 @@ en: invoice_column_tax: "GST" invoice_column_price: "Price" - # Tag Rules - tag_rules: - discount_order: - discount: "Discount" - logo: "Logo (640x130)" #FIXME logo_mobile: "Mobile logo (75x26)" #FIXME logo_mobile_svg: "Mobile logo (SVG)" #FIXME @@ -973,6 +968,7 @@ Please follow the instructions there to make your enterprise visible on the Open account_code: "Account code:" equals: "Equals" contains: "contains" + discount: "Discount" filter_products: "Filter Products" delete_product_variant: "The last variant cannot be deleted!" progress: "progress" diff --git a/db/schema.rb b/db/schema.rb index dc54bd8f3d..c8887ad86e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -683,9 +683,9 @@ ActiveRecord::Schema.define(:version => 20160401043927) do t.string "email" t.text "special_instructions" t.integer "distributor_id" + t.integer "order_cycle_id" t.string "currency" t.string "last_ip_address" - t.integer "order_cycle_id" t.integer "cart_id" t.integer "customer_id" end diff --git a/spec/features/admin/tag_rules_spec.rb b/spec/features/admin/tag_rules_spec.rb index a4e6e62d24..e91215a21d 100644 --- a/spec/features/admin/tag_rules_spec.rb +++ b/spec/features/admin/tag_rules_spec.rb @@ -21,24 +21,24 @@ feature 'Tag Rules', js: true do click_button '+ Add A New Tag' find(:css, "tags-input .tags input").set "volunteer\n" - # New DiscountOrder Rule - expect(page).to have_content 'No rules apply to this tag yet' - click_button '+ Add A New Rule' - select2_select 'Apply a discount to orders', from: 'rule_type_selector' - click_button "Add Rule" - fill_in "enterprise_tag_rules_attributes_0_calculator_attributes_preferred_flat_percent", with: 22 - # New FilterShippingMethods Rule click_button '+ Add A New Rule' select2_select 'Show/Hide shipping methods', from: 'rule_type_selector' click_button "Add Rule" - select2_select "NOT VISIBLE", from: "enterprise_tag_rules_attributes_1_preferred_matched_shipping_methods_visibility" + select2_select "NOT VISIBLE", from: "enterprise_tag_rules_attributes_0_preferred_matched_shipping_methods_visibility" + + # New DiscountOrder Rule + # expect(page).to have_content 'No rules apply to this tag yet' + # click_button '+ Add A New Rule' + # select2_select 'Apply a discount to orders', from: 'rule_type_selector' + # click_button "Add Rule" + # fill_in "enterprise_tag_rules_attributes_1_calculator_attributes_preferred_flat_percent", with: 22 click_button 'Update' - tag_rule = TagRule::DiscountOrder.last - expect(tag_rule.preferred_customer_tags).to eq "volunteer" - expect(tag_rule.calculator.preferred_flat_percent).to eq -22 + # tag_rule = TagRule::DiscountOrder.last + # expect(tag_rule.preferred_customer_tags).to eq "volunteer" + # expect(tag_rule.calculator.preferred_flat_percent).to eq -22 tag_rule = TagRule::FilterShippingMethods.last expect(tag_rule.preferred_customer_tags).to eq "volunteer"