spree_core 3.1.12 → 3.1.13

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: db3ebbca771b182322334dbc1ac1fcf3b7c7b18d
4
- data.tar.gz: 27576641885f1676dc1e22aba3d720cff12efa41
3
+ metadata.gz: 7568a6b4ed997ff5d99042e84358b08ec25554a4
4
+ data.tar.gz: f2ac9e4517f5fb96c8b8a0a0f9200c2c355ab698
5
5
  SHA512:
6
- metadata.gz: c4bb4bd04f186f04ac802ae24e9e22581e4b487335d73fa82474174b6f8555cff8b5ccd5c687e7b4ddc25982119c4fc67787f0332ced653c6e75f5d77538f78e
7
- data.tar.gz: 8a7abab01b4753d4e32d0524414948754890b9a2fbb8d96d0dbe3bdd63857e6d3066c13cf2c5ae4e05feb1f2a4e4cbd486a94d82354cf684ccee9905f238a26d
6
+ metadata.gz: 61d16c88f57a2e168618e2e1fd68fb7d498d2ccd536b08bfff9dd8c705e02dcf7f7ca2a3bf0ec98ce9381e6ca2bcb88908e2cf33047003278ee981bd829f8f5b
7
+ data.tar.gz: ea5ad4e14b89144564066c400e0f36f9faeafedfb6c7b8041e72ef67e460a023244b4d42471c7b95448cd974385b3fae07ac07ca12a29f90c4a409903e8593ff
@@ -9,7 +9,7 @@ module Spree
9
9
 
10
10
  protected
11
11
 
12
- def create_adjustment(order, adjustable, included = nil)
12
+ def create_adjustment(order, adjustable, included = false)
13
13
  amount = compute_amount(adjustable)
14
14
  return if amount == 0
15
15
  adjustments.new(order: order,
@@ -29,7 +29,7 @@ module Spree
29
29
  # a new pending payment record for the remaining amount to capture later.
30
30
  def capture!(amount = nil)
31
31
  return true if completed?
32
- amount ||= money.money.cents
32
+ amount ||= money.amount_in_cents
33
33
  started_processing!
34
34
  protect_from_connection_error do
35
35
  # Standard ActiveMerchant capture usage
@@ -115,7 +115,7 @@ module Spree
115
115
 
116
116
  def gateway_action(source, action, success_state)
117
117
  protect_from_connection_error do
118
- response = payment_method.send(action, money.money.cents,
118
+ response = payment_method.send(action, money.amount_in_cents,
119
119
  source,
120
120
  gateway_options)
121
121
  handle_response(response, success_state, :failure)
@@ -43,7 +43,7 @@ module Spree
43
43
  def perform!
44
44
  return true if transaction_id.present?
45
45
 
46
- credit_cents = Spree::Money.new(amount.to_f, currency: payment.currency).money.cents
46
+ credit_cents = Spree::Money.new(amount.to_f, currency: payment.currency).amount_in_cents
47
47
 
48
48
  @response = process!(credit_cents)
49
49
 
@@ -115,12 +115,13 @@ module Spree
115
115
  end
116
116
 
117
117
  config.to_prepare do
118
- # Load spree locales before decorators
119
- I18n.load_path += Dir.glob(
118
+ # Ensure spree locale paths are present before decorators
119
+ I18n.load_path.unshift(*(Dir.glob(
120
120
  File.join(
121
121
  File.dirname(__FILE__), '../../../config/locales', '*.{rb,yml}'
122
122
  )
123
- )
123
+ ) - I18n.load_path))
124
+
124
125
  # Load application's model / class decorators
125
126
  Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
126
127
  Rails.configuration.cache_classes ? require(c) : load(c)
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "3.1.12"
3
+ "3.1.13"
4
4
  end
5
5
  end
data/lib/spree/money.rb CHANGED
@@ -15,13 +15,17 @@ module Spree
15
15
 
16
16
  attr_reader :money
17
17
 
18
- delegate :cents, to: :money
18
+ delegate :cents, :currency, to: :money
19
19
 
20
20
  def initialize(amount, options={})
21
21
  @money = Monetize.parse([amount, (options[:currency] || Spree::Config[:currency])].join)
22
22
  @options = Spree::Money.default_formatting_rules.merge(options)
23
23
  end
24
24
 
25
+ def amount_in_cents
26
+ (cents / currency.subunit_to_unit.to_f * 100).round
27
+ end
28
+
25
29
  def to_s
26
30
  @money.format(@options)
27
31
  end
@@ -40,6 +44,16 @@ module Spree
40
44
  to_s
41
45
  end
42
46
 
47
+ def decimal_mark
48
+ return @money.decimal_mark if @options[:decimal_mark].nil?
49
+ @options[:decimal_mark]
50
+ end
51
+
52
+ def thousands_separator
53
+ return @money.thousands_separator if @options[:thousands_separator].nil?
54
+ @options[:thousands_separator]
55
+ end
56
+
43
57
  def ==(obj)
44
58
  @money == obj.money
45
59
  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: 3.1.12
4
+ version: 3.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -971,7 +971,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
971
971
  version: 1.8.23
972
972
  requirements: []
973
973
  rubyforge_project:
974
- rubygems_version: 2.6.13
974
+ rubygems_version: 2.6.10
975
975
  signing_key:
976
976
  specification_version: 4
977
977
  summary: The bare bones necessary for Spree.