solidus_legacy_promotions 4.7.3 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2437799e27ac497bdf921ac3a8d044dfc166a072d9f368fd9cabc3a8d2a71518
4
- data.tar.gz: bae186981e43abf5ca0424b75bb22ffe9119dc2d3033549d81b3a62158096010
3
+ metadata.gz: d28523b306aa0d6c03ffca454a927ac78b6336281ae1685e80c075de3f8ee2c4
4
+ data.tar.gz: 96aaeea2e3e7c7184b05e895b304e8d1d30286fe7bfba2208b58b603c8d1f8f8
5
5
  SHA512:
6
- metadata.gz: d1e90fbf03bff5160dbe85165ce8c557a6440189f9f2c01caaa48789ae76d32050e281b6dd127ee400874725ca2c4f3f5657cb1676a489e1e5e005c73a46746c
7
- data.tar.gz: bd39cf56788617f06c38e354bc90e8c2265a2d58998eb9e1a24e56cda4ea8f1460fe27c5b8048c9a3a69865ad241c69c0524a81c6ef78554536116251685ea15
6
+ metadata.gz: df7189a2c2dfd7c74da927efb2a3bad812cad398cd8b76fddfab0a6e4f3d3b9e1bae82468acfde23de7bb3ec72c4cf9dc89dcd2690f3638183c69250add15015
7
+ data.tar.gz: 739d1ff72a82ff639d6f8a9aaef799b7793ab8ab49afa029c4d5587e761cb04da102f8f276c2fbf8f9b348747e0b46bb317df7ef1f1221c6ca2be8ac66c3e70d
data/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2007-2014, Spree Commerce, Inc. and other contributors
2
+ All rights reserved.
3
+
4
+ Copyright (c) 2015-2026, Solidus contributors
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice,
11
+ this list of conditions and the following disclaimer.
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+ * Neither the name Spree nor the names of its contributors may be used to
16
+ endorse or promote products derived from this software without specific
17
+ prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -10,7 +10,7 @@ require_dependency "spree/calculator"
10
10
  module Spree
11
11
  class Calculator::DistributedAmount < Calculator
12
12
  preference :amount, :decimal, default: 0
13
- preference :currency, :string, default: -> { Spree::Config[:currency] }
13
+ preference :currency, :string, default: -> { Spree::Config.currency }
14
14
 
15
15
  def compute_line_item(line_item)
16
16
  return 0 unless line_item
@@ -7,7 +7,7 @@ module Spree
7
7
  preference :first_item, :decimal, default: 0
8
8
  preference :additional_item, :decimal, default: 0
9
9
  preference :max_items, :integer, default: 0
10
- preference :currency, :string, default: -> { Spree::Config[:currency] }
10
+ preference :currency, :string, default: -> { Spree::Config.currency }
11
11
 
12
12
  def compute(object)
13
13
  items_count = object.quantity
@@ -6,7 +6,7 @@ module Spree
6
6
  class Calculator::TieredFlatRate < Calculator
7
7
  preference :base_amount, :decimal, default: 0
8
8
  preference :tiers, :hash, default: {}
9
- preference :currency, :string, default: -> { Spree::Config[:currency] }
9
+ preference :currency, :string, default: -> { Spree::Config.currency }
10
10
 
11
11
  before_validation do
12
12
  # Convert tier values to decimals. Strings don't do us much good.
@@ -6,7 +6,7 @@ module Spree
6
6
  class Calculator::TieredPercent < Calculator
7
7
  preference :base_percent, :decimal, default: 0
8
8
  preference :tiers, :hash, default: {}
9
- preference :currency, :string, default: -> { Spree::Config[:currency] }
9
+ preference :currency, :string, default: -> { Spree::Config.currency }
10
10
 
11
11
  before_validation do
12
12
  # Convert tier values to decimals. Strings don't do us much good.
@@ -15,6 +15,7 @@ module Spree
15
15
 
16
16
  def call(persist: true)
17
17
  all_items = line_items + shipments
18
+ ActiveRecord::Associations::Preloader.new(records: all_items, associations: :adjustments).call
18
19
  all_items.each do |item|
19
20
  promotion_adjustments = item.adjustments.select(&:promotion?)
20
21
 
@@ -10,7 +10,7 @@ module Spree
10
10
  # To customize the error message you can also override `ineligible_message`.
11
11
  class ItemTotal < PromotionRule
12
12
  preference :amount, :decimal, default: 100.00
13
- preference :currency, :string, default: -> { Spree::Config[:currency] }
13
+ preference :currency, :string, default: -> { Spree::Config.currency }
14
14
  preference :operator, :string, default: "gt"
15
15
 
16
16
  # The list of allowed operators names mapped to their symbols.
@@ -240,6 +240,7 @@ module Spree
240
240
  when Spree::LineItem
241
241
  !promotable.variant.product.promotionable?
242
242
  when Spree::Order
243
+ ActiveRecord::Associations::Preloader.new(records: promotable.line_items, associations: {variant: :product}).call
243
244
  promotable.line_items.any? { |line_item| !line_item.variant.product.promotionable? }
244
245
  end
245
246
  end
@@ -3,11 +3,6 @@
3
3
  module Spree
4
4
  module Admin
5
5
  class PromotionCategoriesController < ResourceController
6
- private
7
-
8
- def permitted_resource_params
9
- params.require(:promotion_category).permit(:name, :code)
10
- end
11
6
  end
12
7
  end
13
8
  end
@@ -22,10 +22,6 @@ module Spree
22
22
 
23
23
  private
24
24
 
25
- def permitted_resource_params
26
- params.require(:promotion_code_batch).permit(:base_code, :number_of_codes, :join_characters, :email)
27
- end
28
-
29
25
  def build_promotion_code_batch
30
26
  @promotion_code_batch.process
31
27
  end
@@ -31,45 +31,6 @@ module Spree
31
31
 
32
32
  private
33
33
 
34
- def permitted_resource_params
35
- params.fetch(:promotion, {}).permit(
36
- :name, :description, :promotion_category_id, :usage_limit, :per_code_usage_limit,
37
- :starts_at, :expires_at, :apply_automatically, :path,
38
- promotion_rules_attributes: [
39
- :id, :product_ids_string, :taxon_ids_string, :user_ids_string,
40
- *preference_attributes(Spree::Config.promotions.rules),
41
- store_ids: []
42
- ],
43
- promotion_actions_attributes: [
44
- :id, :calculator_type,
45
- *preference_attributes(Spree::Config.promotions.actions),
46
- calculator_attributes: preference_attributes(promotion_calculators)
47
- ]
48
- )
49
- end
50
-
51
- def promotion_calculators
52
- Spree::Config.promotions.actions.flat_map do |action|
53
- Spree::Config.promotions.calculators[action].to_a
54
- end
55
- end
56
-
57
- # Permits the preferences declared by the given rule, action or calculator classes,
58
- # matching each preference's shape (array and hash preferences may hold multiple values).
59
- def preference_attributes(klasses)
60
- klasses.uniq.flat_map do |klass|
61
- instance = klass.new
62
- instance.defined_preferences.map do |name|
63
- attribute = :"preferred_#{name}"
64
- case instance.preference_type(name)
65
- when :array then [attribute, {attribute => []}]
66
- when :hash then {attribute => {}}
67
- else attribute
68
- end
69
- end
70
- end.flatten.uniq
71
- end
72
-
73
34
  def location_after_save
74
35
  spree.edit_admin_promotion_url(@promotion)
75
36
  end
@@ -94,7 +55,7 @@ module Spree
94
55
  end
95
56
 
96
57
  def promotion_code_batch_params
97
- params.require(:promotion_code_batch).permit(:base_code, :number_of_codes, :join_characters, :email)
58
+ params.require(:promotion_code_batch).permit!
98
59
  end
99
60
 
100
61
  def promotion_includes
@@ -13,7 +13,6 @@ module SolidusLegacyPromotions
13
13
  promotions_menu_item = Spree::BackendConfiguration::MenuItem.new(
14
14
  label: :legacy_promotions,
15
15
  icon: Spree::Backend::Config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn",
16
- partial: "spree/admin/shared/promotion_sub_menu",
17
16
  condition: -> { can?(:admin, Spree::Promotion) },
18
17
  url: :admin_promotions_path,
19
18
  data_hook: :admin_promotion_sub_tabs,
@@ -11,7 +11,7 @@
11
11
  "#{prefix}[calculator_attributes][preferred_currency]",
12
12
  options_for_select(
13
13
  Spree::Config.available_currencies,
14
- calculator.preferred_currency || Spree::Config[:currency]
14
+ calculator.preferred_currency || Spree::Config.currency
15
15
  ),
16
16
  { class: 'custom-select fullwidth' }
17
17
  ) %>
@@ -11,7 +11,7 @@
11
11
  "#{prefix}[calculator_attributes][preferred_currency]",
12
12
  options_for_select(
13
13
  Spree::Config.available_currencies,
14
- calculator.preferred_currency || Spree::Config[:currency]
14
+ calculator.preferred_currency || Spree::Config.currency
15
15
  ),
16
16
  { class: 'custom-select fullwidth' }
17
17
  ) %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_legacy_promotions
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.3
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
@@ -29,28 +29,28 @@ dependencies:
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 4.7.3
32
+ version: 4.8.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 4.7.3
39
+ version: 4.8.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: solidus_core
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 4.7.3
46
+ version: 4.8.0
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 4.7.3
53
+ version: 4.8.0
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: solidus_support
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -77,6 +77,7 @@ executables: []
77
77
  extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
+ - LICENSE
80
81
  - README.md
81
82
  - Rakefile
82
83
  - app/assets/config/solidus_legacy_promotions/manifest.js
@@ -280,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
281
  - !ruby/object:Gem::Version
281
282
  version: 1.8.23
282
283
  requirements: []
283
- rubygems_version: 4.0.10
284
+ rubygems_version: 4.0.20
284
285
  specification_version: 4
285
286
  summary: Legacy Solidus promotion system
286
287
  test_files: []