spree_core 2.0.0.rc1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGY5MGNlMTExNmVhYTBkOTNlN2Y4N2I1ZTdlNTA2MzdhY2NiODQzOQ==
4
+ MGJmY2JjMTNjYWQxNjgzMTYzMDEyOTUyMjUzZjE5ODc2YjVlZjU1YQ==
5
5
  data.tar.gz: !binary |-
6
- YWQxNTc2MjAyNDM1NDk4MWViODEyZTY2MWYyYjdiNTdkYzgxM2Y5YQ==
6
+ NDc2NmRjNzQ0OTlkNmZlNWNkNTIxY2JmZjhmYTBkMDYyYWI2OGZhMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OGQxNGQ2MjU4MWY4NmQ1YzkzOTAyOGM1YjA4MTU3YzZkOGQ5ZjUxMDc2YjM0
10
- ZDY3N2IyYTAyYjE5NjBmM2Q1MmI3YjU1YThkMjkxNjc2ZTFjYjRmNzc0OGY1
11
- MGUwYzQyYTNhYjYyMzI2NDY5MGMzNzVhMTU2OWZkNDczZGUwODI=
9
+ MDg0OGQyMjYwYmYzOTNlNmExODhhYmY1NGJjYTU0YWViNjdjOGFkYzE0ZTRh
10
+ MDgzOWY1NDYxNDEzNWFmN2Q2MjE2MTZhODFlYjUyMTU2MTY3ZDMxYjUyYmRj
11
+ OGFjMjlmNjA5ZmJmMjA4ZmNjZWNhYWJlNDVhN2I4NTlkMzllZTM=
12
12
  data.tar.gz: !binary |-
13
- YmExYjIxNTgwYzcxNzQyZTBlYmZiNWY2Yzk1ZDdmY2E4ZWY5YTY2OTQzMTJl
14
- Yzc5YjZjODgzOGUyZmJlM2YyODA5MGM3YzUzYTU5OWJlM2Q1MWU4ZDc5YTNm
15
- MDA5NmQ1NjQxZmNmOGQxMjJhNDU0NzU1NDkxZWJlOGJhMTJmODc=
13
+ ZmQxMGQ5ODk0ODM5YTUxNDU2MGI5YjE2MDYzNDE5YmZmZGZlZWY0ZGMyMWE2
14
+ ZjVhNmI2YWM2NGY0OTE0ZmU4ZTIwZGNhYjM0ZDAwOThmN2Y4ODcxZDY0NDQz
15
+ NzY5OTI1NWI4NzBmNTdkNzA3YmE1ZjFiNzIyMTk0Y2VjNGRjYmM=
@@ -6,33 +6,22 @@ module Spree
6
6
  @order = order
7
7
  end
8
8
 
9
- def verify(line_item, shipment=nil)
10
- # should only verify inventory for completed orders
11
- # as carts have inventory assigned via create_proposed_shipment methh
12
- #
13
- # or when shipment is explicitly passed
9
+ # Only verify inventory for completed orders
10
+ # as carts have inventory assigned via create_proposed_shipment methh
11
+ #
12
+ # or when shipment is explicitly passed
13
+ def verify(line_item, shipment = nil)
14
14
  if order.completed? || shipment.present?
15
15
 
16
16
  variant_units = inventory_units_for(line_item.variant)
17
17
 
18
18
  if variant_units.size < line_item.quantity
19
- #add
20
19
  quantity = line_item.quantity - variant_units.size
21
20
 
22
21
  shipment = determine_target_shipment(line_item.variant) unless shipment
23
-
24
22
  add_to_shipment(shipment, line_item.variant, quantity)
25
-
26
23
  elsif variant_units.size > line_item.quantity
27
- #remove
28
- quantity = variant_units.size - line_item.quantity
29
-
30
- order.shipments.each do |shipment|
31
- break if quantity == 0
32
-
33
- quantity -= remove_from_shipment(shipment, line_item.variant, quantity)
34
- end
35
-
24
+ remove(line_item, variant_units, shipment)
36
25
  end
37
26
  else
38
27
  true
@@ -45,16 +34,32 @@ module Spree
45
34
  end
46
35
 
47
36
  private
37
+ def remove(line_item, variant_units, shipment = nil)
38
+ quantity = variant_units.size - line_item.quantity
48
39
 
49
- def determine_target_shipment(variant)
50
- # get first unshipped shipment that already includes this variant
51
- shipment = order.shipments.detect { |shipment| (shipment.ready? || shipment.pending?) && shipment.include?(variant) }
40
+ if shipment.present?
41
+ remove_from_shipment(shipment, line_item.variant, quantity)
42
+ else
43
+ order.shipments.each do |shipment|
44
+ break if quantity == 0
45
+ quantity -= remove_from_shipment(shipment, line_item.variant, quantity)
46
+ end
47
+ end
48
+ end
52
49
 
53
- # get first unshipped shipment that's leaving from the a stock_location that stocks this variant
54
- shipment ||= order.shipments.detect { |shipment| (shipment.ready? || shipment.pending?) && variant.stock_location_ids.include?(shipment.stock_location_id) }
50
+ # Returns either one of the shipment:
51
+ #
52
+ # first unshipped that already includes this variant
53
+ # first unshipped that's leaving from a stock_location that stocks this variant
54
+ #
55
+ def determine_target_shipment(variant)
56
+ shipment = order.shipments.detect do |shipment|
57
+ (shipment.ready? || shipment.pending?) && shipment.include?(variant)
58
+ end
55
59
 
56
- # ship it!
57
- shipment
60
+ shipment ||= order.shipments.detect do |shipment|
61
+ (shipment.ready? || shipment.pending?) && variant.stock_location_ids.include?(shipment.stock_location_id)
62
+ end
58
63
  end
59
64
 
60
65
  def add_to_shipment(shipment, variant, quantity)
@@ -104,6 +109,5 @@ module Spree
104
109
  # return quantity removed
105
110
  removed_quantity
106
111
  end
107
-
108
112
  end
109
113
  end
@@ -33,6 +33,11 @@ module Spree
33
33
  self.count_on_hand > 0
34
34
  end
35
35
 
36
+ # Tells whether it's available to be included in a shipment
37
+ def available?
38
+ self.in_stock? || self.backorderable?
39
+ end
40
+
36
41
  private
37
42
  def count_on_hand=(value)
38
43
  write_attribute(:count_on_hand, value)
@@ -34,6 +34,7 @@ en:
34
34
  spree/order:
35
35
  checkout_complete: Checkout Complete
36
36
  completed_at: Completed At
37
+ coupon_code: Coupon Code
37
38
  created_at: Order Date
38
39
  email: Customer E-Mail
39
40
  ip_address: IP Address
@@ -357,6 +358,7 @@ en:
357
358
  cannot_create_returns: Cannot create returns as this order has no shipped units.
358
359
  cannot_perform_operation: Cannot perform requested operation
359
360
  cannot_set_shipping_method_without_address: Cannot set shipping method until customer details are provided.
361
+ capture: Capture
360
362
  card_code: Card Code
361
363
  card_number: Card Number
362
364
  card_type_is: Card type is
@@ -422,6 +424,7 @@ en:
422
424
  current_promotion_usage: ! 'Current Usage: %{count}'
423
425
  customer: Customer
424
426
  customer_details: Customer Details
427
+ customer_details_updated: Customer Details Updated
425
428
  customer_search: Customer Search
426
429
  cut: Cut
427
430
  dash:
@@ -929,8 +932,6 @@ en:
929
932
  smtp_username: SMTP Username
930
933
  source: Source
931
934
  special_instructions: Special Instructions
932
- spree/order:
933
- coupon_code: Coupon Code
934
935
  spree_gateway_error_flash_for_checkout: There was a problem with your payment information. Please check your information and try again.
935
936
  start: Start
936
937
  start_date: Valid from
@@ -0,0 +1,5 @@
1
+ class AddSkuIndexToSpreeVariants < ActiveRecord::Migration
2
+ def change
3
+ add_index :spree_variants, :sku
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.0.0.rc1"
3
+ "2.0.0"
4
4
  end
5
5
  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.0.0.rc1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-13 00:00:00.000000000 Z
11
+ date: 2013-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -569,6 +569,7 @@ files:
569
569
  - db/migrate/20130423110707_drop_products_count_on_hand.rb
570
570
  - db/migrate/20130423223847_set_default_shipping_rate_cost.rb
571
571
  - db/migrate/20130509115210_add_number_to_stock_transfer.rb
572
+ - db/migrate/20130514151929_add_sku_index_to_spree_variants.rb
572
573
  - db/seeds.rb
573
574
  - vendor/assets/javascripts/jquery-migrate-1.0.0.js
574
575
  - vendor/assets/javascripts/jsuri.js
@@ -589,9 +590,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
589
590
  version: 1.9.3
590
591
  required_rubygems_version: !ruby/object:Gem::Requirement
591
592
  requirements:
592
- - - ! '>'
593
+ - - ! '>='
593
594
  - !ruby/object:Gem::Version
594
- version: 1.3.1
595
+ version: '0'
595
596
  requirements: []
596
597
  rubyforge_project:
597
598
  rubygems_version: 2.0.3