solidus_core 2.11.16 → 3.0.0.rc2
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -13
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -2
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +0 -37
- data/app/models/concerns/spree/user_methods.rb +2 -11
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -187
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +12 -48
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -11
- data/app/models/spree/country.rb +1 -6
- data/app/models/spree/credit_card.rb +0 -27
- data/app/models/spree/customer_return.rb +1 -4
- data/app/models/spree/image/active_storage_attachment.rb +2 -10
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +2 -45
- data/app/models/spree/order.rb +4 -137
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_shipping.rb +9 -6
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment/cancellation.rb +3 -22
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +9 -13
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
- data/app/models/spree/payment_method.rb +2 -106
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/product.rb +0 -39
- data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/rules/taxon.rb +2 -15
- data/app/models/spree/promotion.rb +2 -6
- data/app/models/spree/promotion_action.rb +2 -12
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +2 -2
- data/app/models/spree/promotion_rule.rb +0 -4
- data/app/models/spree/refund.rb +0 -60
- data/app/models/spree/reimbursement.rb +3 -41
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +1 -4
- data/app/models/spree/return_item.rb +1 -19
- data/app/models/spree/shipment.rb +1 -54
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/state.rb +0 -4
- data/app/models/spree/stock/simple_coordinator.rb +1 -20
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +1 -7
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +0 -8
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
- data/app/models/spree/tax_rate.rb +0 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
- data/app/models/spree/taxon.rb +0 -11
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/variant.rb +2 -46
- data/config/locales/en.yml +0 -8
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +13 -2
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +6 -73
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -14
- data/lib/spree/core/controller_helpers/order.rb +2 -22
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +0 -43
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +0 -40
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +0 -26
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +9 -8
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +3 -1
- data/lib/spree/event.rb +0 -31
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +3 -60
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +6 -16
- data/lib/spree/testing_support/factories/order_factory.rb +0 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/order_walkthrough.rb +0 -3
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support.rb +1 -1
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +20 -15
- data/solidus_core.gemspec +1 -24
- metadata +9 -74
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/preferences/persistable.rb +0 -23
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/spree/testing_support/fixtures/file.txt +0 -1
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
@@ -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
|
data/app/models/spree/base.rb
CHANGED
@@ -1,60 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spree/preferences/persistable'
|
4
|
-
|
5
3
|
class Spree::Base < ActiveRecord::Base
|
4
|
+
include Spree::Preferences::Preferable
|
6
5
|
include Spree::Core::Permalinks
|
7
6
|
include Spree::RansackableAttributes
|
8
7
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
In order to make #{name} work with future versions of Solidus (and Rails), please add the
|
13
|
-
following line to your class:
|
14
|
-
```
|
15
|
-
class #{name}
|
16
|
-
include Spree::Preferences::Persistable
|
17
|
-
...
|
18
|
-
end
|
19
|
-
```
|
20
|
-
WARN
|
21
|
-
include Spree::Preferences::Persistable
|
22
|
-
preference(*args)
|
23
|
-
end
|
24
|
-
|
25
|
-
def preferences
|
26
|
-
value = read_attribute(:preferences)
|
27
|
-
if !value.is_a?(Hash)
|
28
|
-
Spree::Deprecation.warn <<~WARN
|
29
|
-
#{self.class.name} has a `preferences` column, but does not explicitly (de)serialize this column.
|
30
|
-
In order to make #{self.class.name} work with future versions of Solidus (and Rails), please add the
|
31
|
-
following lines to your class:
|
32
|
-
```
|
33
|
-
class #{self.class.name}
|
34
|
-
include Spree::Preferences::Persistable
|
35
|
-
...
|
36
|
-
end
|
37
|
-
```
|
38
|
-
WARN
|
39
|
-
self.class.include Spree::Preferences::Persistable
|
40
|
-
|
41
|
-
ActiveRecord::Type::Serialized.new(
|
42
|
-
ActiveRecord::Type::Text.new,
|
43
|
-
ActiveRecord::Coders::YAMLColumn.new(:preferences, Hash)
|
44
|
-
).deserialize(value)
|
45
|
-
else
|
46
|
-
value
|
8
|
+
def initialize_preference_defaults
|
9
|
+
if has_attribute?(:preferences)
|
10
|
+
self.preferences = default_preferences.merge(preferences)
|
47
11
|
end
|
48
12
|
end
|
49
13
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
14
|
+
# Only run preference initialization on models which requires it. Improves
|
15
|
+
# performance of record initialization slightly.
|
16
|
+
def self.preference(*args)
|
17
|
+
# after_initialize can be called multiple times with the same symbol, it
|
18
|
+
# will only be called once on initialization.
|
19
|
+
serialize :preferences, Hash
|
20
|
+
after_initialize :initialize_preference_defaults
|
21
|
+
super
|
58
22
|
end
|
59
23
|
|
60
24
|
self.abstract_class = true
|
@@ -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?
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spree/preferences/persistable'
|
4
|
-
|
5
3
|
module Spree
|
6
4
|
class Calculator < Spree::Base
|
7
|
-
include Spree::Preferences::Persistable
|
8
|
-
|
9
5
|
belongs_to :calculable, polymorphic: true, optional: true
|
10
6
|
|
11
7
|
# This method calls a compute_<computable> method. must be overriden in concrete calculator.
|
@@ -31,13 +27,6 @@ module Spree
|
|
31
27
|
|
32
28
|
###################################################################
|
33
29
|
|
34
|
-
# Returns all calculators applicable for kind of work
|
35
|
-
def self.calculators
|
36
|
-
Spree::Deprecation.warn("Calling .calculators is deprecated. Please access through Rails.application.config.spree.calculators")
|
37
|
-
|
38
|
-
Spree::Config.environment.calculators
|
39
|
-
end
|
40
|
-
|
41
30
|
def to_s
|
42
31
|
self.class.name.titleize.gsub("Calculator\/", "")
|
43
32
|
end
|
data/app/models/spree/country.rb
CHANGED
@@ -11,12 +11,7 @@ module Spree
|
|
11
11
|
self.whitelisted_ransackable_attributes = %w[name]
|
12
12
|
|
13
13
|
def self.default
|
14
|
-
|
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 :
|
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)
|
@@ -7,10 +7,6 @@ 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
|
-
|
14
10
|
has_attachment :attachment,
|
15
11
|
styles: {
|
16
12
|
mini: '48x48>',
|
@@ -19,11 +15,7 @@ module Spree::Image::ActiveStorageAttachment
|
|
19
15
|
large: '1200x1200>'
|
20
16
|
},
|
21
17
|
default_style: :product
|
22
|
-
|
23
|
-
|
24
|
-
unless attachment.content_type.in?(Spree::Config.allowed_image_mime_types)
|
25
|
-
errors.add(:attachment, :content_type_not_supported)
|
26
|
-
end
|
27
|
-
end
|
18
|
+
validates :attachment, presence: true
|
19
|
+
validate :attachment_is_an_image
|
28
20
|
end
|
29
21
|
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:
|
18
|
+
content_type: { content_type: %w[image/jpeg image/jpg image/png image/gif] }
|
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
|
data/app/models/spree/image.rb
CHANGED
@@ -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, :
|
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.
|
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)
|