money 6.13.4 → 6.19.0

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
- SHA1:
3
- metadata.gz: ca21de22dba51f2c9b00ca1301f5d21ea936767a
4
- data.tar.gz: 1cfb4f822e6f7a948f8ff31955422372658c0394
2
+ SHA256:
3
+ metadata.gz: 331d852b12ab9a5e62108f3610d1ec5eed8f4fa9bb683be1aab2703cd2df26cd
4
+ data.tar.gz: 56e2bcad250542c80b800db800c2216dd2b3b10f1df5d8a77819d13153a77844
5
5
  SHA512:
6
- metadata.gz: 207a714b183381a90c2c46f1b4cef2a9246e5a8be0f0c30a088b4d71c98fbdc814e356cb3dac8d2301eefd7d18cf7f70914f6ef9e314975039edbe5bc2b2a7c8
7
- data.tar.gz: 8dca4236991ae835e822cd09bc4e0a6fbeb0b2fee52bb85be3dbb38cfa07f7fa60bbde94045b9a643071435126954324da1aa00065af9ab79f2cd961ee50b7d9
6
+ metadata.gz: ae6d529a7382aaab721a4ae933658828f975eaa4c9a0ad9444b74b28d8ff1141d59f3e264d08b650367e327987266be03dcd480e0a850fe224feb6cdca4163d1
7
+ data.tar.gz: bbb76570efd7bf4be700cc3f46d01e26945e9790f5f9f3fee666d4ac3164d1422f5ca1614622a429c430804a9047bcc8f5178886905e5ad814ce21ab4117f94a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,76 @@
1
1
  # Changelog
2
2
 
3
+ ## Upcoming
4
+
5
+ -
6
+
7
+ ## 6.19.0
8
+
9
+ - Change Peruvian Sol (PEN) decimal mark and thousands separator.
10
+ - Improves Precision and Simplifies Allocation Logic
11
+ - explicit declaration of i18n locales
12
+ - Add space to CHF format
13
+ - Update deprecation message to suggest correct formatting.
14
+
15
+ ## 6.18.0
16
+
17
+ - Add second dobra (STN) from São Tomé and Príncipe
18
+ - Correct South African Rand (ZAR) to use comma decimal mark, and space thousands separator
19
+ - Use euro symbol as html_entity for euro currency
20
+ - Update Georgian Lari symbol
21
+ - Add Ruby 3.1 and 3.2 to the CI matrix
22
+ - Add `Money.from_dollars` alias as a more explicit initializer, it's the same as `Money.from_amount`
23
+ - Mark Croatian Kuna (HRK) as obsolete by moving its definition to the backwards compatibility data source
24
+
25
+ ## 6.17.0
26
+
27
+ - Allow true for `thousands_separator`
28
+
29
+ ## 6.16.0
30
+
31
+ - Add `Money.from_cents` alias as a more explicit initializer, it's the same as `Money.new`
32
+
33
+ ## 6.15.0
34
+
35
+ - Add :delimiter_pattern option to the Formatter
36
+
37
+ ## 6.14.1
38
+
39
+ - Fix CHF format regression introduced in v6.14.0
40
+ - Fix deprecation warning in #format_decimal_part
41
+
42
+ ## 6.14.0
43
+
44
+ - Fix Bahraini dinar symbol
45
+ - Raise exception when default currency is not set or passed as parameter
46
+ - Allow specifying default_bank as a lambda
47
+ - Allow passing a default format in currencies definition only valid without symbol_position
48
+ - Always allow comparison with zero Money
49
+ - Rename Money.infinite_precision to default_infinite_precision
50
+ - Add Currency.reset! method to reload all the default currency definitions
51
+ - Fix edgecase for Money#allocate when applying to array of all zero values
52
+
53
+ ## 6.13.8
54
+ - Update symbol for XOF
55
+ - Update UYU currency symbol
56
+ - Allow double conversion using same bank
57
+ - Warn when using unsafe serializer for rate import
58
+ - Move Icelandic symbol after the amount
59
+
60
+ ## 6.13.7
61
+ - Improve deprecation warnings for the upcoming major release
62
+
63
+ ## 6.13.6
64
+ - Fix a regression introduced in 6.13.5 that broken RatesStore::Memory subclasses
65
+
66
+ ## 6.13.5
67
+ - Raise warning on using Money.default_currency
68
+ - Raise warning on using default Money.rounding_mode
69
+ - Add Second Ouguiya MRU 929 to currency iso file
70
+ - Add symbol for UZS
71
+ - Use monitor for recursive mutual exclusion in RatesStore::Memory
72
+ - Allow passing store as a string to Money::Bank::VariableExchange (to support Rails 6)
73
+
3
74
  ## 6.13.4
4
75
  - Update currency config for Zambian Kwacha (ZMW)
5
76
  - Do not modify options passed to FormattingRules
@@ -46,7 +117,7 @@
46
117
  - Wrap all amount parts when `:html_wrap` option is used
47
118
  - Deprecate `#currency_as_string` and `#currency_as_string=` (in favour of `#with_currency`)
48
119
  - Add `#with_currency` for swapping the currency
49
- - Rewrite allocate/split (fixing some penny loosing issues)
120
+ - Rewrite allocate/split (fixing some penny losing issues)
50
121
 
51
122
  ## 6.11.3
52
123
  - Fix regression: if enabled use i18n locales in Money#to_s
@@ -65,7 +136,7 @@
65
136
  - Added new symbol for bitcoin denomination
66
137
  - Specify custom rounding precision when using `infinite_precision`
67
138
  - Allow splits with sums greater than 1
68
- - Prevent arithmetic methods from loosing reference to the bank
139
+ - Prevent arithmetic methods from losing reference to the bank
69
140
  - Fix coerced zero numeric subtraction
70
141
  - Fix south asian formatting to support whole numbers
71
142
  - Refactor formatting logic
data/LICENSE CHANGED
@@ -1,23 +1,23 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
3
  Copyright (c) 2005 Tobias Lutke
4
4
  Copyright (c) 2008 Phusion
5
+ Copyright (c) 2024 Shane Emmons
5
6
 
6
- Permission is hereby granted, free of charge, to any person obtaining
7
- a copy of this software and associated documentation files (the
8
- "Software"), to deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify, merge, publish,
10
- distribute, sublicense, and/or sell copies of the Software, and to
11
- permit persons to whom the Software is furnished to do so, subject to
12
- the following conditions:
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
13
 
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
16
 
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # RubyMoney - Money
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/money.svg)](https://rubygems.org/gems/money)
4
- [![Build Status](https://travis-ci.org/RubyMoney/money.svg?branch=master)](https://travis-ci.org/RubyMoney/money)
4
+ [![Ruby](https://github.com/RubyMoney/money/actions/workflows/ruby.yml/badge.svg)](https://github.com/RubyMoney/money/actions/workflows/ruby.yml)
5
5
  [![Code Climate](https://codeclimate.com/github/RubyMoney/money.svg)](https://codeclimate.com/github/RubyMoney/money)
6
- [![Coverage Status](https://coveralls.io/repos/RubyMoney/money/badge.svg?branch=master)](https://coveralls.io/r/RubyMoney/money?branch=master)
7
6
  [![Inline docs](https://inch-ci.org/github/RubyMoney/money.svg)](https://inch-ci.org/github/RubyMoney/money)
8
7
  [![License](https://img.shields.io/github/license/RubyMoney/money.svg)](https://opensource.org/licenses/MIT)
9
8
 
@@ -21,7 +20,7 @@ A Ruby Library for dealing with money and currency conversion.
21
20
 
22
21
  ### Features
23
22
 
24
- - Provides a `Money` class which encapsulates all information about an certain
23
+ - Provides a `Money` class which encapsulates all information about a certain
25
24
  amount of money, such as its value and its currency.
26
25
  - Provides a `Money::Currency` class which encapsulates all information about
27
26
  a monetary unit.
@@ -61,39 +60,43 @@ The development version (hosted on Github) can be installed with:
61
60
  ``` ruby
62
61
  require 'money'
63
62
 
63
+ # explicitly define locales
64
+ I18n.config.available_locales = :en
65
+ Money.locale_backend = :i18n
66
+
64
67
  # 10.00 USD
65
- money = Money.new(1000, "USD")
68
+ money = Money.from_cents(1000, "USD")
66
69
  money.cents #=> 1000
67
70
  money.currency #=> Currency.new("USD")
68
71
 
69
72
  # Comparisons
70
- Money.new(1000, "USD") == Money.new(1000, "USD") #=> true
71
- Money.new(1000, "USD") == Money.new(100, "USD") #=> false
72
- Money.new(1000, "USD") == Money.new(1000, "EUR") #=> false
73
- Money.new(1000, "USD") != Money.new(1000, "EUR") #=> true
73
+ Money.from_cents(1000, "USD") == Money.from_cents(1000, "USD") #=> true
74
+ Money.from_cents(1000, "USD") == Money.from_cents(100, "USD") #=> false
75
+ Money.from_cents(1000, "USD") == Money.from_cents(1000, "EUR") #=> false
76
+ Money.from_cents(1000, "USD") != Money.from_cents(1000, "EUR") #=> true
74
77
 
75
78
  # Arithmetic
76
- Money.new(1000, "USD") + Money.new(500, "USD") == Money.new(1500, "USD")
77
- Money.new(1000, "USD") - Money.new(200, "USD") == Money.new(800, "USD")
78
- Money.new(1000, "USD") / 5 == Money.new(200, "USD")
79
- Money.new(1000, "USD") * 5 == Money.new(5000, "USD")
79
+ Money.from_cents(1000, "USD") + Money.from_cents(500, "USD") == Money.from_cents(1500, "USD")
80
+ Money.from_cents(1000, "USD") - Money.from_cents(200, "USD") == Money.from_cents(800, "USD")
81
+ Money.from_cents(1000, "USD") / 5 == Money.from_cents(200, "USD")
82
+ Money.from_cents(1000, "USD") * 5 == Money.from_cents(5000, "USD")
80
83
 
81
84
  # Unit to subunit conversions
82
- Money.from_amount(5, "USD") == Money.new(500, "USD") # 5 USD
83
- Money.from_amount(5, "JPY") == Money.new(5, "JPY") # 5 JPY
84
- Money.from_amount(5, "TND") == Money.new(5000, "TND") # 5 TND
85
+ Money.from_amount(5, "USD") == Money.from_cents(500, "USD") # 5 USD
86
+ Money.from_amount(5, "JPY") == Money.from_cents(5, "JPY") # 5 JPY
87
+ Money.from_amount(5, "TND") == Money.from_cents(5000, "TND") # 5 TND
85
88
 
86
89
  # Currency conversions
87
90
  some_code_to_setup_exchange_rates
88
- Money.new(1000, "USD").exchange_to("EUR") == Money.new(some_value, "EUR")
91
+ Money.from_cents(1000, "USD").exchange_to("EUR") == Money.from_cents(some_value, "EUR")
89
92
 
90
93
  # Swap currency
91
- Money.new(1000, "USD").with_currency("EUR") == Money.new(1000, "EUR")
94
+ Money.from_cents(1000, "USD").with_currency("EUR") == Money.from_cents(1000, "EUR")
92
95
 
93
96
  # Formatting (see Formatting section for more options)
94
- Money.new(100, "USD").format #=> "$1.00"
95
- Money.new(100, "GBP").format #=> "£1.00"
96
- Money.new(100, "EUR").format #=> "€1.00"
97
+ Money.from_cents(100, "USD").format #=> "$1.00"
98
+ Money.from_cents(100, "GBP").format #=> "£1.00"
99
+ Money.from_cents(100, "EUR").format #=> "€1.00"
97
100
  ```
98
101
 
99
102
  ## Currency
@@ -103,15 +106,15 @@ The most part of `Money` APIs allows you to supply either a `String` or a
103
106
  `Money::Currency`.
104
107
 
105
108
  ``` ruby
106
- Money.new(1000, "USD") == Money.new(1000, Money::Currency.new("USD"))
107
- Money.new(1000, "EUR").currency == Money::Currency.new("EUR")
109
+ Money.from_cents(1000, "USD") == Money.from_cents(1000, Money::Currency.new("USD"))
110
+ Money.from_cents(1000, "EUR").currency == Money::Currency.new("EUR")
108
111
  ```
109
112
 
110
113
  A `Money::Currency` instance holds all the information about the currency,
111
114
  including the currency symbol, name and much more.
112
115
 
113
116
  ``` ruby
114
- currency = Money.new(1000, "USD").currency
117
+ currency = Money.from_cents(1000, "USD").currency
115
118
  currency.iso_code #=> "USD"
116
119
  currency.name #=> "United States Dollar"
117
120
  ```
@@ -231,18 +234,18 @@ an example of how it works:
231
234
  Money.add_rate("USD", "CAD", 1.24515)
232
235
  Money.add_rate("CAD", "USD", 0.803115)
233
236
 
234
- Money.us_dollar(100).exchange_to("CAD") # => Money.new(124, "CAD")
235
- Money.ca_dollar(100).exchange_to("USD") # => Money.new(80, "USD")
237
+ Money.us_dollar(100).exchange_to("CAD") # => Money.from_cents(124, "CAD")
238
+ Money.ca_dollar(100).exchange_to("USD") # => Money.from_cents(80, "USD")
236
239
  ```
237
240
 
238
241
  Comparison and arithmetic operations work as expected:
239
242
 
240
243
  ``` ruby
241
- Money.new(1000, "USD") <=> Money.new(900, "USD") # => 1; 9.00 USD is smaller
242
- Money.new(1000, "EUR") + Money.new(10, "EUR") == Money.new(1010, "EUR")
244
+ Money.from_cents(1000, "USD") <=> Money.from_cents(900, "USD") # => 1; 9.00 USD is smaller
245
+ Money.from_cents(1000, "EUR") + Money.from_cents(10, "EUR") == Money.from_cents(1010, "EUR")
243
246
 
244
247
  Money.add_rate("USD", "EUR", 0.5)
245
- Money.new(1000, "EUR") + Money.new(1000, "USD") == Money.new(1500, "EUR")
248
+ Money.from_cents(1000, "EUR") + Money.from_cents(1000, "USD") == Money.from_cents(1500, "EUR")
246
249
  ```
247
250
 
248
251
  ### Exchange rate stores
@@ -316,11 +319,10 @@ The following example implements an `ActiveRecord` store to save exchange rates
316
319
  ```ruby
317
320
  # rails g model exchange_rate from:string to:string rate:float
318
321
 
319
- # for Rails 5 replace ActiveRecord::Base with ApplicationRecord
320
- class ExchangeRate < ActiveRecord::Base
322
+ class ExchangeRate < ApplicationRecord
321
323
  def self.get_rate(from_iso_code, to_iso_code)
322
324
  rate = find_by(from: from_iso_code, to: to_iso_code)
323
- rate.present? ? rate.rate : nil
325
+ rate&.rate
324
326
  end
325
327
 
326
328
  def self.add_rate(from_iso_code, to_iso_code, rate)
@@ -328,12 +330,75 @@ class ExchangeRate < ActiveRecord::Base
328
330
  exrate.rate = rate
329
331
  exrate.save!
330
332
  end
333
+
334
+ def self.each_rate
335
+ return find_each unless block_given?
336
+
337
+ find_each do |rate|
338
+ yield rate.from, rate.to, rate.rate
339
+ end
340
+ end
341
+
342
+ def self.marshal_dump
343
+ [self]
344
+ end
345
+ end
346
+ ```
347
+
348
+ The following example implements a `Redis` store to save exchange rates to a redis database.
349
+
350
+ ```ruby
351
+
352
+ class RedisRateStore
353
+ INDEX_KEY_SEPARATOR = '_TO_'.freeze
354
+
355
+ # Using second db of the redis instance
356
+ # because sidekiq uses the first db
357
+ REDIS_DATABASE = 1
358
+
359
+ # Using Hash to store rates data
360
+ REDIS_STORE_KEY = 'rates'
361
+
362
+ def initialize
363
+ conn_url = "#{Rails.application.credentials.redis_server}/#{REDIS_DATABASE}"
364
+ @connection = Redis.new(url: conn_url)
365
+ end
366
+
367
+ def add_rate(iso_from, iso_to, rate)
368
+ @connection.hset(REDIS_STORE_KEY, rate_key_for(iso_from, iso_to), rate)
369
+ end
370
+
371
+ def get_rate(iso_from, iso_to)
372
+ @connection.hget(REDIS_STORE_KEY, rate_key_for(iso_from, iso_to))
373
+ end
374
+
375
+ def each_rate
376
+ rates = @connection.hgetall(REDIS_STORE_KEY)
377
+ return to_enum(:each_rate) unless block_given?
378
+
379
+ rates.each do |key, rate|
380
+ iso_from, iso_to = key.split(INDEX_KEY_SEPARATOR)
381
+ yield iso_from, iso_to, rate
382
+ end
383
+ end
384
+
385
+ def transaction
386
+ yield
387
+ end
388
+
389
+ private
390
+
391
+ def rate_key_for(iso_from, iso_to)
392
+ [iso_from, iso_to].join(INDEX_KEY_SEPARATOR).upcase
393
+ end
331
394
  end
332
395
  ```
333
396
 
334
397
  Now you can use it with the default bank.
335
398
 
336
399
  ```ruby
400
+ # For Rails 6 pass model name as a string to make it compatible with zeitwerk
401
+ # Money.default_bank = Money::Bank::VariableExchange.new("ExchangeRate")
337
402
  Money.default_bank = Money::Bank::VariableExchange.new(ExchangeRate)
338
403
 
339
404
  # Add to the underlying store
@@ -341,7 +406,7 @@ Money.default_bank.add_rate('USD', 'CAD', 0.9)
341
406
  # Retrieve from the underlying store
342
407
  Money.default_bank.get_rate('USD', 'CAD') # => 0.9
343
408
  # Exchanging amounts just works.
344
- Money.new(1000, 'USD').exchange_to('CAD') #=> #<Money fractional:900 currency:CAD>
409
+ Money.from_cents(1000, 'USD').exchange_to('CAD') #=> #<Money fractional:900 currency:CAD>
345
410
  ```
346
411
 
347
412
  There is nothing stopping you from creating store objects which scrapes
@@ -388,7 +453,7 @@ There are several formatting rules for when `Money#format` is called. For more i
388
453
  If you wish to format money according to the EU's [Rules for expressing monetary units](http://publications.europa.eu/code/en/en-370303.htm#position) in either English, Irish, Latvian or Maltese:
389
454
 
390
455
  ```ruby
391
- m = Money.new('123', :gbp) # => #<Money fractional:123 currency:GBP>
456
+ m = Money.from_cents('123', :gbp) # => #<Money fractional:123 currency:GBP>
392
457
  m.format(symbol: m.currency.to_s + ' ') # => "GBP 1.23"
393
458
  ```
394
459
 
@@ -403,7 +468,7 @@ Money.from_amount(2.34567).format #=> "$2.35"
403
468
  To retain the additional precision, you will also need to set `infinite_precision` to `true`.
404
469
 
405
470
  ```ruby
406
- Money.infinite_precision = true
471
+ Money.default_infinite_precision = true
407
472
  Money.from_amount(2.34567).format #=> "$2.34567"
408
473
  ```
409
474
 
@@ -415,11 +480,17 @@ To round to the nearest cent (or anything more precise), you can use the `round`
415
480
  2.34567.round(2) #=> 2.35
416
481
 
417
482
  # Money
418
- Money.infinite_precision = true
419
- Money.new(2.34567).format #=> "$0.0234567"
420
- Money.new(2.34567).round.format #=> "$0.02"
421
- Money.new(2.34567).round(BigDecimal::ROUND_HALF_UP, 2).format #=> "$0.0235"
483
+ Money.default_infinite_precision = true
484
+ Money.from_cents(2.34567).format #=> "$0.0234567"
485
+ Money.from_cents(2.34567).round.format #=> "$0.02"
486
+ Money.from_cents(2.34567).round(BigDecimal::ROUND_HALF_UP, 2).format #=> "$0.0235"
487
+ ```
488
+
489
+ You can set the default rounding mode by passing one of the `BigDecimal` mode enumerables like so:
490
+ ```ruby
491
+ Money.rounding_mode = BigDecimal::ROUND_HALF_EVEN
422
492
  ```
493
+ See [BigDecimal::ROUND_MODE](https://ruby-doc.org/stdlib-2.5.1/libdoc/bigdecimal/rdoc/BigDecimal.html#ROUND_MODE) for more information
423
494
 
424
495
  ## Ruby on Rails
425
496
 
@@ -452,7 +523,7 @@ en:
452
523
  separator: "."
453
524
  ```
454
525
 
455
- For this example `Money.new(123456789, "SEK").format` will return `1,234,567.89
526
+ For this example `Money.from_cents(123456789, "SEK").format` will return `1,234,567.89
456
527
  kr` which otherwise would have returned `1 234 567,89 kr`.
457
528
 
458
529
  This will work seamlessly with [rails-i18n](https://github.com/svenfuchs/rails-i18n) gem that already has a lot of locales defined.
@@ -476,12 +547,22 @@ Money.locale_backend = :i18n
476
547
 
477
548
  # example (using default localization from rails-i18n):
478
549
  I18n.locale = :en
479
- Money.new(10_000_00, 'USD').format # => $10,000.00
480
- Money.new(10_000_00, 'EUR').format # => €10,000.00
550
+ Money.from_cents(10_000_00, 'USD').format # => $10,000.00
551
+ Money.from_cents(10_000_00, 'EUR').format # => €10,000.00
481
552
 
482
553
  I18n.locale = :es
483
- Money.new(10_000_00, 'USD').format # => $10.000,00
484
- Money.new(10_000_00, 'EUR').format # => €10.000,00
554
+ Money.from_cents(10_000_00, 'USD').format # => $10.000,00
555
+ Money.from_cents(10_000_00, 'EUR').format # => €10.000,00
556
+ ```
557
+
558
+ If you need to localize the position of the currency symbol, you
559
+ have to pass it manually. *Note: this will become the default formatting
560
+ behavior in the next version.*
561
+
562
+ ```ruby
563
+ I18n.locale = :fr
564
+ format = I18n.t :format, scope: 'number.currency.format'
565
+ Money.from_cents(10_00, 'EUR').format(format: format) # => 10,00 €
485
566
  ```
486
567
 
487
568
  For the legacy behaviour of "per currency" localization (formatting depends only on currency):
@@ -490,8 +571,8 @@ For the legacy behaviour of "per currency" localization (formatting depends only
490
571
  Money.locale_backend = :currency
491
572
 
492
573
  # example:
493
- Money.new(10_000_00, 'USD').format # => $10,000.00
494
- Money.new(10_000_00, 'EUR').format # => €10.000,00
574
+ Money.from_cents(10_000_00, 'USD').format # => $10,000.00
575
+ Money.from_cents(10_000_00, 'EUR').format # => €10.000,00
495
576
  ```
496
577
 
497
578
  In case you don't need localization and would like to use default values (can be redefined using
@@ -501,8 +582,8 @@ In case you don't need localization and would like to use default values (can be
501
582
  Money.locale_backend = nil
502
583
 
503
584
  # example:
504
- Money.new(10_000_00, 'USD').format # => $10000.00
505
- Money.new(10_000_00, 'EUR').format # => €10000.00
585
+ Money.from_cents(10_000_00, 'USD').format # => $10000.00
586
+ Money.from_cents(10_000_00, 'EUR').format # => €10000.00
506
587
  ```
507
588
 
508
589
  ## Collection
@@ -8,6 +8,7 @@
8
8
  "subunit": "Sent",
9
9
  "subunit_to_unit": 100,
10
10
  "symbol_first": false,
11
+ "format": "%n %u",
11
12
  "html_entity": "",
12
13
  "decimal_mark": ".",
13
14
  "thousands_separator": ",",
@@ -30,6 +31,22 @@
30
31
  "iso_numeric": "288",
31
32
  "smallest_denomination": 1
32
33
  },
34
+ "hrk": {
35
+ "priority": 100,
36
+ "iso_code": "HRK",
37
+ "name": "Croatian Kuna",
38
+ "symbol": "kn",
39
+ "alternate_symbols": [],
40
+ "subunit": "Lipa",
41
+ "subunit_to_unit": 100,
42
+ "symbol_first": false,
43
+ "format": "%n %u",
44
+ "html_entity": "",
45
+ "decimal_mark": ",",
46
+ "thousands_separator": ".",
47
+ "iso_numeric": "191",
48
+ "smallest_denomination": 1
49
+ },
33
50
  "ltl": {
34
51
  "priority": 100,
35
52
  "iso_code": "LTL",
@@ -39,6 +56,7 @@
39
56
  "subunit": "Centas",
40
57
  "subunit_to_unit": 100,
41
58
  "symbol_first": false,
59
+ "format": "%n %u",
42
60
  "html_entity": "",
43
61
  "decimal_mark": ".",
44
62
  "thousands_separator": ",",
@@ -60,6 +78,23 @@
60
78
  "iso_numeric": "428",
61
79
  "smallest_denomination": 1
62
80
  },
81
+ "mro": {
82
+ "priority": 100,
83
+ "iso_code": "MRO",
84
+ "name": "Mauritanian Ouguiya",
85
+ "symbol": "UM",
86
+ "disambiguate_symbol": "A-UM",
87
+ "alternate_symbols": [],
88
+ "subunit": "Khoums",
89
+ "subunit_to_unit": 5,
90
+ "symbol_first": false,
91
+ "format": "%n %u",
92
+ "html_entity": "",
93
+ "decimal_mark": ".",
94
+ "thousands_separator": ",",
95
+ "iso_numeric": "478",
96
+ "smallest_denomination": 1
97
+ },
63
98
  "mtl": {
64
99
  "priority": 100,
65
100
  "iso_code": "MTL",
@@ -84,6 +119,7 @@
84
119
  "subunit": "Tennesi",
85
120
  "subunit_to_unit": 100,
86
121
  "symbol_first": false,
122
+ "format": "%n %u",
87
123
  "html_entity": "",
88
124
  "decimal_mark": ".",
89
125
  "thousands_separator": ",",