spree_core 2.0.10 → 2.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5b6037980373f52370687e88e0ee18fed5d9d8f
4
- data.tar.gz: 7a422916efeb60a2d5260f65c96c8183aad094fa
3
+ metadata.gz: ce81644f3167d18676644b782d34b38282cc43a4
4
+ data.tar.gz: 97ee622222799fab84efe8e61782361e569cf88e
5
5
  SHA512:
6
- metadata.gz: 54e078aeffabf703f9e6dd38cd6949169378ecff49aee0694c23989e028b7ef4dccc9acf0ba13bfbf7626febabe814e7c76c0b8369f333252aabff811aeee559
7
- data.tar.gz: a3f479ad64b7055f9b7612d85a71af7c5467e4bc08954bbf599d3189c05f3ca5164b5f3e4f11ac1809a0dd717adf6da2f2ed0ce8e74fefdb274680b5bf2a4d7f
6
+ metadata.gz: 45a8a9e3e94291dae3b17df911b1253303765f11ee78758d1daa66db2b49201735942db84817782f50af9df92ed38580dd427b9b7bbd03b4af208dab8aab4d2d
7
+ data.tar.gz: 1cf648e2e2680bb4c055913ed9a856844abde7e59b635f27adadca4b2b4e7f1e110582fbe6e3bacf5a69297d8011b531f8ed83c7b1b40a50e0f6be1f376709fa
@@ -75,7 +75,7 @@ module Spree
75
75
  end
76
76
 
77
77
  def sufficient_stock?
78
- Stock::Quantifier.new(variant_id).can_supply? quantity
78
+ Stock::Quantifier.new(variant).can_supply? quantity
79
79
  end
80
80
 
81
81
  def insufficient_stock?
@@ -90,8 +90,12 @@ module Spree
90
90
  where(number: number)
91
91
  end
92
92
 
93
+ scope :created_between, ->(start_date, end_date) { where(created_at: start_date..end_date) }
94
+ scope :completed_between, ->(start_date, end_date) { where(completed_at: start_date..end_date) }
95
+
93
96
  def self.between(start_date, end_date)
94
- where(created_at: start_date..end_date)
97
+ ActiveSupport::Deprecation.warn("Order#between will be deprecated in Spree 2.3, please use either Order#created_between or Order#completed_between instead.")
98
+ self.created_between(start_date, end_date)
95
99
  end
96
100
 
97
101
  def self.by_customer(customer)
@@ -458,7 +462,7 @@ module Spree
458
462
  end
459
463
 
460
464
  def insufficient_stock_lines
461
- @insufficient_stock_lines ||= line_items.select(&:insufficient_stock?)
465
+ line_items.select(&:insufficient_stock?)
462
466
  end
463
467
 
464
468
  def merge!(order, user = nil)
@@ -598,7 +602,7 @@ module Spree
598
602
 
599
603
  def after_cancel
600
604
  shipments.each { |shipment| shipment.cancel! }
601
- payments.completed.each { |payment| payment.credit! }
605
+ payments.completed.each { |payment| payment.cancel! }
602
606
 
603
607
  send_cancel_email
604
608
  self.update_column(:payment_state, 'credit_owed') unless shipped?
@@ -106,6 +106,14 @@ module Spree
106
106
  end
107
107
  end
108
108
 
109
+ def cancel!
110
+ if payment_method.respond_to?(:cancel)
111
+ payment_method.cancel(response_code)
112
+ else
113
+ credit!
114
+ end
115
+ end
116
+
109
117
  def partial_credit(amount)
110
118
  return if amount > credit_allowed
111
119
  started_processing!
@@ -10,7 +10,7 @@ module Spree
10
10
  quantity = line_item.quantity
11
11
  end
12
12
 
13
- quantifier = Stock::Quantifier.new(line_item.variant_id)
13
+ quantifier = Stock::Quantifier.new(line_item.variant)
14
14
 
15
15
  unless quantifier.can_supply? quantity
16
16
  variant = line_item.variant
@@ -4,7 +4,7 @@ module Spree
4
4
  attr_reader :stock_items
5
5
 
6
6
  def initialize(variant)
7
- @variant = resolve_variant_id(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
@@ -46,6 +46,10 @@ module Spree
46
46
  self.in_stock? || self.backorderable?
47
47
  end
48
48
 
49
+ def variant
50
+ Spree::Variant.unscoped { super }
51
+ end
52
+
49
53
  private
50
54
  def count_on_hand=(value)
51
55
  write_attribute(:count_on_hand, value)
@@ -26,9 +26,10 @@ module Spree
26
26
 
27
27
  # Gets the array of TaxRates appropriate for the specified order
28
28
  def self.match(order)
29
- return [] unless order.tax_zone
30
- all.select do |rate|
31
- rate.zone == order.tax_zone || rate.zone.contains?(order.tax_zone) || rate.zone.default_tax
29
+ order_zone = order.tax_zone
30
+ return [] unless order_zone
31
+ includes(zone: { zone_members: :zoneable }).all.select do |rate|
32
+ rate.zone == order_zone || rate.zone.contains?(order_zone) || rate.zone.default_tax
32
33
  end
33
34
  end
34
35
 
@@ -78,7 +78,7 @@ module Spree
78
78
  # allows extensions to override deleted? if they want to provide
79
79
  # their own definition.
80
80
  def deleted?
81
- deleted_at
81
+ !!deleted_at
82
82
  end
83
83
 
84
84
  def options=(options = {})
@@ -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("Spree::Calculator::Shipping::#{old_calculator.class.name.demodulize}").new
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}"
@@ -0,0 +1,5 @@
1
+ class AddUserIdCreatedByIdIndexToOrder < ActiveRecord::Migration
2
+ def change
3
+ add_index :spree_orders, [:user_id, :created_by_id]
4
+ end
5
+ end
@@ -49,7 +49,7 @@ module Spree
49
49
  new_variant = variant.dup
50
50
  new_variant.sku = "COPY OF #{new_variant.sku}"
51
51
  new_variant.deleted_at = nil
52
- new_variant.option_values = variant.option_values.map { |option_value| option_value.dup}
52
+ new_variant.option_values = variant.option_values.map { |option_value| option_value}
53
53
  new_variant
54
54
  end
55
55
 
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.0.10"
3
+ "2.0.11"
4
4
  end
5
5
  end
data/lib/spree/core.rb CHANGED
@@ -5,6 +5,7 @@ require 'awesome_nested_set'
5
5
  require 'cancan'
6
6
  require 'kaminari'
7
7
  require 'mail'
8
+ require 'monetize'
8
9
  require 'paperclip'
9
10
  require 'paranoia'
10
11
  require 'ransack'
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 ::Money.assume_from_symbol && i =~ /^(\$|€|£)/
33
+ c = if ::Monetize.assume_from_symbol && i =~ /^(\$|€|£)/
34
34
  case i
35
35
  when /^\$/ then "USD"
36
36
  when /^€/ then "EUR"
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.0.10
4
+ version: 2.0.11
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-03-25 00:00:00.000000000 Z
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
@@ -505,6 +519,7 @@ files:
505
519
  - db/migrate/20131113035136_add_channel_to_spree_orders.rb
506
520
  - db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb
507
521
  - db/migrate/20140205181631_default_variant_weight_to_zero.rb
522
+ - db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb
508
523
  - db/seeds.rb
509
524
  - lib/generators/spree/custom_user/custom_user_generator.rb
510
525
  - lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
@@ -649,7 +664,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
649
664
  version: '0'
650
665
  requirements: []
651
666
  rubyforge_project:
652
- rubygems_version: 2.2.2
667
+ rubygems_version: 2.2.0
653
668
  signing_key:
654
669
  specification_version: 4
655
670
  summary: The bare bones necessary for Spree.