solidus_core 2.11.10 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/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 -186
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +0 -53
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -7
- 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.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_updater.rb +2 -11
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method.rb +2 -103
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/product.rb +0 -40
- 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 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/refund.rb +0 -52
- 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 +3 -22
- 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 +6 -15
- 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_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 +12 -1
- 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 -65
- 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 -35
- 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/deprecation.rb +1 -1
- 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 +9 -54
- 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 +7 -14
- 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/tasks/upgrade.rake +7 -5
- data/solidus_core.gemspec +2 -5
- metadata +8 -49
- 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/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- 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_address_names.rake +0 -158
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -26
- 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
@@ -33,9 +33,6 @@ module Spree
|
|
33
33
|
order = adjustable.is_a?(Order) ? adjustable : adjustable.order
|
34
34
|
return 0 unless promotion.line_item_actionable?(order, adjustable)
|
35
35
|
promotion_amount = calculator.compute(adjustable)
|
36
|
-
if !promotion_amount.is_a?(BigDecimal)
|
37
|
-
Spree::Deprecation.warn "#{calculator.class.name}#compute returned #{promotion_amount.inspect}, it should return a BigDecimal"
|
38
|
-
end
|
39
36
|
promotion_amount ||= BigDecimal(0)
|
40
37
|
promotion_amount = promotion_amount.abs
|
41
38
|
[adjustable.amount, promotion_amount].min * -1
|
@@ -57,9 +57,6 @@ module Spree
|
|
57
57
|
#
|
58
58
|
def compute_amount(line_item)
|
59
59
|
adjustment_amount = calculator.compute(PartialLineItem.new(line_item))
|
60
|
-
if !adjustment_amount.is_a?(BigDecimal)
|
61
|
-
Spree::Deprecation.warn "#{calculator.class.name}#compute returned #{adjustment_amount.inspect}, it should return a BigDecimal"
|
62
|
-
end
|
63
60
|
adjustment_amount ||= BigDecimal(0)
|
64
61
|
adjustment_amount = adjustment_amount.abs
|
65
62
|
|
@@ -38,11 +38,7 @@ module Spree
|
|
38
38
|
eligibility_errors.add(:base, eligibility_error_message(:has_excluded_taxon), error_code: :has_excluded_taxon)
|
39
39
|
end
|
40
40
|
else
|
41
|
-
|
42
|
-
warn_invalid_match_policy(assume: 'any')
|
43
|
-
unless order_taxons.where(id: rule_taxon_ids_with_children).exists?
|
44
|
-
eligibility_errors.add(:base, eligibility_error_message(:no_matching_taxons), error_code: :no_matching_taxons)
|
45
|
-
end
|
41
|
+
raise "unexpected match policy: #{preferred_match_policy.inspect}"
|
46
42
|
end
|
47
43
|
|
48
44
|
eligibility_errors.empty?
|
@@ -60,9 +56,7 @@ module Spree
|
|
60
56
|
when 'none'
|
61
57
|
!found
|
62
58
|
else
|
63
|
-
|
64
|
-
warn_invalid_match_policy(assume: 'any')
|
65
|
-
found
|
59
|
+
raise "unexpected match policy: #{preferred_match_policy.inspect}"
|
66
60
|
end
|
67
61
|
end
|
68
62
|
|
@@ -77,13 +71,6 @@ module Spree
|
|
77
71
|
|
78
72
|
private
|
79
73
|
|
80
|
-
def warn_invalid_match_policy(assume:)
|
81
|
-
Spree::Deprecation.warn(
|
82
|
-
"#{self.class.name} id=#{id} has unexpected match policy #{preferred_match_policy.inspect}. "\
|
83
|
-
"Interpreting it as '#{assume}'."
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
74
|
# All taxons in an order
|
88
75
|
def taxons_in_order(order)
|
89
76
|
Spree::Taxon.joins(products: { variants_including_master: :line_items })
|
@@ -38,11 +38,7 @@ module Spree
|
|
38
38
|
|
39
39
|
scope :coupons, -> { joins(:codes).distinct }
|
40
40
|
scope :advertised, -> { where(advertise: true) }
|
41
|
-
scope :active, ->
|
42
|
-
return started_and_unexpired if Spree::Config.consider_actionless_promotion_active == true
|
43
|
-
|
44
|
-
has_actions.started_and_unexpired
|
45
|
-
end
|
41
|
+
scope :active, -> { has_actions.started_and_unexpired }
|
46
42
|
scope :started_and_unexpired, -> do
|
47
43
|
table = arel_table
|
48
44
|
time = Time.current
|
@@ -93,7 +89,7 @@ module Spree
|
|
93
89
|
end
|
94
90
|
|
95
91
|
def active?
|
96
|
-
started? && not_expired? &&
|
92
|
+
started? && not_expired? && actions.present?
|
97
93
|
end
|
98
94
|
|
99
95
|
def inactive?
|
@@ -32,15 +32,8 @@ module Spree
|
|
32
32
|
#
|
33
33
|
# @param order [Spree::Order] the order to remove the action from
|
34
34
|
# @return [void]
|
35
|
-
def remove_from(
|
36
|
-
|
37
|
-
[order, *order.line_items, *order.shipments].each do |item|
|
38
|
-
item.adjustments.each do |adjustment|
|
39
|
-
if adjustment.source == self
|
40
|
-
item.adjustments.destroy(adjustment)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
35
|
+
def remove_from(_order)
|
36
|
+
raise 'remove_from should be implemented in a sub-class of PromotionAction'
|
44
37
|
end
|
45
38
|
|
46
39
|
def to_partial_path
|
@@ -10,20 +10,6 @@ class ::Spree::PromotionCode::BatchBuilder
|
|
10
10
|
sample_characters: ('a'..'z').to_a + (2..9).to_a.map(&:to_s)
|
11
11
|
}
|
12
12
|
|
13
|
-
[:random_code_length, :batch_size, :sample_characters].each do |attr|
|
14
|
-
define_singleton_method(attr) do
|
15
|
-
Spree::Deprecation.warn "#{name}.#{attr} is deprecated. Use #{name}::DEFAULT_OPTIONS[:#{attr}] instead"
|
16
|
-
DEFAULT_OPTIONS[attr]
|
17
|
-
end
|
18
|
-
|
19
|
-
define_singleton_method(:"#{attr}=") do |val|
|
20
|
-
Spree::Deprecation.warn "#{name}.#{attr}= is deprecated. Use #{name}::DEFAULT_OPTIONS[:#{attr}]= instead"
|
21
|
-
DEFAULT_OPTIONS[attr] = val
|
22
|
-
end
|
23
|
-
|
24
|
-
delegate attr, to: self
|
25
|
-
end
|
26
|
-
|
27
13
|
def initialize(promotion_code_batch, options = {})
|
28
14
|
@promotion_code_batch = promotion_code_batch
|
29
15
|
options.assert_valid_keys(*DEFAULT_OPTIONS.keys)
|
data/app/models/spree/refund.rb
CHANGED
@@ -15,11 +15,6 @@ module Spree
|
|
15
15
|
validate :amount_is_less_than_or_equal_to_allowed_amount, on: :create
|
16
16
|
|
17
17
|
attr_reader :perform_response
|
18
|
-
attr_accessor :perform_after_create
|
19
|
-
|
20
|
-
after_create :set_perform_after_create_default
|
21
|
-
after_create :perform!
|
22
|
-
after_create :clear_perform_after_create
|
23
18
|
|
24
19
|
scope :non_reimbursement, -> { where(reimbursement_id: nil) }
|
25
20
|
|
@@ -45,29 +40,14 @@ module Spree
|
|
45
40
|
# Attempts to perform the refund,
|
46
41
|
# raises an error if the refund fails.
|
47
42
|
def perform!
|
48
|
-
return true if perform_after_create == false
|
49
43
|
return true if transaction_id.present?
|
50
44
|
|
51
|
-
# This is needed otherwise set_perform_after_create_default callback
|
52
|
-
# will print a deprecation warning when save! creates a record
|
53
|
-
self.perform_after_create = false unless persisted?
|
54
|
-
|
55
45
|
credit_cents = money.cents
|
56
46
|
|
57
47
|
@perform_response = process!(credit_cents)
|
58
|
-
|
59
|
-
@response = Spree::DeprecatedInstanceVariableProxy.new(
|
60
|
-
self,
|
61
|
-
:perform_response,
|
62
|
-
:@response,
|
63
|
-
Spree::Deprecation,
|
64
|
-
"Please, do not use Spree::Refund @response anymore, use Spree::Refund#perform_response"
|
65
|
-
)
|
66
|
-
|
67
48
|
log_entries.build(details: perform_response.to_yaml)
|
68
49
|
|
69
50
|
self.transaction_id = perform_response.authorization
|
70
|
-
|
71
51
|
save!
|
72
52
|
|
73
53
|
update_order
|
@@ -75,38 +55,6 @@ module Spree
|
|
75
55
|
|
76
56
|
private
|
77
57
|
|
78
|
-
# This callback takes care of setting the behavior that determines if it is needed
|
79
|
-
# to execute the perform! callback after_create.
|
80
|
-
# Existing code that creates refund without explicitely passing
|
81
|
-
#
|
82
|
-
# perform_after_create: false
|
83
|
-
#
|
84
|
-
# as attribute will still call perform! but a deprecation warning is emitted in order
|
85
|
-
# to ask users to change their code with the new supported behavior.
|
86
|
-
def set_perform_after_create_default
|
87
|
-
return true if perform_after_create == false
|
88
|
-
|
89
|
-
Spree::Deprecation.warn <<-WARN.strip_heredoc, caller
|
90
|
-
From Solidus v3.0 onwards, #perform! will need to be explicitly called when creating new
|
91
|
-
refunds. Please, change your code from:
|
92
|
-
|
93
|
-
Spree::Refund.create(your: attributes)
|
94
|
-
|
95
|
-
to:
|
96
|
-
|
97
|
-
Spree::Refund.create(your: attributes, perform_after_create: false).perform!
|
98
|
-
WARN
|
99
|
-
|
100
|
-
self.perform_after_create = true
|
101
|
-
end
|
102
|
-
|
103
|
-
# This is needed to avoid that when you create a refund with perform_after_create = false,
|
104
|
-
# it's not possibile to call perform! on that instance, since the value of this attribute
|
105
|
-
# will remain false until a reload of the instance.
|
106
|
-
def clear_perform_after_create
|
107
|
-
@perform_after_create = nil
|
108
|
-
end
|
109
|
-
|
110
58
|
# return an activemerchant response object if successful or else raise an error
|
111
59
|
def process!(credit_cents)
|
112
60
|
response = if payment.payment_method.payment_profiles_supported?
|
@@ -51,14 +51,6 @@ module Spree
|
|
51
51
|
class_attribute :reimbursement_performer
|
52
52
|
self.reimbursement_performer = ReimbursementPerformer
|
53
53
|
|
54
|
-
# These are called if the call to "reimburse!" succeeds.
|
55
|
-
class_attribute :reimbursement_success_hooks
|
56
|
-
self.reimbursement_success_hooks = []
|
57
|
-
|
58
|
-
# These are called if the call to "reimburse!" fails.
|
59
|
-
class_attribute :reimbursement_failure_hooks
|
60
|
-
self.reimbursement_failure_hooks = []
|
61
|
-
|
62
54
|
include ::Spree::Config.state_machines.reimbursement
|
63
55
|
|
64
56
|
class << self
|
@@ -91,10 +83,7 @@ module Spree
|
|
91
83
|
total - paid_amount
|
92
84
|
end
|
93
85
|
|
94
|
-
def perform!(created_by:
|
95
|
-
unless created_by
|
96
|
-
Spree::Deprecation.warn("Calling #perform on #{self} without created_by is deprecated")
|
97
|
-
end
|
86
|
+
def perform!(created_by:)
|
98
87
|
reimbursement_tax_calculator.call(self)
|
99
88
|
reload
|
100
89
|
update!(total: calculated_total)
|
@@ -104,21 +93,9 @@ module Spree
|
|
104
93
|
if unpaid_amount_within_tolerance?
|
105
94
|
reimbursed!
|
106
95
|
Spree::Event.fire 'reimbursement_reimbursed', reimbursement: self
|
107
|
-
if reimbursement_success_hooks.any?
|
108
|
-
Spree::Deprecation.warn \
|
109
|
-
"reimbursement_success_hooks are deprecated. Please remove them " \
|
110
|
-
"and subscribe to `reimbursement_reimbursed` event instead", caller(1)
|
111
|
-
end
|
112
|
-
reimbursement_success_hooks.each { |hook| hook.call self }
|
113
96
|
else
|
114
97
|
errored!
|
115
98
|
Spree::Event.fire 'reimbursement_errored', reimbursement: self
|
116
|
-
if reimbursement_failure_hooks.any?
|
117
|
-
Spree::Deprecation.warn \
|
118
|
-
"reimbursement_failure_hooks are deprecated. Please remove them " \
|
119
|
-
"and subscribe to `reimbursement_errored` event instead", caller(1)
|
120
|
-
end
|
121
|
-
reimbursement_failure_hooks.each { |hook| hook.call self }
|
122
99
|
end
|
123
100
|
|
124
101
|
if errored?
|
@@ -126,10 +103,7 @@ module Spree
|
|
126
103
|
end
|
127
104
|
end
|
128
105
|
|
129
|
-
def simulate(created_by:
|
130
|
-
unless created_by
|
131
|
-
Spree::Deprecation.warn("Calling #simulate on #{self} without created_by is deprecated")
|
132
|
-
end
|
106
|
+
def simulate(created_by:)
|
133
107
|
reimbursement_simulator_tax_calculator.call(self)
|
134
108
|
reload
|
135
109
|
update!(total: calculated_total)
|
@@ -154,10 +128,7 @@ module Spree
|
|
154
128
|
# @api public
|
155
129
|
# @param [Spree.user_class] created_by the user that is performing this action
|
156
130
|
# @return [void]
|
157
|
-
def return_all(created_by:
|
158
|
-
unless created_by
|
159
|
-
Spree::Deprecation.warn("Calling #return_all on #{self} without created_by is deprecated")
|
160
|
-
end
|
131
|
+
def return_all(created_by:)
|
161
132
|
return_items.each(&:accept!)
|
162
133
|
save!
|
163
134
|
perform!(created_by: created_by)
|
@@ -168,15 +139,6 @@ module Spree
|
|
168
139
|
#
|
169
140
|
# @return [Spree::StoreCreditCategory]
|
170
141
|
def store_credit_category
|
171
|
-
if Spree::Config.use_legacy_store_credit_reimbursement_category_name
|
172
|
-
Spree::Deprecation.warn("Using the legacy reimbursement_category_name is deprecated. "\
|
173
|
-
"Set Spree::Config.use_legacy_store_credit_reimbursement_category_name to false to use "\
|
174
|
-
"the new version instead.", caller)
|
175
|
-
|
176
|
-
name = Spree::StoreCreditCategory.reimbursement_category_name
|
177
|
-
return Spree::StoreCreditCategory.find_by(name: name) || Spree::StoreCreditCategory.first
|
178
|
-
end
|
179
|
-
|
180
142
|
Spree::StoreCreditCategory.find_by(name: Spree::StoreCreditCategory::REIMBURSEMENT)
|
181
143
|
end
|
182
144
|
|
@@ -11,18 +11,12 @@ module Spree
|
|
11
11
|
# - #description
|
12
12
|
# - #display_amount
|
13
13
|
# so they can be displayed in the Admin UI appropriately.
|
14
|
-
def simulate(reimbursement, created_by:
|
15
|
-
unless created_by
|
16
|
-
Spree::Deprecation.warn("Calling #simulate on #{self} without created_by is deprecated")
|
17
|
-
end
|
14
|
+
def simulate(reimbursement, created_by:)
|
18
15
|
execute(reimbursement, true, created_by: created_by)
|
19
16
|
end
|
20
17
|
|
21
18
|
# Actually perform the reimbursement
|
22
|
-
def perform(reimbursement, created_by:
|
23
|
-
unless created_by
|
24
|
-
Spree::Deprecation.warn("Calling #perform on #{self} without created_by is deprecated")
|
25
|
-
end
|
19
|
+
def perform(reimbursement, created_by:)
|
26
20
|
execute(reimbursement, false, created_by: created_by)
|
27
21
|
end
|
28
22
|
|
@@ -5,10 +5,7 @@ module Spree
|
|
5
5
|
extend Spree::ReimbursementType::ReimbursementHelpers
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def reimburse(reimbursement, return_items, simulate, created_by:
|
9
|
-
unless created_by
|
10
|
-
Spree::Deprecation.warn("Calling #reimburse on #{self} without created_by is deprecated")
|
11
|
-
end
|
8
|
+
def reimburse(reimbursement, return_items, simulate, created_by:)
|
12
9
|
unpaid_amount = return_items.sum(&:total).round(2, :down)
|
13
10
|
reimbursement_list, _unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate, created_by: created_by)
|
14
11
|
reimbursement_list
|
@@ -34,8 +34,7 @@ module Spree
|
|
34
34
|
refund = reimbursement.refunds.build({
|
35
35
|
payment: payment,
|
36
36
|
amount: amount,
|
37
|
-
reason: Spree::RefundReason.return_processing_reason
|
38
|
-
perform_after_create: false
|
37
|
+
reason: Spree::RefundReason.return_processing_reason
|
39
38
|
})
|
40
39
|
|
41
40
|
if simulate
|
@@ -4,10 +4,7 @@ class Spree::ReimbursementType::StoreCredit < Spree::ReimbursementType
|
|
4
4
|
extend Spree::ReimbursementType::ReimbursementHelpers
|
5
5
|
|
6
6
|
class << self
|
7
|
-
def reimburse(reimbursement, return_items, simulate, created_by:
|
8
|
-
unless created_by
|
9
|
-
Spree::Deprecation.warn("Calling #reimburse on #{self} without created_by is deprecated")
|
10
|
-
end
|
7
|
+
def reimburse(reimbursement, return_items, simulate, created_by:)
|
11
8
|
unpaid_amount = return_items.sum(&:total).to_d.round(2, :down)
|
12
9
|
payments = store_credit_payments(reimbursement)
|
13
10
|
reimbursement_list = []
|
@@ -25,16 +25,13 @@ module Spree
|
|
25
25
|
include ::Spree::Config.state_machines.return_authorization
|
26
26
|
|
27
27
|
extend DisplayMoney
|
28
|
-
money_methods :
|
29
|
-
deprecate display_pre_tax_total: :display_total_excluding_vat, deprecator: Spree::Deprecation
|
28
|
+
money_methods :amount, :total_excluding_vat
|
30
29
|
|
31
30
|
self.whitelisted_ransackable_attributes = ['memo']
|
32
31
|
|
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)
|
@@ -81,8 +81,7 @@ module Spree
|
|
81
81
|
include ::Spree::Config.state_machines.return_item_acceptance
|
82
82
|
|
83
83
|
extend DisplayMoney
|
84
|
-
money_methods :
|
85
|
-
deprecate display_pre_tax_amount: :display_total_excluding_vat, deprecator: Spree::Deprecation
|
84
|
+
money_methods :amount, :total, :total_excluding_vat
|
86
85
|
|
87
86
|
# @return [Boolean] true when this retur item is in a complete reception
|
88
87
|
# state
|
@@ -90,14 +89,6 @@ module Spree
|
|
90
89
|
COMPLETED_RECEPTION_STATUSES.map(&:to_s).include?(reception_status.to_s)
|
91
90
|
end
|
92
91
|
|
93
|
-
def skip_customer_return_processing=(value)
|
94
|
-
@skip_customer_return_processing = value
|
95
|
-
Deprecation.warn \
|
96
|
-
'From Solidus v2.11 onwards, #skip_customer_return_processing does ' \
|
97
|
-
'nothing, and #process_inventory_unit! will restore calling ' \
|
98
|
-
'customer_return#process_return!', caller(1)
|
99
|
-
end
|
100
|
-
|
101
92
|
# @param inventory_unit [Spree::InventoryUnit] the inventory for which we
|
102
93
|
# want a return item
|
103
94
|
# @return [Spree::ReturnItem] a valid return item for the given inventory
|
@@ -134,8 +125,6 @@ module Spree
|
|
134
125
|
def total_excluding_vat
|
135
126
|
amount - included_tax_total
|
136
127
|
end
|
137
|
-
alias pre_tax_amount total_excluding_vat
|
138
|
-
deprecate pre_tax_amount: :total_excluding_vat, deprecator: Spree::Deprecation
|
139
128
|
|
140
129
|
# @note This uses the exchange_variant_engine configured on the class.
|
141
130
|
# @param stock_locations [Array<Spree::StockLocation>] the stock locations to check
|
@@ -206,13 +195,6 @@ module Spree
|
|
206
195
|
customer_return.stock_location.restock(inventory_unit.variant, 1, customer_return)
|
207
196
|
end
|
208
197
|
|
209
|
-
unless @skip_customer_return_processing.nil?
|
210
|
-
Deprecation.warn \
|
211
|
-
'From Solidus v2.11 onwards, #skip_customer_return_processing does ' \
|
212
|
-
'nothing, and #process_inventory_unit! will restore calling ' \
|
213
|
-
'customer_return#process_return!'
|
214
|
-
end
|
215
|
-
|
216
198
|
customer_return&.process_return!
|
217
199
|
end
|
218
200
|
|
@@ -272,10 +254,9 @@ module Spree
|
|
272
254
|
}).where.not(id: id).first
|
273
255
|
|
274
256
|
if other_return_item && (new_record? || COMPLETED_RECEPTION_STATUSES.include?(reception_status.to_sym))
|
275
|
-
errors.add(:inventory_unit, :other_completed_return_item_exists,
|
257
|
+
errors.add(:inventory_unit, :other_completed_return_item_exists,
|
276
258
|
inventory_unit_id: inventory_unit_id,
|
277
|
-
return_item_id: other_return_item.id
|
278
|
-
})
|
259
|
+
return_item_id: other_return_item.id)
|
279
260
|
end
|
280
261
|
end
|
281
262
|
|
@@ -62,18 +62,11 @@ module Spree
|
|
62
62
|
|
63
63
|
extend DisplayMoney
|
64
64
|
money_methods(
|
65
|
-
:cost, :amount, :
|
65
|
+
:cost, :amount, :item_cost,
|
66
66
|
:total, :total_before_tax,
|
67
67
|
)
|
68
|
-
deprecate display_discounted_cost: :display_total_before_tax, deprecator: Spree::Deprecation
|
69
|
-
deprecate display_final_price: :display_total, deprecator: Spree::Deprecation
|
70
68
|
alias_attribute :amount, :cost
|
71
69
|
|
72
|
-
def add_shipping_method(shipping_method, selected = false)
|
73
|
-
shipping_rates.create(shipping_method: shipping_method, selected: selected, cost: cost)
|
74
|
-
end
|
75
|
-
deprecate :add_shipping_method, deprecator: Spree::Deprecation
|
76
|
-
|
77
70
|
def after_cancel
|
78
71
|
manifest.each { |item| manifest_restock(item) }
|
79
72
|
end
|
@@ -90,20 +83,11 @@ module Spree
|
|
90
83
|
order ? order.currency : Spree::Config[:currency]
|
91
84
|
end
|
92
85
|
|
93
|
-
def discounted_cost
|
94
|
-
cost + promo_total
|
95
|
-
end
|
96
|
-
deprecate discounted_cost: :total_before_tax, deprecator: Spree::Deprecation
|
97
|
-
alias discounted_amount discounted_cost
|
98
|
-
deprecate discounted_amount: :total_before_tax, deprecator: Spree::Deprecation
|
99
|
-
|
100
86
|
# @return [BigDecimal] the amount of this shipment, taking into
|
101
87
|
# consideration all its adjustments.
|
102
88
|
def total
|
103
89
|
cost + adjustment_total
|
104
90
|
end
|
105
|
-
alias final_price total
|
106
|
-
deprecate final_price: :total, deprecator: Spree::Deprecation
|
107
91
|
|
108
92
|
# @return [BigDecimal] the amount of this item, taking into consideration
|
109
93
|
# all non-tax adjustments.
|
@@ -116,14 +100,10 @@ module Spree
|
|
116
100
|
def total_excluding_vat
|
117
101
|
total_before_tax - included_tax_total
|
118
102
|
end
|
119
|
-
alias pre_tax_amount total_excluding_vat
|
120
|
-
deprecate pre_tax_amount: :total_excluding_vat, deprecator: Spree::Deprecation
|
121
103
|
|
122
104
|
def total_with_items
|
123
105
|
total + item_cost
|
124
106
|
end
|
125
|
-
alias final_price_with_items total_with_items
|
126
|
-
deprecate final_price_with_items: :total_with_items, deprecator: Spree::Deprecation
|
127
107
|
|
128
108
|
def editable_by?(_user)
|
129
109
|
!shipped?
|
@@ -320,43 +300,10 @@ module Spree
|
|
320
300
|
end
|
321
301
|
end
|
322
302
|
|
323
|
-
def update!(order_or_attrs)
|
324
|
-
if order_or_attrs.is_a?(Spree::Order)
|
325
|
-
Spree::Deprecation.warn "Calling Shipment#update! with an order to update the shipments state is deprecated. Please use Shipment#update_state instead."
|
326
|
-
if order_or_attrs.object_id != order.object_id
|
327
|
-
Spree::Deprecation.warn "Additionally, update! is being passed an instance of order which isn't the same object as the shipment's order association"
|
328
|
-
end
|
329
|
-
update_state
|
330
|
-
else
|
331
|
-
super
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
def transfer_to_location(variant, quantity, stock_location)
|
336
|
-
Spree::Deprecation.warn("Please use the Spree::FulfilmentChanger class instead of Spree::Shipment#transfer_to_location", caller)
|
337
|
-
new_shipment = order.shipments.create!(stock_location: stock_location)
|
338
|
-
transfer_to_shipment(variant, quantity, new_shipment)
|
339
|
-
end
|
340
|
-
|
341
|
-
def transfer_to_shipment(variant, quantity, shipment_to_transfer_to)
|
342
|
-
Spree::Deprecation.warn("Please use the Spree::FulfilmentChanger class instead of Spree::Shipment#transfer_to_location", caller)
|
343
|
-
Spree::FulfilmentChanger.new(
|
344
|
-
current_shipment: self,
|
345
|
-
desired_shipment: shipment_to_transfer_to,
|
346
|
-
variant: variant,
|
347
|
-
quantity: quantity
|
348
|
-
).run!
|
349
|
-
end
|
350
|
-
|
351
303
|
def requires_shipment?
|
352
304
|
!stock_location || stock_location.fulfillable?
|
353
305
|
end
|
354
306
|
|
355
|
-
def address
|
356
|
-
Spree::Deprecation.warn("Calling Shipment#address is deprecated. Use Order#ship_address instead", caller)
|
357
|
-
order.ship_address if order
|
358
|
-
end
|
359
|
-
|
360
307
|
private
|
361
308
|
|
362
309
|
def finalize_pending_inventory_units
|