spree_core 6.0.4 → 6.0.6
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/app/jobs/spree/imports/create_rows_job.rb +4 -2
- data/app/jobs/spree/imports/process_rows_job.rb +4 -2
- data/app/jobs/spree/payments/handle_modification_webhook_job.rb +93 -0
- data/app/jobs/spree/payments/handle_webhook_job.rb +4 -2
- data/app/jobs/spree/products/auto_match_taxons_job.rb +5 -2
- data/app/jobs/spree/search_provider/index_job.rb +8 -0
- data/app/jobs/spree/search_provider/remove_job.rb +3 -0
- data/app/jobs/spree/stock_locations/stock_items/create_job.rb +5 -2
- data/app/mailers/spree/base_mailer.rb +1 -1
- data/app/maintenance_tasks/spree/maintenance_tasks/upgrade/backfill_settlement_statuses.rb +40 -0
- data/app/models/concerns/spree/acted_by.rb +2 -2
- data/app/models/concerns/spree/customer_methods.rb +7 -5
- data/app/models/concerns/spree/deprecated_customer_alias.rb +11 -3
- data/app/models/concerns/spree/derived_number.rb +1 -1
- data/app/models/concerns/spree/has_custom_fields.rb +12 -10
- data/app/models/concerns/spree/integrations_concern.rb +5 -3
- data/app/models/concerns/spree/label_translatable.rb +4 -4
- data/app/models/concerns/spree/metadata.rb +3 -3
- data/app/models/concerns/spree/presentation_translatable.rb +1 -1
- data/app/models/concerns/spree/product_scopes.rb +5 -2
- data/app/models/concerns/spree/purchase/addresses.rb +8 -5
- data/app/models/concerns/spree/purchase/deprecated_aliases.rb +2 -2
- data/app/models/concerns/spree/purchase/payment_processing.rb +11 -0
- data/app/models/concerns/spree/purchase/purchase_order.rb +21 -0
- data/app/models/concerns/spree/purchase/totals.rb +3 -2
- data/app/models/concerns/spree/ransackable_attributes.rb +81 -4
- data/app/models/concerns/spree/settlement_status.rb +29 -0
- data/app/models/concerns/spree/stores/markets.rb +4 -32
- data/app/models/concerns/spree/user_address.rb +5 -2
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +29 -14
- data/app/models/spree/asset.rb +3 -3
- data/app/models/spree/base.rb +4 -4
- data/app/models/spree/calculator/shipping/flat_rate.rb +6 -4
- data/app/models/spree/cart.rb +2 -2
- data/app/models/spree/category.rb +61 -38
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/collection_rule.rb +5 -1
- data/app/models/spree/current.rb +19 -0
- data/app/models/spree/custom_field.rb +6 -6
- data/app/models/spree/custom_field_definition.rb +10 -7
- data/app/models/spree/delivery_method.rb +21 -15
- data/app/models/spree/delivery_rate.rb +1 -1
- data/app/models/spree/digital.rb +1 -1
- data/app/models/spree/digital_asset.rb +2 -2
- data/app/models/spree/digital_link.rb +4 -4
- data/app/models/spree/export.rb +32 -3
- data/app/models/spree/exports/products.rb +9 -1
- data/app/models/spree/fulfillment/custom_events.rb +18 -10
- data/app/models/spree/fulfillment.rb +53 -29
- data/app/models/spree/fulfillment_group.rb +2 -2
- data/app/models/spree/fulfillment_item.rb +3 -3
- data/app/models/spree/fulfilment_changer.rb +1 -1
- data/app/models/spree/gateway/bogus.rb +41 -2
- data/app/models/spree/gift_card.rb +26 -14
- data/app/models/spree/import.rb +23 -15
- data/app/models/spree/import_row.rb +6 -6
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/invitation.rb +8 -4
- data/app/models/spree/line_item.rb +10 -8
- data/app/models/spree/media.rb +3 -3
- data/app/models/spree/metafield.rb +1 -1
- data/app/models/spree/metafield_definition.rb +1 -1
- data/app/models/spree/metafields.rb +2 -2
- data/app/models/spree/option_type.rb +27 -0
- data/app/models/spree/option_value.rb +3 -3
- data/app/models/spree/order.rb +97 -49
- data/app/models/spree/order_group.rb +2 -2
- data/app/models/spree/order_inventory.rb +2 -2
- data/app/models/spree/order_merger.rb +2 -2
- data/app/models/spree/order_updater.rb +34 -20
- data/app/models/spree/payment/custom_events.rb +2 -1
- data/app/models/spree/payment/processing.rb +20 -3
- data/app/models/spree/payment.rb +194 -15
- data/app/models/spree/payment_capture_event.rb +2 -0
- data/app/models/spree/payment_method/store_credit.rb +6 -0
- data/app/models/spree/payment_method.rb +65 -11
- data/app/models/spree/payment_response.rb +19 -0
- data/app/models/spree/payment_session.rb +15 -3
- data/app/models/spree/payment_split.rb +14 -2
- data/app/models/spree/price.rb +20 -8
- data/app/models/spree/price_list.rb +12 -6
- data/app/models/spree/price_rules/zone_rule.rb +1 -1
- data/app/models/spree/product.rb +30 -28
- data/app/models/spree/product_category.rb +3 -3
- data/app/models/spree/promotion/rules/category.rb +27 -10
- data/app/models/spree/promotion/rules/country.rb +1 -1
- data/app/models/spree/promotion/rules/taxon.rb +4 -2
- data/app/models/spree/promotion/rules/user.rb +1 -1
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_rule_category.rb +5 -5
- data/app/models/spree/promotion_rule_taxon.rb +2 -2
- data/app/models/spree/prototype.rb +4 -1
- data/app/models/spree/purchase_order.rb +20 -3
- data/app/models/spree/refund.rb +7 -1
- data/app/models/spree/return.rb +7 -1
- data/app/models/spree/return_authorization_reason.rb +3 -3
- data/app/models/spree/return_reason.rb +1 -1
- data/app/models/spree/search_provider/base.rb +12 -2
- data/app/models/spree/search_provider/database.rb +8 -5
- data/app/models/spree/search_provider.rb +7 -5
- data/app/models/spree/shipment.rb +4 -1
- data/app/models/spree/shipping_method.rb +4 -1
- data/app/models/spree/shipping_rate.rb +1 -1
- data/app/models/spree/stock/coordinator.rb +2 -2
- data/app/models/spree/stock/estimator.rb +7 -5
- data/app/models/spree/stock/package.rb +10 -8
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_level/custom_events.rb +1 -1
- data/app/models/spree/stock_level.rb +1 -1
- data/app/models/spree/stock_location.rb +12 -8
- data/app/models/spree/stock_movement.rb +6 -6
- data/app/models/spree/stock_reservation.rb +5 -5
- data/app/models/spree/store.rb +64 -16
- data/app/models/spree/store_credit.rb +3 -3
- data/app/models/spree/store_credit_category.rb +5 -5
- data/app/models/spree/store_credit_type.rb +2 -2
- data/app/models/spree/subscriber.rb +7 -7
- data/app/models/spree/tax_rate.rb +5 -5
- data/app/models/spree/taxon.rb +3 -3
- data/app/models/spree/taxon_rule.rb +2 -2
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/variant.rb +45 -10
- data/app/models/spree/variant_media.rb +1 -1
- data/app/models/spree/wished_item.rb +1 -1
- data/app/models/spree/wishlist.rb +2 -2
- data/app/models/spree/wishlist_item/custom_events.rb +2 -2
- data/app/models/spree/zone.rb +1 -1
- data/app/models/spree/zone_member.rb +1 -1
- data/app/presenters/spree/csv/product_variant_presenter.rb +17 -8
- data/app/serializers/spree/emails/store_serializer.rb +1 -1
- data/app/services/spree/carts/associate.rb +6 -2
- data/app/services/spree/carts/create.rb +1 -1
- data/app/services/spree/carts/destroy.rb +1 -1
- data/app/services/spree/carts/remove_item.rb +1 -1
- data/app/services/spree/carts/remove_line_item.rb +2 -2
- data/app/services/spree/carts/remove_out_of_stock_items.rb +3 -1
- data/app/services/spree/carts/set_quantity.rb +2 -2
- data/app/services/spree/carts/split_by_seller.rb +4 -13
- data/app/services/spree/carts/update.rb +17 -0
- data/app/services/spree/checkout/add_store_credit.rb +3 -3
- data/app/services/spree/checkout/remove_store_credit.rb +2 -2
- data/app/services/spree/imports/row_processors/product_variant.rb +19 -0
- data/app/services/spree/orders/approve.rb +3 -3
- data/app/services/spree/orders/create_from_cart.rb +2 -0
- data/app/services/spree/orders/create_user_account.rb +2 -2
- data/app/services/spree/orders/update_statuses.rb +4 -2
- data/app/services/spree/products/auto_match_taxons.rb +5 -2
- data/app/services/spree/shipments/update.rb +2 -2
- data/app/services/spree/stock_locations/stock_items/create.rb +5 -2
- data/app/services/spree/stock_reservations/extend.rb +3 -1
- data/app/services/spree/stock_reservations/reserve.rb +3 -1
- data/app/services/spree/store_credits/apply.rb +1 -1
- data/app/services/spree/taxons/add_products.rb +4 -2
- data/app/services/spree/taxons/regenerate_products.rb +5 -2
- data/app/services/spree/taxons/remove_products.rb +4 -2
- data/app/subscribers/spree/order_status_subscriber.rb +4 -3
- data/app/subscribers/spree/payment_split_subscriber.rb +39 -21
- data/app/subscribers/spree/seller_transfer_reversal_subscriber.rb +19 -7
- data/app/tools/spree/agent_tools/query_report.rb +116 -14
- data/app/workflows/spree/carts/add_item.rb +1 -1
- data/app/workflows/spree/carts/complete.rb +1 -19
- data/app/workflows/spree/carts/recalculate.rb +1 -1
- data/app/workflows/spree/carts/recalculate_totals.rb +3 -3
- data/app/workflows/spree/fulfillments/update.rb +1 -1
- data/app/workflows/spree/orders/cancel.rb +22 -1
- data/app/workflows/spree/orders/complete.rb +7 -1
- data/app/workflows/spree/payments/capture.rb +101 -7
- data/app/workflows/spree/payments/handle_modification_webhook.rb +218 -0
- data/app/workflows/spree/payments/handle_webhook.rb +7 -1
- data/app/workflows/spree/payments/process.rb +47 -4
- data/app/workflows/spree/payments/void.rb +4 -1
- data/app/workflows/spree/products/approve.rb +17 -0
- data/app/workflows/spree/refunds/create.rb +10 -1
- data/app/workflows/spree/refunds/order_payments.rb +3 -1
- data/app/workflows/spree/seller_transfers/create.rb +1 -1
- data/config/locales/be.yml +2 -2
- data/config/locales/bg.yml +4 -4
- data/config/locales/en.yml +12 -0
- data/config/locales/ru.yml +3 -3
- data/db/migrate/20260710000001_rename_taxons_to_categories.rb +1 -1
- data/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb +1 -1
- data/db/migrate/20260806000001_add_store_id_to_spree_tax_rates_and_categories.rb +1 -1
- data/db/migrate/20260807130001_add_country_state_codes_to_consumers.rb +1 -1
- data/db/migrate/20260809000001_rename_metafields_to_custom_fields.rb +1 -1
- data/db/migrate/20260809150001_promote_shipping_categories_to_delivery_profiles.rb +1 -1
- data/db/migrate/20260811000001_add_delivery_tracking_to_fulfillments.rb +1 -1
- data/db/migrate/20260824000001_add_store_to_spree_media.rb +1 -1
- data/db/migrate/20260828100001_unify_import_and_export_tenancy.rb +1 -1
- data/db/migrate/20261016000001_remove_default_from_spree_tax_rates_included_in_price.rb +1 -1
- data/db/migrate/20261116100001_add_status_to_spree_payment_capture_events_and_refunds.rb +17 -0
- data/lib/spree/agent_tool.rb +11 -4
- data/lib/spree/agent_tools/default_catalog.rb +2 -2
- data/lib/spree/agent_tools/legacy_tools.rb +1 -1
- data/lib/spree/core/dependencies.rb +11 -10
- data/lib/spree/core/engine.rb +4 -0
- data/lib/spree/core/number_generator.rb +4 -3
- data/lib/spree/core/preferences/preferable.rb +1 -1
- data/lib/spree/core/preferences/preferable_class_methods.rb +5 -1
- data/lib/spree/core/pricing/resolver.rb +2 -2
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +37 -10
- data/lib/spree/i18n.rb +6 -2
- data/lib/spree/localized_number.rb +1 -1
- data/lib/spree/removed_apis.rb +274 -0
- data/lib/spree/reporting/adapters/live.rb +69 -8
- data/lib/spree/reporting/default_vocabulary.rb +11 -5
- data/lib/spree/reporting/query.rb +4 -1
- data/lib/spree/reporting/registry.rb +50 -3
- data/lib/spree/testing_support/factories/digital_asset_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_capture_event_factory.rb +10 -0
- data/lib/spree/testing_support/factories/refund_factory.rb +10 -0
- data/lib/spree/testing_support/factories/stock_level_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/wishlist_item_factory.rb +1 -1
- data/lib/spree/testing_support/i18n.rb +7 -2
- data/lib/spree/testing_support/order_walkthrough.rb +5 -2
- data/lib/spree/upgrades/5_6_to_6_0/manifest.yml +71 -14
- data/lib/tasks/carts_migration.rake +1 -1
- data/lib/tasks/categories_and_collections.rake +1 -1
- data/lib/tasks/deliveries_migration.rake +1 -1
- data/lib/tasks/delivery_method_rules_migration.rake +1 -1
- data/lib/tasks/delivery_migration.rake +1 -1
- data/lib/tasks/delivery_profiles_migration.rake +2 -2
- data/lib/tasks/fold_store_credit_categories.rake +1 -1
- data/lib/tasks/migrate_country_state_codes.rake +1 -1
- data/lib/tasks/migrate_returns.rake +4 -4
- data/lib/tasks/migrate_rich_text_to_columns.rake +1 -1
- data/lib/tasks/store_settings.rake +1 -1
- data/lib/tasks/typed_stock_movements_migration.rake +1 -1
- metadata +26 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5194af3427b9ca7bc42294f49a00db40225b42ef85b129625545f91da07ce74
|
|
4
|
+
data.tar.gz: a4f7d851aefe2c406973b9e3f034f9523e99c1e2d83f90e2965d35d28ac02799
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a79ca48edd3e8b2caf20ec031be2fbb7f208cf256422a81177a774d2b7e8032d1fcfc193a169b5626e517d536289f456f16827db3e41cba5b4d179a311cb541
|
|
7
|
+
data.tar.gz: 0e92e81e2f39f437bee1efac62983ccbade8883a2b3f8c1f0ae4b6167f1edaa0d9ddbbf0c31e55be9659232e13c30b331cea22304ca0b59c5fb7a690dc8ab12b
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
module Imports
|
|
3
|
-
# @deprecated Use {Spree::Imports::ProcessJob}; removed in 6.
|
|
3
|
+
# @deprecated Use {Spree::Imports::ProcessJob}; removed in 6.3.
|
|
4
4
|
class CreateRowsJob < Spree::Imports::BaseJob
|
|
5
5
|
def perform(import_id)
|
|
6
|
-
Spree::Deprecation.warn(
|
|
6
|
+
Spree::Deprecation.warn(
|
|
7
|
+
'Spree::Imports::CreateRowsJob is deprecated and will be removed in Spree 6.3. Use Spree::Imports::ProcessJob instead.'
|
|
8
|
+
)
|
|
7
9
|
Spree::Imports::ProcessJob.perform_now(import_id)
|
|
8
10
|
end
|
|
9
11
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
module Imports
|
|
3
3
|
# @deprecated Use {Spree::Imports::ProcessJob} with skip_row_creation:
|
|
4
|
-
# true; removed in 6.
|
|
4
|
+
# true; removed in 6.3.
|
|
5
5
|
class ProcessRowsJob < Spree::Imports::BaseJob
|
|
6
6
|
def perform(import_id)
|
|
7
|
-
Spree::Deprecation.warn(
|
|
7
|
+
Spree::Deprecation.warn(
|
|
8
|
+
'Spree::Imports::ProcessRowsJob is deprecated and will be removed in Spree 6.3. Use Spree::Imports::ProcessJob instead.'
|
|
9
|
+
)
|
|
8
10
|
Spree::Imports::ProcessJob.perform_now(import_id, skip_row_creation: true)
|
|
9
11
|
end
|
|
10
12
|
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Payments
|
|
3
|
+
# Runs Spree::Payments::HandleModificationWebhook for an outcome the
|
|
4
|
+
# webhook endpoint accepted: the provider got its 200 already and will not
|
|
5
|
+
# send it again, so a failure is retried here.
|
|
6
|
+
#
|
|
7
|
+
# An outcome can name a record Spree has not written yet: it arrived
|
|
8
|
+
# before the request that writes it finished, or that request's answer
|
|
9
|
+
# never reached Spree and a retry of it writes the record later. The job
|
|
10
|
+
# waits for the record as long as a retried request still gets the
|
|
11
|
+
# provider's first answer.
|
|
12
|
+
class HandleModificationWebhookJob < Spree::BaseJob
|
|
13
|
+
queue_as Spree.queues.payment_webhooks
|
|
14
|
+
|
|
15
|
+
retry_on ActiveRecord::Deadlocked, wait: 5.seconds, attempts: 3
|
|
16
|
+
retry_on ActiveRecord::LockWaitTimeout, wait: 5.seconds, attempts: 3
|
|
17
|
+
discard_on ActiveRecord::RecordNotFound
|
|
18
|
+
|
|
19
|
+
class OutcomeFailed < StandardError; end
|
|
20
|
+
# The wait ended with no record: an action taken outside Spree, or a
|
|
21
|
+
# request whose answer never reached Spree and that nobody retried.
|
|
22
|
+
class RecordNeverWritten < StandardError; end
|
|
23
|
+
|
|
24
|
+
retry_on OutcomeFailed, wait: :polynomially_longer, attempts: 5
|
|
25
|
+
|
|
26
|
+
CAPTURE_ACTIONS = %w[capture_succeeded capture_failed].freeze
|
|
27
|
+
# How long a retried request still gets the provider's first answer:
|
|
28
|
+
# Adyen keeps an idempotency key for at least 7 days.
|
|
29
|
+
RECORD_WAIT = 7.days
|
|
30
|
+
# Longer than any gateway call takes with its own retries, so after it
|
|
31
|
+
# no request for this outcome can still be running.
|
|
32
|
+
ANSWER_WINDOW = 5.minutes
|
|
33
|
+
|
|
34
|
+
# @param reference [String] the provider reference the outcome names its record by
|
|
35
|
+
# @param received_at [String] when the endpoint accepted the outcome, ISO 8601
|
|
36
|
+
# @param payment_id [Integer, nil] the payment a capture outcome's capture was asked for
|
|
37
|
+
def perform(payment_method_id:, action:, reference:, received_at:, payment_id: nil, metadata: {})
|
|
38
|
+
payment_method = Spree::PaymentMethod.find(payment_method_id)
|
|
39
|
+
Spree::Current.store = payment_method.store
|
|
40
|
+
received_at = Time.zone.parse(received_at)
|
|
41
|
+
|
|
42
|
+
record = payment_method.modification_record(action.to_sym, reference) ||
|
|
43
|
+
unanswered_capture(payment_method, action, reference, payment_id, metadata, received_at)
|
|
44
|
+
return wait_for_record(payment_method, action, reference, received_at) if record.nil?
|
|
45
|
+
|
|
46
|
+
result = Spree.payments_handle_modification_webhook_workflow.call(
|
|
47
|
+
payment_method: payment_method,
|
|
48
|
+
action: action.to_sym,
|
|
49
|
+
record: record,
|
|
50
|
+
metadata: metadata
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
raise OutcomeFailed, "#{action} #{reference}: #{result.error}" if result&.failure?
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
# A capture whose answer never reached Spree leaves its payment
|
|
59
|
+
# processing, with no capture event waiting. Once no request can still be
|
|
60
|
+
# running, the event is written as the request would have, so the
|
|
61
|
+
# outcome settles it.
|
|
62
|
+
def unanswered_capture(payment_method, action, reference, payment_id, metadata, received_at)
|
|
63
|
+
return unless CAPTURE_ACTIONS.include?(action.to_s) && payment_id
|
|
64
|
+
return if Time.current - received_at < ANSWER_WINDOW
|
|
65
|
+
|
|
66
|
+
payment = Spree::Payment.where(payment_method_id: payment_method.id).find_by(id: payment_id)
|
|
67
|
+
return if payment.nil?
|
|
68
|
+
|
|
69
|
+
payment.with_lock do
|
|
70
|
+
next unless payment.processing? && payment.capture_events.where(status: 'requested').none?
|
|
71
|
+
|
|
72
|
+
amount = metadata['amount'].presence&.to_d || payment.amount
|
|
73
|
+
payment.capture_events.create!(amount: amount, status: 'requested', transaction_id: reference)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Looks again quickly at first, when the record is most likely only
|
|
78
|
+
# moments away, then every few hours.
|
|
79
|
+
def wait_for_record(payment_method, action, reference, received_at)
|
|
80
|
+
if Time.current - received_at < RECORD_WAIT
|
|
81
|
+
retry_job(wait: [5.seconds * (4**(executions - 1).clamp(0, 8)), 6.hours].min)
|
|
82
|
+
else
|
|
83
|
+
Rails.error.report(
|
|
84
|
+
RecordNeverWritten.new("#{action} names no record: #{reference}"),
|
|
85
|
+
handled: true,
|
|
86
|
+
context: { payment_method_id: payment_method.id, action: action, reference: reference },
|
|
87
|
+
source: 'spree.payments.modification_webhook'
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -16,7 +16,8 @@ module Spree
|
|
|
16
16
|
|
|
17
17
|
retry_on SettlementFailed, wait: :polynomially_longer, attempts: 5
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
# metadata defaults to {} so jobs enqueued before it was passed still run.
|
|
20
|
+
def perform(payment_method_id:, action:, payment_session_id:, metadata: {})
|
|
20
21
|
payment_method = Spree::PaymentMethod.find(payment_method_id)
|
|
21
22
|
Spree::Current.store = payment_method.store
|
|
22
23
|
payment_session = Spree::PaymentSession.find(payment_session_id)
|
|
@@ -24,7 +25,8 @@ module Spree
|
|
|
24
25
|
result = Spree.payments_handle_webhook_workflow.call(
|
|
25
26
|
payment_method: payment_method,
|
|
26
27
|
action: action.to_sym,
|
|
27
|
-
payment_session: payment_session
|
|
28
|
+
payment_session: payment_session,
|
|
29
|
+
metadata: metadata
|
|
28
30
|
)
|
|
29
31
|
|
|
30
32
|
raise SettlementFailed, "Payment session #{payment_session.id}: #{result.error}" if result&.failure?
|
|
@@ -2,10 +2,13 @@ module Spree
|
|
|
2
2
|
module Products
|
|
3
3
|
# @deprecated Renamed to AutoMatchCollectionsJob in 6.0 (behavior moved to
|
|
4
4
|
# collections). Subclasses it so jobs enqueued under the old class name still
|
|
5
|
-
# deserialize and run; removed in 6.
|
|
5
|
+
# deserialize and run; removed in 6.3.
|
|
6
6
|
class AutoMatchTaxonsJob < AutoMatchCollectionsJob
|
|
7
7
|
def perform(product_id)
|
|
8
|
-
Spree::Deprecation.warn(
|
|
8
|
+
Spree::Deprecation.warn(
|
|
9
|
+
'Spree::Products::AutoMatchTaxonsJob is deprecated and will be removed in Spree 6.3. ' \
|
|
10
|
+
'Use Spree::Products::AutoMatchCollectionsJob instead.'
|
|
11
|
+
)
|
|
9
12
|
super
|
|
10
13
|
end
|
|
11
14
|
end
|
|
@@ -3,6 +3,14 @@ module Spree
|
|
|
3
3
|
class IndexJob < Spree::BaseJob
|
|
4
4
|
queue_as Spree.queues.search
|
|
5
5
|
|
|
6
|
+
# A bulk write (CSV import, sample data) enqueues thousands of these at
|
|
7
|
+
# once; run in parallel they flood the search service with requests and
|
|
8
|
+
# it answers 429 Too Many Requests. Run one search job per store at a
|
|
9
|
+
# time; the rest wait as blocked executions, so no update is lost. Shared
|
|
10
|
+
# with RemoveJob. The duration only has to outlive one job; expiry lifts
|
|
11
|
+
# the cap, it doesn't drop jobs. Solid Queue only (no-op elsewhere).
|
|
12
|
+
limits_concurrency to: 1, key: ->(*, store_id) { store_id }, group: 'spree_search', duration: 5.minutes if respond_to?(:limits_concurrency)
|
|
13
|
+
|
|
6
14
|
# Search providers are external services (Meilisearch, etc.); a transient 5xx or
|
|
7
15
|
# network blip should not drop the index update.
|
|
8
16
|
retry_on StandardError, wait: :polynomially_longer, attempts: 5
|
|
@@ -3,6 +3,9 @@ module Spree
|
|
|
3
3
|
class RemoveJob < Spree::BaseJob
|
|
4
4
|
queue_as Spree.queues.search
|
|
5
5
|
|
|
6
|
+
# Shares IndexJob's per-store limit, see there.
|
|
7
|
+
limits_concurrency to: 1, key: ->(*, store_id) { store_id }, group: 'spree_search', duration: 5.minutes if respond_to?(:limits_concurrency)
|
|
8
|
+
|
|
6
9
|
# Search providers are external services; broad retry covers network blips and 5xx.
|
|
7
10
|
retry_on StandardError, wait: :polynomially_longer, attempts: 5
|
|
8
11
|
# Must come after `retry_on StandardError` so DeserializationError lands in discard
|
|
@@ -3,10 +3,13 @@ module Spree
|
|
|
3
3
|
module StockItems
|
|
4
4
|
# @deprecated Renamed to Spree::StockLocations::StockLevels::CreateJob in 6.0.
|
|
5
5
|
# Subclasses it so jobs enqueued under the old class name before the deploy
|
|
6
|
-
# still deserialize and run; removed in 6.
|
|
6
|
+
# still deserialize and run; removed in 6.3.
|
|
7
7
|
class CreateJob < StockLevels::CreateJob
|
|
8
8
|
def perform(*args)
|
|
9
|
-
Spree::Deprecation.warn(
|
|
9
|
+
Spree::Deprecation.warn(
|
|
10
|
+
'Spree::StockLocations::StockItems::CreateJob is deprecated and will be removed in Spree 6.3. ' \
|
|
11
|
+
'Use Spree::StockLocations::StockLevels::CreateJob instead.'
|
|
12
|
+
)
|
|
10
13
|
super
|
|
11
14
|
end
|
|
12
15
|
end
|
|
@@ -29,7 +29,7 @@ module Spree
|
|
|
29
29
|
@_store_locale_active = true
|
|
30
30
|
begin
|
|
31
31
|
Spree::Locales::SetFallbackLocaleForStore.new.call(store: store) if store
|
|
32
|
-
I18n.with_locale(locale, &block)
|
|
32
|
+
Spree::Current.with_content_locale(store&.default_market&.default_locale) { I18n.with_locale(locale, &block) }
|
|
33
33
|
ensure
|
|
34
34
|
@_store_locale_active = previously_active
|
|
35
35
|
Mobility.store_based_fallbacks = previous_fallbacks
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module MaintenanceTasks
|
|
3
|
+
module Upgrade
|
|
4
|
+
# Capture events and refunds gained a status in a 6.0 patch release (a
|
|
5
|
+
# gateway may now answer that it is still waiting on its provider), added
|
|
6
|
+
# empty by the migration. Every row written before then is money that
|
|
7
|
+
# moved, so it is marked completed here. Walks payments, the one record
|
|
8
|
+
# both tables hang from, so the run has a single cursor.
|
|
9
|
+
class BackfillSettlementStatuses < Spree::MaintenanceTask
|
|
10
|
+
supports_dry_run
|
|
11
|
+
collection_batch_size 1_000
|
|
12
|
+
|
|
13
|
+
def collection
|
|
14
|
+
capture_event_payment_ids = Spree::PaymentCaptureEvent.where(status: nil).select(:payment_id)
|
|
15
|
+
refund_payment_ids = Spree::Refund.where(status: nil).select(:payment_id)
|
|
16
|
+
|
|
17
|
+
Spree::Payment.unscoped.
|
|
18
|
+
where(id: capture_event_payment_ids).
|
|
19
|
+
or(Spree::Payment.unscoped.where(id: refund_payment_ids)).
|
|
20
|
+
order(:id)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def process(payment)
|
|
24
|
+
capture_events = Spree::PaymentCaptureEvent.where(payment_id: payment.id, status: nil)
|
|
25
|
+
refunds = Spree::Refund.where(payment_id: payment.id, status: nil)
|
|
26
|
+
|
|
27
|
+
if dry_run?
|
|
28
|
+
tally(:capture_events_would_complete, capture_events.count)
|
|
29
|
+
tally(:refunds_would_complete, refunds.count)
|
|
30
|
+
return
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
now = Time.current
|
|
34
|
+
tally(:capture_events_completed, capture_events.update_all(status: 'completed', updated_at: now))
|
|
35
|
+
tally(:refunds_completed, refunds.update_all(status: 'completed', updated_at: now))
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -178,7 +178,7 @@ module Spree
|
|
|
178
178
|
# Prepended rather than defined outright, so `super` reaches the
|
|
179
179
|
# generated reader.
|
|
180
180
|
#
|
|
181
|
-
# Removed in 6.
|
|
181
|
+
# Removed in 6.3, once the backfill is a release behind.
|
|
182
182
|
def define_transitional_actor_reader(name)
|
|
183
183
|
transitional_actor_readers.module_eval do
|
|
184
184
|
define_method(name) do
|
|
@@ -188,7 +188,7 @@ module Spree
|
|
|
188
188
|
Spree::Deprecation.warn(
|
|
189
189
|
"#{self.class.name}##{name} resolved through #{Spree.admin_user_class} because " \
|
|
190
190
|
"#{name}_type is blank. Run `rake spree:upgrade:backfill_actor_types`; the fallback " \
|
|
191
|
-
'is removed in Spree 6.
|
|
191
|
+
'is removed in Spree 6.3.'
|
|
192
192
|
)
|
|
193
193
|
|
|
194
194
|
# Fill the type across the whole lazily-preloaded group, not just
|
|
@@ -198,7 +198,7 @@ module Spree
|
|
|
198
198
|
# Two-state scope: see Spree::Base.ransack_flag? for why the cast is
|
|
199
199
|
# opted out of here and done inside the scope instead.
|
|
200
200
|
def self.ransackable_scopes_skip_sanitize_args
|
|
201
|
-
%
|
|
201
|
+
super | %w[anonymized]
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
# Whether an erasure has been carried out. A scope rather than a
|
|
@@ -295,14 +295,14 @@ module Spree
|
|
|
295
295
|
# @deprecated Carts are {Spree::Cart} since 6.0, so an incomplete order is
|
|
296
296
|
# a backoffice draft rather than the customer's cart. Use
|
|
297
297
|
# +carts.where(store: store)+ for carts, or +orders.drafts+ for drafts.
|
|
298
|
-
# Removed in Spree 6.
|
|
298
|
+
# Removed in Spree 6.3.
|
|
299
299
|
# @param [Spree::Store] store
|
|
300
300
|
# @param [Hash] options
|
|
301
301
|
# @option options [Array<Symbol>] :includes
|
|
302
302
|
# @return [Spree::Order]
|
|
303
303
|
def last_incomplete_spree_order(store, options = {})
|
|
304
304
|
Spree::Deprecation.warn(
|
|
305
|
-
'Spree::CustomerMethods#last_incomplete_spree_order is deprecated and will be removed in Spree 6.
|
|
305
|
+
'Spree::CustomerMethods#last_incomplete_spree_order is deprecated and will be removed in Spree 6.3. ' \
|
|
306
306
|
'Carts are Spree::Cart since 6.0 and this returns draft orders; use #carts for the customer\'s carts.'
|
|
307
307
|
)
|
|
308
308
|
|
|
@@ -393,9 +393,11 @@ module Spree
|
|
|
393
393
|
# every column carrying personal data rather than three on this row —
|
|
394
394
|
# the address book, the address snapshots on past orders, gateway
|
|
395
395
|
# profiles, OAuth identities and live sessions all outlived this method.
|
|
396
|
-
# Removed in Spree 6.
|
|
396
|
+
# Removed in Spree 6.3.
|
|
397
397
|
def scramble_email_and_names
|
|
398
|
-
Spree::Deprecation.warn(
|
|
398
|
+
Spree::Deprecation.warn(
|
|
399
|
+
'Spree::CustomerMethods#scramble_email_and_names is deprecated and will be removed in Spree 6.3. Use Spree::Customers::Anonymize instead.'
|
|
400
|
+
)
|
|
399
401
|
|
|
400
402
|
Spree.customer_anonymize_workflow.call(customer: self, store: Spree::Current.store).success?
|
|
401
403
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
# Deprecation shim for the 6.0 user_id -> customer_id / belongs_to :user -> :customer
|
|
3
3
|
# rename. Included by customer-facing models so `.user` / `.user_id` keep working
|
|
4
|
-
#
|
|
4
|
+
# until Spree 6.3.
|
|
5
5
|
module DeprecatedCustomerAlias
|
|
6
6
|
extend ActiveSupport::Concern
|
|
7
7
|
|
|
@@ -10,12 +10,20 @@ module Spree
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def user
|
|
13
|
-
|
|
13
|
+
if defined?(Spree::Deprecation)
|
|
14
|
+
Spree::Deprecation.warn(
|
|
15
|
+
"#{self.class}#user is deprecated and will be removed in Spree 6.3. Use #customer instead."
|
|
16
|
+
)
|
|
17
|
+
end
|
|
14
18
|
customer
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
def user=(value)
|
|
18
|
-
|
|
22
|
+
if defined?(Spree::Deprecation)
|
|
23
|
+
Spree::Deprecation.warn(
|
|
24
|
+
"#{self.class}#user= is deprecated and will be removed in Spree 6.3. Use #customer= instead."
|
|
25
|
+
)
|
|
26
|
+
end
|
|
19
27
|
self.customer = value
|
|
20
28
|
end
|
|
21
29
|
end
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
#
|
|
12
12
|
# Rows created before 6.0 keep their stored number, so gateway references
|
|
13
13
|
# and packing slips already in the wild still resolve. New rows never write
|
|
14
|
-
# the column — it is frozen legacy data awaiting the 6.
|
|
14
|
+
# the column — it is frozen legacy data awaiting the 6.3 drop.
|
|
15
15
|
module DerivedNumber
|
|
16
16
|
extend ActiveSupport::Concern
|
|
17
17
|
|
|
@@ -22,19 +22,21 @@ module Spree
|
|
|
22
22
|
[namespace, key]
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# Deprecated 6.0 names, removed in 6.
|
|
25
|
+
# Deprecated 6.0 names, removed in 6.3.
|
|
26
26
|
def ensure_metafield_definition_exists!(key_with_namespace, store: Spree::Current.store)
|
|
27
|
-
Spree::Deprecation.warn(
|
|
27
|
+
Spree::Deprecation.warn(
|
|
28
|
+
'ensure_metafield_definition_exists! is deprecated and will be removed in Spree 6.3. Use ensure_custom_field_definition_exists! instead.'
|
|
29
|
+
)
|
|
28
30
|
ensure_custom_field_definition_exists!(key_with_namespace, store: store)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def with_metafield_key(key_with_namespace)
|
|
32
|
-
Spree::Deprecation.warn('.with_metafield_key is deprecated and will be removed in Spree 6.
|
|
34
|
+
Spree::Deprecation.warn('.with_metafield_key is deprecated and will be removed in Spree 6.3. Use .with_custom_field_key instead.')
|
|
33
35
|
with_custom_field_key(key_with_namespace)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
def with_metafield_key_value(key_with_namespace, value)
|
|
37
|
-
Spree::Deprecation.warn('.with_metafield_key_value is deprecated and will be removed in Spree 6.
|
|
39
|
+
Spree::Deprecation.warn('.with_metafield_key_value is deprecated and will be removed in Spree 6.3. Use .with_custom_field_key_value instead.')
|
|
38
40
|
with_custom_field_key_value(key_with_namespace, value)
|
|
39
41
|
end
|
|
40
42
|
end
|
|
@@ -46,7 +48,7 @@ module Spree
|
|
|
46
48
|
has_many :custom_fields, -> { includes(:custom_field_definition) }, as: :resource, inverse_of: :resource, class_name: 'Spree::CustomField', dependent: :destroy
|
|
47
49
|
has_many :storefront_custom_fields, -> { includes(:custom_field_definition).storefront_visible }, as: :resource, class_name: 'Spree::CustomField'
|
|
48
50
|
|
|
49
|
-
# Deprecated 6.0 association names, removed in 6.
|
|
51
|
+
# Deprecated 6.0 association names, removed in 6.3. `private_metafields`
|
|
50
52
|
# has no replacement — read `custom_fields` and filter, or query
|
|
51
53
|
# Spree::CustomField.admin_only directly.
|
|
52
54
|
has_many :metafields, -> { includes(:custom_field_definition) }, as: :resource, class_name: 'Spree::CustomField', deprecated: true
|
|
@@ -170,26 +172,26 @@ module Spree
|
|
|
170
172
|
custom_fields.with_key(namespace, key).exists?
|
|
171
173
|
end
|
|
172
174
|
|
|
173
|
-
# Deprecated 6.0 names, removed in 6.
|
|
175
|
+
# Deprecated 6.0 names, removed in 6.3.
|
|
174
176
|
def set_metafield(definition_or_key, value)
|
|
175
|
-
Spree::Deprecation.warn('#set_metafield is deprecated and will be removed in Spree 6.
|
|
177
|
+
Spree::Deprecation.warn('#set_metafield is deprecated and will be removed in Spree 6.3. Use #set_custom_field instead.')
|
|
176
178
|
set_custom_field(definition_or_key, value)
|
|
177
179
|
end
|
|
178
180
|
|
|
179
181
|
def get_metafield(key_with_namespace)
|
|
180
|
-
Spree::Deprecation.warn('#get_metafield is deprecated and will be removed in Spree 6.
|
|
182
|
+
Spree::Deprecation.warn('#get_metafield is deprecated and will be removed in Spree 6.3. Use #get_custom_field instead.')
|
|
181
183
|
get_custom_field(key_with_namespace)
|
|
182
184
|
end
|
|
183
185
|
|
|
184
186
|
def has_metafield?(key_with_namespace)
|
|
185
|
-
Spree::Deprecation.warn('#has_metafield? is deprecated and will be removed in Spree 6.
|
|
187
|
+
Spree::Deprecation.warn('#has_metafield? is deprecated and will be removed in Spree 6.3. Use #has_custom_field? instead.')
|
|
186
188
|
has_custom_field?(key_with_namespace)
|
|
187
189
|
end
|
|
188
190
|
|
|
189
191
|
# Legacy payloads key the definition as `metafield_definition_id`, which
|
|
190
192
|
# the new writer rejects — translate rather than silently dropping them.
|
|
191
193
|
def metafields_attributes=(attributes)
|
|
192
|
-
Spree::Deprecation.warn('#metafields_attributes= is deprecated and will be removed in Spree 6.
|
|
194
|
+
Spree::Deprecation.warn('#metafields_attributes= is deprecated and will be removed in Spree 6.3. Use #custom_fields_attributes= instead.')
|
|
193
195
|
|
|
194
196
|
attributes = attributes.values if attributes.is_a?(Hash)
|
|
195
197
|
translated = attributes.map do |attrs|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Spree
|
|
2
|
-
# @deprecated Use {Spree::Current.integrations}; removed in Spree 6.
|
|
2
|
+
# @deprecated Use {Spree::Current.integrations}; removed in Spree 6.3.
|
|
3
3
|
#
|
|
4
4
|
# Nothing in Spree calls these — the per-request integration set lives on
|
|
5
5
|
# {Spree::Current} — but the concern sits on Spree::Base, so every model has
|
|
@@ -7,7 +7,8 @@ module Spree
|
|
|
7
7
|
module IntegrationsConcern
|
|
8
8
|
def store_integrations
|
|
9
9
|
Spree::Deprecation.warn(
|
|
10
|
-
'Spree::IntegrationsConcern#store_integrations is deprecated and will be removed in Spree 6.
|
|
10
|
+
'Spree::IntegrationsConcern#store_integrations is deprecated and will be removed in Spree 6.3. ' \
|
|
11
|
+
'Use Spree::Current.integrations instead.'
|
|
11
12
|
)
|
|
12
13
|
|
|
13
14
|
Spree::Current.integrations
|
|
@@ -15,7 +16,8 @@ module Spree
|
|
|
15
16
|
|
|
16
17
|
def store_integration(name)
|
|
17
18
|
Spree::Deprecation.warn(
|
|
18
|
-
'Spree::IntegrationsConcern#store_integration is deprecated and will be removed in Spree 6.
|
|
19
|
+
'Spree::IntegrationsConcern#store_integration is deprecated and will be removed in Spree 6.3. ' \
|
|
20
|
+
'Use Spree::Current.integrations.find { |integration| integration.type.to_s.demodulize.underscore == name } instead.'
|
|
19
21
|
)
|
|
20
22
|
|
|
21
23
|
Spree::Current.integrations.find { |integration| integration.type.to_s.demodulize.underscore == name }
|
|
@@ -16,7 +16,7 @@ module Spree
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
# @deprecated The column is +label+ since 6.0; removed in 6.
|
|
19
|
+
# @deprecated The column is +label+ since 6.0; removed in 6.3.
|
|
20
20
|
#
|
|
21
21
|
# Unlike the attribute aliases the other 6.0 renames use, this is a plain
|
|
22
22
|
# method — Mobility owns +label+, so it cannot be an alias_attribute. It
|
|
@@ -24,13 +24,13 @@ module Spree
|
|
|
24
24
|
# and +find_by(presentation:)+ name a column that no longer exists and
|
|
25
25
|
# raise. Query by +label+.
|
|
26
26
|
def presentation(*args, **kwargs)
|
|
27
|
-
Spree::Deprecation.warn("#{self.class.name}#presentation is deprecated and will be removed in Spree 6.
|
|
27
|
+
Spree::Deprecation.warn("#{self.class.name}#presentation is deprecated and will be removed in Spree 6.3. Use #label instead.")
|
|
28
28
|
label(*args, **kwargs)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# @deprecated See {#presentation}; removed in 6.
|
|
31
|
+
# @deprecated See {#presentation}; removed in 6.3.
|
|
32
32
|
def presentation=(value)
|
|
33
|
-
Spree::Deprecation.warn("#{self.class.name}#presentation= is deprecated and will be removed in Spree 6.
|
|
33
|
+
Spree::Deprecation.warn("#{self.class.name}#presentation= is deprecated and will be removed in Spree 6.3. Use #label= instead.")
|
|
34
34
|
self.label = value
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
serialize :metadata, coder: HashSerializer
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# Deprecated alias for the renamed `metadata` column. Removed in Spree 6.
|
|
14
|
+
# Deprecated alias for the renamed `metadata` column. Removed in Spree 6.3.
|
|
15
15
|
#
|
|
16
16
|
# Only the reader and writer are bridged. The column is gone, so the attribute
|
|
17
17
|
# methods Active Record generated alongside it — `private_metadata?`,
|
|
@@ -19,12 +19,12 @@ module Spree
|
|
|
19
19
|
# `private_metadata_before_type_cast` and the rest of the dirty-tracking family
|
|
20
20
|
# — no longer exist and raise NoMethodError. Call the `metadata` equivalents.
|
|
21
21
|
def private_metadata
|
|
22
|
-
Spree::Deprecation.warn('private_metadata is deprecated and will be removed in Spree 6.
|
|
22
|
+
Spree::Deprecation.warn('private_metadata is deprecated and will be removed in Spree 6.3. Use metadata instead.')
|
|
23
23
|
metadata
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def private_metadata=(value)
|
|
27
|
-
Spree::Deprecation.warn('private_metadata= is deprecated and will be removed in Spree 6.
|
|
27
|
+
Spree::Deprecation.warn('private_metadata= is deprecated and will be removed in Spree 6.3. Use metadata= instead.')
|
|
28
28
|
self.metadata = value
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -193,7 +193,10 @@ module Spree
|
|
|
193
193
|
# a red XL. Every axis is therefore counted against the same variant row
|
|
194
194
|
# rather than asked of the product separately — which is also what keeps
|
|
195
195
|
# a filter honest once several sellers list variants on one product.
|
|
196
|
-
|
|
196
|
+
#
|
|
197
|
+
# +variants+ narrows which variants may answer: the storefront passes
|
|
198
|
+
# +Variant.for_option_filters+, while the admin keeps every variant.
|
|
199
|
+
def self.with_option_value_ids(*ids, variants: nil)
|
|
197
200
|
ids = ids.flatten.compact
|
|
198
201
|
return none if ids.empty?
|
|
199
202
|
|
|
@@ -203,7 +206,7 @@ module Spree
|
|
|
203
206
|
grouped = OptionValue.where(id: actual_ids).group_by(&:option_type_id)
|
|
204
207
|
return none if grouped.empty?
|
|
205
208
|
|
|
206
|
-
matching_product_ids = Variant.where(deleted_at: nil).
|
|
209
|
+
matching_product_ids = (variants || Variant).where(deleted_at: nil).
|
|
207
210
|
joins(option_value_variants: :option_value).
|
|
208
211
|
where(OptionValue.table_name => { id: actual_ids }).
|
|
209
212
|
group(Variant.arel_table[:id]).
|
|
@@ -7,7 +7,7 @@ module Spree
|
|
|
7
7
|
# of checkout addresses to the customer's defaults, and the ship→bill cloning
|
|
8
8
|
# predicate. The shipping address is canonical: use_shipping copies it
|
|
9
9
|
# onto the billing address; the reverse use_billing direction is a
|
|
10
|
-
# deprecated 6.
|
|
10
|
+
# deprecated 6.3-removal bridge. Clone callbacks are wired per model.
|
|
11
11
|
module Addresses
|
|
12
12
|
extend ActiveSupport::Concern
|
|
13
13
|
|
|
@@ -85,13 +85,16 @@ module Spree
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
# @deprecated The shipping address is canonical — use +use_shipping+ to
|
|
88
|
-
# copy it onto the billing address. Removed in 6.
|
|
88
|
+
# copy it onto the billing address. Removed in 6.3.
|
|
89
89
|
def use_billing=(value)
|
|
90
|
-
Spree::Deprecation.warn(
|
|
90
|
+
Spree::Deprecation.warn(
|
|
91
|
+
'use_billing is deprecated and will be removed in Spree 6.3. ' \
|
|
92
|
+
'The shipping address comes first — use use_shipping to copy it onto the billing address.'
|
|
93
|
+
)
|
|
91
94
|
@use_billing = value
|
|
92
95
|
end
|
|
93
96
|
|
|
94
|
-
# @deprecated See {#use_billing=}; removed in 6.
|
|
97
|
+
# @deprecated See {#use_billing=}; removed in 6.3.
|
|
95
98
|
# @return [Boolean]
|
|
96
99
|
def use_billing?
|
|
97
100
|
use_billing.in?([true, 'true', '1'])
|
|
@@ -194,7 +197,7 @@ module Spree
|
|
|
194
197
|
# customer's default ship address.
|
|
195
198
|
#
|
|
196
199
|
# @deprecated The shipping address is canonical (see {#use_billing=});
|
|
197
|
-
# removed in 6.
|
|
200
|
+
# removed in 6.3 together with the use_billing bridge.
|
|
198
201
|
# @return [true]
|
|
199
202
|
def clone_billing_address
|
|
200
203
|
self.ship_address = bill_address if bill_address
|
|
@@ -4,7 +4,7 @@ module Spree
|
|
|
4
4
|
# {Spree::Cart} and {Spree::Order}. Before 6.0 a cart was an incomplete
|
|
5
5
|
# order, so extensions written against 5.x (payment gateways, checkout
|
|
6
6
|
# plugins) call the legacy names on carts too. Every legacy name warns and
|
|
7
|
-
# forwards to its replacement. Removed in 6.
|
|
7
|
+
# forwards to its replacement. Removed in 6.3.
|
|
8
8
|
#
|
|
9
9
|
# Renamed columns are also registered with +alias_attribute+, so the legacy
|
|
10
10
|
# name keeps working in +where+ / +find_by+ (those paths do not warn).
|
|
@@ -80,7 +80,7 @@ module Spree
|
|
|
80
80
|
private
|
|
81
81
|
|
|
82
82
|
def warn_deprecated_name(legacy_name, current_name)
|
|
83
|
-
Spree::Deprecation.warn("#{self.class.name}##{legacy_name} is deprecated and will be removed in Spree 6.
|
|
83
|
+
Spree::Deprecation.warn("#{self.class.name}##{legacy_name} is deprecated and will be removed in Spree 6.3. Use ##{current_name} instead.")
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -62,6 +62,14 @@ module Spree
|
|
|
62
62
|
payments.select(&:checkout?)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# What is still owed once every live payment is counted, settled or not —
|
|
66
|
+
# the amount a new payment should be for. Never negative.
|
|
67
|
+
#
|
|
68
|
+
# @return [BigDecimal]
|
|
69
|
+
def amount_left_to_pay
|
|
70
|
+
[outstanding_balance - valid_payments.reject { |payment| payment.status == 'completed' }.sum(BigDecimal('0'), &:amount), BigDecimal('0')].max
|
|
71
|
+
end
|
|
72
|
+
|
|
65
73
|
private
|
|
66
74
|
|
|
67
75
|
# On a list the association batches across the page, so the loaded rows
|
|
@@ -85,6 +93,9 @@ module Spree
|
|
|
85
93
|
|
|
86
94
|
unprocessed_payments.each do |payment|
|
|
87
95
|
break if settled_payment_total >= total
|
|
96
|
+
# An order can carry several live payments; once those processed
|
|
97
|
+
# so far cover it, net of refunds, the rest are left uncharged.
|
|
98
|
+
break if is_a?(Spree::Order) && payment.amount_owed_by_order(including_in_flight: true)&.zero?
|
|
88
99
|
|
|
89
100
|
result = Spree.payment_process_workflow.call(payment: payment, action: action)
|
|
90
101
|
raise Spree::Core::GatewayError, result.error.value.to_s if result.failure?
|