solidus_core 4.3.5 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +2 -2
- data/app/mailers/spree/base_mailer.rb +1 -1
- data/app/mailers/spree/carton_mailer.rb +1 -1
- data/app/mailers/spree/order_mailer.rb +3 -3
- data/app/mailers/spree/reimbursement_mailer.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter/normalization.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter.rb +1 -1
- data/app/models/concerns/spree/display_money.rb +1 -1
- data/app/models/concerns/spree/ordered_property_value_list.rb +2 -2
- data/app/models/concerns/spree/user_address_book.rb +4 -4
- data/app/models/concerns/spree/user_methods.rb +3 -3
- data/app/models/spree/address.rb +6 -6
- data/app/models/spree/adjustment.rb +13 -66
- data/app/models/spree/calculator/returns/default_refund_amount.rb +1 -1
- data/app/models/spree/carton.rb +2 -2
- data/app/models/spree/credit_card.rb +6 -6
- data/app/models/spree/deprecated_configurable_class.rb +40 -0
- data/app/models/spree/fulfilment_changer.rb +4 -4
- data/app/models/spree/inventory_unit.rb +2 -2
- data/app/models/spree/line_item.rb +1 -4
- data/app/models/spree/null_promotion_adjuster.rb +13 -0
- data/app/models/spree/null_promotion_advertiser.rb +9 -0
- data/app/models/spree/null_promotion_finder.rb +9 -0
- data/app/models/spree/null_promotion_handler.rb +44 -0
- data/app/models/spree/order.rb +15 -22
- data/app/models/spree/order_cancellations.rb +8 -8
- data/app/models/spree/order_mutex.rb +2 -2
- data/app/models/spree/order_shipping.rb +9 -9
- data/app/models/spree/order_updater.rb +6 -10
- data/app/models/spree/payment/processing.rb +2 -2
- data/app/models/spree/payment.rb +2 -2
- data/app/models/spree/payment_create.rb +1 -1
- data/app/models/spree/payment_method/store_credit.rb +1 -1
- data/app/models/spree/payment_source.rb +5 -1
- data/app/models/spree/permission_set.rb +11 -0
- data/app/models/spree/product.rb +7 -28
- data/app/models/spree/refund.rb +1 -1
- data/app/models/spree/reimbursement.rb +4 -4
- data/app/models/spree/reimbursement_performer.rb +3 -3
- data/app/models/spree/reimbursement_tax_calculator.rb +2 -2
- data/app/models/spree/reimbursement_type/credit.rb +1 -1
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +6 -6
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -1
- data/app/models/spree/return_item.rb +9 -9
- data/app/models/spree/role.rb +3 -1
- data/app/models/spree/role_permission.rb +8 -0
- data/app/models/spree/shipment.rb +7 -7
- data/app/models/spree/shipping_category.rb +2 -0
- data/app/models/spree/shipping_rate.rb +1 -1
- data/app/models/spree/{order_contents.rb → simple_order_contents.rb} +4 -11
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/inventory_unit_builder.rb +1 -1
- data/app/models/spree/stock/package.rb +2 -2
- data/app/models/spree/stock/simple_coordinator.rb +1 -1
- data/app/models/spree/stock_location.rb +5 -5
- data/app/models/spree/store.rb +1 -1
- data/app/models/spree/store_credit.rb +15 -15
- data/app/models/spree/store_credit_event.rb +3 -3
- data/app/models/spree/tax_calculator/default.rb +2 -2
- data/app/models/spree/tax_calculator/shipping_rate.rb +1 -1
- data/app/models/spree/tax_category.rb +3 -1
- data/app/models/spree/tax_rate.rb +3 -3
- data/app/models/spree/taxonomy.rb +2 -2
- data/app/models/spree/unit_cancel.rb +1 -2
- data/app/models/spree/variant/vat_price_generator.rb +1 -1
- data/app/models/spree/variant.rb +7 -2
- data/app/models/spree/wallet.rb +2 -2
- data/app/views/spree/order_mailer/cancel_email.html.erb +1 -1
- data/app/views/spree/order_mailer/cancel_email.text.erb +1 -1
- data/app/views/spree/order_mailer/confirm_email.html.erb +5 -5
- data/app/views/spree/order_mailer/confirm_email.text.erb +5 -5
- data/config/locales/en.yml +4 -90
- data/db/default/spree/permission_sets.rb +10 -0
- data/db/default/spree/return_reasons.rb +3 -1
- data/db/default/spree/states.rb +1 -1
- data/db/migrate/20160101010000_solidus_one_four.rb +0 -127
- data/db/migrate/20240821173254_create_spree_permission_sets_in_core.rb +9 -0
- data/db/migrate/20240821173341_create_spree_roles_permissions_in_core.rb +9 -0
- data/db/migrate/20240821173641_add_description_to_spree_roles.rb +5 -0
- data/db/migrate/20240904152041_add_privilege_and_category_to_spree_permission_sets.rb +6 -0
- data/db/seeds.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -1
- data/lib/generators/solidus/update/update_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/test.rb +6 -1
- data/lib/spree/app_configuration.rb +53 -84
- data/lib/spree/core/class_constantizer.rb +2 -2
- data/lib/spree/core/controller_helpers/payment_parameters.rb +1 -1
- data/lib/spree/core/engine.rb +1 -0
- data/lib/spree/core/environment/calculators.rb +35 -3
- data/lib/spree/core/environment/promotions.rb +25 -4
- data/lib/spree/core/environment_extension.rb +16 -2
- data/lib/spree/core/importer/order.rb +5 -5
- data/lib/spree/core/importer/product.rb +3 -3
- data/lib/spree/core/nested_class_set.rb +28 -0
- data/lib/spree/core/null_promotion_configuration.rb +84 -0
- data/lib/spree/core/product_filters.rb +1 -1
- data/lib/spree/core/search/variant.rb +2 -2
- data/lib/spree/core/state_machines/order.rb +0 -1
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +2 -6
- data/lib/spree/deprecator.rb +9 -0
- data/lib/spree/i18n.rb +1 -1
- data/lib/spree/mailer_previews/carton_preview.rb +1 -1
- data/lib/spree/permission_sets/base.rb +13 -1
- data/lib/spree/permission_sets/configuration_display.rb +10 -0
- data/lib/spree/permission_sets/configuration_management.rb +10 -0
- data/lib/spree/permission_sets/dashboard_display.rb +12 -0
- data/lib/spree/permission_sets/default_customer.rb +11 -1
- data/lib/spree/permission_sets/order_display.rb +10 -0
- data/lib/spree/permission_sets/order_management.rb +10 -0
- data/lib/spree/permission_sets/product_display.rb +10 -0
- data/lib/spree/permission_sets/product_management.rb +10 -0
- data/lib/spree/permission_sets/restricted_stock_display.rb +10 -0
- data/lib/spree/permission_sets/restricted_stock_management.rb +10 -0
- data/lib/spree/permission_sets/stock_display.rb +10 -0
- data/lib/spree/permission_sets/stock_management.rb +10 -0
- data/lib/spree/permission_sets/super_user.rb +10 -0
- data/lib/spree/permission_sets/user_display.rb +10 -0
- data/lib/spree/permission_sets/user_management.rb +10 -0
- data/lib/spree/permission_sets.rb +0 -2
- data/lib/spree/permitted_attributes.rb +2 -2
- data/lib/spree/preferences/store.rb +2 -2
- data/lib/spree/testing_support/capybara_ext.rb +1 -1
- data/lib/spree/testing_support/dummy_ability.rb +7 -0
- data/lib/spree/testing_support/dummy_app/database.yml +2 -2
- data/lib/spree/testing_support/dummy_app/migrations.rb +8 -15
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +2 -2
- data/lib/spree/testing_support/dummy_app.rb +17 -12
- data/lib/spree/testing_support/factories/adjustment_factory.rb +1 -2
- data/lib/spree/testing_support/factories/calculator_factory.rb +1 -5
- data/lib/spree/testing_support/factories/carton_factory.rb +2 -2
- data/lib/spree/testing_support/factories/customer_return_factory.rb +2 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +3 -3
- data/lib/spree/testing_support/factories/order_factory.rb +5 -24
- data/lib/spree/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +5 -1
- data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
- data/lib/spree/testing_support/factories/user_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_factory.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +3 -3
- data/lib/spree/testing_support/shared_examples/calculator.rb +10 -0
- data/lib/spree/testing_support/shared_examples/order_factory.rb +141 -0
- data/lib/spree/testing_support/shared_examples/working_factory.rb +15 -0
- data/lib/tasks/colorado_delivery_fee.rake +2 -2
- data/solidus_core.gemspec +7 -7
- metadata +60 -93
- data/app/jobs/spree/promotion_code_batch_job.rb +0 -26
- data/app/mailers/spree/promotion_code_batch_mailer.rb +0 -15
- data/app/models/spree/calculator/distributed_amount.rb +0 -33
- data/app/models/spree/calculator/flat_percent_item_total.rb +0 -23
- data/app/models/spree/calculator/flexi_rate.rb +0 -22
- data/app/models/spree/calculator/percent_on_line_item.rb +0 -13
- data/app/models/spree/calculator/tiered_flat_rate.rb +0 -52
- data/app/models/spree/calculator/tiered_percent.rb +0 -62
- data/app/models/spree/line_item_action.rb +0 -8
- data/app/models/spree/order_promotion.rb +0 -27
- data/app/models/spree/promotion/actions/create_adjustment.rb +0 -81
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -98
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -139
- data/app/models/spree/promotion/actions/free_shipping.rb +0 -59
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +0 -92
- data/app/models/spree/promotion/rules/first_order.rb +0 -38
- data/app/models/spree/promotion/rules/first_repeat_purchase_since.rb +0 -36
- data/app/models/spree/promotion/rules/item_total.rb +0 -86
- data/app/models/spree/promotion/rules/minimum_quantity.rb +0 -59
- data/app/models/spree/promotion/rules/nth_order.rb +0 -45
- data/app/models/spree/promotion/rules/one_use_per_user.rb +0 -25
- data/app/models/spree/promotion/rules/option_value.rb +0 -50
- data/app/models/spree/promotion/rules/product.rb +0 -86
- data/app/models/spree/promotion/rules/store.rb +0 -26
- data/app/models/spree/promotion/rules/taxon.rb +0 -91
- data/app/models/spree/promotion/rules/user.rb +0 -34
- data/app/models/spree/promotion/rules/user_logged_in.rb +0 -20
- data/app/models/spree/promotion/rules/user_role.rb +0 -45
- data/app/models/spree/promotion.rb +0 -271
- data/app/models/spree/promotion_action.rb +0 -47
- data/app/models/spree/promotion_category.rb +0 -8
- data/app/models/spree/promotion_chooser.rb +0 -34
- data/app/models/spree/promotion_code/batch_builder.rb +0 -64
- data/app/models/spree/promotion_code.rb +0 -54
- data/app/models/spree/promotion_code_batch.rb +0 -27
- data/app/models/spree/promotion_handler/cart.rb +0 -75
- data/app/models/spree/promotion_handler/coupon.rb +0 -123
- data/app/models/spree/promotion_handler/page.rb +0 -26
- data/app/models/spree/promotion_handler/shipping.rb +0 -61
- data/app/models/spree/promotion_rule.rb +0 -55
- data/app/models/spree/promotion_rule_store.rb +0 -10
- data/app/models/spree/promotion_rule_taxon.rb +0 -8
- data/app/models/spree/promotion_rule_user.rb +0 -10
- data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +0 -2
- data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +0 -2
- data/bin/rails +0 -13
- data/db/migrate/20161017102621_create_spree_promotion_code_batch.rb +0 -38
- data/db/migrate/20180202190713_create_promotion_rule_stores.rb +0 -12
- data/db/migrate/20180328172631_add_join_characters_to_promotion_code_batch.rb +0 -11
- data/db/migrate/20190106184413_remove_code_from_spree_promotions.rb +0 -42
- data/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb +0 -20
- data/db/migrate/20230322085416_remove_match_policy_from_spree_promotion.rb +0 -5
- data/db/migrate/20230325132905_remove_unused_columns_from_promotion_rules.rb +0 -6
- data/db/migrate/20230325161633_drop_unused_promo_action_line_items.rb +0 -13
- data/db/migrate/20231027084517_add_order_promotions_foreign_key.rb +0 -10
- data/db/migrate/20231031175215_add_promotion_order_promotion_foreign_key.rb +0 -10
- data/lib/solidus/migrations/promotions_with_code_handlers.rb +0 -66
- data/lib/spree/permission_sets/promotion_display.rb +0 -25
- data/lib/spree/permission_sets/promotion_management.rb +0 -25
- data/lib/spree/ransack_4_1_patch.rb +0 -16
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +0 -7
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_factory.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26085f8db02874db3e6107dee9429c843c213f42d32a55a71a10cba46acf75b7
|
4
|
+
data.tar.gz: bc4bf5cfb609e38878f5abbac50be9d6565b5ca555f19bf662506b42992f0312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0c721a6c89879768639749bb8f3ff110beb622b2d93442ec77e3a5ef1e4511def197a38aecd436ec9e1962821d0a26b8a5348499f9696b467be1bf32441c6bd
|
7
|
+
data.tar.gz: d6e9c27b1441d31ffd3c25a6e205a38c363d7b6c1dc63e69db3bea9c74370552ab63bdd61632faec39a690cf836be1f97f94a6ad54547f0eb235de6e6e3075a7
|
@@ -48,7 +48,7 @@ module Spree
|
|
48
48
|
|
49
49
|
def meta_data_tags
|
50
50
|
meta_data.map do |name, content|
|
51
|
-
tag('meta', name
|
51
|
+
tag('meta', name:, content:)
|
52
52
|
end.join("\n")
|
53
53
|
end
|
54
54
|
|
@@ -111,7 +111,7 @@ module Spree
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def available_countries(restrict_to_zone: Spree::Config[:checkout_zone])
|
114
|
-
countries = Spree::Country.available(restrict_to_zone:
|
114
|
+
countries = Spree::Country.available(restrict_to_zone:)
|
115
115
|
|
116
116
|
country_names = Carmen::Country.all.map do |country|
|
117
117
|
[country.code, country.name]
|
@@ -19,7 +19,7 @@ module Spree
|
|
19
19
|
@store = @order.store
|
20
20
|
subject = (options[:resend] ? "[#{t('spree.resend').upcase}] " : '')
|
21
21
|
subject += "#{@store.name} #{t('spree.shipment_mailer.shipped_email.subject')} ##{@order.number}"
|
22
|
-
mail(to: @order.email, from: from_address(@store), subject:
|
22
|
+
mail(to: @order.email, from: from_address(@store), subject:)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
@store = @order.store
|
8
8
|
subject = build_subject(t('.subject'), resend)
|
9
9
|
|
10
|
-
mail(to: @order.email, bcc: bcc_address(@store), from: from_address(@store), subject:
|
10
|
+
mail(to: @order.email, bcc: bcc_address(@store), from: from_address(@store), subject:)
|
11
11
|
end
|
12
12
|
|
13
13
|
def cancel_email(order, resend = false)
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
@store = @order.store
|
16
16
|
subject = build_subject(t('.subject'), resend)
|
17
17
|
|
18
|
-
mail(to: @order.email, from: from_address(@store), subject:
|
18
|
+
mail(to: @order.email, from: from_address(@store), subject:)
|
19
19
|
end
|
20
20
|
|
21
21
|
def inventory_cancellation_email(order, inventory_units, resend = false)
|
@@ -23,7 +23,7 @@ module Spree
|
|
23
23
|
@store = @order.store
|
24
24
|
subject = build_subject(t('spree.order_mailer.inventory_cancellation.subject'), resend)
|
25
25
|
|
26
|
-
mail(to: @order.email, from: from_address(@store), subject:
|
26
|
+
mail(to: @order.email, from: from_address(@store), subject:)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
store = @reimbursement.order.store
|
8
8
|
subject = (resend ? "[#{t('spree.resend').upcase}] " : '')
|
9
9
|
subject += "#{store.name} #{t('.subject')} ##{@reimbursement.order.number}"
|
10
|
-
mail(to: @reimbursement.order.email, from: from_address(store), subject:
|
10
|
+
mail(to: @reimbursement.order.email, from: from_address(store), subject:)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -24,7 +24,7 @@ module Spree
|
|
24
24
|
money_method = { money_method => {} } unless money_method.is_a? Hash
|
25
25
|
money_method.each do |method_name, opts|
|
26
26
|
define_method("display_#{method_name}") do
|
27
|
-
default_opts = respond_to?(:currency) ? { currency:
|
27
|
+
default_opts = respond_to?(:currency) ? { currency: } : {}
|
28
28
|
Spree::Money.new(send(method_name), default_opts.merge(opts))
|
29
29
|
end
|
30
30
|
end
|
@@ -18,8 +18,8 @@ module Spree
|
|
18
18
|
|
19
19
|
def property_name=(name)
|
20
20
|
unless name.blank?
|
21
|
-
unless property = Spree::Property.find_by(name:
|
22
|
-
property = Spree::Property.create(name
|
21
|
+
unless property = Spree::Property.find_by(name:)
|
22
|
+
property = Spree::Property.create(name:, presentation: name)
|
23
23
|
end
|
24
24
|
self.property = property
|
25
25
|
end
|
@@ -120,7 +120,7 @@ module Spree
|
|
120
120
|
remove_from_address_book(address_attributes[:id])
|
121
121
|
end
|
122
122
|
|
123
|
-
user_addresses.mark_default(user_address, address_type:
|
123
|
+
user_addresses.mark_default(user_address, address_type:) if default || first_one
|
124
124
|
|
125
125
|
if persisted?
|
126
126
|
user_address.save!
|
@@ -140,15 +140,15 @@ module Spree
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def mark_default_ship_address(address)
|
143
|
-
user_addresses.mark_default(user_addresses.find_by(address:
|
143
|
+
user_addresses.mark_default(user_addresses.find_by(address:))
|
144
144
|
end
|
145
145
|
|
146
146
|
def mark_default_bill_address(address)
|
147
|
-
user_addresses.mark_default(user_addresses.find_by(address:
|
147
|
+
user_addresses.mark_default(user_addresses.find_by(address:), address_type: :billing)
|
148
148
|
end
|
149
149
|
|
150
150
|
def remove_from_address_book(address_id)
|
151
|
-
user_address = user_addresses.find_by(address_id:
|
151
|
+
user_address = user_addresses.find_by(address_id:)
|
152
152
|
if user_address
|
153
153
|
remove_user_address_reference(address_id)
|
154
154
|
user_address.update(archived: true, default: false)
|
@@ -58,7 +58,7 @@ module Spree
|
|
58
58
|
def last_incomplete_spree_order(store: nil, only_frontend_viewable: true)
|
59
59
|
self_orders = orders
|
60
60
|
self_orders = self_orders.where(frontend_viewable: true) if only_frontend_viewable
|
61
|
-
self_orders = self_orders.where(store:
|
61
|
+
self_orders = self_orders.where(store:) if store
|
62
62
|
self_orders = self_orders.where('updated_at > ?', Spree::Config.completable_order_updated_cutoff_days.days.ago) if Spree::Config.completable_order_updated_cutoff_days
|
63
63
|
self_orders = self_orders.where('created_at > ?', Spree::Config.completable_order_created_cutoff_days.days.ago) if Spree::Config.completable_order_created_cutoff_days
|
64
64
|
last_order = self_orders.order(:created_at).last
|
@@ -73,8 +73,8 @@ module Spree
|
|
73
73
|
|
74
74
|
def display_available_store_credit_total(currency:)
|
75
75
|
Spree::Money.new(
|
76
|
-
available_store_credit_total(currency:
|
77
|
-
currency
|
76
|
+
available_store_credit_total(currency:),
|
77
|
+
currency:,
|
78
78
|
)
|
79
79
|
end
|
80
80
|
|
data/app/models/spree/address.rb
CHANGED
@@ -97,14 +97,14 @@ module Spree
|
|
97
97
|
# @return [Hash] an ActiveMerchant compatible address hash
|
98
98
|
def active_merchant_hash
|
99
99
|
{
|
100
|
-
name
|
101
|
-
address1
|
102
|
-
address2
|
103
|
-
city
|
100
|
+
name:,
|
101
|
+
address1:,
|
102
|
+
address2:,
|
103
|
+
city:,
|
104
104
|
state: state_text,
|
105
105
|
zip: zipcode,
|
106
106
|
country: country.try(:iso),
|
107
|
-
phone:
|
107
|
+
phone:
|
108
108
|
}
|
109
109
|
end
|
110
110
|
|
@@ -132,7 +132,7 @@ module Spree
|
|
132
132
|
# @return [Country] setter that sets self.country to the Country with a matching 2 letter iso
|
133
133
|
# @raise [ActiveRecord::RecordNotFound] if country with the iso doesn't exist
|
134
134
|
def country_iso=(iso)
|
135
|
-
self.country = Spree::Country.find_by!(iso:
|
135
|
+
self.country = Spree::Country.find_by!(iso:)
|
136
136
|
end
|
137
137
|
|
138
138
|
def country_iso
|
@@ -4,29 +4,18 @@ module Spree
|
|
4
4
|
# Adjustments represent a change to the +item_total+ of an Order. Each
|
5
5
|
# adjustment has an +amount+ that can be either positive or negative.
|
6
6
|
#
|
7
|
-
# Adjustments can be "
|
7
|
+
# Adjustments can be "unfinalized" or "finalized". Once an adjustment is finalized, it
|
8
8
|
# will not be automatically updated.
|
9
|
-
#
|
10
|
-
# == Boolean attributes
|
11
|
-
#
|
12
|
-
# 1. *eligible?*
|
13
|
-
#
|
14
|
-
# This boolean attributes stores whether this adjustment is currently
|
15
|
-
# eligible for its order. Only eligible adjustments count towards the
|
16
|
-
# order's adjustment total. This allows an adjustment to be preserved if
|
17
|
-
# it becomes ineligible so it might be reinstated.
|
18
9
|
class Adjustment < Spree::Base
|
19
10
|
belongs_to :adjustable, polymorphic: true, touch: true, optional: true
|
20
11
|
belongs_to :source, polymorphic: true, optional: true
|
21
12
|
belongs_to :order, class_name: 'Spree::Order', inverse_of: :all_adjustments, optional: true
|
22
|
-
belongs_to :promotion_code, class_name: 'Spree::PromotionCode', optional: true
|
23
13
|
belongs_to :adjustment_reason, class_name: 'Spree::AdjustmentReason', inverse_of: :adjustments, optional: true
|
24
14
|
|
25
15
|
validates :adjustable, presence: true
|
26
16
|
validates :order, presence: true
|
27
17
|
validates :label, presence: true
|
28
18
|
validates :amount, numericality: true
|
29
|
-
validates :promotion_code, presence: true, if: :require_promotion_code?
|
30
19
|
|
31
20
|
scope :not_finalized, -> { where(finalized: false) }
|
32
21
|
scope :finalized, -> { where(finalized: true) }
|
@@ -38,18 +27,23 @@ module Spree
|
|
38
27
|
end
|
39
28
|
scope :price, -> { where(adjustable_type: 'Spree::LineItem') }
|
40
29
|
scope :shipping, -> { where(adjustable_type: 'Spree::Shipment') }
|
41
|
-
scope :eligible, -> {
|
30
|
+
scope :eligible, -> { all }
|
31
|
+
class << self
|
32
|
+
deprecate :eligible, deprecator: Spree.deprecator
|
33
|
+
end
|
42
34
|
scope :charge, -> { where("#{quoted_table_name}.amount >= 0") }
|
43
35
|
scope :credit, -> { where("#{quoted_table_name}.amount < 0") }
|
44
36
|
scope :nonzero, -> { where("#{quoted_table_name}.amount != 0") }
|
45
|
-
scope :promotion, -> { where(source_type:
|
46
|
-
scope :non_promotion, -> { where.not(source_type:
|
37
|
+
scope :promotion, -> { where(source_type: Spree::Config.adjustment_promotion_source_types.map(&:to_s)) }
|
38
|
+
scope :non_promotion, -> { where.not(source_type: Spree::Config.adjustment_promotion_source_types.map(&:to_s)) }
|
47
39
|
scope :return_authorization, -> { where(source_type: "Spree::ReturnAuthorization") }
|
48
40
|
scope :is_included, -> { where(included: true) }
|
49
41
|
scope :additional, -> { where(included: false) }
|
50
42
|
|
51
43
|
singleton_class.deprecate :return_authorization, deprecator: Spree.deprecator
|
52
44
|
|
45
|
+
allowed_ransackable_attributes << 'label'
|
46
|
+
|
53
47
|
extend DisplayMoney
|
54
48
|
money_methods :amount
|
55
49
|
|
@@ -75,7 +69,7 @@ module Spree
|
|
75
69
|
|
76
70
|
# @return [Boolean] true when this is a promotion adjustment (Promotion adjustments have a {PromotionAction} source)
|
77
71
|
def promotion?
|
78
|
-
source_type
|
72
|
+
source_type.to_s.in?(Spree::Config.adjustment_promotion_source_types.map(&:to_s))
|
79
73
|
end
|
80
74
|
|
81
75
|
# @return [Boolean] true when this is a tax adjustment (Tax adjustments have a {TaxRate} source)
|
@@ -88,56 +82,9 @@ module Spree
|
|
88
82
|
source_type == 'Spree::UnitCancel'
|
89
83
|
end
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
#
|
94
|
-
# If the adjustment has no source (such as when created manually from the
|
95
|
-
# admin) or is closed, this is a noop.
|
96
|
-
#
|
97
|
-
# @return [BigDecimal] New amount of this adjustment
|
98
|
-
def recalculate
|
99
|
-
if finalized? && !tax?
|
100
|
-
return amount
|
101
|
-
end
|
102
|
-
|
103
|
-
# If the adjustment has no source, do not attempt to re-calculate the
|
104
|
-
# amount.
|
105
|
-
# Some scenarios where this happens:
|
106
|
-
# - Adjustments that are manually created via the admin backend
|
107
|
-
# - PromotionAction adjustments where the PromotionAction was deleted
|
108
|
-
# after the order was completed.
|
109
|
-
if source.present?
|
110
|
-
self.amount = source.compute_amount(adjustable)
|
111
|
-
|
112
|
-
if promotion?
|
113
|
-
self.eligible = calculate_eligibility
|
114
|
-
end
|
115
|
-
|
116
|
-
# Persist only if changed
|
117
|
-
# This is only not a save! to avoid the extra queries to load the order
|
118
|
-
# (for validations) and to touch the adjustment.
|
119
|
-
update_columns(eligible: eligible, amount: amount, updated_at: Time.current) if changed?
|
120
|
-
end
|
121
|
-
amount
|
122
|
-
end
|
123
|
-
|
124
|
-
# Calculates based on attached promotion (if this is a promotion
|
125
|
-
# adjustment) whether this promotion is still eligible.
|
126
|
-
# @api private
|
127
|
-
# @return [true,false] Whether this adjustment is eligible
|
128
|
-
def calculate_eligibility
|
129
|
-
if !finalized? && source && promotion?
|
130
|
-
source.promotion.eligible?(adjustable, promotion_code: promotion_code)
|
131
|
-
else
|
132
|
-
eligible?
|
133
|
-
end
|
134
|
-
end
|
135
|
-
deprecate :calculate_eligibility, deprecator: Spree.deprecator
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def require_promotion_code?
|
140
|
-
promotion? && !source.promotion.apply_automatically && source.promotion.codes.any?
|
85
|
+
def eligible?
|
86
|
+
true
|
141
87
|
end
|
88
|
+
alias_method :eligible, :eligible?
|
142
89
|
end
|
143
90
|
end
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def weighted_order_adjustment_amount(inventory_unit)
|
17
|
-
inventory_unit.order.adjustments.
|
17
|
+
inventory_unit.order.adjustments.non_tax.sum(:amount) * percentage_of_order_total(inventory_unit)
|
18
18
|
end
|
19
19
|
|
20
20
|
def weighted_line_item_amount(inventory_unit)
|
data/app/models/spree/carton.rb
CHANGED
@@ -46,11 +46,11 @@ class Spree::Carton < Spree::Base
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def manifest
|
49
|
-
@manifest ||= Spree::ShippingManifest.new(inventory_units:
|
49
|
+
@manifest ||= Spree::ShippingManifest.new(inventory_units:).items
|
50
50
|
end
|
51
51
|
|
52
52
|
def manifest_for_order(order)
|
53
|
-
Spree::ShippingManifest.new(inventory_units:
|
53
|
+
Spree::ShippingManifest.new(inventory_units:).for_order(order).items
|
54
54
|
end
|
55
55
|
|
56
56
|
def any_exchanges?
|
@@ -155,12 +155,12 @@ module Spree
|
|
155
155
|
# card that represents this credit card
|
156
156
|
def to_active_merchant
|
157
157
|
ActiveMerchant::Billing::CreditCard.new(
|
158
|
-
number
|
159
|
-
month
|
160
|
-
year
|
161
|
-
verification_value
|
162
|
-
first_name
|
163
|
-
last_name:
|
158
|
+
number:,
|
159
|
+
month:,
|
160
|
+
year:,
|
161
|
+
verification_value:,
|
162
|
+
first_name:,
|
163
|
+
last_name:
|
164
164
|
)
|
165
165
|
end
|
166
166
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
class DeprecatedConfigurableClass
|
5
|
+
def self.new(*_args, &_block)
|
6
|
+
@deprecation_proxy ||= DeprecationProxy.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.method_missing(method_name, *args, &block)
|
10
|
+
@deprecation_proxy ||= DeprecationProxy.new
|
11
|
+
@deprecation_proxy.send(method_name, args, block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.respond_to_missing?(_method_name, _include_private = false)
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
class DeprecationProxy
|
19
|
+
def method_missing(_method_name, *_args, &_block)
|
20
|
+
issue_deprecation_warning
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to_missing?(_method_name, _include_private = false)
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def issue_deprecation_warning
|
31
|
+
Spree.deprecator.warn(
|
32
|
+
<<-WARNING
|
33
|
+
It appears you are using Solidus' Legacy promotion system. This system has been extracted into the
|
34
|
+
`solidus_legacy_promotions` gem. Please add the gem to your Gemfile and follow in the instructions in the README.
|
35
|
+
WARNING
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -107,14 +107,14 @@ module Spree
|
|
107
107
|
# We order by state, because `'backordered' < 'on_hand'`.
|
108
108
|
current_shipment.
|
109
109
|
inventory_units.
|
110
|
-
where(variant:
|
110
|
+
where(variant:).
|
111
111
|
order(state: :asc).
|
112
112
|
limit(new_on_hand_quantity).
|
113
113
|
update_all(shipment_id: desired_shipment.id, state: :on_hand)
|
114
114
|
|
115
115
|
current_shipment.
|
116
116
|
inventory_units.
|
117
|
-
where(variant:
|
117
|
+
where(variant:).
|
118
118
|
order(state: :asc).
|
119
119
|
limit(quantity - new_on_hand_quantity).
|
120
120
|
update_all(shipment_id: desired_shipment.id, state: :backordered)
|
@@ -127,7 +127,7 @@ module Spree
|
|
127
127
|
ActiveRecord::Base.transaction do
|
128
128
|
current_shipment.
|
129
129
|
inventory_units.
|
130
|
-
where(variant:
|
130
|
+
where(variant:).
|
131
131
|
order(state: :asc).
|
132
132
|
limit(quantity).
|
133
133
|
update_all(shipment_id: desired_shipment.id)
|
@@ -145,7 +145,7 @@ module Spree
|
|
145
145
|
if current_stock_location != desired_stock_location
|
146
146
|
0
|
147
147
|
else
|
148
|
-
current_shipment.inventory_units.where(variant:
|
148
|
+
current_shipment.inventory_units.where(variant:).on_hand.count
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -64,7 +64,7 @@ module Spree
|
|
64
64
|
# stock location that is associated with this inventory unit's variant
|
65
65
|
def find_stock_item
|
66
66
|
Spree::StockItem.where(stock_location_id: shipment.stock_location_id,
|
67
|
-
variant_id:
|
67
|
+
variant_id:).first
|
68
68
|
end
|
69
69
|
|
70
70
|
# @return [Spree::ReturnItem] a valid return item for this inventory unit
|
@@ -114,7 +114,7 @@ module Spree
|
|
114
114
|
|
115
115
|
def ensure_can_destroy
|
116
116
|
if !backordered? && !on_hand?
|
117
|
-
errors.add(:state, :cannot_destroy, state:
|
117
|
+
errors.add(:state, :cannot_destroy, state:)
|
118
118
|
throw :abort
|
119
119
|
end
|
120
120
|
|
@@ -19,9 +19,6 @@ module Spree
|
|
19
19
|
has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :destroy
|
20
20
|
has_many :inventory_units, inverse_of: :line_item
|
21
21
|
|
22
|
-
has_many :line_item_actions, dependent: :destroy
|
23
|
-
has_many :actions, through: :line_item_actions
|
24
|
-
|
25
22
|
before_validation :normalize_quantity
|
26
23
|
before_validation :set_required_attributes
|
27
24
|
|
@@ -62,7 +59,7 @@ module Spree
|
|
62
59
|
# @return [BigDecimal] the amount of this item, taking into consideration
|
63
60
|
# all non-tax adjustments.
|
64
61
|
def total_before_tax
|
65
|
-
amount + adjustments.
|
62
|
+
amount + adjustments.reject(&:tax?).sum(&:amount)
|
66
63
|
end
|
67
64
|
|
68
65
|
# @return [BigDecimal] the amount of this line item before VAT tax
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
class NullPromotionHandler
|
5
|
+
attr_reader :order, :coupon_code
|
6
|
+
|
7
|
+
def initialize(order)
|
8
|
+
@order = order
|
9
|
+
@coupon_code = order.coupon_code&.downcase
|
10
|
+
end
|
11
|
+
|
12
|
+
def activate
|
13
|
+
@order
|
14
|
+
end
|
15
|
+
|
16
|
+
def apply
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def can_apply?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def error
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def success
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def successful?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def status_code
|
37
|
+
:coupon_code_applied
|
38
|
+
end
|
39
|
+
|
40
|
+
def status
|
41
|
+
I18n.t(:coupon_code_applied, scope: [:spree, :null_promotion_handler])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|