solidus_core 2.11.10 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +6 -2
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/helpers/spree/products_helper.rb +2 -2
- 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 +30 -11
- data/app/models/concerns/spree/active_storage_adapter.rb +1 -1
- 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/default_price.rb +39 -10
- data/app/models/concerns/spree/ransackable_attributes.rb +24 -4
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +10 -37
- data/app/models/concerns/spree/user_methods.rb +38 -13
- 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 +7 -33
- data/app/models/spree/base.rb +0 -53
- data/app/models/spree/calculator/flat_fee.rb +21 -0
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -7
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/country.rb +2 -7
- data/app/models/spree/credit_card.rb +1 -28
- data/app/models/spree/customer_return.rb +5 -7
- data/app/models/spree/image/active_storage_attachment.rb +2 -7
- data/app/models/spree/image/paperclip_attachment.rb +2 -2
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +6 -49
- data/app/models/spree/log_entry.rb +74 -1
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_value.rb +10 -1
- data/app/models/spree/order/number_generator.rb +7 -1
- data/app/models/spree/order.rb +82 -170
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_contents.rb +2 -1
- data/app/models/spree/order_inventory.rb +1 -1
- data/app/models/spree/order_merger.rb +2 -2
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_shipping.rb +6 -9
- data/app/models/spree/order_taxation.rb +6 -4
- data/app/models/spree/order_updater.rb +17 -16
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment/processing.rb +58 -55
- 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 +6 -7
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +8 -0
- data/app/models/spree/payment_method.rb +26 -110
- data/app/models/spree/price.rb +3 -3
- data/app/models/spree/product/scopes.rb +24 -33
- data/app/models/spree/product.rb +15 -42
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/actions/create_adjustment.rb +4 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -9
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +92 -0
- data/app/models/spree/promotion/rules/item_total.rb +50 -6
- data/app/models/spree/promotion/rules/product.rb +20 -8
- data/app/models/spree/promotion/rules/store.rb +4 -0
- data/app/models/spree/promotion/rules/taxon.rb +6 -15
- data/app/models/spree/promotion/rules/user.rb +4 -0
- data/app/models/spree/promotion.rb +39 -32
- data/app/models/spree/promotion_action.rb +6 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +11 -7
- data/app/models/spree/promotion_handler/cart.rb +26 -6
- data/app/models/spree/promotion_rule.rb +5 -0
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/refund.rb +8 -52
- data/app/models/spree/reimbursement.rb +5 -43
- 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 +2 -5
- data/app/models/spree/return_item.rb +4 -24
- data/app/models/spree/shipment.rb +3 -56
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/shipping_rate_tax.rb +1 -1
- data/app/models/spree/state.rb +1 -5
- data/app/models/spree/stock/allocator/on_hand_first.rb +2 -2
- data/app/models/spree/stock/availability.rb +11 -3
- data/app/models/spree/stock/quantifier.rb +12 -8
- data/app/models/spree/stock/simple_coordinator.rb +8 -26
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +2 -8
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +14 -1
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/store_credit_prioritizer.rb +17 -0
- data/app/models/spree/tax/item_tax.rb +3 -2
- data/app/models/spree/tax/order_tax.rb +3 -1
- data/app/models/spree/tax/tax_helpers.rb +2 -2
- data/app/models/spree/tax/tax_location.rb +4 -7
- data/app/models/spree/tax_calculator/default.rb +31 -0
- data/app/models/spree/tax_calculator/shipping_rate.rb +2 -13
- data/app/models/spree/tax_rate.rb +9 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +2 -7
- data/app/models/spree/taxon/paperclip_attachment.rb +3 -8
- data/app/models/spree/taxon.rb +1 -12
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +34 -4
- data/app/models/spree/variant.rb +52 -66
- data/app/models/spree/zone.rb +1 -1
- data/app/subscribers/spree/mailer_subscriber.rb +4 -0
- data/app/subscribers/spree/order_mailer_subscriber.rb +35 -0
- data/config/i18n-tasks.yml +134 -0
- data/config/locales/en.yml +406 -263
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/db/migrate/20201127212108_add_type_before_removal_to_spree_payment_methods.rb +7 -0
- data/db/migrate/20210312061050_change_column_null_on_prices.rb +7 -0
- data/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb +20 -0
- data/db/migrate/20220805202442_add_level_to_spree_tax_rates.rb +5 -0
- data/db/migrate/20221123152807_add_shipping_category_to_spree_variants.rb +5 -0
- data/db/seeds.rb +4 -1
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +21 -0
- data/lib/generators/solidus/install/app_templates/authentication/devise.rb +16 -0
- data/lib/generators/solidus/install/app_templates/authentication/existing.rb +10 -0
- data/lib/generators/solidus/install/app_templates/authentication/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +54 -0
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +16 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +2 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +3 -0
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +13 -0
- data/lib/generators/solidus/install/app_templates/payment_method/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +10 -0
- data/lib/generators/solidus/install/install_generator.rb +247 -149
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +15 -60
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/backend/all.js +2 -2
- data/lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt +30 -0
- data/lib/generators/solidus/update/update_generator.rb +112 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +6 -4
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +2 -6
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +12 -9
- data/lib/generators/spree/dummy/templates/rails/application.rb.tt +0 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +81 -39
- 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 +134 -64
- data/lib/spree/bus.rb +20 -0
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +10 -15
- data/lib/spree/core/controller_helpers/current_host.rb +5 -3
- data/lib/spree/core/controller_helpers/order.rb +12 -32
- 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/search.rb +1 -1
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +54 -50
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +1 -41
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +18 -35
- data/lib/spree/core/state_machines/order.rb +2 -2
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/stock_configuration.rb +18 -0
- data/lib/spree/core/validators/email.rb +5 -3
- data/lib/spree/core/version.rb +5 -1
- data/lib/spree/core/versioned_value.rb +75 -0
- data/lib/spree/core.rb +40 -11
- 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 +7 -7
- data/lib/spree/event.rb +1 -32
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/migrations.rb +13 -11
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permission_sets/default_customer.rb +8 -1
- data/lib/spree/permitted_attributes.rb +17 -59
- data/lib/spree/preferences/configuration.rb +84 -0
- data/lib/spree/preferences/preferable.rb +13 -0
- data/lib/spree/preferences/preferable_class_methods.rb +37 -4
- data/lib/spree/preferences/preference_differentiator.rb +29 -0
- data/lib/spree/preferences/static_model_preferences.rb +25 -10
- data/lib/spree/rails_compatibility.rb +106 -0
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/bus_helpers.rb +101 -0
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/common_rake.rb +71 -23
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/database.yml +42 -22
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +47 -34
- data/lib/spree/testing_support/factories/address_factory.rb +9 -6
- data/lib/spree/testing_support/factories/calculator_factory.rb +3 -0
- data/lib/spree/testing_support/factories/country_factory.rb +1 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +8 -5
- data/lib/spree/testing_support/factories/product_factory.rb +4 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +28 -14
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/factories/state_factory.rb +8 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +4 -4
- data/lib/spree/testing_support/factories/user_factory.rb +6 -0
- data/lib/spree/testing_support/factory_bot.rb +2 -2
- data/lib/spree/testing_support/order_walkthrough.rb +6 -8
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support/silence_deprecations.rb +9 -0
- data/lib/tasks/colorado_delivery_fee.rake +28 -0
- data/lib/tasks/payment_method.rake +29 -0
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +18 -0
- data/lib/tasks/solidus/delete_prices_with_nil_amount.rake +8 -0
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +33 -0
- data/solidus_core.gemspec +14 -7
- metadata +127 -78
- 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/app/models/spree/tax/shipping_rate_taxer.rb +0 -24
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/frontend/all.js +0 -10
- data/lib/generators/solidus/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +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
- data/lib/tasks/upgrade.rake +0 -13
@@ -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)
|
@@ -5,13 +5,13 @@ class Spree::PromotionCode < Spree::Base
|
|
5
5
|
belongs_to :promotion_code_batch, class_name: "Spree::PromotionCodeBatch", optional: true
|
6
6
|
has_many :adjustments
|
7
7
|
|
8
|
+
before_validation :normalize_code
|
9
|
+
|
8
10
|
validates :value, presence: true, uniqueness: { allow_blank: true, case_sensitive: true }
|
9
11
|
validates :promotion, presence: true
|
10
12
|
validate :promotion_not_apply_automatically, on: :create
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
self.whitelisted_ransackable_attributes = ['value']
|
14
|
+
self.allowed_ransackable_attributes = ['value']
|
15
15
|
|
16
16
|
# Whether the promotion code has exceeded its usage restrictions
|
17
17
|
#
|
@@ -28,10 +28,14 @@ class Spree::PromotionCode < Spree::Base
|
|
28
28
|
# @param excluded_orders [Array<Spree::Order>] Orders to exclude from usage count
|
29
29
|
# @return [Integer] usage count
|
30
30
|
def usage_count(excluded_orders: [])
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
promotion.
|
32
|
+
discounted_orders.
|
33
|
+
complete.
|
34
|
+
where.not(spree_orders: { state: :canceled }).
|
35
|
+
joins(:order_promotions).
|
36
|
+
where(spree_orders_promotions: { promotion_code_id: self.id }).
|
37
|
+
where.not(id: excluded_orders.map(&:id)).
|
38
|
+
count
|
35
39
|
end
|
36
40
|
|
37
41
|
def usage_limit
|
@@ -33,23 +33,43 @@ module Spree
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def promotions
|
36
|
-
connected_order_promotions | sale_promotions
|
36
|
+
promos = connected_order_promotions | sale_promotions
|
37
|
+
promos.flat_map(&:promotion_actions).group_by(&:preload_relations).each do |preload_relations, actions|
|
38
|
+
preload(records: actions, associations: preload_relations)
|
39
|
+
end
|
40
|
+
promos.flat_map(&:promotion_rules).group_by(&:preload_relations).each do |preload_relations, rules|
|
41
|
+
preload(records: rules, associations: preload_relations)
|
42
|
+
end
|
43
|
+
promos
|
44
|
+
end
|
45
|
+
|
46
|
+
def preload(records:, associations:)
|
47
|
+
if Rails::VERSION::MAJOR >= 7
|
48
|
+
ActiveRecord::Associations::Preloader.new(records: records, associations: associations).call
|
49
|
+
else
|
50
|
+
ActiveRecord::Associations::Preloader.new.preload(records, associations)
|
51
|
+
end
|
37
52
|
end
|
38
53
|
|
39
54
|
def connected_order_promotions
|
40
|
-
|
41
|
-
joins(:order_promotions).
|
42
|
-
where(spree_orders_promotions: { order_id: order.id }).readonly(false).to_a
|
55
|
+
order.promotions.active.includes(promotion_includes)
|
43
56
|
end
|
44
57
|
|
45
58
|
def sale_promotions
|
46
|
-
Spree::Promotion.where(apply_automatically: true).active.includes(
|
59
|
+
Spree::Promotion.where(apply_automatically: true).active.includes(promotion_includes)
|
47
60
|
end
|
48
61
|
|
49
62
|
def promotion_code(promotion)
|
50
|
-
order_promotion =
|
63
|
+
order_promotion = order.order_promotions.detect { |op| op.promotion_id == promotion.id }
|
51
64
|
order_promotion.present? ? order_promotion.promotion_code : nil
|
52
65
|
end
|
66
|
+
|
67
|
+
def promotion_includes
|
68
|
+
[
|
69
|
+
:promotion_rules,
|
70
|
+
:promotion_actions,
|
71
|
+
]
|
72
|
+
end
|
53
73
|
end
|
54
74
|
end
|
55
75
|
end
|
@@ -14,9 +14,14 @@ module Spree
|
|
14
14
|
validates :promotion, presence: true
|
15
15
|
validate :unique_per_promotion, on: :create
|
16
16
|
|
17
|
+
def preload_relations
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
|
17
21
|
def self.for(promotable)
|
18
22
|
all.select { |rule| rule.applicable?(promotable) }
|
19
23
|
end
|
24
|
+
deprecate :for, "Please select promotion rules by their applicable status on the promotable instead."
|
20
25
|
|
21
26
|
def applicable?(_promotable)
|
22
27
|
raise NotImplementedError, "applicable? should be implemented in a sub-class of Spree::PromotionRule"
|
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
|
|
@@ -36,6 +31,14 @@ module Spree
|
|
36
31
|
end
|
37
32
|
end
|
38
33
|
|
34
|
+
# Sets this price's amount to a new value, parsing it if the new value is
|
35
|
+
# a string.
|
36
|
+
#
|
37
|
+
# @param price [String, #to_d] a new amount
|
38
|
+
def amount=(price)
|
39
|
+
self[:amount] = Spree::LocalizedNumber.parse(price)
|
40
|
+
end
|
41
|
+
|
39
42
|
def description
|
40
43
|
payment.payment_method.name
|
41
44
|
end
|
@@ -45,29 +48,14 @@ module Spree
|
|
45
48
|
# Attempts to perform the refund,
|
46
49
|
# raises an error if the refund fails.
|
47
50
|
def perform!
|
48
|
-
return true if perform_after_create == false
|
49
51
|
return true if transaction_id.present?
|
50
52
|
|
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
53
|
credit_cents = money.cents
|
56
54
|
|
57
55
|
@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
56
|
log_entries.build(details: perform_response.to_yaml)
|
68
57
|
|
69
58
|
self.transaction_id = perform_response.authorization
|
70
|
-
|
71
59
|
save!
|
72
60
|
|
73
61
|
update_order
|
@@ -75,38 +63,6 @@ module Spree
|
|
75
63
|
|
76
64
|
private
|
77
65
|
|
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
66
|
# return an activemerchant response object if successful or else raise an error
|
111
67
|
def process!(credit_cents)
|
112
68
|
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)
|
@@ -103,22 +92,10 @@ module Spree
|
|
103
92
|
|
104
93
|
if unpaid_amount_within_tolerance?
|
105
94
|
reimbursed!
|
106
|
-
Spree::
|
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 }
|
95
|
+
Spree::Bus.publish :reimbursement_reimbursed, reimbursement: self
|
113
96
|
else
|
114
97
|
errored!
|
115
|
-
Spree::
|
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 }
|
98
|
+
Spree::Bus.publish :reimbursement_errored, reimbursement: 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
|
-
self.
|
30
|
+
self.allowed_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)
|
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
self.refund_amount_calculator = Calculator::Returns::DefaultRefundAmount
|
31
31
|
|
32
32
|
belongs_to :return_authorization, inverse_of: :return_items, optional: true
|
33
|
-
belongs_to :inventory_unit, inverse_of: :return_items
|
33
|
+
belongs_to :inventory_unit, inverse_of: :return_items
|
34
34
|
belongs_to :exchange_variant, class_name: 'Spree::Variant', optional: true
|
35
35
|
belongs_to :exchange_inventory_unit, class_name: 'Spree::InventoryUnit', inverse_of: :original_return_item, optional: true
|
36
36
|
belongs_to :customer_return, inverse_of: :return_items, optional: true
|
@@ -42,7 +42,6 @@ module Spree
|
|
42
42
|
validate :eligible_exchange_variant
|
43
43
|
validate :belongs_to_same_customer_order
|
44
44
|
validate :validate_acceptance_status_for_reimbursement
|
45
|
-
validates :inventory_unit, presence: true
|
46
45
|
validate :validate_no_other_completed_return_items
|
47
46
|
|
48
47
|
after_create :cancel_others, unless: :cancelled?
|
@@ -81,8 +80,7 @@ module Spree
|
|
81
80
|
include ::Spree::Config.state_machines.return_item_acceptance
|
82
81
|
|
83
82
|
extend DisplayMoney
|
84
|
-
money_methods :
|
85
|
-
deprecate display_pre_tax_amount: :display_total_excluding_vat, deprecator: Spree::Deprecation
|
83
|
+
money_methods :amount, :total, :total_excluding_vat
|
86
84
|
|
87
85
|
# @return [Boolean] true when this retur item is in a complete reception
|
88
86
|
# state
|
@@ -90,14 +88,6 @@ module Spree
|
|
90
88
|
COMPLETED_RECEPTION_STATUSES.map(&:to_s).include?(reception_status.to_s)
|
91
89
|
end
|
92
90
|
|
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
91
|
# @param inventory_unit [Spree::InventoryUnit] the inventory for which we
|
102
92
|
# want a return item
|
103
93
|
# @return [Spree::ReturnItem] a valid return item for the given inventory
|
@@ -134,8 +124,6 @@ module Spree
|
|
134
124
|
def total_excluding_vat
|
135
125
|
amount - included_tax_total
|
136
126
|
end
|
137
|
-
alias pre_tax_amount total_excluding_vat
|
138
|
-
deprecate pre_tax_amount: :total_excluding_vat, deprecator: Spree::Deprecation
|
139
127
|
|
140
128
|
# @note This uses the exchange_variant_engine configured on the class.
|
141
129
|
# @param stock_locations [Array<Spree::StockLocation>] the stock locations to check
|
@@ -206,13 +194,6 @@ module Spree
|
|
206
194
|
customer_return.stock_location.restock(inventory_unit.variant, 1, customer_return)
|
207
195
|
end
|
208
196
|
|
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
197
|
customer_return&.process_return!
|
217
198
|
end
|
218
199
|
|
@@ -272,10 +253,9 @@ module Spree
|
|
272
253
|
}).where.not(id: id).first
|
273
254
|
|
274
255
|
if other_return_item && (new_record? || COMPLETED_RECEPTION_STATUSES.include?(reception_status.to_sym))
|
275
|
-
errors.add(:inventory_unit, :other_completed_return_item_exists,
|
256
|
+
errors.add(:inventory_unit, :other_completed_return_item_exists,
|
276
257
|
inventory_unit_id: inventory_unit_id,
|
277
|
-
return_item_id: other_return_item.id
|
278
|
-
})
|
258
|
+
return_item_id: other_return_item.id)
|
279
259
|
end
|
280
260
|
end
|
281
261
|
|
@@ -41,8 +41,8 @@ module Spree
|
|
41
41
|
|
42
42
|
include ::Spree::Config.state_machines.shipment
|
43
43
|
|
44
|
-
self.
|
45
|
-
self.
|
44
|
+
self.allowed_ransackable_associations = ['order']
|
45
|
+
self.allowed_ransackable_attributes = ['number']
|
46
46
|
|
47
47
|
delegate :tax_category, :tax_category_id, to: :selected_shipping_rate, allow_nil: true
|
48
48
|
|
@@ -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
|
@@ -6,11 +6,6 @@ module Spree
|
|
6
6
|
class ShippingMethod < Spree::Base
|
7
7
|
include Spree::SoftDeletable
|
8
8
|
include Spree::CalculatedAdjustments
|
9
|
-
DISPLAY = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
|
10
|
-
[:both, :front_end, :back_end],
|
11
|
-
"Spree::ShippingMethod::DISPLAY is deprecated",
|
12
|
-
Spree::Deprecation
|
13
|
-
)
|
14
9
|
|
15
10
|
has_many :shipping_method_categories, dependent: :destroy
|
16
11
|
has_many :shipping_categories, through: :shipping_method_categories
|
@@ -95,26 +90,6 @@ module Spree
|
|
95
90
|
tracking_url.gsub(/:tracking/, ERB::Util.url_encode(tracking)) # :url_encode exists in 1.8.7 through 2.1.0
|
96
91
|
end
|
97
92
|
|
98
|
-
def display_on
|
99
|
-
if available_to_users?
|
100
|
-
"both"
|
101
|
-
else
|
102
|
-
"back_end"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
deprecate display_on: :available_to_users?, deprecator: Spree::Deprecation
|
106
|
-
|
107
|
-
def display_on=(value)
|
108
|
-
self.available_to_users = (value != "back_end")
|
109
|
-
end
|
110
|
-
deprecate 'display_on=': :available_to_users=, deprecator: Spree::Deprecation
|
111
|
-
|
112
|
-
# Some shipping methods are only meant to be set via backend
|
113
|
-
def frontend?
|
114
|
-
available_to_users?
|
115
|
-
end
|
116
|
-
deprecate frontend?: :available_to_users?, deprecator: Spree::Deprecation
|
117
|
-
|
118
93
|
private
|
119
94
|
|
120
95
|
def at_least_one_shipping_category
|
@@ -19,8 +19,6 @@ module Spree
|
|
19
19
|
delegate :code, to: :shipping_method, prefix: true
|
20
20
|
alias_attribute :amount, :cost
|
21
21
|
|
22
|
-
alias_method :discounted_amount, :amount
|
23
|
-
deprecate discounted_amount: :total_before_tax, deprecator: Spree::Deprecation
|
24
22
|
alias_method :total_before_tax, :amount
|
25
23
|
|
26
24
|
extend DisplayMoney
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
# @attr [Spree::ShippingRate] shipping_rate The shipping rate to be taxed
|
6
6
|
# @attr [Spree::TaxRate] tax_rate The tax rate used to calculate the tax amount
|
7
7
|
# @since 1.3.0
|
8
|
-
# @see Spree::
|
8
|
+
# @see Spree::Stock::Estimator
|
9
9
|
class ShippingRateTax < Spree::Base
|
10
10
|
belongs_to :shipping_rate, class_name: "Spree::ShippingRate", optional: true
|
11
11
|
belongs_to :tax_rate, class_name: "Spree::TaxRate", optional: true
|
data/app/models/spree/state.rb
CHANGED
@@ -14,12 +14,8 @@ module Spree
|
|
14
14
|
)
|
15
15
|
)
|
16
16
|
end
|
17
|
-
class << self
|
18
|
-
alias_method :find_all_by_name_or_abbr, :with_name_or_abbr
|
19
|
-
deprecate find_all_by_name_or_abbr: :with_name_or_abbr, deprecator: Spree::Deprecation
|
20
|
-
end
|
21
17
|
|
22
|
-
self.
|
18
|
+
self.allowed_ransackable_attributes = %w[name]
|
23
19
|
|
24
20
|
# table of { country.id => [ state.id , state.name ] }, arrays sorted by name
|
25
21
|
# blank is added elsewhere, if needed
|
@@ -7,11 +7,11 @@ module Spree
|
|
7
7
|
def allocate_inventory(desired)
|
8
8
|
# Allocate any available on hand inventory
|
9
9
|
on_hand = allocate_on_hand(desired)
|
10
|
-
desired -= on_hand.values.
|
10
|
+
desired -= on_hand.values.reduce(&:+) if on_hand.present?
|
11
11
|
|
12
12
|
# Allocate remaining desired inventory from backorders
|
13
13
|
backordered = allocate_backordered(desired)
|
14
|
-
desired -= backordered.values.
|
14
|
+
desired -= backordered.values.reduce(&:+) if backordered.present?
|
15
15
|
|
16
16
|
# If all works at this point desired must be empty
|
17
17
|
[on_hand, backordered, desired]
|