spree_core 2.4.2 → 2.4.3
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/models/spree/adjustment.rb +1 -1
- data/app/models/spree/calculator/flat_rate.rb +5 -1
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/inventory_unit.rb +3 -3
- data/app/models/spree/item_adjustments.rb +1 -1
- data/app/models/spree/order.rb +8 -2
- data/app/models/spree/order_populator.rb +1 -0
- data/app/models/spree/order_updater.rb +2 -4
- data/app/models/spree/payment.rb +20 -9
- data/app/models/spree/payment/processing.rb +5 -4
- data/app/models/spree/product.rb +1 -1
- data/app/models/spree/promotion.rb +15 -1
- data/app/models/spree/promotion_handler/free_shipping.rb +10 -8
- data/app/models/spree/reimbursement.rb +2 -2
- data/app/models/spree/return_item/eligibility_validator/default.rb +1 -0
- data/app/models/spree/return_item/eligibility_validator/order_completed.rb +16 -0
- data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +1 -1
- data/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb +1 -2
- data/app/models/spree/shipment.rb +20 -27
- data/app/models/spree/shipping_category.rb +1 -1
- data/app/models/spree/stock/inventory_unit_builder.rb +11 -2
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/taxon.rb +2 -1
- data/app/models/spree/variant.rb +5 -0
- data/app/models/spree/variant/scopes.rb +5 -1
- data/config/initializers/user_class_extensions.rb +1 -1
- data/config/locales/en.yml +7 -1
- data/db/migrate/20130807024301_upgrade_adjustments.rb +5 -4
- data/lib/spree/core/search/base.rb +18 -5
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/factories/address_factory.rb +2 -2
- data/lib/spree/testing_support/factories/calculator_factory.rb +8 -0
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +1 -0
- data/lib/spree/testing_support/factories/payment_factory.rb +7 -0
- data/lib/spree/testing_support/factories/promotion_factory.rb +3 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +2 -2
- data/lib/tasks/core.rake +4 -0
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 830a074cf4aa461f6a0048f7b0578b50bec34123
|
4
|
+
data.tar.gz: 89b65b78a3b6402475e921f6adfd77e0cbb1556c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68771092861e282cbb550d6eadad20cbe20b30d79d26edeb213cffb2a4f34156a77526d60c82f6021b7358833375aa7d2c6b1e045ce371ad06bca4c6b7212c32
|
7
|
+
data.tar.gz: a597449e89e72c2c27f60e3b3c92cc5edccfa43f8827441f5d2497ef5f6f2ab3c16745a4522f81facd00383d718d9ad243a624268e5a380b2e6f98ed01d785e2
|
@@ -60,7 +60,7 @@ module Spree
|
|
60
60
|
scope :nonzero, -> { where("#{quoted_table_name}.amount != 0") }
|
61
61
|
scope :promotion, -> { where(source_type: 'Spree::PromotionAction') }
|
62
62
|
scope :return_authorization, -> { where(source_type: "Spree::ReturnAuthorization") }
|
63
|
-
scope :
|
63
|
+
scope :is_included, -> { where(included: true) }
|
64
64
|
scope :additional, -> { where(included: false) }
|
65
65
|
|
66
66
|
def closed?
|
@@ -3,9 +3,9 @@ module Spree
|
|
3
3
|
self.table_name = 'spree_products_taxons'
|
4
4
|
acts_as_list scope: :taxon
|
5
5
|
belongs_to :product, class_name: "Spree::Product", inverse_of: :classifications
|
6
|
-
belongs_to :taxon, class_name: "Spree::Taxon", inverse_of: :classifications
|
6
|
+
belongs_to :taxon, class_name: "Spree::Taxon", inverse_of: :classifications, touch: true
|
7
7
|
|
8
8
|
# For #3494
|
9
|
-
validates_uniqueness_of :taxon_id, :
|
9
|
+
validates_uniqueness_of :taxon_id, scope: :product_id, message: :already_linked
|
10
10
|
end
|
11
11
|
end
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
event :fill_backorder do
|
27
27
|
transition to: :on_hand, from: :backordered
|
28
28
|
end
|
29
|
-
after_transition on: :fill_backorder, do: :
|
29
|
+
after_transition on: :fill_backorder, do: :fulfill_order
|
30
30
|
|
31
31
|
event :ship do
|
32
32
|
transition to: :shipped, if: :allow_ship?
|
@@ -86,9 +86,9 @@ module Spree
|
|
86
86
|
self.on_hand?
|
87
87
|
end
|
88
88
|
|
89
|
-
def
|
89
|
+
def fulfill_order
|
90
90
|
self.reload
|
91
|
-
order.
|
91
|
+
order.fulfill!
|
92
92
|
end
|
93
93
|
|
94
94
|
def percentage_of_line_item
|
@@ -52,7 +52,7 @@ module Spree
|
|
52
52
|
additional_tax_total = 0
|
53
53
|
run_callbacks :tax_adjustments do
|
54
54
|
tax = (item.respond_to?(:all_adjustments) ? item.all_adjustments : item.adjustments).tax
|
55
|
-
included_tax_total = tax.
|
55
|
+
included_tax_total = tax.is_included.reload.map(&:update!).compact.sum
|
56
56
|
additional_tax_total = tax.additional.reload.map(&:update!).compact.sum
|
57
57
|
end
|
58
58
|
|
data/app/models/spree/order.rb
CHANGED
@@ -41,9 +41,9 @@ module Spree
|
|
41
41
|
|
42
42
|
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address'
|
43
43
|
alias_attribute :shipping_address, :ship_address
|
44
|
-
|
45
44
|
alias_attribute :ship_total, :shipment_total
|
46
45
|
|
46
|
+
belongs_to :store, class_name: 'Spree::Store'
|
47
47
|
has_many :state_changes, as: :stateful
|
48
48
|
has_many :line_items, -> { order("#{LineItem.table_name}.created_at ASC") }, dependent: :destroy, inverse_of: :order
|
49
49
|
has_many :payments, dependent: :destroy
|
@@ -349,7 +349,7 @@ module Spree
|
|
349
349
|
end
|
350
350
|
|
351
351
|
def outstanding_balance
|
352
|
-
if
|
352
|
+
if state == 'canceled'
|
353
353
|
-1 * payment_total
|
354
354
|
else
|
355
355
|
total - payment_total
|
@@ -404,6 +404,12 @@ module Spree
|
|
404
404
|
consider_risk
|
405
405
|
end
|
406
406
|
|
407
|
+
def fulfill!
|
408
|
+
shipments.each { |shipment| shipment.update!(self) if shipment.persisted? }
|
409
|
+
updater.update_shipment_state
|
410
|
+
save!
|
411
|
+
end
|
412
|
+
|
407
413
|
def deliver_order_confirmation_email
|
408
414
|
OrderMailer.confirm_email(self.id).deliver
|
409
415
|
update_column(:confirmation_delivered, true)
|
@@ -10,6 +10,7 @@ module Spree
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def populate(variant_id, quantity, options = {})
|
13
|
+
ActiveSupport::Deprecation.warn "OrderPopulator is deprecated and will be removed from Spree 3, use OrderContents with order.contents.add instead.", caller
|
13
14
|
# protect against passing a nil hash being passed in
|
14
15
|
# due to an empty params[:options]
|
15
16
|
attempt_cart_add(variant_id, quantity, options || {})
|
@@ -59,7 +59,7 @@ module Spree
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def update_payment_total
|
62
|
-
order.payment_total = payments.completed.sum(:amount)
|
62
|
+
order.payment_total = payments.completed.includes(:refunds).inject(0) { |sum, payment| sum + payment.amount - payment.refunds.sum(:amount) }
|
63
63
|
end
|
64
64
|
|
65
65
|
def update_shipment_total
|
@@ -158,9 +158,7 @@ module Spree
|
|
158
158
|
last_state = order.payment_state
|
159
159
|
if payments.present? && payments.valid.size == 0
|
160
160
|
order.payment_state = 'failed'
|
161
|
-
elsif
|
162
|
-
order.payment_state = 'void'
|
163
|
-
elsif order.state == 'canceled' && order.payment_total == 0 && payments.completed.size > 0
|
161
|
+
elsif order.state == 'canceled' && order.payment_total == 0
|
164
162
|
order.payment_state = 'void'
|
165
163
|
else
|
166
164
|
order.payment_state = 'balance_due' if order.outstanding_balance > 0
|
data/app/models/spree/payment.rb
CHANGED
@@ -30,7 +30,6 @@ module Spree
|
|
30
30
|
attr_accessor :source_attributes, :request_env
|
31
31
|
|
32
32
|
after_initialize :build_source
|
33
|
-
after_rollback :persist_invalid
|
34
33
|
|
35
34
|
validates :amount, numericality: true
|
36
35
|
|
@@ -55,12 +54,6 @@ module Spree
|
|
55
54
|
response_code
|
56
55
|
end
|
57
56
|
|
58
|
-
def persist_invalid
|
59
|
-
return unless ['failed', 'invalid'].include?(state)
|
60
|
-
state_will_change!
|
61
|
-
save
|
62
|
-
end
|
63
|
-
|
64
57
|
# order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
|
65
58
|
state_machine initial: :checkout do
|
66
59
|
# With card payments, happens before purchase or authorization happens
|
@@ -163,8 +156,12 @@ module Spree
|
|
163
156
|
return true
|
164
157
|
end
|
165
158
|
|
159
|
+
def captured_amount
|
160
|
+
capture_events.sum(:amount)
|
161
|
+
end
|
162
|
+
|
166
163
|
def uncaptured_amount
|
167
|
-
amount -
|
164
|
+
amount - captured_amount
|
168
165
|
end
|
169
166
|
|
170
167
|
private
|
@@ -204,8 +201,22 @@ module Spree
|
|
204
201
|
end
|
205
202
|
end
|
206
203
|
|
204
|
+
def split_uncaptured_amount
|
205
|
+
if uncaptured_amount > 0
|
206
|
+
order.payments.create! amount: uncaptured_amount,
|
207
|
+
avs_response: avs_response,
|
208
|
+
cvv_response_code: cvv_response_code,
|
209
|
+
cvv_response_message: cvv_response_message,
|
210
|
+
payment_method: payment_method,
|
211
|
+
response_code: response_code,
|
212
|
+
source: source,
|
213
|
+
state: 'pending'
|
214
|
+
update_attributes(amount: captured_amount)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
207
218
|
def update_order
|
208
|
-
if
|
219
|
+
if completed? || void?
|
209
220
|
order.updater.update_payment_total
|
210
221
|
end
|
211
222
|
|
@@ -19,10 +19,11 @@ module Spree
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Takes the amount in cents to capture.
|
22
|
-
# Can be used to capture partial amounts of a payment
|
23
|
-
|
24
|
-
|
22
|
+
# Can be used to capture partial amounts of a payment, and will create
|
23
|
+
# a new pending payment record for the remaining amount to capture later.
|
24
|
+
def capture!(amount = nil)
|
25
25
|
return true if completed?
|
26
|
+
amount ||= money.money.cents
|
26
27
|
started_processing!
|
27
28
|
protect_from_connection_error do
|
28
29
|
check_environment
|
@@ -32,9 +33,9 @@ module Spree
|
|
32
33
|
response_code,
|
33
34
|
gateway_options
|
34
35
|
)
|
35
|
-
|
36
36
|
money = ::Money.new(amount, currency)
|
37
37
|
capture_events.create!(amount: money.to_f)
|
38
|
+
split_uncaptured_amount
|
38
39
|
handle_response(response, :complete, :failure)
|
39
40
|
end
|
40
41
|
end
|
data/app/models/spree/product.rb
CHANGED
@@ -147,7 +147,21 @@ module Spree
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def used_by?(user, excluded_orders = [])
|
150
|
-
|
150
|
+
[
|
151
|
+
:adjustments,
|
152
|
+
:line_item_adjustments,
|
153
|
+
:shipment_adjustments
|
154
|
+
].any? do |adjustment_type|
|
155
|
+
user.orders.complete.joins(adjustment_type).where(
|
156
|
+
spree_adjustments: {
|
157
|
+
source_type: 'Spree::PromotionAction',
|
158
|
+
source_id: actions.map(&:id),
|
159
|
+
eligible: true
|
160
|
+
}
|
161
|
+
).where.not(
|
162
|
+
id: excluded_orders.map(&:id)
|
163
|
+
).any?
|
164
|
+
end
|
151
165
|
end
|
152
166
|
|
153
167
|
private
|
@@ -2,15 +2,18 @@ module Spree
|
|
2
2
|
module PromotionHandler
|
3
3
|
# Used for activating promotions with shipping rules
|
4
4
|
class FreeShipping
|
5
|
-
attr_reader :order
|
5
|
+
attr_reader :order, :order_promo_ids
|
6
6
|
attr_accessor :error, :success
|
7
7
|
|
8
8
|
def initialize(order)
|
9
9
|
@order = order
|
10
|
+
@order_promo_ids = order.promotions.pluck(:id)
|
10
11
|
end
|
11
12
|
|
12
13
|
def activate
|
13
14
|
promotions.each do |promotion|
|
15
|
+
next if promotion.code.present? && !order_promo_ids.include?(promotion.id)
|
16
|
+
|
14
17
|
if promotion.eligible?(order)
|
15
18
|
promotion.activate(order: order)
|
16
19
|
end
|
@@ -19,13 +22,12 @@ module Spree
|
|
19
22
|
|
20
23
|
private
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
25
|
+
def promotions
|
26
|
+
Spree::Promotion.active.where(
|
27
|
+
id: Spree::Promotion::Actions::FreeShipping.pluck(:promotion_id),
|
28
|
+
path: nil
|
29
|
+
)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
class Reimbursement < Spree::Base
|
3
|
-
class
|
3
|
+
class IncompleteReimbursementError < StandardError; end
|
4
4
|
|
5
5
|
belongs_to :order, inverse_of: :reimbursements
|
6
6
|
belongs_to :customer_return, inverse_of: :reimbursements, touch: true
|
@@ -112,7 +112,7 @@ module Spree
|
|
112
112
|
else
|
113
113
|
errored!
|
114
114
|
reimbursement_failure_hooks.each { |h| h.call self }
|
115
|
-
raise
|
115
|
+
raise IncompleteReimbursementError, Spree.t("validation.unpaid_amount_not_zero", amount: unpaid_amount)
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -2,6 +2,7 @@ module Spree
|
|
2
2
|
class ReturnItem::EligibilityValidator::Default < Spree::ReturnItem::EligibilityValidator::BaseValidator
|
3
3
|
class_attribute :permitted_eligibility_validators
|
4
4
|
self.permitted_eligibility_validators = [
|
5
|
+
ReturnItem::EligibilityValidator::OrderCompleted,
|
5
6
|
ReturnItem::EligibilityValidator::TimeSincePurchase,
|
6
7
|
ReturnItem::EligibilityValidator::RMARequired,
|
7
8
|
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Spree
|
2
|
+
class ReturnItem::EligibilityValidator::OrderCompleted < Spree::ReturnItem::EligibilityValidator::BaseValidator
|
3
|
+
def eligible_for_return?
|
4
|
+
if @return_item.inventory_unit.order.completed?
|
5
|
+
return true
|
6
|
+
else
|
7
|
+
add_error(:order_not_completed, Spree.t('return_item_order_not_completed'))
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def requires_manual_intervention?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class ReturnItem::EligibilityValidator::TimeSincePurchase < Spree::ReturnItem::EligibilityValidator::BaseValidator
|
3
3
|
def eligible_for_return?
|
4
|
-
if (@return_item.inventory_unit.
|
4
|
+
if (@return_item.inventory_unit.order.completed_at + Spree::Config[:return_eligibility_number_of_days].days) > Time.now
|
5
5
|
return true
|
6
6
|
else
|
7
7
|
add_error(:number_of_days, Spree.t('return_item_time_period_ineligible'))
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
module ReturnItem::ExchangeVariantEligibility
|
3
3
|
class SameProduct
|
4
|
-
|
5
4
|
def self.eligible_variants(variant)
|
6
|
-
Spree::Variant.where(product_id: variant.product_id, is_master:
|
5
|
+
Spree::Variant.where(product_id: variant.product_id, is_master: variant.is_master?).in_stock
|
7
6
|
end
|
8
7
|
end
|
9
8
|
end
|
@@ -159,7 +159,7 @@ module Spree
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def item_cost
|
162
|
-
line_items.map(&:
|
162
|
+
line_items.map(&:final_amount).sum
|
163
163
|
end
|
164
164
|
|
165
165
|
def line_items
|
@@ -188,33 +188,26 @@ module Spree
|
|
188
188
|
pending_payments = order.pending_payments
|
189
189
|
.sort_by(&:uncaptured_amount).reverse
|
190
190
|
|
191
|
-
|
192
|
-
|
193
|
-
raise Spree::Core::GatewayError, Spree.t(:no_pending_payments)
|
194
|
-
else
|
195
|
-
shipment_to_pay = final_price_with_items
|
196
|
-
payments_amount = 0
|
197
|
-
|
198
|
-
payments_pool = pending_payments.each_with_object([]) do |payment, pool|
|
199
|
-
next if payments_amount >= shipment_to_pay
|
200
|
-
payments_amount += payment.uncaptured_amount
|
201
|
-
pool << payment
|
202
|
-
end
|
191
|
+
shipment_to_pay = final_price_with_items
|
192
|
+
payments_amount = 0
|
203
193
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
194
|
+
payments_pool = pending_payments.each_with_object([]) do |payment, pool|
|
195
|
+
break if payments_amount >= shipment_to_pay
|
196
|
+
payments_amount += payment.uncaptured_amount
|
197
|
+
pool << payment
|
198
|
+
end
|
199
|
+
|
200
|
+
payments_pool.each do |payment|
|
201
|
+
capturable_amount = if payment.amount >= shipment_to_pay
|
202
|
+
shipment_to_pay
|
203
|
+
else
|
204
|
+
payment.amount
|
205
|
+
end
|
206
|
+
|
207
|
+
cents = (capturable_amount * 100).to_i
|
208
|
+
payment.capture!(cents)
|
209
|
+
shipment_to_pay -= capturable_amount
|
214
210
|
end
|
215
|
-
rescue Spree::Core::GatewayError => e
|
216
|
-
errors.add(:base, e.message)
|
217
|
-
return !!Spree::Config[:allow_checkout_on_gateway_error]
|
218
211
|
end
|
219
212
|
|
220
213
|
def ready_or_pending?
|
@@ -285,7 +278,7 @@ module Spree
|
|
285
278
|
|
286
279
|
def to_package
|
287
280
|
package = Stock::Package.new(stock_location)
|
288
|
-
inventory_units.group_by(&:state).each do |state, state_inventory_units|
|
281
|
+
inventory_units.includes(:variant).joins(:variant).group_by(&:state).each do |state, state_inventory_units|
|
289
282
|
package.add_multiple state_inventory_units, state.to_sym
|
290
283
|
end
|
291
284
|
package
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class ShippingCategory < Spree::Base
|
3
3
|
validates :name, presence: true
|
4
4
|
has_many :products, inverse_of: :shipping_category
|
5
|
-
has_many :shipping_method_categories, inverse_of: :
|
5
|
+
has_many :shipping_method_categories, inverse_of: :shipping_category
|
6
6
|
has_many :shipping_methods, through: :shipping_method_categories
|
7
7
|
end
|
8
8
|
end
|
@@ -8,10 +8,19 @@ module Spree
|
|
8
8
|
def units
|
9
9
|
@order.line_items.flat_map do |line_item|
|
10
10
|
line_item.quantity.times.map do |i|
|
11
|
-
@order.inventory_units.
|
11
|
+
@order.inventory_units.includes(
|
12
|
+
variant: {
|
13
|
+
product: {
|
14
|
+
shipping_category: {
|
15
|
+
shipping_methods: [:calculator, { zones: :zone_members }]
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
).build(
|
12
20
|
pending: true,
|
13
21
|
variant: line_item.variant,
|
14
|
-
line_item: line_item
|
22
|
+
line_item: line_item,
|
23
|
+
order: @order
|
15
24
|
)
|
16
25
|
end
|
17
26
|
end
|
data/app/models/spree/taxon.rb
CHANGED
@@ -15,6 +15,7 @@ module Spree
|
|
15
15
|
validates :meta_description, length: { maximum: 255 }
|
16
16
|
validates :meta_title, length: { maximum: 255 }
|
17
17
|
|
18
|
+
after_save :touch_ancestors_and_taxonomy
|
18
19
|
after_touch :touch_ancestors_and_taxonomy
|
19
20
|
|
20
21
|
has_attached_file :icon,
|
@@ -89,7 +90,7 @@ module Spree
|
|
89
90
|
# Touches all ancestors at once to avoid recursive taxonomy touch, and reduce queries.
|
90
91
|
self.class.where(id: ancestors.pluck(:id)).update_all(updated_at: Time.now)
|
91
92
|
# Have taxonomy touch happen in #touch_ancestors_and_taxonomy rather than association option in order for imports to override.
|
92
|
-
taxonomy.touch
|
93
|
+
taxonomy.try!(:touch)
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
data/app/models/spree/variant.rb
CHANGED
@@ -84,6 +84,11 @@ module Spree
|
|
84
84
|
values.to_sentence({ words_connector: ", ", two_words_connector: ", " })
|
85
85
|
end
|
86
86
|
|
87
|
+
# Default to master name
|
88
|
+
def exchange_name
|
89
|
+
is_master? ? name : options_text
|
90
|
+
end
|
91
|
+
|
87
92
|
# use deleted? rather than checking the attribute directly. this
|
88
93
|
# allows extensions to override deleted? if they want to provide
|
89
94
|
# their own definition.
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module Spree
|
2
2
|
class Variant < Spree::Base
|
3
3
|
#FIXME WARNING tested only under sqlite and postgresql
|
4
|
-
scope :descend_by_popularity, -> {
|
4
|
+
scope :descend_by_popularity, -> {
|
5
|
+
ActiveSupport::Deprecation.warn "Variant.descend_by_popularity is deprecated and will be removed from Spree 3.", caller
|
6
|
+
order("COALESCE((SELECT COUNT(*) FROM #{LineItem.quoted_table_name} GROUP BY #{LineItem.quoted_table_name}.variant_id HAVING #{LineItem.quoted_table_name}.variant_id = #{Variant.quoted_table_name}.id), 0) DESC")
|
7
|
+
}
|
5
8
|
|
6
9
|
class << self
|
7
10
|
# Returns variants that match a given option value
|
@@ -10,6 +13,7 @@ module Spree
|
|
10
13
|
#
|
11
14
|
# product.variants_including_master.has_option(OptionType.find_by(name: 'shoe-size'), OptionValue.find_by(name: '8'))
|
12
15
|
def has_option(option_type, *option_values)
|
16
|
+
ActiveSupport::Deprecation.warn "Variant.descend_by_popularity is deprecated and will be removed from Spree 3.", caller
|
13
17
|
option_types = OptionType.table_name
|
14
18
|
|
15
19
|
option_type_conditions = case option_type
|
data/config/locales/en.yml
CHANGED
@@ -633,6 +633,7 @@ en:
|
|
633
633
|
display: Display
|
634
634
|
display_currency: Display currency
|
635
635
|
edit: Edit
|
636
|
+
editing_country: Editing Country
|
636
637
|
editing_option_type: Editing Option Type
|
637
638
|
editing_payment_method: Editing Payment Method
|
638
639
|
editing_product: Editing Product
|
@@ -957,7 +958,7 @@ en:
|
|
957
958
|
order_number: Order %{number}
|
958
959
|
order_populator:
|
959
960
|
out_of_stock: ! '%{item} is out of stock.'
|
960
|
-
selected_quantity_not_available: ! '
|
961
|
+
selected_quantity_not_available: ! 'selected of %{item} is not available.'
|
961
962
|
please_enter_reasonable_quantity: Please enter a reasonable quantity.
|
962
963
|
order_processed_successfully: Your order has been processed successfully
|
963
964
|
order_resumed: Order resumed
|
@@ -1147,6 +1148,9 @@ en:
|
|
1147
1148
|
return_authorization_reasons: Return Authorization Reasons
|
1148
1149
|
return_authorization_updated: Return authorization updated
|
1149
1150
|
return_authorizations: Return Authorizations
|
1151
|
+
return_item_inventory_unit_ineligible: Return item's inventory unit must be shipped
|
1152
|
+
return_item_inventory_unit_reimbursed: Return item's inventory unit is already reimbursed
|
1153
|
+
return_item_order_not_completed: Return item's order must be completed
|
1150
1154
|
return_item_rma_ineligible: Return item requires an RMA
|
1151
1155
|
return_item_time_period_ineligible: Return item is outside the eligible time period
|
1152
1156
|
return_items: Return Items
|
@@ -1347,7 +1351,9 @@ en:
|
|
1347
1351
|
usage_limit: Usage Limit
|
1348
1352
|
use_app_default: Use App Default
|
1349
1353
|
use_billing_address: Use Billing Address
|
1354
|
+
use_existing_cc: Use an existing card on file
|
1350
1355
|
use_new_cc: Use a new card
|
1356
|
+
use_new_cc_or_payment_method: Use a new card / payment method
|
1351
1357
|
use_s3: Use Amazon S3 For Images
|
1352
1358
|
user: User
|
1353
1359
|
user_rule:
|
@@ -9,13 +9,14 @@ class UpgradeAdjustments < ActiveRecord::Migration
|
|
9
9
|
# Account for possible invalid data
|
10
10
|
next if adjustment.source.nil?
|
11
11
|
adjustment.source.update_column(:cost, adjustment.amount)
|
12
|
-
adjustment.destroy
|
12
|
+
adjustment.destroy!
|
13
13
|
end
|
14
14
|
|
15
15
|
# Tax adjustments have their sources altered
|
16
16
|
Spree::Adjustment.where(:originator_type => "Spree::TaxRate").find_each do |adjustment|
|
17
|
-
adjustment.
|
18
|
-
adjustment.
|
17
|
+
adjustment.source_id = adjustment.originator_id
|
18
|
+
adjustment.source_type = "Spree::TaxRate"
|
19
|
+
adjustment.save!
|
19
20
|
end
|
20
21
|
|
21
22
|
# Promotion adjustments have their source altered also
|
@@ -33,7 +34,7 @@ class UpgradeAdjustments < ActiveRecord::Migration
|
|
33
34
|
# Fail silently. This is primarily in instances where the calculator no longer exists
|
34
35
|
end
|
35
36
|
|
36
|
-
adjustment.save
|
37
|
+
adjustment.save!
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -41,11 +41,24 @@ module Spree
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def add_eagerload_scopes scope
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
# TL;DR Switch from `preload` to `includes` as soon as Rails starts honoring
|
45
|
+
# `order` clauses on `has_many` associations when a `where` constraint
|
46
|
+
# affecting a joined table is present (see
|
47
|
+
# https://github.com/rails/rails/issues/6769).
|
48
|
+
#
|
49
|
+
# Ideally this would use `includes` instead of `preload` calls, leaving it
|
50
|
+
# up to Rails whether associated objects should be fetched in one big join
|
51
|
+
# or multiple independent queries. However as of Rails 4.1.8 any `order`
|
52
|
+
# defined on `has_many` associations are ignored when Rails builds a join
|
53
|
+
# query.
|
54
|
+
#
|
55
|
+
# Would we use `includes` in this particular case, Rails would do
|
56
|
+
# separate queries most of the time but opt for a join as soon as any
|
57
|
+
# `where` constraints affecting joined tables are added to the search;
|
58
|
+
# which is the case as soon as a taxon is added to the base scope.
|
59
|
+
scope = scope.preload(master: :prices)
|
60
|
+
scope = scope.preload(master: :images) if include_images
|
61
|
+
scope
|
49
62
|
end
|
50
63
|
|
51
64
|
def add_search_scopes(base_scope)
|
data/lib/spree/core/version.rb
CHANGED
@@ -7,8 +7,8 @@ FactoryGirl.define do
|
|
7
7
|
address2 'Northwest'
|
8
8
|
city 'Herndon'
|
9
9
|
zipcode '35005'
|
10
|
-
phone '
|
11
|
-
alternative_phone '
|
10
|
+
phone '555-555-0199'
|
11
|
+
alternative_phone '555-555-0199'
|
12
12
|
|
13
13
|
state { |address| address.association(:state) }
|
14
14
|
country do |address|
|
@@ -9,4 +9,12 @@ FactoryGirl.define do
|
|
9
9
|
|
10
10
|
factory :default_tax_calculator, class: Spree::Calculator::DefaultTax do
|
11
11
|
end
|
12
|
+
|
13
|
+
factory :shipping_calculator, class: Spree::Calculator::Shipping::FlatRate do
|
14
|
+
after(:create) { |c| c.set_preference(:amount, 10.0) }
|
15
|
+
end
|
16
|
+
|
17
|
+
factory :shipping_no_amount_calculator, class: Spree::Calculator::Shipping::FlatRate do
|
18
|
+
after(:create) { |c| c.set_preference(:amount, 0) }
|
19
|
+
end
|
12
20
|
end
|
@@ -2,7 +2,7 @@ FactoryGirl.define do
|
|
2
2
|
factory :credit_card, class: Spree::CreditCard do
|
3
3
|
verification_value 123
|
4
4
|
month 12
|
5
|
-
year {
|
5
|
+
year { 1.year.from_now.year }
|
6
6
|
number '4111111111111111'
|
7
7
|
name 'Spree Commerce'
|
8
8
|
association(:payment_method, factory: :credit_card_payment_method)
|
@@ -6,6 +6,13 @@ FactoryGirl.define do
|
|
6
6
|
order
|
7
7
|
state 'checkout'
|
8
8
|
response_code '12345'
|
9
|
+
|
10
|
+
factory :payment_with_refund do
|
11
|
+
state 'completed'
|
12
|
+
after :create do |payment|
|
13
|
+
create(:refund, amount: 5, payment: payment)
|
14
|
+
end
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
11
18
|
factory :check_payment, class: Spree::Payment do
|
@@ -23,11 +23,12 @@ FactoryGirl.define do
|
|
23
23
|
after(:create) do |promotion, evaluator|
|
24
24
|
calculator = Spree::Calculator::FlatRate.new
|
25
25
|
calculator.preferred_amount = evaluator.weighted_order_adjustment_amount
|
26
|
-
action = Spree::Promotion::Actions::CreateAdjustment.create!(:
|
26
|
+
action = Spree::Promotion::Actions::CreateAdjustment.create!(calculator: calculator)
|
27
27
|
promotion.actions << action
|
28
28
|
promotion.save!
|
29
29
|
end
|
30
30
|
end
|
31
|
+
factory :promotion_with_order_adjustment, traits: [:with_order_adjustment]
|
31
32
|
|
32
33
|
trait :with_item_total_rule do
|
33
34
|
transient do
|
@@ -45,6 +46,7 @@ FactoryGirl.define do
|
|
45
46
|
promotion.save!
|
46
47
|
end
|
47
48
|
end
|
49
|
+
factory :promotion_with_item_total_rule, traits: [:with_item_total_rule]
|
48
50
|
|
49
51
|
end
|
50
52
|
end
|
@@ -11,11 +11,11 @@ FactoryGirl.define do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
factory :shipping_method, class: Spree::ShippingMethod do
|
14
|
-
association(:calculator, factory: :
|
14
|
+
association(:calculator, factory: :shipping_calculator, strategy: :build)
|
15
15
|
end
|
16
16
|
|
17
17
|
factory :free_shipping_method, class: Spree::ShippingMethod do
|
18
|
-
association(:calculator, factory: :
|
18
|
+
association(:calculator, factory: :shipping_no_amount_calculator, strategy: :build)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/tasks/core.rake
CHANGED
@@ -22,6 +22,10 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
22
22
|
ruby_files[File.basename(fixture_file, '.*')] = fixture_file
|
23
23
|
end
|
24
24
|
ruby_files.sort.each do |fixture , ruby_file|
|
25
|
+
# If file is exists within application it takes precendence.
|
26
|
+
if File.exists?(File.join(Rails.root, "db/default/spree", "#{fixture}.rb"))
|
27
|
+
ruby_file = File.expand_path(File.join(Rails.root, "db/default/spree", "#{fixture}.rb"))
|
28
|
+
end
|
25
29
|
# an invoke will only execute the task once
|
26
30
|
Rake::Task["db:load_file"].execute( Rake::TaskArguments.new([:file], [ruby_file]) )
|
27
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: acts_as_list
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.3
|
33
|
+
version: '0.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.3
|
40
|
+
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: awesome_nested_set
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,16 +202,16 @@ dependencies:
|
|
202
202
|
name: monetize
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
|
-
- - "
|
205
|
+
- - "~>"
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: '
|
207
|
+
version: '1.1'
|
208
208
|
type: :runtime
|
209
209
|
prerelease: false
|
210
210
|
version_requirements: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
|
-
- - "
|
212
|
+
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version: '
|
214
|
+
version: '1.1'
|
215
215
|
- !ruby/object:Gem::Dependency
|
216
216
|
name: paperclip
|
217
217
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,14 +232,14 @@ dependencies:
|
|
232
232
|
requirements:
|
233
233
|
- - "~>"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
235
|
+
version: 2.0.5
|
236
236
|
type: :runtime
|
237
237
|
prerelease: false
|
238
238
|
version_requirements: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
240
|
- - "~>"
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
242
|
+
version: 2.0.5
|
243
243
|
- !ruby/object:Gem::Dependency
|
244
244
|
name: premailer-rails
|
245
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -492,6 +492,7 @@ files:
|
|
492
492
|
- app/models/spree/return_item.rb
|
493
493
|
- app/models/spree/return_item/eligibility_validator/base_validator.rb
|
494
494
|
- app/models/spree/return_item/eligibility_validator/default.rb
|
495
|
+
- app/models/spree/return_item/eligibility_validator/order_completed.rb
|
495
496
|
- app/models/spree/return_item/eligibility_validator/rma_required.rb
|
496
497
|
- app/models/spree/return_item/eligibility_validator/time_since_purchase.rb
|
497
498
|
- app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb
|
@@ -891,7 +892,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
891
892
|
version: '0'
|
892
893
|
requirements: []
|
893
894
|
rubyforge_project:
|
894
|
-
rubygems_version: 2.
|
895
|
+
rubygems_version: 2.4.5
|
895
896
|
signing_key:
|
896
897
|
specification_version: 4
|
897
898
|
summary: The bare bones necessary for Spree.
|