solidus_core 2.9.6 → 2.10.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/concerns/spree/user_address_book.rb +2 -2
- data/app/models/spree/address.rb +2 -2
- data/app/models/spree/adjustment.rb +9 -9
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/base.rb +0 -2
- data/app/models/spree/calculator.rb +1 -1
- data/app/models/spree/carton.rb +3 -3
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/inventory_unit.rb +4 -4
- data/app/models/spree/line_item.rb +3 -3
- data/app/models/spree/line_item_action.rb +2 -2
- data/app/models/spree/log_entry.rb +1 -1
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/option_values_variant.rb +2 -2
- data/app/models/spree/order.rb +8 -25
- data/app/models/spree/order_cancellations.rb +1 -1
- data/app/models/spree/order_contents.rb +2 -2
- data/app/models/spree/order_mutex.rb +1 -1
- data/app/models/spree/order_promotion.rb +3 -3
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/order_taxation.rb +1 -1
- data/app/models/spree/payment/processing.rb +1 -1
- data/app/models/spree/payment.rb +4 -4
- data/app/models/spree/payment_capture_event.rb +1 -1
- data/app/models/spree/payment_method/bogus_credit_card.rb +1 -1
- data/app/models/spree/payment_method.rb +3 -0
- data/app/models/spree/payment_source.rb +1 -1
- data/app/models/spree/price.rb +2 -2
- data/app/models/spree/product/scopes.rb +217 -210
- data/app/models/spree/product.rb +2 -2
- data/app/models/spree/product_option_type.rb +2 -2
- data/app/models/spree/product_promotion_rule.rb +2 -2
- data/app/models/spree/product_property.rb +2 -2
- data/app/models/spree/promotion.rb +1 -1
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_code.rb +2 -2
- data/app/models/spree/promotion_code_batch.rb +1 -1
- data/app/models/spree/promotion_rule.rb +1 -1
- data/app/models/spree/promotion_rule_role.rb +2 -2
- data/app/models/spree/promotion_rule_store.rb +2 -2
- data/app/models/spree/promotion_rule_taxon.rb +2 -2
- data/app/models/spree/promotion_rule_user.rb +2 -2
- data/app/models/spree/refund.rb +3 -3
- data/app/models/spree/reimbursement/credit.rb +2 -2
- data/app/models/spree/reimbursement.rb +2 -2
- data/app/models/spree/reimbursement_tax_calculator.rb +1 -1
- data/app/models/spree/return_authorization.rb +3 -3
- data/app/models/spree/return_item.rb +10 -10
- data/app/models/spree/role_user.rb +2 -2
- data/app/models/spree/shipment.rb +3 -3
- data/app/models/spree/shipping_manifest.rb +3 -3
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/shipping_method_category.rb +2 -2
- data/app/models/spree/shipping_method_stock_location.rb +2 -2
- data/app/models/spree/shipping_method_zone.rb +2 -2
- data/app/models/spree/shipping_rate.rb +2 -2
- data/app/models/spree/shipping_rate_tax.rb +2 -2
- data/app/models/spree/state.rb +1 -1
- data/app/models/spree/state_change.rb +2 -2
- data/app/models/spree/stock_item.rb +2 -2
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store_credit.rb +8 -8
- data/app/models/spree/store_credit_event.rb +3 -3
- data/app/models/spree/store_payment_method.rb +2 -2
- data/app/models/spree/store_shipping_method.rb +2 -2
- data/app/models/spree/tax_rate.rb +1 -1
- data/app/models/spree/tax_rate_tax_category.rb +2 -2
- data/app/models/spree/unit_cancel.rb +5 -2
- data/app/models/spree/user_address.rb +2 -2
- data/app/models/spree/user_stock_location.rb +2 -2
- data/app/models/spree/variant/scopes.rb +37 -29
- data/app/models/spree/variant.rb +1 -1
- data/app/models/spree/variant_property_rule.rb +1 -1
- data/app/models/spree/variant_property_rule_condition.rb +2 -2
- data/app/models/spree/variant_property_rule_value.rb +2 -2
- data/app/models/spree/wallet_payment_source.rb +2 -2
- data/app/models/spree/zone_member.rb +2 -2
- data/config/initializers/inflections.rb +5 -0
- data/config/locales/en.yml +22 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -0
- data/lib/generators/spree/install/install_generator.rb +0 -3
- data/lib/spree/core/controller_helpers/strong_parameters.rb +7 -21
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/importer/order.rb +3 -4
- data/lib/spree/core/importer/product.rb +2 -2
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/permission_sets/default_customer.rb +1 -1
- data/lib/spree/permitted_attributes.rb +6 -75
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +6 -2
- data/solidus_core.gemspec +4 -4
- data/spec/lib/search/base_spec.rb +5 -1
- data/spec/lib/search/variant_spec.rb +1 -1
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +1 -8
- data/spec/lib/spree/core/environment_extension_spec.rb +1 -12
- data/spec/lib/spree/event_spec.rb +15 -3
- data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +18 -4
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +1 -1
- data/spec/models/spree/carton_spec.rb +2 -2
- data/spec/models/spree/concerns/user_methods_spec.rb +3 -3
- data/spec/models/spree/credit_card_spec.rb +2 -2
- data/spec/models/spree/customer_return_spec.rb +1 -1
- data/spec/models/spree/order/checkout_spec.rb +1 -1
- data/spec/models/spree/order/outstanding_balance_integration_spec.rb +5 -5
- data/spec/models/spree/order/payment_spec.rb +1 -1
- data/spec/models/spree/order_contents_spec.rb +1 -1
- data/spec/models/spree/order_inventory_spec.rb +3 -3
- data/spec/models/spree/order_shipping_spec.rb +1 -1
- data/spec/models/spree/order_spec.rb +6 -6
- data/spec/models/spree/payment_create_spec.rb +2 -2
- data/spec/models/spree/payment_spec.rb +12 -12
- data/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/nth_order_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/taxon_spec.rb +0 -1
- data/spec/models/spree/promotion_spec.rb +0 -4
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +2 -2
- data/spec/models/spree/return_item_spec.rb +11 -11
- data/spec/models/spree/shipment_spec.rb +6 -6
- data/spec/models/spree/stock/inventory_units_finalizer_spec.rb +4 -4
- data/spec/models/spree/stock/quantifier_spec.rb +2 -2
- data/spec/models/spree/store_credit_spec.rb +7 -7
- data/spec/models/spree/tax_category_spec.rb +1 -1
- data/spec/models/spree/taxon_spec.rb +2 -2
- data/spec/models/spree/unit_cancel_spec.rb +5 -0
- data/spec/models/spree/user_spec.rb +3 -3
- metadata +32 -32
- data/spec/lib/spree/permitted_attributes_spec.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d36219391d7785627d0a35a8929f818350001dbe3f06149bc0f954daadaf301
|
4
|
+
data.tar.gz: 982ce1d0d2866b852b7e421361f06c81b6b4a98066093e5d6c8ae03ceb0d5866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cedc37f87d1641177f28e8172b6c667da086cd3ed4c1e8081390ffb8026974dd582731c5a4a2d827ff3333495e51705c0975b3efff5e25bce7d3b030302a7b4
|
7
|
+
data.tar.gz: f577d26426c6723f1b6bba21d11c647549a6569851b286b29756dfe9b8eccd710f235452393b12f8bd3ab43666eefd7b2d519024888e737233c9a69b14a81fc5
|
@@ -25,7 +25,7 @@ module Spree
|
|
25
25
|
has_many :addresses, through: :user_addresses
|
26
26
|
|
27
27
|
# bill_address is only minimally used now, but we can't get rid of it without a major version release
|
28
|
-
belongs_to :bill_address, class_name: 'Spree::Address'
|
28
|
+
belongs_to :bill_address, class_name: 'Spree::Address', optional: true
|
29
29
|
|
30
30
|
has_one :default_user_address, ->{ default }, class_name: 'Spree::UserAddress', foreign_key: 'user_id'
|
31
31
|
has_one :default_address, through: :default_user_address, source: :address
|
@@ -130,7 +130,7 @@ module Spree
|
|
130
130
|
def remove_from_address_book(address_id)
|
131
131
|
user_address = user_addresses.find_by(address_id: address_id)
|
132
132
|
if user_address
|
133
|
-
user_address.
|
133
|
+
user_address.update(archived: true, default: false)
|
134
134
|
else
|
135
135
|
false
|
136
136
|
end
|
data/app/models/spree/address.rb
CHANGED
@@ -8,8 +8,8 @@ module Spree
|
|
8
8
|
class Address < Spree::Base
|
9
9
|
extend ActiveModel::ForbiddenAttributesProtection
|
10
10
|
|
11
|
-
belongs_to :country, class_name: "Spree::Country"
|
12
|
-
belongs_to :state, class_name: "Spree::State"
|
11
|
+
belongs_to :country, class_name: "Spree::Country", optional: true
|
12
|
+
belongs_to :state, class_name: "Spree::State", optional: true
|
13
13
|
|
14
14
|
validates :firstname, :address1, :city, :country_id, presence: true
|
15
15
|
validates :zipcode, presence: true, if: :require_zipcode?
|
@@ -16,11 +16,11 @@ module Spree
|
|
16
16
|
# order's adjustment total. This allows an adjustment to be preserved if
|
17
17
|
# it becomes ineligible so it might be reinstated.
|
18
18
|
class Adjustment < Spree::Base
|
19
|
-
belongs_to :adjustable, polymorphic: true, touch: true
|
20
|
-
belongs_to :source, polymorphic: true
|
21
|
-
belongs_to :order, class_name: 'Spree::Order', inverse_of: :all_adjustments
|
22
|
-
belongs_to :promotion_code, class_name: 'Spree::PromotionCode'
|
23
|
-
belongs_to :adjustment_reason, class_name: 'Spree::AdjustmentReason', inverse_of: :adjustments
|
19
|
+
belongs_to :adjustable, polymorphic: true, touch: true, optional: true
|
20
|
+
belongs_to :source, polymorphic: true, optional: true
|
21
|
+
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
|
+
belongs_to :adjustment_reason, class_name: 'Spree::AdjustmentReason', inverse_of: :adjustments, optional: true
|
24
24
|
|
25
25
|
validates :adjustable, presence: true
|
26
26
|
validates :order, presence: true
|
@@ -57,19 +57,19 @@ module Spree
|
|
57
57
|
money_methods :amount
|
58
58
|
|
59
59
|
def finalize!
|
60
|
-
|
60
|
+
update!(finalized: true)
|
61
61
|
end
|
62
62
|
|
63
63
|
def unfinalize!
|
64
|
-
|
64
|
+
update!(finalized: false)
|
65
65
|
end
|
66
66
|
|
67
67
|
def finalize
|
68
|
-
|
68
|
+
update(finalized: true)
|
69
69
|
end
|
70
70
|
|
71
71
|
def unfinalize
|
72
|
-
|
72
|
+
update(finalized: false)
|
73
73
|
end
|
74
74
|
|
75
75
|
def currency
|
data/app/models/spree/asset.rb
CHANGED
data/app/models/spree/base.rb
CHANGED
data/app/models/spree/carton.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Spree::Carton < Spree::Base
|
4
|
-
belongs_to :address, class_name: 'Spree::Address'
|
5
|
-
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :cartons
|
6
|
-
belongs_to :shipping_method, class_name: 'Spree::ShippingMethod', inverse_of: :cartons
|
4
|
+
belongs_to :address, class_name: 'Spree::Address', optional: true
|
5
|
+
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :cartons, optional: true
|
6
|
+
belongs_to :shipping_method, class_name: 'Spree::ShippingMethod', inverse_of: :cartons, optional: true
|
7
7
|
|
8
8
|
has_many :inventory_units, class_name: "Spree::InventoryUnit", inverse_of: :carton, dependent: :nullify
|
9
9
|
has_many :orders, -> { distinct }, through: :inventory_units
|
@@ -4,8 +4,8 @@ module Spree
|
|
4
4
|
class Classification < Spree::Base
|
5
5
|
self.table_name = 'spree_products_taxons'
|
6
6
|
acts_as_list scope: :taxon
|
7
|
-
belongs_to :product, class_name: "Spree::Product", inverse_of: :classifications, touch: true
|
8
|
-
belongs_to :taxon, class_name: "Spree::Taxon", inverse_of: :classifications, touch: true
|
7
|
+
belongs_to :product, class_name: "Spree::Product", inverse_of: :classifications, touch: true, optional: true
|
8
|
+
belongs_to :taxon, class_name: "Spree::Taxon", inverse_of: :classifications, touch: true, optional: true
|
9
9
|
|
10
10
|
# For https://github.com/spree/spree/issues/3494
|
11
11
|
validates_uniqueness_of :taxon_id, scope: :product_id, message: :already_linked
|
@@ -4,8 +4,8 @@ module Spree
|
|
4
4
|
# The default `source` of a `Spree::Payment`.
|
5
5
|
#
|
6
6
|
class CreditCard < Spree::PaymentSource
|
7
|
-
belongs_to :user, class_name: Spree::UserClassHandle.new, foreign_key: 'user_id'
|
8
|
-
belongs_to :address
|
7
|
+
belongs_to :user, class_name: Spree::UserClassHandle.new, foreign_key: 'user_id', optional: true
|
8
|
+
belongs_to :address, optional: true
|
9
9
|
|
10
10
|
before_save :set_last_digits
|
11
11
|
|
@@ -7,7 +7,7 @@ module Spree::Image::PaperclipAttachment
|
|
7
7
|
validate :no_attachment_errors
|
8
8
|
|
9
9
|
has_attached_file :attachment,
|
10
|
-
styles: { mini: '48x48>', small: '
|
10
|
+
styles: { mini: '48x48>', small: '400x400>', product: '680x680>', large: '1200x1200>' },
|
11
11
|
default_style: :product,
|
12
12
|
default_url: 'noimage/:style.png',
|
13
13
|
url: '/spree/products/:id/:style/:basename.:extension',
|
@@ -8,10 +8,10 @@ module Spree
|
|
8
8
|
POST_SHIPMENT_STATES = %w(returned)
|
9
9
|
CANCELABLE_STATES = ['on_hand', 'backordered', 'shipped']
|
10
10
|
|
11
|
-
belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :inventory_units
|
12
|
-
belongs_to :shipment, class_name: "Spree::Shipment", touch: true, inverse_of: :inventory_units
|
13
|
-
belongs_to :carton, class_name: "Spree::Carton", inverse_of: :inventory_units
|
14
|
-
belongs_to :line_item, class_name: "Spree::LineItem", inverse_of: :inventory_units
|
11
|
+
belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :inventory_units, optional: true
|
12
|
+
belongs_to :shipment, class_name: "Spree::Shipment", touch: true, inverse_of: :inventory_units, optional: true
|
13
|
+
belongs_to :carton, class_name: "Spree::Carton", inverse_of: :inventory_units, optional: true
|
14
|
+
belongs_to :line_item, class_name: "Spree::LineItem", inverse_of: :inventory_units, optional: true
|
15
15
|
|
16
16
|
has_many :return_items, inverse_of: :inventory_unit, dependent: :destroy
|
17
17
|
has_one :original_return_item, class_name: "Spree::ReturnItem", foreign_key: :exchange_inventory_unit_id, dependent: :destroy
|
@@ -12,9 +12,9 @@ module Spree
|
|
12
12
|
class LineItem < Spree::Base
|
13
13
|
class CurrencyMismatch < StandardError; end
|
14
14
|
|
15
|
-
belongs_to :order, class_name: "Spree::Order", inverse_of: :line_items, touch: true
|
16
|
-
belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :line_items
|
17
|
-
belongs_to :tax_category, class_name: "Spree::TaxCategory"
|
15
|
+
belongs_to :order, class_name: "Spree::Order", inverse_of: :line_items, touch: true, optional: true
|
16
|
+
belongs_to :variant, -> { with_deleted }, class_name: "Spree::Variant", inverse_of: :line_items, optional: true
|
17
|
+
belongs_to :tax_category, class_name: "Spree::TaxCategory", optional: true
|
18
18
|
|
19
19
|
has_one :product, through: :variant
|
20
20
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
class OptionValue < Spree::Base
|
5
|
-
belongs_to :option_type, class_name: 'Spree::OptionType', inverse_of: :option_values
|
5
|
+
belongs_to :option_type, class_name: 'Spree::OptionType', inverse_of: :option_values, optional: true
|
6
6
|
acts_as_list scope: :option_type
|
7
7
|
|
8
8
|
has_many :option_values_variants, dependent: :destroy
|
data/app/models/spree/order.rb
CHANGED
@@ -55,15 +55,15 @@ module Spree
|
|
55
55
|
deprecate :temporary_credit_card= => :temporary_payment_source=, deprecator: Spree::Deprecation
|
56
56
|
|
57
57
|
# Customer info
|
58
|
-
belongs_to :user, class_name: Spree::UserClassHandle.new
|
59
|
-
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address'
|
58
|
+
belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
|
59
|
+
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address', optional: true
|
60
60
|
alias_attribute :billing_address, :bill_address
|
61
61
|
|
62
|
-
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address'
|
62
|
+
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address', optional: true
|
63
63
|
alias_attribute :shipping_address, :ship_address
|
64
64
|
alias_attribute :ship_total, :shipment_total
|
65
65
|
|
66
|
-
belongs_to :store, class_name: 'Spree::Store'
|
66
|
+
belongs_to :store, class_name: 'Spree::Store', optional: true
|
67
67
|
|
68
68
|
# Items
|
69
69
|
has_many :line_items, -> { order(:created_at, :id) }, dependent: :destroy, inverse_of: :order
|
@@ -101,9 +101,9 @@ module Spree
|
|
101
101
|
|
102
102
|
# Logging
|
103
103
|
has_many :state_changes, as: :stateful
|
104
|
-
belongs_to :created_by, class_name: Spree::UserClassHandle.new
|
105
|
-
belongs_to :approver, class_name: Spree::UserClassHandle.new
|
106
|
-
belongs_to :canceler, class_name: Spree::UserClassHandle.new
|
104
|
+
belongs_to :created_by, class_name: Spree::UserClassHandle.new, optional: true
|
105
|
+
belongs_to :approver, class_name: Spree::UserClassHandle.new, optional: true
|
106
|
+
belongs_to :canceler, class_name: Spree::UserClassHandle.new, optional: true
|
107
107
|
|
108
108
|
accepts_nested_attributes_for :line_items
|
109
109
|
accepts_nested_attributes_for :bill_address
|
@@ -435,13 +435,6 @@ module Spree
|
|
435
435
|
touch :completed_at
|
436
436
|
|
437
437
|
Spree::Event.fire 'order_finalized', order: self
|
438
|
-
|
439
|
-
if method(:deliver_order_confirmation_email).owner != self.class
|
440
|
-
Spree::Deprecation.warn \
|
441
|
-
"deliver_order_confirmation_email has been deprecated and moved to " \
|
442
|
-
"Spree::MailerSubscriber#order_finalized, please move there any customizations.",
|
443
|
-
caller(1)
|
444
|
-
end
|
445
438
|
end
|
446
439
|
|
447
440
|
def fulfill!
|
@@ -450,16 +443,6 @@ module Spree
|
|
450
443
|
save!
|
451
444
|
end
|
452
445
|
|
453
|
-
def deliver_order_confirmation_email
|
454
|
-
Spree::Deprecation.warn \
|
455
|
-
"deliver_order_confirmation_email has been deprecated and moved to " \
|
456
|
-
"Spree::MailerSubscriber#order_finalized.",
|
457
|
-
caller(1)
|
458
|
-
|
459
|
-
Spree::Config.order_mailer_class.confirm_email(order).deliver_later
|
460
|
-
order.update_column(:confirmation_delivered, true)
|
461
|
-
end
|
462
|
-
|
463
446
|
# Helper methods for checkout steps
|
464
447
|
def paid?
|
465
448
|
%w(paid credit_owed).include?(payment_state)
|
@@ -676,7 +659,7 @@ module Spree
|
|
676
659
|
if remaining_total.zero?
|
677
660
|
other_payments.each(&:invalidate!)
|
678
661
|
elsif other_payments.size == 1
|
679
|
-
other_payments.first.
|
662
|
+
other_payments.first.update!(amount: remaining_total)
|
680
663
|
end
|
681
664
|
|
682
665
|
payments.reset
|
@@ -139,7 +139,7 @@ class Spree::OrderCancellations
|
|
139
139
|
|
140
140
|
shipments.each do |shipment|
|
141
141
|
if shipment.inventory_units.all? { |iu| iu.shipped? || iu.canceled? }
|
142
|
-
shipment.
|
142
|
+
shipment.update!(state: 'shipped', shipped_at: Time.current)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -35,7 +35,7 @@ module Spree
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def update_cart(params)
|
38
|
-
if order.
|
38
|
+
if order.update(params)
|
39
39
|
unless order.completed?
|
40
40
|
order.line_items = order.line_items.select { |li| li.quantity > 0 }
|
41
41
|
# Update totals, then check if the order is eligible for any cart promotions.
|
@@ -61,7 +61,7 @@ module Spree
|
|
61
61
|
raise ArgumentError, 'user or name must be specified'
|
62
62
|
end
|
63
63
|
|
64
|
-
order.
|
64
|
+
order.update!(
|
65
65
|
approver: user,
|
66
66
|
approver_name: name,
|
67
67
|
approved_at: Time.current
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
class OrderMutex < Spree::Base
|
5
5
|
class LockFailed < StandardError; end
|
6
6
|
|
7
|
-
belongs_to :order, class_name: "Spree::Order"
|
7
|
+
belongs_to :order, class_name: "Spree::Order", optional: true
|
8
8
|
|
9
9
|
scope :expired, -> { where(arel_table[:created_at].lteq(Spree::Config[:order_mutex_max_age].seconds.ago)) }
|
10
10
|
|
@@ -8,9 +8,9 @@ module Spree
|
|
8
8
|
class OrderPromotion < Spree::Base
|
9
9
|
self.table_name = 'spree_orders_promotions'
|
10
10
|
|
11
|
-
belongs_to :order, class_name: 'Spree::Order'
|
12
|
-
belongs_to :promotion, class_name: 'Spree::Promotion'
|
13
|
-
belongs_to :promotion_code, class_name: 'Spree::PromotionCode'
|
11
|
+
belongs_to :order, class_name: 'Spree::Order', optional: true
|
12
|
+
belongs_to :promotion, class_name: 'Spree::Promotion', optional: true
|
13
|
+
belongs_to :promotion_code, class_name: 'Spree::PromotionCode', optional: true
|
14
14
|
|
15
15
|
validates :order, presence: true
|
16
16
|
validates :promotion, presence: true
|
@@ -64,7 +64,7 @@ class Spree::OrderShipping
|
|
64
64
|
inventory_units.map(&:shipment).uniq.each do |shipment|
|
65
65
|
# Temporarily propagate the tracking number to the shipment as well
|
66
66
|
# TODO: Remove tracking numbers from shipments.
|
67
|
-
shipment.
|
67
|
+
shipment.update!(tracking: tracking_number)
|
68
68
|
|
69
69
|
next unless shipment.inventory_units.reload.all? { |iu| iu.shipped? || iu.canceled? }
|
70
70
|
# TODO: make OrderShipping#ship_shipment call Shipment#ship! rather than
|
data/app/models/spree/payment.rb
CHANGED
@@ -15,9 +15,9 @@ module Spree
|
|
15
15
|
NON_RISKY_AVS_CODES = ['B', 'D', 'H', 'J', 'M', 'Q', 'T', 'V', 'X', 'Y'].freeze
|
16
16
|
RISKY_AVS_CODES = ['A', 'C', 'E', 'F', 'G', 'I', 'K', 'L', 'N', 'O', 'P', 'R', 'S', 'U', 'W', 'Z'].freeze
|
17
17
|
|
18
|
-
belongs_to :order, class_name: 'Spree::Order', touch: true, inverse_of: :payments
|
19
|
-
belongs_to :source, polymorphic: true
|
20
|
-
belongs_to :payment_method, -> { with_deleted }, class_name: 'Spree::PaymentMethod', inverse_of: :payments
|
18
|
+
belongs_to :order, class_name: 'Spree::Order', touch: true, inverse_of: :payments, optional: true
|
19
|
+
belongs_to :source, polymorphic: true, optional: true
|
20
|
+
belongs_to :payment_method, -> { with_deleted }, class_name: 'Spree::PaymentMethod', inverse_of: :payments, optional: true
|
21
21
|
|
22
22
|
has_many :offsets, -> { offset_payment }, class_name: "Spree::Payment", foreign_key: :source_id
|
23
23
|
has_many :log_entries, as: :source
|
@@ -273,7 +273,7 @@ module Spree
|
|
273
273
|
# type of payment getting refunded, hence the additional check
|
274
274
|
# if the source is a store credit.
|
275
275
|
if store_credit? && source.is_a?(Spree::StoreCredit)
|
276
|
-
source.
|
276
|
+
source.update!({
|
277
277
|
action: Spree::StoreCredit::ELIGIBLE_ACTION,
|
278
278
|
action_amount: amount,
|
279
279
|
action_authorization_code: response_code
|
@@ -19,7 +19,7 @@ module Spree
|
|
19
19
|
return if payment.source.has_payment_profile?
|
20
20
|
# simulate the storage of credit card profile using remote service
|
21
21
|
if success = VALID_CCS.include?(payment.source.number)
|
22
|
-
payment.source.
|
22
|
+
payment.source.update(gateway_customer_profile_id: generate_profile_id(success))
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -199,6 +199,9 @@ module Spree
|
|
199
199
|
# 4. app/views/spree/admin/payments/source_views/_{partial_name}.html.erb
|
200
200
|
# The view that represents your payment method on orders in the backend
|
201
201
|
#
|
202
|
+
# 5. app/views/spree/api/payments/source_views/_{partial_name}.json.jbuilder
|
203
|
+
# The view that represents your payment method on orders through the api
|
204
|
+
#
|
202
205
|
def partial_name
|
203
206
|
deprecated_method_type_override || type.demodulize.underscore
|
204
207
|
end
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
class PaymentSource < Spree::Base
|
5
5
|
self.abstract_class = true
|
6
6
|
|
7
|
-
belongs_to :payment_method
|
7
|
+
belongs_to :payment_method, optional: true
|
8
8
|
|
9
9
|
has_many :payments, as: :source
|
10
10
|
has_many :wallet_payment_sources, class_name: 'Spree::WalletPaymentSource', as: :payment_source, inverse_of: :payment_source
|
data/app/models/spree/price.rb
CHANGED
@@ -12,8 +12,8 @@ module Spree
|
|
12
12
|
|
13
13
|
MAXIMUM_AMOUNT = BigDecimal('99_999_999.99')
|
14
14
|
|
15
|
-
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant', touch: true
|
16
|
-
belongs_to :country, class_name: "Spree::Country", foreign_key: "country_iso", primary_key: "iso"
|
15
|
+
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant', touch: true, optional: true
|
16
|
+
belongs_to :country, class_name: "Spree::Country", foreign_key: "country_iso", primary_key: "iso", optional: true
|
17
17
|
|
18
18
|
delegate :product, to: :variant
|
19
19
|
delegate :tax_rates, to: :variant
|