solidus_core 2.11.7 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree.js.erb +0 -51
  3. data/app/helpers/spree/store_helper.rb +0 -11
  4. data/app/mailers/spree/carton_mailer.rb +1 -5
  5. data/app/models/concerns/spree/active_storage_adapter.rb +2 -0
  6. data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -11
  7. data/app/models/concerns/spree/adjustment_source.rb +0 -15
  8. data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
  9. data/app/models/concerns/spree/soft_deletable.rb +2 -4
  10. data/app/models/concerns/spree/user_address_book.rb +0 -37
  11. data/app/models/concerns/spree/user_methods.rb +2 -11
  12. data/app/models/spree/ability.rb +0 -37
  13. data/app/models/spree/address.rb +8 -186
  14. data/app/models/spree/address/name.rb +2 -20
  15. data/app/models/spree/adjustment.rb +0 -28
  16. data/app/models/spree/base.rb +0 -35
  17. data/app/models/spree/calculator.rb +4 -7
  18. data/app/models/spree/calculator/flexi_rate.rb +0 -5
  19. data/app/models/spree/country.rb +1 -6
  20. data/app/models/spree/credit_card.rb +0 -27
  21. data/app/models/spree/customer_return.rb +1 -4
  22. data/app/models/spree/image.rb +0 -7
  23. data/app/models/spree/image/active_storage_attachment.rb +10 -2
  24. data/app/models/spree/image/paperclip_attachment.rb +1 -1
  25. data/app/models/spree/inventory_unit.rb +0 -21
  26. data/app/models/spree/line_item.rb +2 -45
  27. data/app/models/spree/order.rb +3 -136
  28. data/app/models/spree/order_cancellations.rb +4 -24
  29. data/app/models/spree/order_updater.rb +2 -11
  30. data/app/models/spree/payment.rb +0 -3
  31. data/app/models/spree/payment/cancellation.rb +1 -1
  32. data/app/models/spree/payment_create.rb +1 -13
  33. data/app/models/spree/payment_method.rb +5 -103
  34. data/app/models/spree/payment_method/bogus_credit_card.rb +13 -9
  35. data/app/models/spree/payment_method/credit_card.rb +1 -3
  36. data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
  37. data/app/models/spree/product.rb +0 -39
  38. data/app/models/spree/product/scopes.rb +0 -27
  39. data/app/models/spree/promotion.rb +2 -6
  40. data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
  41. data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
  42. data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
  43. data/app/models/spree/promotion/rules/taxon.rb +2 -15
  44. data/app/models/spree/promotion_action.rb +5 -9
  45. data/app/models/spree/promotion_code/batch_builder.rb +0 -14
  46. data/app/models/spree/promotion_rule.rb +4 -0
  47. data/app/models/spree/refund.rb +0 -50
  48. data/app/models/spree/reimbursement.rb +3 -41
  49. data/app/models/spree/reimbursement_performer.rb +2 -8
  50. data/app/models/spree/reimbursement_type/credit.rb +1 -4
  51. data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
  52. data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
  53. data/app/models/spree/return_authorization.rb +1 -4
  54. data/app/models/spree/return_item.rb +1 -19
  55. data/app/models/spree/shipment.rb +1 -54
  56. data/app/models/spree/shipping_method.rb +0 -25
  57. data/app/models/spree/shipping_rate.rb +0 -2
  58. data/app/models/spree/state.rb +0 -4
  59. data/app/models/spree/stock/simple_coordinator.rb +0 -14
  60. data/app/models/spree/stock/splitter/base.rb +2 -7
  61. data/app/models/spree/stock_item.rb +1 -7
  62. data/app/models/spree/store.rb +0 -12
  63. data/app/models/spree/store_credit_category.rb +0 -32
  64. data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
  65. data/app/models/spree/tax_rate.rb +0 -27
  66. data/app/models/spree/taxon.rb +0 -11
  67. data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
  68. data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
  69. data/app/models/spree/user_address.rb +0 -5
  70. data/app/models/spree/variant.rb +1 -45
  71. data/config/locales/en.yml +0 -8
  72. data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
  73. data/lib/generators/solidus/install/install_generator.rb +13 -2
  74. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
  75. data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
  76. data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
  77. data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
  78. data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
  79. data/lib/spree/app_configuration.rb +14 -65
  80. data/lib/spree/core.rb +9 -8
  81. data/lib/spree/core/class_constantizer.rb +2 -0
  82. data/lib/spree/core/controller_helpers/auth.rb +1 -14
  83. data/lib/spree/core/controller_helpers/order.rb +2 -22
  84. data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
  85. data/lib/spree/core/controller_helpers/pricing.rb +0 -8
  86. data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
  87. data/lib/spree/core/engine.rb +0 -35
  88. data/lib/spree/core/environment_extension.rb +0 -9
  89. data/lib/spree/core/product_filters.rb +0 -40
  90. data/lib/spree/core/role_configuration.rb +0 -14
  91. data/lib/spree/core/search/base.rb +0 -26
  92. data/lib/spree/core/state_machines.rb +2 -11
  93. data/lib/spree/core/version.rb +1 -1
  94. data/lib/spree/deprecation.rb +1 -1
  95. data/lib/spree/event.rb +0 -31
  96. data/lib/spree/event/configuration.rb +0 -5
  97. data/lib/spree/event/subscriber.rb +0 -18
  98. data/lib/spree/event/subscriber_registry.rb +3 -1
  99. data/lib/spree/i18n.rb +0 -22
  100. data/lib/spree/money.rb +3 -18
  101. data/lib/spree/permitted_attributes.rb +2 -53
  102. data/lib/spree/preferences/persistable.rb +23 -0
  103. data/lib/spree/testing_support/capybara_ext.rb +0 -30
  104. data/lib/spree/testing_support/controller_requests.rb +0 -82
  105. data/lib/spree/testing_support/dummy_app.rb +6 -14
  106. data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
  107. data/lib/spree/testing_support/factories/order_factory.rb +0 -1
  108. data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
  109. data/lib/spree/testing_support/fixtures/file.txt +1 -0
  110. data/lib/spree/testing_support/order_walkthrough.rb +0 -3
  111. data/lib/spree/testing_support/preferences.rb +0 -25
  112. data/lib/tasks/upgrade.rake +7 -5
  113. data/solidus_core.gemspec +2 -5
  114. metadata +9 -48
  115. data/app/mailers/spree/test_mailer.rb +0 -13
  116. data/app/models/concerns/spree/user_payment_source.rb +0 -26
  117. data/app/models/spree/calculator/free_shipping.rb +0 -22
  118. data/app/models/spree/calculator/percent_per_item.rb +0 -51
  119. data/app/models/spree/calculator/price_sack.rb +0 -28
  120. data/app/models/spree/gateway.rb +0 -14
  121. data/app/models/spree/gateway/bogus.rb +0 -13
  122. data/app/models/spree/gateway/bogus_simple.rb +0 -13
  123. data/app/models/spree/order/checkout.rb +0 -244
  124. data/app/models/spree/order_capturing.rb +0 -50
  125. data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
  126. data/lib/generators/spree/install/install_generator.rb +0 -15
  127. data/lib/solidus/migrations/rename_gateways.rb +0 -41
  128. data/lib/spree/core/current_store.rb +0 -24
  129. data/lib/spree/paranoia_deprecations.rb +0 -41
  130. data/lib/spree/promo/environment.rb +0 -12
  131. data/lib/spree/testing_support/bar_ability.rb +0 -19
  132. data/lib/tasks/core.rake +0 -104
  133. data/lib/tasks/email.rake +0 -12
  134. data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
  135. data/lib/tasks/migrations/migrate_address_names.rake +0 -158
  136. data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -38
  137. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
  138. data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
  139. data/lib/tasks/migrations/rename_gateways.rake +0 -23
  140. data/lib/tasks/order_capturing.rake +0 -27
@@ -2,29 +2,11 @@
2
2
 
3
3
  module Spree
4
4
  class Address
5
- # Provides a value object to help transitioning from legacy
6
- # firstname and lastname fields to a unified name field.
5
+ # Provides a value object to help splitting and joining
6
+ # name fields
7
7
  class Name
8
8
  attr_reader :first_name, :last_name, :value
9
9
 
10
- # Creates an instance of Spree::Address::Name parsing input attributes.
11
- # @param attributes [Hash] an hash possibly containing name-related
12
- # attributes (name, firstname, lastname, first_name, last_name)
13
- # @return [Spree::Address::Name] the object created
14
- def self.from_attributes(attributes)
15
- params = attributes.with_indifferent_access
16
-
17
- if params[:name].present?
18
- Spree::Address::Name.new(params[:name])
19
- elsif params[:firstname].present?
20
- Spree::Address::Name.new(params[:firstname], params[:lastname])
21
- elsif params[:first_name].present?
22
- Spree::Address::Name.new(params[:first_name], params[:last_name])
23
- else
24
- Spree::Address::Name.new
25
- end
26
- end
27
-
28
10
  def initialize(*components)
29
11
  @value = components.join(' ').strip
30
12
  initialize_name_components(components)
@@ -28,11 +28,6 @@ module Spree
28
28
  validates :amount, numericality: true
29
29
  validates :promotion_code, presence: true, if: :require_promotion_code?
30
30
 
31
- # We need to use `after_commit` here because otherwise it's too early to
32
- # tell if any repair is needed.
33
- after_commit :repair_adjustments_associations_on_create, on: [:create]
34
- after_commit :repair_adjustments_associations_on_destroy, on: [:destroy]
35
-
36
31
  scope :not_finalized, -> { where(finalized: false) }
37
32
  scope :finalized, -> { where(finalized: true) }
38
33
  scope :cancellation, -> { where(source_type: 'Spree::UnitCancel') }
@@ -135,15 +130,6 @@ module Spree
135
130
  amount
136
131
  end
137
132
 
138
- def update!(*args)
139
- if args.empty?
140
- Spree::Deprecation.warn "Calling adjustment.update! with no arguments to recalculate amounts and eligibility is deprecated, since it conflicts with AR::Base#update! Please use adjustment.recalculate instead"
141
- recalculate
142
- else
143
- super
144
- end
145
- end
146
-
147
133
  # Calculates based on attached promotion (if this is a promotion
148
134
  # adjustment) whether this promotion is still eligible.
149
135
  # @api private
@@ -161,19 +147,5 @@ module Spree
161
147
  def require_promotion_code?
162
148
  promotion? && !source.promotion.apply_automatically && source.promotion.codes.any?
163
149
  end
164
-
165
- def repair_adjustments_associations_on_create
166
- if adjustable.adjustments.loaded? && !adjustable.adjustments.include?(self) && !destroyed?
167
- Spree::Deprecation.warn("Adjustment #{id} was not added to #{adjustable.class} #{adjustable.id}. Add adjustments via `adjustable.adjustments.create!`. Partial call stack: #{caller.select { |line| line =~ %r(/(app|spec)/) }}.", caller)
168
- adjustable.adjustments.proxy_association.add_to_target(self)
169
- end
170
- end
171
-
172
- def repair_adjustments_associations_on_destroy
173
- if adjustable.adjustments.loaded? && adjustable.adjustments.include?(self)
174
- Spree::Deprecation.warn("Adjustment #{id} was not removed from #{adjustable.class} #{adjustable.id}. Remove adjustments via `adjustable.adjustments.destroy`. Partial call stack: #{caller.select { |line| line =~ %r(/(app|spec)/) }}.", caller)
175
- adjustable.adjustments.proxy_association.target.delete(self)
176
- end
177
- end
178
150
  end
179
151
  end
@@ -1,44 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Spree::Base < ActiveRecord::Base
4
- include Spree::Preferences::Preferable
5
4
  include Spree::Core::Permalinks
6
5
  include Spree::RansackableAttributes
7
6
 
8
- def preferences
9
- read_attribute(:preferences) || self.class.preferences_coder_class.new
10
- end
11
-
12
- def initialize_preference_defaults
13
- if has_attribute?(:preferences)
14
- self.preferences = default_preferences.merge(preferences)
15
- end
16
- end
17
-
18
- # Only run preference initialization on models which requires it. Improves
19
- # performance of record initialization slightly.
20
- def self.preference(*args)
21
- # after_initialize can be called multiple times with the same symbol, it
22
- # will only be called once on initialization.
23
- serialize :preferences, preferences_coder_class
24
- after_initialize :initialize_preference_defaults
25
- super
26
- end
27
-
28
- if Kaminari.config.page_method_name != :page
29
- def self.page(num)
30
- Spree::Deprecation.warn \
31
- "Redefining Spree::Base.page for a different kaminari page name is better done inside " \
32
- "your own app. This will be removed from future versions of solidus."
33
-
34
- send Kaminari.config.page_method_name, num
35
- end
36
- end
37
-
38
- def self.preferences_coder_class
39
- Hash
40
- end
41
-
42
7
  self.abstract_class = true
43
8
 
44
9
  # Provides a scope that should be included any time products
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/persistable'
4
+
3
5
  module Spree
4
6
  class Calculator < Spree::Base
7
+ include Spree::Preferences::Persistable
8
+
5
9
  belongs_to :calculable, polymorphic: true, optional: true
6
10
 
7
11
  # This method calls a compute_<computable> method. must be overriden in concrete calculator.
@@ -27,13 +31,6 @@ module Spree
27
31
 
28
32
  ###################################################################
29
33
 
30
- # Returns all calculators applicable for kind of work
31
- def self.calculators
32
- Spree::Deprecation.warn("Calling .calculators is deprecated. Please access through Rails.application.config.spree.calculators")
33
-
34
- Spree::Config.environment.calculators
35
- end
36
-
37
34
  def to_s
38
35
  self.class.name.titleize.gsub("Calculator\/", "")
39
36
  end
@@ -9,11 +9,6 @@ module Spree
9
9
  preference :max_items, :integer, default: 0
10
10
  preference :currency, :string, default: ->{ Spree::Config[:currency] }
11
11
 
12
- def self.available?(_object)
13
- Spree::Deprecation.warn('Spree::Calculator::FlexiRate::available is DEPRECATED. Use the instance method instead.')
14
- true
15
- end
16
-
17
12
  def compute(object)
18
13
  items_count = object.quantity
19
14
  items_count = [items_count, preferred_max_items].min unless preferred_max_items.zero?
@@ -11,12 +11,7 @@ module Spree
11
11
  self.whitelisted_ransackable_attributes = %w[name]
12
12
 
13
13
  def self.default
14
- if Spree::Config.default_country_id
15
- Spree::Deprecation.warn("Setting your default country via its ID is deprecated. Please set your default country via the `default_country_iso` setting.", caller)
16
- find_by(id: Spree::Config.default_country_id) || find_by!(iso: Spree::Config.default_country_iso)
17
- else
18
- find_by!(iso: Spree::Config.default_country_iso)
19
- end
14
+ find_by!(iso: Spree::Config.default_country_iso)
20
15
  end
21
16
 
22
17
  def self.available(restrict_to_zone: Spree::Config[:checkout_zone])
@@ -21,11 +21,6 @@ module Spree
21
21
 
22
22
  scope :with_payment_profile, -> { where('gateway_customer_profile_id IS NOT NULL') }
23
23
 
24
- def self.default
25
- Spree::Deprecation.warn("CreditCard.default is deprecated. Please use Spree::Wallet instead.")
26
- joins(:wallet_payment_sources).where(spree_wallet_payment_sources: { default: true })
27
- end
28
-
29
24
  # needed for some of the ActiveMerchant gateways (eg. SagePay)
30
25
  alias_attribute :brand, :cc_type
31
26
 
@@ -46,28 +41,6 @@ module Spree
46
41
  'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/
47
42
  }.freeze
48
43
 
49
- def default
50
- Spree::Deprecation.warn("CreditCard#default is deprecated. Please use user.wallet.default_wallet_payment_source instead.", caller)
51
- return false if user.nil?
52
- user.wallet.default_wallet_payment_source.try!(:payment_source) == self
53
- end
54
-
55
- def default=(set_as_default)
56
- Spree::Deprecation.warn("CreditCard#default= is deprecated. Please use user.wallet.default_wallet_payment_source= instead.", caller)
57
- if user.nil?
58
- raise "Cannot set 'default' on a credit card without a user"
59
- elsif set_as_default # setting this card as default
60
- wallet_payment_source = user.wallet.add(self)
61
- user.wallet.default_wallet_payment_source = wallet_payment_source
62
- true
63
- else # removing this card as default
64
- if user.wallet.default_wallet_payment_source.try!(:payment_source) == self
65
- user.wallet.default_wallet_payment_source = nil
66
- end
67
- false
68
- end
69
- end
70
-
71
44
  def address_attributes=(attributes)
72
45
  self.address = Spree::Address.immutable_merge(address, attributes)
73
46
  end
@@ -20,8 +20,7 @@ module Spree
20
20
  self.whitelisted_ransackable_attributes = ['number']
21
21
 
22
22
  extend DisplayMoney
23
- money_methods :pre_tax_total, :total, :total_excluding_vat, :amount
24
- deprecate display_pre_tax_total: :display_total_excluding_vat, deprecator: Spree::Deprecation
23
+ money_methods :total, :total_excluding_vat, :amount
25
24
 
26
25
  delegate :currency, to: :order
27
26
  delegate :id, to: :order, prefix: true, allow_nil: true
@@ -33,8 +32,6 @@ module Spree
33
32
  def total_excluding_vat
34
33
  return_items.sum(&:total_excluding_vat)
35
34
  end
36
- alias pre_tax_total total_excluding_vat
37
- deprecate pre_tax_total: :total_excluding_vat, deprecator: Spree::Deprecation
38
35
 
39
36
  def amount
40
37
  return_items.sum(:amount)
@@ -3,12 +3,5 @@
3
3
  module Spree
4
4
  class Image < Asset
5
5
  include ::Spree::Config.image_attachment_module
6
-
7
- def mini_url
8
- Spree::Deprecation.warn(
9
- 'Spree::Image#mini_url is DEPRECATED. Use Spree::Image#url(:mini) instead.'
10
- )
11
- url(:mini)
12
- end
13
6
  end
14
7
  end
@@ -7,6 +7,10 @@ module Spree::Image::ActiveStorageAttachment
7
7
  delegate :width, :height, to: :attachment, prefix: true
8
8
 
9
9
  included do
10
+ validates :attachment, presence: true
11
+ validate :attachment_is_an_image
12
+ validate :supported_content_type
13
+
10
14
  has_attachment :attachment,
11
15
  styles: {
12
16
  mini: '48x48>',
@@ -15,7 +19,11 @@ module Spree::Image::ActiveStorageAttachment
15
19
  large: '1200x1200>'
16
20
  },
17
21
  default_style: :product
18
- validates :attachment, presence: true
19
- validate :attachment_is_an_image
22
+
23
+ def supported_content_type
24
+ unless attachment.content_type.in?(Spree::Config.allowed_image_mime_types)
25
+ errors.add(:attachment, :content_type_not_supported)
26
+ end
27
+ end
20
28
  end
21
29
  end
@@ -15,7 +15,7 @@ module Spree::Image::PaperclipAttachment
15
15
  convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
16
16
  validates_attachment :attachment,
17
17
  presence: true,
18
- content_type: { content_type: %w[image/jpeg image/jpg image/png image/gif] }
18
+ content_type: { content_type: Spree::Config.allowed_image_mime_types }
19
19
 
20
20
  # save the w,h of the original image (from which others can be calculated)
21
21
  # we need to look at the write-queue for images which have not been saved yet
@@ -60,27 +60,6 @@ module Spree
60
60
 
61
61
  include ::Spree::Config.state_machines.inventory_unit
62
62
 
63
- # Updates the given inventory units to not be pending.
64
- #
65
- # @deprecated do not use this, use
66
- # Spree::Stock::InventoryUnitsFinalizer.new(inventory_units).run!
67
- # @param inventory_units [<Spree::InventoryUnit>] the inventory to be
68
- # finalized
69
- def self.finalize_units!(inventory_units)
70
- Spree::Deprecation.warn(
71
- "inventory_units.finalize_units!(inventory_units) is deprecated. Please
72
- use Spree::Stock::InventoryUnitsFinalizer.new(inventory_units).run!",
73
- caller
74
- )
75
-
76
- inventory_units.map do |iu|
77
- iu.update_columns(
78
- pending: false,
79
- updated_at: Time.current
80
- )
81
- end
82
- end
83
-
84
63
  # @return [Spree::StockItem] the first stock item from this shipment's
85
64
  # stock location that is associated with this inventory unit's variant
86
65
  def find_stock_item
@@ -10,8 +10,6 @@ module Spree
10
10
  # promotion system.
11
11
  #
12
12
  class LineItem < Spree::Base
13
- class CurrencyMismatch < StandardError; end
14
-
15
13
  belongs_to :order, class_name: "Spree::Order", inverse_of: :line_items, touch: true, optional: true
16
14
  belongs_to :variant, -> { with_discarded }, class_name: "Spree::Variant", inverse_of: :line_items, optional: true
17
15
  belongs_to :tax_category, class_name: "Spree::TaxCategory", optional: true
@@ -55,20 +53,11 @@ module Spree
55
53
  end
56
54
  alias subtotal amount
57
55
 
58
- # @return [BigDecimal] the amount of this line item, taking into
59
- # consideration line item promotions.
60
- def discounted_amount
61
- amount + promo_total
62
- end
63
- deprecate discounted_amount: :total_before_tax, deprecator: Spree::Deprecation
64
-
65
56
  # @return [BigDecimal] the amount of this line item, taking into
66
57
  # consideration all its adjustments.
67
58
  def total
68
59
  amount + adjustment_total
69
60
  end
70
- alias final_amount total
71
- deprecate final_amount: :total, deprecator: Spree::Deprecation
72
61
 
73
62
  # @return [BigDecimal] the amount of this item, taking into consideration
74
63
  # all non-tax adjustments.
@@ -81,20 +70,11 @@ module Spree
81
70
  def total_excluding_vat
82
71
  total_before_tax - included_tax_total
83
72
  end
84
- alias pre_tax_amount total_excluding_vat
85
- deprecate pre_tax_amount: :total_excluding_vat, deprecator: Spree::Deprecation
86
73
 
87
74
  extend Spree::DisplayMoney
88
- money_methods :amount, :discounted_amount, :price,
75
+ money_methods :amount, :price,
89
76
  :included_tax_total, :additional_tax_total,
90
77
  :total, :total_before_tax, :total_excluding_vat
91
- deprecate display_discounted_amount: :display_total_before_tax, deprecator: Spree::Deprecation
92
- alias display_final_amount display_total
93
- deprecate display_final_amount: :display_total, deprecator: Spree::Deprecation
94
- alias display_pre_tax_amount display_total_excluding_vat
95
- deprecate display_pre_tax_amount: :display_total_excluding_vat, deprecator: Spree::Deprecation
96
- alias discounted_money display_discounted_amount
97
- deprecate discounted_money: :display_total_before_tax, deprecator: Spree::Deprecation
98
78
 
99
79
  # @return [Spree::Money] the price of this line item
100
80
  alias money_price display_price
@@ -103,8 +83,6 @@ module Spree
103
83
 
104
84
  # @return [Spree::Money] the amount of this line item
105
85
  alias money display_amount
106
- alias display_total display_amount
107
- deprecate display_total: :display_amount, deprecator: Spree::Deprecation
108
86
 
109
87
  # Sets price from a `Spree::Money` object
110
88
  #
@@ -112,9 +90,6 @@ module Spree
112
90
  def money_price=(money)
113
91
  if !money
114
92
  self.price = nil
115
- elsif money.currency.iso_code != currency && Spree::Config.raise_with_invalid_currency
116
- line_item_errors = ActiveModel::Errors.new(self)
117
- raise CurrencyMismatch, line_item_errors.generate_message(:price, :does_not_match_order_currency, locale: :en)
118
93
  else
119
94
  self.price_currency = money.currency.iso_code
120
95
  self.price = money.to_d
@@ -156,12 +131,6 @@ module Spree
156
131
  Spree::Config.pricing_options_class.from_line_item(self)
157
132
  end
158
133
 
159
- def currency=(_currency)
160
- Spree::Deprecation.warn 'Spree::LineItem#currency= is deprecated ' \
161
- 'and will take no effect.',
162
- caller
163
- end
164
-
165
134
  private
166
135
 
167
136
  # Sets the quantity to zero if it is nil or less than zero.
@@ -177,25 +146,13 @@ module Spree
177
146
  set_pricing_attributes
178
147
  end
179
148
 
180
- # Set price, cost_price and currency. This method used to be called #copy_price, but actually
181
- # did more than just setting the price, hence renamed to #set_pricing_attributes
149
+ # Set price, cost_price and currency.
182
150
  def set_pricing_attributes
183
- # If the legacy method #copy_price has been overridden, handle that gracefully
184
- return handle_copy_price_override if respond_to?(:copy_price)
185
-
186
151
  self.cost_price ||= variant.cost_price
187
152
  self.money_price = variant.price_for(pricing_options) if price.nil?
188
153
  true
189
154
  end
190
155
 
191
- def handle_copy_price_override
192
- copy_price
193
- Spree::Deprecation.warn 'You have overridden Spree::LineItem#copy_price. ' \
194
- 'This method is now called Spree::LineItem#set_pricing_attributes. ' \
195
- 'Please adjust your override.',
196
- caller
197
- end
198
-
199
156
  def update_inventory
200
157
  if (saved_changes? || target_shipment.present?) && order.has_checkout_step?("delivery")
201
158
  Spree::OrderInventory.new(order, self).verify(target_shipment)
@@ -50,18 +50,13 @@ module Spree
50
50
  go_to_state :confirm
51
51
  end
52
52
 
53
- ransack_alias :bill_address_firstname_or_lastname, :bill_address_firstname_or_bill_address_lastname
54
53
  self.whitelisted_ransackable_associations = %w[shipments user order_promotions promotions bill_address ship_address line_items]
55
- self.whitelisted_ransackable_attributes = %w[bill_address_firstname_or_lastname completed_at created_at email number state payment_state shipment_state total store_id]
54
+ self.whitelisted_ransackable_attributes = %w[bill_address_name completed_at created_at email number state payment_state shipment_state total store_id]
56
55
 
57
56
  attr_reader :coupon_code
58
57
  attr_accessor :temporary_address
59
58
 
60
59
  attr_accessor :temporary_payment_source
61
- alias_method :temporary_credit_card, :temporary_payment_source
62
- alias_method :temporary_credit_card=, :temporary_payment_source=
63
- deprecate temporary_credit_card: :temporary_payment_source, deprecator: Spree::Deprecation
64
- deprecate :temporary_credit_card= => :temporary_payment_source=, deprecator: Spree::Deprecation
65
60
 
66
61
  # Customer info
67
62
  belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
@@ -147,14 +142,9 @@ module Spree
147
142
  find_by! number: value
148
143
  end
149
144
 
150
- delegate :name, :firstname, :lastname, to: :bill_address, prefix: true, allow_nil: true
151
- alias_method :billing_firstname, :bill_address_firstname
152
- alias_method :billing_lastname, :bill_address_lastname
145
+ delegate :name, to: :bill_address, prefix: true, allow_nil: true
153
146
  alias_method :billing_name, :bill_address_name
154
147
 
155
- class_attribute :update_hooks
156
- self.update_hooks = Set.new
157
-
158
148
  class_attribute :line_item_comparison_hooks
159
149
  self.line_item_comparison_hooks = Set.new
160
150
 
@@ -190,15 +180,6 @@ module Spree
190
180
  where.not(state: 'canceled')
191
181
  end
192
182
 
193
- # Use this method in other gems that wish to register their own custom logic
194
- # that should be called after Order#update
195
- def self.register_update_hook(hook)
196
- Spree::Deprecation.warn \
197
- "Spree::Order::update_hooks are deprecated. Please remove them " \
198
- "and subscribe to `order_recalculated` and/or `order_finalized` event instead", caller(1)
199
- update_hooks.add(hook)
200
- end
201
-
202
183
  # Use this method in other gems that wish to register their own custom logic
203
184
  # that should be called when determining if two line items are equal.
204
185
  def self.register_line_item_comparison_hook(hook)
@@ -210,12 +191,6 @@ module Spree
210
191
  line_items.sum(&:amount)
211
192
  end
212
193
 
213
- # Sum of all line item amounts after promotions, before added tax
214
- def discounted_item_amount
215
- line_items.to_a.sum(&:discounted_amount)
216
- end
217
- deprecate discounted_item_amount: :item_total_before_tax, deprecator: Spree::Deprecation
218
-
219
194
  def item_total_before_tax
220
195
  line_items.to_a.sum(&:total_before_tax)
221
196
  end
@@ -224,8 +199,6 @@ module Spree
224
199
  def item_total_excluding_vat
225
200
  line_items.to_a.sum(&:total_excluding_vat)
226
201
  end
227
- alias pre_tax_item_amount item_total_excluding_vat
228
- deprecate pre_tax_item_amount: :item_total_excluding_vat, deprecator: Spree::Deprecation
229
202
 
230
203
  def currency
231
204
  self[:currency] || Spree::Config[:currency]
@@ -256,11 +229,6 @@ module Spree
256
229
  total > 0
257
230
  end
258
231
 
259
- def confirmation_required?
260
- true
261
- end
262
- deprecate :confirmation_required?, deprecator: Spree::Deprecation
263
-
264
232
  def backordered?
265
233
  shipments.any?(&:backordered?)
266
234
  end
@@ -282,15 +250,6 @@ module Spree
282
250
  updater.update
283
251
  end
284
252
 
285
- def update!(*args)
286
- if args.empty?
287
- Spree::Deprecation.warn "Calling order.update! with no arguments as a way to invoke the OrderUpdater is deprecated, since it conflicts with AR::Base#update! Please use order.recalculate instead"
288
- recalculate
289
- else
290
- super
291
- end
292
- end
293
-
294
253
  def assign_billing_to_shipping_address
295
254
  self.ship_address = bill_address if bill_address
296
255
  true
@@ -336,14 +295,7 @@ module Spree
336
295
  assign_attributes(attrs_to_set)
337
296
  end
338
297
 
339
- def generate_order_number(options = nil)
340
- if options
341
- Spree::Deprecation.warn \
342
- "Passing options to Order#generate_order_number is deprecated. " \
343
- "Please add your own instance of the order number generator " \
344
- "with your options (#{options.inspect}) and store it as " \
345
- "Spree::Config.order_number_generator in your stores config."
346
- end
298
+ def generate_order_number
347
299
  self.number ||= Spree::Config.order_number_generator.generate
348
300
  end
349
301
 
@@ -384,14 +336,6 @@ module Spree
384
336
  }
385
337
  end
386
338
 
387
- # Creates new tax charges if there are any applicable rates. If prices already
388
- # include taxes then price adjustments are created instead.
389
- # @deprecated This now happens during #recalculate
390
- def create_tax_charge!
391
- recalculate
392
- end
393
- deprecate create_tax_charge!: :recalculate, deprecator: Spree::Deprecation
394
-
395
339
  def reimbursement_total
396
340
  reimbursements.sum(:total)
397
341
  end
@@ -450,18 +394,10 @@ module Spree
450
394
 
451
395
  updater.update_shipment_state
452
396
  save!
453
- updater.run_hooks if update_hooks.any?
454
397
 
455
398
  touch :completed_at
456
399
 
457
400
  Spree::Event.fire 'order_finalized', order: self
458
-
459
- if method(:deliver_order_confirmation_email).owner != self.class
460
- Spree::Deprecation.warn \
461
- "deliver_order_confirmation_email has been deprecated and moved to " \
462
- "Spree::MailerSubscriber#order_finalized, please move there any customizations.",
463
- caller(1)
464
- end
465
401
  end
466
402
 
467
403
  def fulfill!
@@ -470,16 +406,6 @@ module Spree
470
406
  save!
471
407
  end
472
408
 
473
- def deliver_order_confirmation_email
474
- Spree::Deprecation.warn \
475
- "deliver_order_confirmation_email has been deprecated and moved to " \
476
- "Spree::MailerSubscriber#order_finalized.",
477
- caller(1)
478
-
479
- Spree::Config.order_mailer_class.confirm_email(order).deliver_later
480
- order.update_column(:confirmation_delivered, true)
481
- end
482
-
483
409
  # Helper methods for checkout steps
484
410
  def paid?
485
411
  %w(paid credit_owed).include?(payment_state)
@@ -523,26 +449,6 @@ module Spree
523
449
  recalculate
524
450
  end
525
451
 
526
- alias_method :has_step?, :has_checkout_step?
527
- deprecate has_step?: :has_checkout_step?, deprecator: Spree::Deprecation
528
-
529
- def state_changed(name)
530
- state = "#{name}_state"
531
- if persisted?
532
- old_state = send("#{state}_was")
533
- new_state = send(state)
534
- unless old_state == new_state
535
- state_changes.create(
536
- previous_state: old_state,
537
- next_state: new_state,
538
- name: name,
539
- user_id: user_id
540
- )
541
- end
542
- end
543
- end
544
- deprecate :state_changed, deprecator: Spree::Deprecation
545
-
546
452
  def coupon_code=(code)
547
453
  @coupon_code = begin
548
454
  code.strip.downcase
@@ -599,8 +505,6 @@ module Spree
599
505
  Spree::PromotionHandler::Shipping.new(self).activate
600
506
  recalculate
601
507
  end
602
- alias_method :apply_free_shipping_promotions, :apply_shipping_promotions
603
- deprecate apply_free_shipping_promotions: :apply_shipping_promotions, deprecator: Spree::Deprecation
604
508
 
605
509
  # Clean shipments and make order back to address state
606
510
  #
@@ -633,12 +537,6 @@ module Spree
633
537
  bill_address == ship_address
634
538
  end
635
539
 
636
- # @deprecated This now happens during #recalculate
637
- def set_shipments_cost
638
- recalculate
639
- end
640
- deprecate set_shipments_cost: :recalculate, deprecator: Spree::Deprecation
641
-
642
540
  def is_risky?
643
541
  payments.risky.count > 0
644
542
  end
@@ -669,11 +567,6 @@ module Spree
669
567
  payments.offset_payment.exists? # how old versions of spree stored refunds
670
568
  end
671
569
 
672
- def token
673
- Spree::Deprecation.warn("Spree::Order#token is DEPRECATED, please use #guest_token instead.", caller)
674
- guest_token
675
- end
676
-
677
570
  def tax_total
678
571
  additional_tax_total + included_tax_total
679
572
  end
@@ -778,11 +671,6 @@ module Spree
778
671
  end
779
672
  end
780
673
 
781
- alias_method :assign_default_user_addresses!, :assign_default_user_addresses
782
- deprecate assign_default_user_addresses!: :assign_default_user_addresses, deprecator: Spree::Deprecation
783
- alias_method :assign_default_addresses!, :assign_default_user_addresses
784
- deprecate assign_default_addresses!: :assign_default_user_addresses, deprecator: Spree::Deprecation
785
-
786
674
  def persist_user_address!
787
675
  if !temporary_address && user && user.respond_to?(:persist_order_address) && bill_address_id
788
676
  user.persist_order_address(self)
@@ -794,8 +682,6 @@ module Spree
794
682
  add_payment_sources_to_wallet_class.new(self).
795
683
  add_to_wallet
796
684
  end
797
- alias_method :persist_user_credit_card, :add_payment_sources_to_wallet
798
- deprecate persist_user_credit_card: :add_payment_sources_to_wallet, deprecator: Spree::Deprecation
799
685
 
800
686
  def add_default_payment_from_wallet
801
687
  builder = Spree::Config.default_payment_builder_class.new(self)
@@ -810,8 +696,6 @@ module Spree
810
696
  end
811
697
  end
812
698
  end
813
- alias_method :assign_default_credit_card, :add_default_payment_from_wallet
814
- deprecate assign_default_credit_card: :add_default_payment_from_wallet, deprecator: Spree::Deprecation
815
699
 
816
700
  def record_ip_address(ip_address)
817
701
  if new_record?
@@ -857,23 +741,6 @@ module Spree
857
741
  end
858
742
  end
859
743
 
860
- # In case a existing credit card is provided it needs to build the payment
861
- # attributes from scratch so we can set the amount. example payload:
862
- #
863
- # {
864
- # "order": {
865
- # "existing_card": "2"
866
- # }
867
- # }
868
- #
869
- def update_params_payment_source
870
- Spree::Deprecation.warn('update_params_payment_source is deprecated. Please use set_payment_parameters_amount instead.', caller)
871
- if @updating_params[:order] && (@updating_params[:order][:payments_attributes] || @updating_params[:order][:existing_card])
872
- @updating_params[:order][:payments_attributes] ||= [{}]
873
- @updating_params[:order][:payments_attributes].first[:amount] = total
874
- end
875
- end
876
-
877
744
  def associate_store
878
745
  self.store ||= Spree::Store.default
879
746
  end