spree_core 2.1.6 → 2.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/spree/credit_card.rb +11 -5
- data/app/models/spree/line_item.rb +2 -2
- data/app/models/spree/order.rb +6 -2
- data/app/models/spree/payment.rb +2 -2
- data/app/models/spree/payment/processing.rb +9 -0
- data/app/models/spree/stock/availability_validator.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +1 -9
- data/app/models/spree/stock_item.rb +4 -0
- data/app/models/spree/tax_rate.rb +3 -2
- data/app/models/spree/variant.rb +8 -4
- data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +1 -1
- data/db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb +5 -0
- data/lib/spree/core.rb +1 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +2 -0
- data/lib/spree/testing_support/factories/shipment_factory.rb +3 -2
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee66832489cf763d21c38a512e8b99392c104dba
|
4
|
+
data.tar.gz: 9e34bc2957303933d3b7ba62d043d27daac480c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9afb43b63ff91f6293536c6c3ab9bb451d8fefb01ab318e7efb401e1934b3e814a8796f53463271ad9a8f5d9588e53c748adce20ce89012dcbf1b4e8be0c2ec2
|
7
|
+
data.tar.gz: a845cd6990e60b712c0fa99e630ebe2b5c46d6abe7181e9e8f5508b4d8feb7f0f7c13736ff717fd258ecb749cfe8e5761bd963a3b3d5d1b3ef5881e9c740388a
|
@@ -26,12 +26,18 @@ module Spree
|
|
26
26
|
}
|
27
27
|
|
28
28
|
def expiry=(expiry)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
return unless expiry.present?
|
30
|
+
|
31
|
+
self[:month], self[:year] =
|
32
|
+
if expiry.match(/\d\s?\/\s?\d/) # will match mm/yy and mm / yyyy
|
33
|
+
expiry.delete(' ').split('/')
|
34
|
+
elsif match = expiry.match(/(\d{2})(\d{2,4})/) # will match mmyy and mmyyyy
|
35
|
+
[match[1], match[2]]
|
34
36
|
end
|
37
|
+
|
38
|
+
self[:year] = "20" + self[:year] if self[:year].length == 2
|
39
|
+
self[:year] = self[:year].to_i
|
40
|
+
self[:month] = self[:month].to_i
|
35
41
|
end
|
36
42
|
|
37
43
|
def number=(num)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class LineItem < ActiveRecord::Base
|
3
3
|
before_validation :adjust_quantity
|
4
|
-
belongs_to :order, class_name: "Spree::Order"
|
4
|
+
belongs_to :order, class_name: "Spree::Order", touch: true
|
5
5
|
belongs_to :variant, class_name: "Spree::Variant"
|
6
6
|
belongs_to :tax_category, class_name: "Spree::TaxCategory"
|
7
7
|
|
@@ -63,7 +63,7 @@ module Spree
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def sufficient_stock?
|
66
|
-
Stock::Quantifier.new(
|
66
|
+
Stock::Quantifier.new(variant).can_supply? quantity
|
67
67
|
end
|
68
68
|
|
69
69
|
def insufficient_stock?
|
data/app/models/spree/order.rb
CHANGED
@@ -79,8 +79,12 @@ module Spree
|
|
79
79
|
where(number: number)
|
80
80
|
end
|
81
81
|
|
82
|
+
scope :created_between, ->(start_date, end_date) { where(created_at: start_date..end_date) }
|
83
|
+
scope :completed_between, ->(start_date, end_date) { where(completed_at: start_date..end_date) }
|
84
|
+
|
82
85
|
def self.between(start_date, end_date)
|
83
|
-
|
86
|
+
ActiveSupport::Deprecation.warn("Order#between will be deprecated in Spree 2.3, please use either Order#created_between or Order#completed_between instead.")
|
87
|
+
self.created_between(start_date, end_date)
|
84
88
|
end
|
85
89
|
|
86
90
|
def self.by_customer(customer)
|
@@ -572,7 +576,7 @@ module Spree
|
|
572
576
|
|
573
577
|
def after_cancel
|
574
578
|
shipments.each { |shipment| shipment.cancel! }
|
575
|
-
payments.completed.each { |payment| payment.
|
579
|
+
payments.completed.each { |payment| payment.cancel! }
|
576
580
|
|
577
581
|
send_cancel_email
|
578
582
|
self.update_column(:payment_state, 'credit_owed') unless shipped?
|
data/app/models/spree/payment.rb
CHANGED
@@ -102,8 +102,8 @@ module Spree
|
|
102
102
|
|
103
103
|
# see https://github.com/spree/spree/issues/981
|
104
104
|
def build_source
|
105
|
-
return
|
106
|
-
if
|
105
|
+
return unless new_record?
|
106
|
+
if source_attributes.present? && source.blank? && payment_method.try(:payment_source_class)
|
107
107
|
self.source = payment_method.payment_source_class.new(source_attributes)
|
108
108
|
end
|
109
109
|
end
|
@@ -108,6 +108,14 @@ module Spree
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
def cancel!
|
112
|
+
if payment_method.respond_to?(:cancel)
|
113
|
+
payment_method.cancel(response_code)
|
114
|
+
else
|
115
|
+
credit!
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
111
119
|
def partial_credit(amount)
|
112
120
|
return if amount > credit_allowed
|
113
121
|
started_processing!
|
@@ -115,6 +123,7 @@ module Spree
|
|
115
123
|
end
|
116
124
|
|
117
125
|
def gateway_options
|
126
|
+
order.reload
|
118
127
|
options = { :email => order.email,
|
119
128
|
:customer => order.email,
|
120
129
|
:customer_id => order.user_id,
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
attr_reader :stock_items
|
5
5
|
|
6
6
|
def initialize(variant)
|
7
|
-
@variant =
|
7
|
+
@variant = variant
|
8
8
|
@stock_items = Spree::StockItem.joins(:stock_location).where(:variant_id => @variant, Spree::StockLocation.table_name =>{ :active => true})
|
9
9
|
end
|
10
10
|
|
@@ -24,14 +24,6 @@ module Spree
|
|
24
24
|
total_on_hand >= required || backorderable?
|
25
25
|
end
|
26
26
|
|
27
|
-
private
|
28
|
-
|
29
|
-
# return variant when passed either variant object or variant id
|
30
|
-
def resolve_variant_id(variant)
|
31
|
-
variant = Spree::Variant.find_by_id(variant) unless variant.respond_to?(:should_track_inventory?)
|
32
|
-
variant
|
33
|
-
end
|
34
|
-
|
35
27
|
end
|
36
28
|
end
|
37
29
|
end
|
@@ -23,8 +23,9 @@ module Spree
|
|
23
23
|
|
24
24
|
# Gets the array of TaxRates appropriate for the specified order
|
25
25
|
def self.match(order)
|
26
|
-
|
27
|
-
|
26
|
+
order_zone = order.tax_zone
|
27
|
+
return [] unless order_zone
|
28
|
+
includes(zone: { zone_members: :zoneable }).load.select do |rate|
|
28
29
|
(!rate.included_in_price && (rate.zone == order.tax_zone || rate.zone.contains?(order.tax_zone) || (order.tax_address.nil? && rate.zone.default_tax))) ||
|
29
30
|
rate.included_in_price
|
30
31
|
end
|
data/app/models/spree/variant.rb
CHANGED
@@ -75,7 +75,7 @@ module Spree
|
|
75
75
|
# allows extensions to override deleted? if they want to provide
|
76
76
|
# their own definition.
|
77
77
|
def deleted?
|
78
|
-
deleted_at
|
78
|
+
!!deleted_at
|
79
79
|
end
|
80
80
|
|
81
81
|
# Product may be created with deleted_at already set,
|
@@ -149,9 +149,13 @@ module Spree
|
|
149
149
|
"#{sku} #{options_text}".strip
|
150
150
|
end
|
151
151
|
|
152
|
-
def in_stock?(quantity
|
153
|
-
|
154
|
-
|
152
|
+
def in_stock?(quantity=:argument_here_is_deprecated)
|
153
|
+
if quantity == :argument_here_is_deprecated
|
154
|
+
can_stock?(1)
|
155
|
+
else
|
156
|
+
puts %q{[DEPRECATION] In Spree 2.2, Variant#in_stock? will no longer take a quantity. Use Variant#can_supply? instead.}
|
157
|
+
can_stock?(quantity)
|
158
|
+
end
|
155
159
|
end
|
156
160
|
|
157
161
|
def can_stock?(quantity=1)
|
@@ -3,7 +3,7 @@ class MigrateOldShippingCalculators < ActiveRecord::Migration
|
|
3
3
|
Spree::ShippingMethod.all.each do |shipping_method|
|
4
4
|
old_calculator = shipping_method.calculator
|
5
5
|
next if old_calculator.class < Spree::ShippingCalculator # We don't want to mess with new shipping calculators
|
6
|
-
new_calculator = eval(
|
6
|
+
new_calculator = eval(old_calculator.class.name.sub("::Calculator::", "::Calculator::Shipping::")).new
|
7
7
|
new_calculator.preferences.keys.each do |pref|
|
8
8
|
# Preferences can't be read/set by name, you have to prefix preferred_
|
9
9
|
pref_method = "preferred_#{pref}"
|
data/lib/spree/core.rb
CHANGED
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/money.rb
CHANGED
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
|
31
31
|
# Check the first character for a currency symbol, alternatively get it
|
32
32
|
# from the stated currency string
|
33
|
-
c = if ::
|
33
|
+
c = if ::Monetize.assume_from_symbol && i =~ /^(\$|€|£)/
|
34
34
|
case i
|
35
35
|
when /^\$/ then "USD"
|
36
36
|
when /^€/ then "EUR"
|
@@ -52,6 +52,8 @@ FactoryGirl.define do
|
|
52
52
|
|
53
53
|
factory :shipped_order do
|
54
54
|
after(:create) do |order|
|
55
|
+
order.update_totals # To ensure we have the right total
|
56
|
+
create(:payment, amount: order.total, order: order, state: 'completed')
|
55
57
|
order.shipments.each do |shipment|
|
56
58
|
shipment.inventory_units.each { |u| u.update_column('state', 'shipped') }
|
57
59
|
shipment.update_column('state', 'shipped')
|
@@ -2,14 +2,15 @@ FactoryGirl.define do
|
|
2
2
|
factory :shipment, class: Spree::Shipment do
|
3
3
|
tracking 'U10000'
|
4
4
|
number '100'
|
5
|
-
cost 100.00
|
6
5
|
state 'pending'
|
7
6
|
order
|
8
7
|
address
|
9
8
|
stock_location
|
10
9
|
|
11
10
|
after(:create) do |shipment, evalulator|
|
12
|
-
|
11
|
+
shipping_method = create(:shipping_method)
|
12
|
+
shipping_method.calculator.preferred_amount = 100
|
13
|
+
shipment.add_shipping_method(shipping_method, true)
|
13
14
|
|
14
15
|
shipment.order.line_items.each do |line_item|
|
15
16
|
line_item.quantity.times { shipment.inventory_units.create(variant_id: line_item.variant_id) }
|
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.1.
|
4
|
+
version: 2.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 0.15.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: monetize
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: paperclip
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -514,6 +528,7 @@ files:
|
|
514
528
|
- db/migrate/20140129024326_add_deleted_at_to_spree_prices.rb
|
515
529
|
- db/migrate/20140204192230_add_auto_capture_to_payment_methods.rb
|
516
530
|
- db/migrate/20140205181631_default_variant_weight_to_zero.rb
|
531
|
+
- db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb
|
517
532
|
- db/seeds.rb
|
518
533
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
519
534
|
- lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
|
@@ -663,7 +678,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
663
678
|
version: '0'
|
664
679
|
requirements: []
|
665
680
|
rubyforge_project:
|
666
|
-
rubygems_version: 2.2.
|
681
|
+
rubygems_version: 2.2.0
|
667
682
|
signing_key:
|
668
683
|
specification_version: 4
|
669
684
|
summary: The bare bones necessary for Spree.
|