solidus_core 3.4.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -1
  3. data/app/helpers/spree/products_helper.rb +1 -1
  4. data/app/models/concerns/spree/active_storage_adapter.rb +0 -17
  5. data/app/models/concerns/spree/default_price.rb +0 -15
  6. data/app/models/concerns/spree/ransackable_attributes.rb +0 -21
  7. data/app/models/spree/adjustment.rb +0 -13
  8. data/app/models/spree/carton.rb +1 -1
  9. data/app/models/spree/fulfilment_changer.rb +2 -14
  10. data/app/models/spree/option_value.rb +2 -11
  11. data/app/models/spree/order.rb +9 -21
  12. data/app/models/spree/order_updater.rb +0 -29
  13. data/app/models/spree/payment.rb +5 -37
  14. data/app/models/spree/product/scopes.rb +0 -5
  15. data/app/models/spree/product.rb +3 -10
  16. data/app/models/spree/promotion/rules/item_total.rb +0 -11
  17. data/app/models/spree/promotion.rb +7 -30
  18. data/app/models/spree/promotion_rule.rb +0 -5
  19. data/app/models/spree/taxon.rb +2 -2
  20. data/app/models/spree/taxonomy.rb +1 -1
  21. data/app/models/spree/variant/price_selector.rb +1 -14
  22. data/app/models/spree/variant.rb +1 -17
  23. data/db/migrate/20210815004823_add_unique_index_to_option_values_variants.rb +16 -0
  24. data/db/migrate/20230321161854_change_column_null_option_values_option_type_id.rb +5 -0
  25. data/db/migrate/20230322085416_remove_match_policy_from_spree_promotion.rb +5 -0
  26. data/db/migrate/20230325132905_remove_unused_columns_from_promotion_rules.rb +6 -0
  27. data/db/migrate/20230325161633_drop_unused_promo_action_line_items.rb +13 -0
  28. data/db/migrate/20230425103509_remove_taxon_position.rb +5 -0
  29. data/db/migrate/20230427095534_drop_deprecated_address_id_from_shipments.rb +11 -0
  30. data/lib/generators/solidus/install/app_templates/frontend/none.rb +1 -2
  31. data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -3
  32. data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +2 -14
  33. data/lib/generators/solidus/install/app_templates/payment_method/stripe.rb +5 -0
  34. data/lib/generators/solidus/install/install_generator.rb +59 -153
  35. data/lib/spree/app_configuration.rb +2 -82
  36. data/lib/spree/bus.rb +0 -11
  37. data/lib/spree/core/controller_helpers/auth.rb +0 -16
  38. data/lib/spree/core/engine.rb +11 -31
  39. data/lib/spree/core/validators/email.rb +0 -4
  40. data/lib/spree/core/version.rb +2 -2
  41. data/lib/spree/core.rb +0 -2
  42. data/lib/spree/migration_helpers.rb +3 -3
  43. data/lib/spree/preferences/preferable_class_methods.rb +1 -25
  44. data/lib/spree/testing_support/common_rake.rb +5 -1
  45. data/lib/spree/testing_support/dummy_app/rake_tasks.rb +4 -8
  46. data/lib/spree/testing_support/dummy_app.rb +1 -6
  47. data/lib/spree/testing_support/factories/address_factory.rb +0 -7
  48. data/lib/spree/testing_support/factories/adjustment_factory.rb +0 -11
  49. data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +0 -5
  50. data/lib/spree/testing_support/factories/calculator_factory.rb +0 -5
  51. data/lib/spree/testing_support/factories/carton_factory.rb +0 -8
  52. data/lib/spree/testing_support/factories/country_factory.rb +0 -5
  53. data/lib/spree/testing_support/factories/credit_card_factory.rb +0 -5
  54. data/lib/spree/testing_support/factories/customer_return_factory.rb +0 -9
  55. data/lib/spree/testing_support/factories/image_factory.rb +0 -5
  56. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +0 -10
  57. data/lib/spree/testing_support/factories/line_item_factory.rb +0 -8
  58. data/lib/spree/testing_support/factories/option_type_factory.rb +0 -8
  59. data/lib/spree/testing_support/factories/option_value_factory.rb +0 -5
  60. data/lib/spree/testing_support/factories/order_factory.rb +0 -12
  61. data/lib/spree/testing_support/factories/order_promotion_factory.rb +0 -8
  62. data/lib/spree/testing_support/factories/payment_factory.rb +0 -10
  63. data/lib/spree/testing_support/factories/payment_method_factory.rb +0 -5
  64. data/lib/spree/testing_support/factories/price_factory.rb +0 -7
  65. data/lib/spree/testing_support/factories/product_factory.rb +0 -11
  66. data/lib/spree/testing_support/factories/product_option_type_factory.rb +0 -8
  67. data/lib/spree/testing_support/factories/product_property_factory.rb +0 -8
  68. data/lib/spree/testing_support/factories/promotion_category_factory.rb +0 -5
  69. data/lib/spree/testing_support/factories/promotion_code_factory.rb +0 -8
  70. data/lib/spree/testing_support/factories/promotion_factory.rb +0 -8
  71. data/lib/spree/testing_support/factories/property_factory.rb +0 -5
  72. data/lib/spree/testing_support/factories/refund_factory.rb +0 -8
  73. data/lib/spree/testing_support/factories/refund_reason_factory.rb +0 -5
  74. data/lib/spree/testing_support/factories/reimbursement_factory.rb +0 -7
  75. data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +0 -5
  76. data/lib/spree/testing_support/factories/return_authorization_factory.rb +0 -9
  77. data/lib/spree/testing_support/factories/return_item_factory.rb +0 -9
  78. data/lib/spree/testing_support/factories/return_reason_factory.rb +0 -5
  79. data/lib/spree/testing_support/factories/role_factory.rb +0 -5
  80. data/lib/spree/testing_support/factories/shipment_factory.rb +0 -10
  81. data/lib/spree/testing_support/factories/shipping_category_factory.rb +0 -5
  82. data/lib/spree/testing_support/factories/shipping_method_factory.rb +0 -9
  83. data/lib/spree/testing_support/factories/shipping_rate_factory.rb +0 -8
  84. data/lib/spree/testing_support/factories/state_factory.rb +0 -8
  85. data/lib/spree/testing_support/factories/stock_item_factory.rb +0 -8
  86. data/lib/spree/testing_support/factories/stock_location_factory.rb +0 -9
  87. data/lib/spree/testing_support/factories/stock_movement_factory.rb +0 -7
  88. data/lib/spree/testing_support/factories/stock_package_factory.rb +0 -8
  89. data/lib/spree/testing_support/factories/store_credit_category_factory.rb +0 -5
  90. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +0 -8
  91. data/lib/spree/testing_support/factories/store_credit_factory.rb +0 -9
  92. data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +0 -5
  93. data/lib/spree/testing_support/factories/store_credit_type_factory.rb +0 -5
  94. data/lib/spree/testing_support/factories/store_factory.rb +0 -5
  95. data/lib/spree/testing_support/factories/tax_category_factory.rb +0 -8
  96. data/lib/spree/testing_support/factories/tax_rate_factory.rb +0 -9
  97. data/lib/spree/testing_support/factories/taxon_factory.rb +0 -7
  98. data/lib/spree/testing_support/factories/taxonomy_factory.rb +0 -5
  99. data/lib/spree/testing_support/factories/user_factory.rb +0 -9
  100. data/lib/spree/testing_support/factories/variant_factory.rb +0 -10
  101. data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +0 -8
  102. data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +0 -9
  103. data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +0 -8
  104. data/lib/spree/testing_support/factories/zone_factory.rb +0 -8
  105. data/lib/spree/testing_support/factory_bot.rb +4 -28
  106. data/lib/spree/testing_support/sequences.rb +0 -5
  107. data/solidus_core.gemspec +4 -4
  108. metadata +48 -76
  109. data/app/subscribers/spree/mailer_subscriber.rb +0 -29
  110. data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +0 -54
  111. data/lib/generators/solidus/install/app_templates/frontend/classic.rb +0 -16
  112. data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +0 -13
  113. data/lib/spree/core/controller_helpers/current_host.rb +0 -19
  114. data/lib/spree/event/adapters/active_support_notifications.rb +0 -67
  115. data/lib/spree/event/configuration.rb +0 -25
  116. data/lib/spree/event/subscriber.rb +0 -86
  117. data/lib/spree/event/subscriber_registry.rb +0 -92
  118. data/lib/spree/event.rb +0 -119
  119. data/lib/spree/promotion/match_policies.rb +0 -2
  120. data/lib/spree/rails_compatibility.rb +0 -106
  121. data/lib/spree/testing_support/factories.rb +0 -11
  122. data/lib/spree/testing_support.rb +0 -36
  123. data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
  124. data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0e5d61f97cd11e88925c26f71b3b19ae3afe9b52b5b6b4648fad0791ffd9ba6
4
- data.tar.gz: a78286a729dffebc660f360a8709bf66c39ba783445e35ee9e56eff4cd4c4fb2
3
+ metadata.gz: 677b2f47102db33dd5b14575dc05d083d724328c5715eb041260fa5eff1888d8
4
+ data.tar.gz: 80193fd6f6737c2e3d8e5227ef8bbed008bfd98826a26b73be775402615cdd0b
5
5
  SHA512:
6
- metadata.gz: b0875f1af33311cf2d0af2a9167a548a54e6d8a4e7bc41cdd3e715a55150a52b08fa0e7623adf160f1eefe55faee792a9ae00fc4f53fc547f48c67b6f2b2c499
7
- data.tar.gz: 7ff7ddcacc7ee31d1cfd4d0264b551ee44ff62981549986c8a084665018a37b7edc47403233bab679c634211bd7acbcb170fe798ee6d2fd4bd1ffe4dabef52f8
6
+ metadata.gz: 3862a797f6ae51be78ec7115d8becfe0d741f79d84e9f8223661054338f0deba010d438b29ba8bce3d50579490be97054feabf171fe4d0ce3dbddf6cf0e22436
7
+ data.tar.gz: 707096c5ad49198707ea0ed90dc11dd0a8debcc845d2b52e30f819cd7b9a22fb473894710db1eb618fe4b7344ca9776af3619378677f5b0b849fdd647d7be96a
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'rake'
5
5
  require 'rake/testtask'
6
6
  require 'rspec/core/rake_task'
7
7
  require 'spree/testing_support/dummy_app/rake_tasks'
8
- require 'bundler/gem_tasks'
9
8
 
10
9
  RSpec::Core::RakeTask.new
11
10
  task default: :spec
@@ -68,7 +68,7 @@ module Spree
68
68
  # @return [String] a cache invalidation key for products
69
69
  def cache_key_for_products
70
70
  count = @products.count
71
- max_updated_at = Spree::RailsCompatibility.to_fs((@products.maximum(:updated_at) || Date.today), :number)
71
+ max_updated_at = (@products.maximum(:updated_at) || Date.today).to_fs(:number)
72
72
  "#{I18n.locale}/#{current_pricing_options.cache_key}/spree/products/all-#{params[:page]}-#{max_updated_at}-#{count}"
73
73
  end
74
74
  end
@@ -7,23 +7,6 @@ module Spree
7
7
  extend ActiveSupport::Concern
8
8
  include Spree::ActiveStorageAdapter::Normalization
9
9
 
10
- included do
11
- next if Rails.gem_version >= Gem::Version.new('6.1.0.alpha')
12
-
13
- raise <<~MESSAGE
14
- Configuration Error: Solidus ActiveStorage attachment adpater requires Rails >= 6.1.0.
15
-
16
- Spree::Config.image_attachment_module preference is set to #{Spree::Config.image_attachment_module}
17
- Spree::Config.taxon_attachment_module preference is set to #{Spree::Config.taxon_attachment_module}
18
- Rails version is #{Rails.gem_version}
19
-
20
- To solve the problem you can upgrade to a Rails version greater than or equal to 6.1.0
21
- or use legacy Paperclip attachment adapter by editing `config/initialiers/spree/rb`:
22
- config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
23
- config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
24
- MESSAGE
25
- end
26
-
27
10
  class_methods do
28
11
  attr_reader :attachment_name
29
12
  attr_reader :attachment_definition
@@ -14,15 +14,6 @@ module Spree
14
14
  end
15
15
  end
16
16
 
17
- # Returns `#prices` prioritized for being considered as default price
18
- #
19
- # @deprecated
20
- # @return [ActiveRecord::Relation<Spree::Price>]
21
- def currently_valid_prices
22
- prices.currently_valid
23
- end
24
- deprecate :currently_valid_prices, deprecator: Spree::Deprecation
25
-
26
17
  # Returns {#default_price} or builds it from {Spree::Variant.default_price_attributes}
27
18
  #
28
19
  # @return [Spree::Price, nil]
@@ -32,12 +23,6 @@ module Spree
32
23
  prices.build(self.class.default_price_attributes)
33
24
  end
34
25
 
35
- # @deprecated Use {#default_price_or_build} instead.
36
- def find_or_build_default_price
37
- default_price_or_build
38
- end
39
- deprecate find_or_build_default_price: :default_price_or_build, deprecator: Spree::Deprecation
40
-
41
26
  # Select from {#prices} the one to be considered as the default
42
27
  #
43
28
  # This method works with the in-memory association, so non-persisted prices
@@ -6,27 +6,6 @@ module Spree::RansackableAttributes
6
6
  class_attribute :allowed_ransackable_associations, default: []
7
7
  class_attribute :allowed_ransackable_attributes, default: []
8
8
  class_attribute :allowed_ransackable_scopes, default: []
9
-
10
- def self.whitelisted_ransackable_associations
11
- Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_associations, 'use allowed_ransackable_associations instead')
12
- allowed_ransackable_associations
13
- end
14
-
15
- def self.whitelisted_ransackable_associations=(new_value)
16
- Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_associations=, 'use allowed_ransackable_associations= instead')
17
- self.allowed_ransackable_associations = new_value
18
- end
19
-
20
- def self.whitelisted_ransackable_attributes
21
- Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_attributes, 'use allowed_ransackable_attributes instead')
22
- allowed_ransackable_attributes
23
- end
24
-
25
- def self.whitelisted_ransackable_attributes=(new_value)
26
- Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_attributes=, 'use allowed_ransackable_attributes= instead')
27
- self.allowed_ransackable_attributes = new_value
28
- end
29
-
30
9
  class_attribute :default_ransackable_attributes
31
10
  self.default_ransackable_attributes = %w[id]
32
11
  end
@@ -51,19 +51,6 @@ module Spree
51
51
  extend DisplayMoney
52
52
  money_methods :amount
53
53
 
54
- # Returns Adjustments of completed Orders.
55
- #
56
- # @param excluded_orders [Array<Spree::Order>] Orders to exclude from query
57
- # @return [ActiveRecord::Relation] Scoped Adjustments
58
- def self.in_completed_orders(excluded_orders: [], exclude_canceled: false)
59
- result = joins(:order)
60
- .merge(Spree::Order.complete)
61
- .where.not(spree_orders: { id: excluded_orders })
62
- .distinct
63
- exclude_canceled ? result.merge(Spree::Order.not_canceled) : result
64
- end
65
- deprecate :in_completed_orders, "Please don't use this and rather go through Spree::Promotion#discounted_orders"
66
-
67
54
  def finalize!
68
55
  update!(finalized: true)
69
56
  end
@@ -42,7 +42,7 @@ class Spree::Carton < Spree::Base
42
42
  end
43
43
 
44
44
  def display_shipped_at
45
- Spree::RailsCompatibility.to_fs(shipped_at, :rfc822)
45
+ shipped_at.to_fs(:rfc822)
46
46
  end
47
47
 
48
48
  def manifest
@@ -17,31 +17,19 @@ module Spree
17
17
  # @attr [Integer] quantity How many units we want to move
18
18
  #
19
19
  class FulfilmentChanger
20
- # @note This private constant is only used to deprecate not passing the `track_inventory` argument
21
- # on initialization. It will be removed in Solidus 4.0, please do not use it.
22
- TRACK_INVENTORY_NOT_PROVIDED = Object.new.freeze
23
- private_constant :TRACK_INVENTORY_NOT_PROVIDED
24
-
25
20
  include ActiveModel::Validations
26
21
 
27
22
  attr_accessor :current_shipment, :desired_shipment
28
23
  attr_reader :variant, :quantity, :current_stock_location, :desired_stock_location, :track_inventory
29
24
 
30
- def initialize(current_shipment:, desired_shipment:, variant:, quantity:, track_inventory: TRACK_INVENTORY_NOT_PROVIDED)
25
+ def initialize(current_shipment:, desired_shipment:, variant:, quantity:, track_inventory:)
31
26
  @current_shipment = current_shipment
32
27
  @desired_shipment = desired_shipment
33
28
  @current_stock_location = current_shipment.stock_location
34
29
  @desired_stock_location = desired_shipment.stock_location
35
30
  @variant = variant
36
31
  @quantity = quantity
37
- @track_inventory = if track_inventory == TRACK_INVENTORY_NOT_PROVIDED
38
- Spree::Deprecation.warn(
39
- "Not passing `track_inventory` to `Spree::FulfilmentChanger` is deprecated." \
40
- )
41
- true
42
- else
43
- track_inventory
44
- end
32
+ @track_inventory = track_inventory
45
33
  end
46
34
 
47
35
  validates :quantity, numericality: { greater_than: 0 }
@@ -2,9 +2,7 @@
2
2
 
3
3
  module Spree
4
4
  class OptionValue < Spree::Base
5
- # TODO: Remove optional on Solidus v4.0. Don't forget adding a migration to
6
- # enforce at the database layer
7
- belongs_to :option_type, class_name: 'Spree::OptionType', inverse_of: :option_values, optional: true
5
+ belongs_to :option_type, class_name: 'Spree::OptionType', inverse_of: :option_values
8
6
  acts_as_list scope: :option_type
9
7
 
10
8
  has_many :option_values_variants, dependent: :destroy
@@ -15,15 +13,8 @@ module Spree
15
13
 
16
14
  after_save :touch, if: :saved_changes?
17
15
  after_touch :touch_all_variants
18
- after_save do
19
- Spree::Deprecation.warn <<~MSG if option_type.nil?
20
- Having an option_value with no associated option_type will be deprecated
21
- on Solidus v4.0
22
- MSG
23
- end
24
16
 
25
- # TODO: Remove allow_nil once option_type is required on Solidus v4.0
26
- delegate :name, :presentation, to: :option_type, prefix: :option_type, allow_nil: true
17
+ delegate :name, :presentation, to: :option_type, prefix: :option_type
27
18
 
28
19
  self.allowed_ransackable_attributes = %w[name presentation]
29
20
 
@@ -395,18 +395,6 @@ module Spree
395
395
  Spree::CreditCard.where(id: credit_card_ids)
396
396
  end
397
397
 
398
- # TODO: Remove on Solidus 4.0
399
- # @api private
400
- def finalize!
401
- Spree::Deprecation.warn <<~MSG
402
- Calling `Spree::Order#finalize!` is discouraged. Instead, use
403
- `Spree::Order#complete!`, which goes through all the needed safety
404
- checks before finalizing an order. This method will be removed
405
- altogether on Solidus 4.0.
406
- MSG
407
- finalize
408
- end
409
-
410
398
  def fulfill!
411
399
  shipments.each { |shipment| shipment.update_state if shipment.persisted? }
412
400
  updater.update_shipment_state
@@ -534,7 +522,7 @@ module Spree
534
522
  state: 'cart',
535
523
  updated_at: Time.current
536
524
  )
537
- self.next if line_items.any?
525
+ self.next
538
526
  end
539
527
 
540
528
  def refresh_shipment_rates
@@ -571,8 +559,7 @@ module Spree
571
559
  end
572
560
 
573
561
  def has_non_reimbursement_related_refunds?
574
- refunds.non_reimbursement.exists? ||
575
- payments.where("source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed'").exists? # how old versions of spree stored refunds
562
+ refunds.non_reimbursement.exists?
576
563
  end
577
564
 
578
565
  def tax_total
@@ -779,16 +766,17 @@ module Spree
779
766
  self.email = user.email if user
780
767
  end
781
768
 
782
- # Determine if email is required (we don't want validation errors before we hit the checkout)
769
+ # Determine if the email is required for this order
770
+ #
771
+ # We don't require email for orders in the cart state or address state because those states
772
+ # precede the entry of an email address.
773
+ #
774
+ # @return [Boolean] true if the email is required
775
+ # @note This method was called require_email before.
783
776
  def email_required?
784
777
  true unless new_record? || ['cart', 'address'].include?(state)
785
778
  end
786
779
 
787
- def require_email
788
- Spree::Deprecation.warn "Use email_required? instead", caller(1)
789
- email_required?
790
- end
791
-
792
780
  def ensure_inventory_units
793
781
  if has_checkout_step?("delivery")
794
782
  inventory_validator = Spree::Config.stock.inventory_validator_class.new
@@ -162,9 +162,6 @@ module Spree
162
162
  order.included_tax_total = all_items.sum(&:included_tax_total) + order_tax_adjustments.select(&:included?).sum(&:amount)
163
163
  order.additional_tax_total = all_items.sum(&:additional_tax_total) + order_tax_adjustments.reject(&:included?).sum(&:amount)
164
164
 
165
- # TODO: Delete this line in Solidus 4.0, when it is run in `update_promotions`.
166
- order.promo_total = all_items.sum(&:promo_total) + adjustments.select(&:eligible?).select(&:promotion?).sum(&:amount)
167
-
168
165
  update_order_total
169
166
  end
170
167
 
@@ -200,32 +197,6 @@ module Spree
200
197
  Spree::Config.promotion_adjuster_class.new(order).call
201
198
  end
202
199
 
203
- # DEPRECATED; this functionality is handled in #update_promotions
204
- def update_item_promotions
205
- [*line_items, *shipments].each do |item|
206
- promotion_adjustments = item.adjustments.select(&:promotion?)
207
-
208
- promotion_adjustments.each(&:recalculate)
209
- Spree::Config.promotion_chooser_class.new(promotion_adjustments).update
210
-
211
- item.promo_total = promotion_adjustments.select(&:eligible?).sum(&:amount)
212
- end
213
- end
214
- deprecate update_item_promotions: :update_promotions, deprecator: Spree::Deprecation
215
-
216
- # Update and select the best promotion adjustment for the order.
217
- # We don't update the order.promo_total yet. Order totals are updated later
218
- # in #update_adjustment_total since they include the totals from the order's
219
- # line items and/or shipments.
220
- #
221
- # DEPRECATED; this functionality is handled in #update_promotions
222
- def update_order_promotions
223
- promotion_adjustments = order.adjustments.select(&:promotion?)
224
- promotion_adjustments.each(&:recalculate)
225
- Spree::Config.promotion_chooser_class.new(promotion_adjustments).update
226
- end
227
- deprecate update_order_promotions: :update_promotions, deprecator: Spree::Deprecation
228
-
229
200
  def update_taxes
230
201
  Spree::Config.tax_adjuster_class.new(order).adjust!
231
202
 
@@ -16,7 +16,6 @@ module Spree
16
16
  belongs_to :source, polymorphic: true, optional: true
17
17
  belongs_to :payment_method, -> { with_discarded }, class_name: 'Spree::PaymentMethod', inverse_of: :payments, optional: true
18
18
 
19
- has_many :offsets, -> { offset_payment }, class_name: "Spree::Payment", foreign_key: :source_id
20
19
  has_many :log_entries, as: :source
21
20
  has_many :state_changes, as: :stateful
22
21
  has_many :capture_events, class_name: 'Spree::PaymentCaptureEvent'
@@ -45,19 +44,6 @@ module Spree
45
44
 
46
45
  scope :from_credit_card, -> { where(source_type: 'Spree::CreditCard') }
47
46
  scope :with_state, ->(state) { where(state: state.to_s) }
48
- # "offset" is reserved by activerecord
49
- # TODO: When removing the method we can also:
50
- # - Remove the `.offsets` association
51
- # - Remove the `#offsets_total` method
52
- # - Remove offsets count from the `#credit_allowed` method
53
- # - Remove offsets check from `Spree::Order#has_non_reimbursement_related_refunds?
54
- def self.offset_payment
55
- Spree::Deprecation.warn <<~MSG
56
- `Spree::Payment offsets` are deprecated. Use the refund system (`Spree::Refund`) instead.
57
- MSG
58
-
59
- where("source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed'")
60
- end
61
47
 
62
48
  scope :checkout, -> { with_state('checkout') }
63
49
  scope :completed, -> { with_state('completed') }
@@ -100,22 +86,11 @@ module Spree
100
86
  end || amount
101
87
  end
102
88
 
103
- # The total amount of the offsets (for old-style refunds) for this payment.
104
- #
105
- # @return [BigDecimal] the total amount of this payment's offsets
106
- def offsets_total
107
- offsets.pluck(:amount).sum
108
- end
109
-
110
89
  # The total amount this payment can be credited.
111
90
  #
112
- # @return [BigDecimal] the amount of this payment minus the offsets
113
- # (old-style refunds) and refunds
91
+ # @return [BigDecimal] the amount of this payment minus refunds
114
92
  def credit_allowed
115
- amount - (
116
- (self.class.where("source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed' AND source_id = ?", id).sum(:amount)).abs +
117
- refunds.sum(:amount)
118
- )
93
+ amount - refunds.sum(:amount)
119
94
  end
120
95
 
121
96
  # @return [Boolean] true when this payment can be credited
@@ -183,16 +158,9 @@ module Spree
183
158
 
184
159
  def validate_source
185
160
  if source && !source.valid?
186
- if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
187
- source.errors.each do |error|
188
- field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{error.attribute}")
189
- errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error.message}")
190
- end
191
- else
192
- source.errors.each do |field, error|
193
- field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{field}")
194
- errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error}")
195
- end
161
+ source.errors.each do |error|
162
+ field_name = I18n.t("activerecord.attributes.#{source.class.to_s.underscore}.#{error.attribute}")
163
+ errors.add(I18n.t(source.class.to_s.demodulize.underscore, scope: 'spree'), "#{field_name} #{error.message}")
196
164
  end
197
165
  end
198
166
  if errors.any?
@@ -214,11 +214,6 @@ module Spree
214
214
  where(subquery.arel.exists)
215
215
  end
216
216
 
217
- def self.with_variant_sku_cont(sku)
218
- Spree::Deprecation.warn("use .with_kept_variant_sku_cont instead")
219
- with_kept_variant_sku_cont(sku)
220
- end
221
-
222
217
  class << self
223
218
  private
224
219
 
@@ -96,7 +96,6 @@ module Spree
96
96
  :display_price,
97
97
  :has_default_price?,
98
98
  :images,
99
- :price_for,
100
99
  :price_for_options,
101
100
  :rebuild_vat_prices=,
102
101
  to: :find_or_build_master
@@ -134,7 +133,7 @@ module Spree
134
133
 
135
134
  self.allowed_ransackable_associations = %w[stores variants_including_master master variants]
136
135
  self.allowed_ransackable_attributes = %w[name slug]
137
- self.allowed_ransackable_scopes = %i[available with_discarded with_variant_sku_cont with_all_variant_sku_cont with_kept_variant_sku_cont]
136
+ self.allowed_ransackable_scopes = %i[available with_discarded with_all_variant_sku_cont with_kept_variant_sku_cont]
138
137
 
139
138
  # @return [Boolean] true if there are any variants
140
139
  def has_variants?
@@ -337,14 +336,8 @@ module Spree
337
336
  # If the master is invalid, the Product object will be assigned its errors
338
337
  def validate_master
339
338
  unless master.valid?
340
- if Gem::Requirement.new(">= 6.1").satisfied_by?(Rails.gem_version)
341
- master.errors.each do |error|
342
- errors.add(error.attribute, error.message)
343
- end
344
- else
345
- master.errors.each do |att, error|
346
- errors.add(att, error)
347
- end
339
+ master.errors.each do |error|
340
+ errors.add(error.attribute, error.message)
348
341
  end
349
342
  end
350
343
  end
@@ -9,8 +9,6 @@ module Spree
9
9
  # To add extra operators please override `self.operators_map` or any other helper method.
10
10
  # To customize the error message you can also override `ineligible_message`.
11
11
  class ItemTotal < PromotionRule
12
- include ActiveSupport::Deprecation::DeprecatedConstantAccessor
13
-
14
12
  preference :amount, :decimal, default: 100.00
15
13
  preference :currency, :string, default: ->{ Spree::Config[:currency] }
16
14
  preference :operator, :string, default: 'gt'
@@ -29,15 +27,6 @@ module Spree
29
27
  end
30
28
  end
31
29
 
32
- # @deprecated
33
- OPERATORS = operators_map.keys.map(&:to_s)
34
- deprecate_constant(
35
- :OPERATORS,
36
- :operators_map,
37
- message: "OPERATORS is deprecated! Use `operators_map.keys.map(&:to_s)` instead.",
38
- deprecator: Spree::Deprecation,
39
- )
40
-
41
30
  def applicable?(promotable)
42
31
  promotable.is_a?(Spree::Order)
43
32
  end
@@ -2,9 +2,6 @@
2
2
 
3
3
  module Spree
4
4
  class Promotion < Spree::Base
5
-
6
- autoload(:MATCH_POLICIES, "spree/promotion/match_policies")
7
-
8
5
  UNACTIVATABLE_ORDER_STATES = ["complete", "awaiting_return", "returned"]
9
6
 
10
7
  attr_reader :eligibility_errors
@@ -167,27 +164,13 @@ module Spree
167
164
  specific_rules = rules.select { |rule| rule.applicable?(promotable) }
168
165
  return [] if specific_rules.none?
169
166
 
170
- if match_all?
171
- # If there are rules for this promotion, but no rules for this
172
- # particular promotable, then the promotion is ineligible by default.
173
- unless specific_rules.all?(&eligible)
174
- @eligibility_errors = specific_rules.map(&:eligibility_errors).detect(&:present?)
175
- return nil
176
- end
177
- specific_rules
178
- else
179
- Spree::Deprecation.warn(
180
- <<~WARN
181
- Your promotion "#{name}" with ID #{id} has a match_policy of 'any'.
182
- This is deprecated, please split the promotion into separate promotions for each rule.
183
- WARN
184
- )
185
- unless specific_rules.any?(&eligible)
186
- @eligibility_errors = specific_rules.map(&:eligibility_errors).detect(&:present?)
187
- return nil
188
- end
189
- specific_rules.select(&eligible)
167
+ # If there are rules for this promotion, but no rules for this
168
+ # particular promotable, then the promotion is ineligible by default.
169
+ unless specific_rules.all?(&eligible)
170
+ @eligibility_errors = specific_rules.map(&:eligibility_errors).detect(&:present?)
171
+ return nil
190
172
  end
173
+ specific_rules
191
174
  end
192
175
 
193
176
  def products
@@ -224,9 +207,7 @@ module Spree
224
207
  if rules.blank?
225
208
  true
226
209
  else
227
- rules.send(match_all? ? :all? : :any?) do |rule|
228
- rule.actionable? line_item
229
- end
210
+ rules.all? { |rule| rule.actionable? line_item }
230
211
  end
231
212
  else
232
213
  false
@@ -271,10 +252,6 @@ module Spree
271
252
  self[:path] = nil if self[:path].blank?
272
253
  end
273
254
 
274
- def match_all?
275
- match_policy == "all"
276
- end
277
-
278
255
  def apply_automatically_disallowed_with_paths
279
256
  return unless apply_automatically
280
257
 
@@ -18,11 +18,6 @@ module Spree
18
18
  []
19
19
  end
20
20
 
21
- def self.for(promotable)
22
- all.select { |rule| rule.applicable?(promotable) }
23
- end
24
- deprecate :for, "Please select promotion rules by their applicable status on the promotable instead."
25
-
26
21
  def applicable?(_promotable)
27
22
  raise NotImplementedError, "applicable? should be implemented in a sub-class of Spree::PromotionRule"
28
23
  end
@@ -18,11 +18,11 @@ module Spree
18
18
  after_update :update_child_permalinks, if: :saved_change_to_permalink?
19
19
 
20
20
  validates :name, presence: true
21
- validates :name, uniqueness: { scope: :parent_id, message: :must_be_unique_under_same_parent }, if: -> { Spree::Config.extra_taxon_validations}
21
+ validates :name, uniqueness: { scope: :parent_id, message: :must_be_unique_under_same_parent }
22
22
  validates :meta_keywords, length: { maximum: 255 }
23
23
  validates :meta_description, length: { maximum: 255 }
24
24
  validates :meta_title, length: { maximum: 255 }
25
- validates :taxonomy_id, uniqueness: { scope: :parent_id, message: :can_have_only_one_root }, if: -> { Spree::Config.extra_taxon_validations && root? }
25
+ validates :taxonomy_id, uniqueness: { message: :can_have_only_one_root }, if: -> { root? }
26
26
 
27
27
  after_save :touch_ancestors_and_taxonomy
28
28
  after_touch :touch_ancestors_and_taxonomy
@@ -5,7 +5,7 @@ module Spree
5
5
  acts_as_list
6
6
 
7
7
  validates :name, presence: true
8
- validates :name, uniqueness: true, if: -> { Spree::Config.extra_taxonomy_validations }
8
+ validates :name, uniqueness: true
9
9
 
10
10
  has_many :taxons, inverse_of: :taxonomy
11
11
  has_one :root, -> { where parent_id: nil }, class_name: "Spree::Taxon", dependent: :destroy
@@ -3,7 +3,7 @@
3
3
  module Spree
4
4
  class Variant < Spree::Base
5
5
  # This class is responsible for selecting a price for a variant given certain pricing options.
6
- # A variant can have multiple or even dynamic prices. The `price_for`
6
+ # A variant can have multiple or even dynamic prices. The `price_for_options`
7
7
  # method determines which price applies under the given circumstances.
8
8
  #
9
9
  class PriceSelector
@@ -22,19 +22,6 @@ module Spree
22
22
  @variant = variant
23
23
  end
24
24
 
25
- # The variant's price, given a set of pricing options
26
- # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
27
- # @return [Spree::Money, nil] The most specific price for this set of pricing options.
28
- def price_for(price_options)
29
- Spree::Deprecation.warn(
30
- "price_for is deprecated and will be removed. The price_for method
31
- should return a Spree::Price as described. Please use
32
- #price_for_options and adjust your frontend code to explicitly call
33
- &.money where required"
34
- )
35
- price_for_options(price_options)&.money
36
- end
37
-
38
25
  # The variant's Spree::Price record, given a set of pricing options
39
26
  # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
40
27
  # @return [Spree::Price, nil] The most specific price for this set of pricing options.
@@ -39,6 +39,7 @@ module Spree
39
39
  delegate :shipping_category, :shipping_category_id,
40
40
  to: :product, prefix: true
41
41
  delegate :tax_rates, to: :tax_category
42
+ delegate :price_for_options, to: :price_selector
42
43
 
43
44
  has_many :inventory_units, inverse_of: :variant
44
45
  has_many :line_items, inverse_of: :variant
@@ -287,12 +288,6 @@ module Spree
287
288
  @price_selector ||= Spree::Config.variant_price_selector_class.new(self)
288
289
  end
289
290
 
290
- # Chooses an appropriate price for the given pricing options
291
- # This has been deprecated in favor of #price_for_options.
292
- #
293
- # @see Spree::Variant::PriceSelector#price_for_options
294
- delegate :price_for, to: :price_selector
295
-
296
291
  # Returns the difference in price from the master variant
297
292
  def price_difference_from_master(pricing_options = Spree::Config.default_pricing_options)
298
293
  master_price = product.master.price_for_options(pricing_options)
@@ -306,17 +301,6 @@ module Spree
306
301
  diff && diff.zero?
307
302
  end
308
303
 
309
- def price_for_options(price_options)
310
- if price_selector.respond_to?(:price_for_options)
311
- price_selector.price_for_options(price_options)
312
- else
313
- money = price_for(price_options)
314
- return if money.nil?
315
-
316
- Spree::Price.new(amount: money.to_d, variant: self, currency: price_options.currency)
317
- end
318
- end
319
-
320
304
  # Generates a friendly name and sku string.
321
305
  #
322
306
  # @return [String]
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddUniqueIndexToOptionValuesVariants < ActiveRecord::Migration[5.2]
4
+ def up
5
+ remove_index :spree_option_values_variants, [:variant_id, :option_value_id]
6
+ add_index :spree_option_values_variants, [:variant_id, :option_value_id],
7
+ name: "index_option_values_variants_on_variant_id_and_option_value_id",
8
+ unique: true
9
+ end
10
+
11
+ def down
12
+ remove_index :spree_option_values_variants, [:variant_id, :option_value_id]
13
+ add_index :spree_option_values_variants, [:variant_id, :option_value_id],
14
+ name: "index_option_values_variants_on_variant_id_and_option_value_id"
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ class ChangeColumnNullOptionValuesOptionTypeId < ActiveRecord::Migration[5.2]
2
+ def change
3
+ change_column_null(:spree_option_values, :option_type_id, false)
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveMatchPolicyFromSpreePromotion < ActiveRecord::Migration[5.2]
2
+ def change
3
+ remove_column :spree_promotions, :match_policy, :string, default: "all"
4
+ end
5
+ end