spree_core 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,6 @@ module Spree
25
25
  preference :admin_interface_logo, :string, default: 'admin/bg/spree_50.png'
26
26
  preference :admin_products_per_page, :integer, default: 10
27
27
  preference :allow_backorder_shipping, :boolean, default: false # should only be true if you don't need to track inventory
28
- preference :allow_backorders, :boolean, default: true
29
28
  preference :allow_checkout_on_gateway_error, :boolean, default: false
30
29
  preference :allow_guest_checkout, :boolean, default: true
31
30
  preference :allow_ssl_in_development_and_test, :boolean, default: false
@@ -6,7 +6,13 @@ module Spree
6
6
  belongs_to :return_authorization, class_name: "Spree::ReturnAuthorization"
7
7
 
8
8
  scope :backordered, -> { where state: 'backordered' }
9
- scope :shipped, -> { where state: 'shipped' }
9
+ scope :shipped, -> { where state: 'shipped' }
10
+ scope :backordered_per_variant, ->(stock_item) do
11
+ includes(:shipment)
12
+ .where("spree_shipments.state != 'canceled'")
13
+ .where(variant_id: stock_item.variant_id)
14
+ .backordered.order("#{self.table_name}.created_at ASC")
15
+ end
10
16
 
11
17
  attr_accessible :shipment, :variant_id
12
18
 
@@ -26,14 +32,16 @@ module Spree
26
32
  end
27
33
  end
28
34
 
35
+ # This was refactored from a simpler query because the previous implementation
36
+ # lead to issues once users tried to modify the objects returned. That's due
37
+ # to ActiveRecord `joins(shipment: :stock_location)` only return readonly
38
+ # objects
39
+ #
40
+ # Returns an array of backordered inventory units as per a given stock item
29
41
  def self.backordered_for_stock_item(stock_item)
30
- stock_locations_table = Spree::StockLocation.table_name
31
- shipments_table = Spree::Shipment.table_name
32
- joins(shipment: :stock_location).
33
- where("#{stock_locations_table}.id = ?", stock_item.stock_location_id).
34
- where(variant_id: stock_item.variant_id).
35
- where("#{shipments_table}.state != 'canceled'").
36
- backordered.order('created_at ASC')
42
+ backordered_per_variant(stock_item).select do |unit|
43
+ unit.shipment.stock_location == stock_item.stock_location
44
+ end
37
45
  end
38
46
 
39
47
  def self.finalize_units!(inventory_units)
@@ -16,10 +16,7 @@ module Spree
16
16
  go_to_state :address
17
17
  go_to_state :delivery
18
18
  go_to_state :payment, if: ->(order) {
19
- # Fix for #2191
20
- if order.shipments
21
- order.update_totals
22
- end
19
+ order.update_totals
23
20
  order.payment_required?
24
21
  }
25
22
  go_to_state :confirm, if: ->(order) { order.confirmation_required? }
@@ -170,7 +167,6 @@ module Spree
170
167
 
171
168
  # Is this a free order in which case the payment step should be skipped
172
169
  def payment_required?
173
- update_totals
174
170
  total.to_f > 0.0
175
171
  end
176
172
 
@@ -316,9 +312,8 @@ module Spree
316
312
  self.number
317
313
  end
318
314
 
319
- # TODO should be deprecated by split shipments
320
- # convenience method since many stores will not allow user to create multiple shipments
321
315
  def shipment
316
+ ActiveSupport::Deprecation.warn("[SPREE] Spree::Order#shipment is typically incorrect due to multiple shipments and will be deprecated in Spree 2.1, please process Spree::Order#shipments instead.")
322
317
  @shipment ||= shipments.last
323
318
  end
324
319
 
@@ -273,12 +273,12 @@ module Spree
273
273
  def ensure_correct_adjustment
274
274
  if adjustment
275
275
  adjustment.originator = shipping_method
276
- adjustment.label = shipping_method.name
276
+ adjustment.label = shipping_method.adjustment_label
277
277
  adjustment.amount = selected_shipping_rate.cost if adjustment.open?
278
278
  adjustment.save!
279
279
  adjustment.reload
280
280
  elsif selected_shipping_rate_id
281
- shipping_method.create_adjustment shipping_method.name, order, self, true, "open"
281
+ shipping_method.create_adjustment shipping_method.adjustment_label, order, self, true, "open"
282
282
  reload #ensure adjustment is present on later saves
283
283
  end
284
284
  end
@@ -55,5 +55,13 @@ module Spree
55
55
  self.errors[:base] << "You need to select at least one shipping category"
56
56
  end
57
57
  end
58
+
59
+ def self.on_backend_query
60
+ "#{table_name}.display_on != 'front_end' OR #{table_name}.display_on IS NULL"
61
+ end
62
+
63
+ def self.on_frontend_query
64
+ "#{table_name}.display_on != 'back_end' OR #{table_name}.display_on IS NULL"
65
+ end
58
66
  end
59
67
  end
@@ -6,6 +6,9 @@ module Spree
6
6
  attr_accessible :id, :shipping_method, :shipment,
7
7
  :name, :cost, :selected, :shipping_method_id
8
8
 
9
+ scope :frontend, -> { includes(:shipping_method).where(ShippingMethod.on_frontend_query) }
10
+ scope :backend, -> { includes(:shipping_method).where(ShippingMethod.on_backend_query) }
11
+
9
12
  delegate :order, :currency, to: :shipment
10
13
  delegate :name, to: :shipping_method
11
14
 
@@ -18,6 +18,7 @@ module Spree
18
18
  shipping_rates << ShippingRate.new( :shipping_method => shipping_method,
19
19
  :cost => cost)
20
20
  end
21
+ shipping_rates.sort_by! { |r| r.cost || 0 }
21
22
  shipping_rates.first.selected = true unless shipping_rates.empty?
22
23
  shipping_rates
23
24
  end
@@ -9,8 +9,6 @@ module Spree
9
9
 
10
10
  attr_accessible :count_on_hand, :variant, :stock_location, :backorderable, :variant_id
11
11
 
12
- after_save :process_backorders
13
-
14
12
  delegate :weight, to: :variant
15
13
 
16
14
  def backordered_inventory_units
@@ -23,8 +21,9 @@ module Spree
23
21
 
24
22
  def adjust_count_on_hand(value)
25
23
  self.with_lock do
26
- self.reload
27
- self.update_attribute(:count_on_hand, self.count_on_hand + value)
24
+ self.count_on_hand = self.count_on_hand + value
25
+ process_backorders if in_stock?
26
+
28
27
  self.save!
29
28
  end
30
29
  end
@@ -39,19 +38,15 @@ module Spree
39
38
  end
40
39
 
41
40
  private
42
- def count_on_hand=(value)
43
- write_attribute(:count_on_hand, value)
44
- end
45
-
46
- def process_backorders
47
- return unless changes['count_on_hand'] && changes['count_on_hand'].last.to_i > 0
41
+ def count_on_hand=(value)
42
+ write_attribute(:count_on_hand, value)
43
+ end
48
44
 
49
- backordered_units = backordered_inventory_units
50
- while in_stock? && !backordered_units.empty?
51
- inventory_unit = backordered_units.shift
52
- inventory_unit.fill_backorder
53
- self.adjust_count_on_hand(-1)
45
+ def process_backorders
46
+ backordered_inventory_units.each do |unit|
47
+ return unless in_stock?
48
+ unit.fill_backorder
49
+ end
54
50
  end
55
- end
56
51
  end
57
52
  end
@@ -40,18 +40,21 @@ module Spree
40
40
  end
41
41
 
42
42
  def fill_status(variant, quantity)
43
- item = stock_item(variant)
43
+ if item = stock_item(variant)
44
+
45
+ if item.count_on_hand >= quantity
46
+ on_hand = quantity
47
+ backordered = 0
48
+ else
49
+ on_hand = item.count_on_hand
50
+ on_hand = 0 if on_hand < 0
51
+ backordered = item.backorderable? ? (quantity - on_hand) : 0
52
+ end
44
53
 
45
- if item.count_on_hand >= quantity
46
- on_hand = quantity
47
- backordered = 0
54
+ [on_hand, backordered]
48
55
  else
49
- on_hand = item.count_on_hand
50
- on_hand = 0 if on_hand < 0
51
- backordered = item.backorderable? ? (quantity - on_hand) : 0
56
+ [0, 0]
52
57
  end
53
-
54
- [on_hand, backordered]
55
58
  end
56
59
 
57
60
  private
@@ -536,6 +536,18 @@ en:
536
536
  height: Height
537
537
  hide_cents: Hide cents
538
538
  home: Home
539
+ i18n:
540
+ available_locales: Available Locales
541
+ fields: Fields
542
+ language: Language
543
+ localization_settings: Localization Settings
544
+ only_incomplete: Only incomplete
545
+ only_complete: Only complete
546
+ select_locale: Select locale
547
+ show_only: Show only
548
+ supported_locales: Supported Locales
549
+ this_file_language: English (US)
550
+ translations: Translations
539
551
  icon: Icon
540
552
  image: Image
541
553
  image_settings: Image Settings
@@ -66,7 +66,7 @@ module Spree
66
66
  Mail.register_interceptor(Spree::Core::MailInterceptor)
67
67
  end
68
68
 
69
- initializer 'spree.promo.environment', :after => 'spree.environment' do |app|
69
+ initializer 'spree.promo.environment' do |app|
70
70
  app.config.spree.add_class('promotions')
71
71
  app.config.spree.promotions = Spree::Promo::Environment.new
72
72
  end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.0.0"
3
+ "2.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Sean Schofield
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-05-19 00:00:00.000000000 Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: highline
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - '='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - '='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: acts_as_list
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - '='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - '='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: awesome_nested_set
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - '='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - '='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: kaminari
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - '='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - '='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: state_machine
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - '='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - '='
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: ffaker
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: paperclip
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ~>
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: aws-sdk
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ~>
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :runtime
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ~>
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: ransack
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - '='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :runtime
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - '='
137
156
  - !ruby/object:Gem::Version
@@ -139,6 +158,7 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: activemerchant
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - ~>
144
164
  - !ruby/object:Gem::Version
@@ -146,6 +166,7 @@ dependencies:
146
166
  type: :runtime
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
171
  - - ~>
151
172
  - !ruby/object:Gem::Version
@@ -153,6 +174,7 @@ dependencies:
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: json
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - ! '>='
158
180
  - !ruby/object:Gem::Version
@@ -160,6 +182,7 @@ dependencies:
160
182
  type: :runtime
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - ! '>='
165
188
  - !ruby/object:Gem::Version
@@ -167,6 +190,7 @@ dependencies:
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: rails
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
195
  - - ~>
172
196
  - !ruby/object:Gem::Version
@@ -174,6 +198,7 @@ dependencies:
174
198
  type: :runtime
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
177
202
  requirements:
178
203
  - - ~>
179
204
  - !ruby/object:Gem::Version
@@ -181,6 +206,7 @@ dependencies:
181
206
  - !ruby/object:Gem::Dependency
182
207
  name: deface
183
208
  requirement: !ruby/object:Gem::Requirement
209
+ none: false
184
210
  requirements:
185
211
  - - ! '>='
186
212
  - !ruby/object:Gem::Version
@@ -188,6 +214,7 @@ dependencies:
188
214
  type: :runtime
189
215
  prerelease: false
190
216
  version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
191
218
  requirements:
192
219
  - - ! '>='
193
220
  - !ruby/object:Gem::Version
@@ -195,6 +222,7 @@ dependencies:
195
222
  - !ruby/object:Gem::Dependency
196
223
  name: stringex
197
224
  requirement: !ruby/object:Gem::Requirement
225
+ none: false
198
226
  requirements:
199
227
  - - ~>
200
228
  - !ruby/object:Gem::Version
@@ -202,6 +230,7 @@ dependencies:
202
230
  type: :runtime
203
231
  prerelease: false
204
232
  version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
205
234
  requirements:
206
235
  - - ~>
207
236
  - !ruby/object:Gem::Version
@@ -209,6 +238,7 @@ dependencies:
209
238
  - !ruby/object:Gem::Dependency
210
239
  name: cancan
211
240
  requirement: !ruby/object:Gem::Requirement
241
+ none: false
212
242
  requirements:
213
243
  - - '='
214
244
  - !ruby/object:Gem::Version
@@ -216,6 +246,7 @@ dependencies:
216
246
  type: :runtime
217
247
  prerelease: false
218
248
  version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
219
250
  requirements:
220
251
  - - '='
221
252
  - !ruby/object:Gem::Version
@@ -223,6 +254,7 @@ dependencies:
223
254
  - !ruby/object:Gem::Dependency
224
255
  name: truncate_html
225
256
  requirement: !ruby/object:Gem::Requirement
257
+ none: false
226
258
  requirements:
227
259
  - - '='
228
260
  - !ruby/object:Gem::Version
@@ -230,6 +262,7 @@ dependencies:
230
262
  type: :runtime
231
263
  prerelease: false
232
264
  version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
233
266
  requirements:
234
267
  - - '='
235
268
  - !ruby/object:Gem::Version
@@ -237,6 +270,7 @@ dependencies:
237
270
  - !ruby/object:Gem::Dependency
238
271
  name: money
239
272
  requirement: !ruby/object:Gem::Requirement
273
+ none: false
240
274
  requirements:
241
275
  - - '='
242
276
  - !ruby/object:Gem::Version
@@ -244,6 +278,7 @@ dependencies:
244
278
  type: :runtime
245
279
  prerelease: false
246
280
  version_requirements: !ruby/object:Gem::Requirement
281
+ none: false
247
282
  requirements:
248
283
  - - '='
249
284
  - !ruby/object:Gem::Version
@@ -251,6 +286,7 @@ dependencies:
251
286
  - !ruby/object:Gem::Dependency
252
287
  name: httparty
253
288
  requirement: !ruby/object:Gem::Requirement
289
+ none: false
254
290
  requirements:
255
291
  - - ~>
256
292
  - !ruby/object:Gem::Version
@@ -258,6 +294,7 @@ dependencies:
258
294
  type: :runtime
259
295
  prerelease: false
260
296
  version_requirements: !ruby/object:Gem::Requirement
297
+ none: false
261
298
  requirements:
262
299
  - - ~>
263
300
  - !ruby/object:Gem::Version
@@ -578,25 +615,29 @@ files:
578
615
  homepage: http://spreecommerce.com
579
616
  licenses:
580
617
  - BSD-3
581
- metadata: {}
582
618
  post_install_message:
583
619
  rdoc_options: []
584
620
  require_paths:
585
621
  - lib
586
622
  required_ruby_version: !ruby/object:Gem::Requirement
623
+ none: false
587
624
  requirements:
588
625
  - - ! '>='
589
626
  - !ruby/object:Gem::Version
590
627
  version: 1.9.3
591
628
  required_rubygems_version: !ruby/object:Gem::Requirement
629
+ none: false
592
630
  requirements:
593
631
  - - ! '>='
594
632
  - !ruby/object:Gem::Version
595
633
  version: '0'
634
+ segments:
635
+ - 0
636
+ hash: -283587825053128084
596
637
  requirements: []
597
638
  rubyforge_project:
598
- rubygems_version: 2.0.3
639
+ rubygems_version: 1.8.25
599
640
  signing_key:
600
- specification_version: 4
641
+ specification_version: 3
601
642
  summary: The bare bones necessary for Spree.
602
643
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MGJmY2JjMTNjYWQxNjgzMTYzMDEyOTUyMjUzZjE5ODc2YjVlZjU1YQ==
5
- data.tar.gz: !binary |-
6
- NDc2NmRjNzQ0OTlkNmZlNWNkNTIxY2JmZjhmYTBkMDYyYWI2OGZhMA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MDg0OGQyMjYwYmYzOTNlNmExODhhYmY1NGJjYTU0YWViNjdjOGFkYzE0ZTRh
10
- MDgzOWY1NDYxNDEzNWFmN2Q2MjE2MTZhODFlYjUyMTU2MTY3ZDMxYjUyYmRj
11
- OGFjMjlmNjA5ZmJmMjA4ZmNjZWNhYWJlNDVhN2I4NTlkMzllZTM=
12
- data.tar.gz: !binary |-
13
- ZmQxMGQ5ODk0ODM5YTUxNDU2MGI5YjE2MDYzNDE5YmZmZGZlZWY0ZGMyMWE2
14
- ZjVhNmI2YWM2NGY0OTE0ZmU4ZTIwZGNhYjM0ZDAwOThmN2Y4ODcxZDY0NDQz
15
- NzY5OTI1NWI4NzBmNTdkNzA3YmE1ZjFiNzIyMTk0Y2VjNGRjYmM=