spree_core 2.2.11 → 2.2.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11ef4d76fbb16b4e612c0fc431cbbe907d106470
4
- data.tar.gz: 9e84c5508361845f02f985c0a428ab8a15d3f33e
3
+ metadata.gz: 92b5e846d05190304783fa5e19dd8b0e69c2fc42
4
+ data.tar.gz: 993fec4f99e61b8a22498f8a331dc2367bde321d
5
5
  SHA512:
6
- metadata.gz: 66aaaaa4635f833f2ee9ac0915251bf58e9340fd78c4dadd33c4aaf1eab18ba5d1c08a6039ff9e868cce5902b5d40d232a86e31d9959b4f7535e930fb9302702
7
- data.tar.gz: 351836895c5b43cb5573d2dc2dd0ff901419917f4cd16f0b574928b3d6b901b1a76d93a0399bf6bfb479aec59fb59872da5cb306dcbfb37c472f0c2f759dcce2
6
+ metadata.gz: 973fe4de757aaf4d9513120337d2e8f09b74d6583279fd179c00a9947a9f12de5d63a2a5d052dfe58d58500829f0a7febab70c1f9ef461591c50639c978f41be
7
+ data.tar.gz: 23d1efe8df2ec9095d9f3a8cc11bd8e96db31fc680764fae7ba22cb3444b2e23832ce3acb7d66d765b622972c0d3ec27bead93cc8bb39c17538d03c6e9b7c163
@@ -39,14 +39,23 @@ module Spree
39
39
  order = options[:order]
40
40
  return unless self.eligible? order
41
41
 
42
+ action_taken = false
42
43
  promotion_action_line_items.each do |item|
43
44
  current_quantity = order.quantity_of(item.variant)
44
- if current_quantity < item.quantity
45
- order.contents.add(item.variant, item.quantity - current_quantity)
45
+ if current_quantity < item.quantity && item_available?(item)
46
+ line_item = order.contents.add(item.variant, item.quantity - current_quantity)
47
+ action_taken = true if line_item.try(:valid?)
46
48
  end
47
49
  end
48
- true
50
+ action_taken
49
51
  end
52
+
53
+ # Checks that there's enough stock to add the line item to the order
54
+ def item_available?(item)
55
+ quantifier = Spree::Stock::Quantifier.new(item.variant)
56
+ quantifier.can_supply? item.quantity
57
+ end
58
+
50
59
  end
51
60
  end
52
61
  end
@@ -105,7 +105,8 @@ module Spree
105
105
  end
106
106
 
107
107
  def adjusted_credits_count(promotable)
108
- credits_count - promotable.adjustments.promotion.where(:source_id => actions.pluck(:id)).count
108
+ adjustments = promotable.is_a?(Order) ? promotable.all_adjustments : promotable.adjustments
109
+ credits_count - adjustments.promotion.where(:source_id => actions.pluck(:id)).count
109
110
  end
110
111
 
111
112
  def credits
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.2.11"
3
+ "2.2.12"
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.2.11
4
+ version: 2.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2015-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant