├── .gitignore ├── README.md ├── data └── currencies │ ├── aed.json │ ├── afn.json │ ├── all.json │ ├── amd.json │ ├── ang.json │ ├── aoa.json │ ├── ars.json │ ├── aud.json │ ├── awg.json │ ├── azn.json │ ├── bam.json │ ├── bbd.json │ ├── bdt.json │ ├── bgn.json │ ├── bhd.json │ ├── bif.json │ ├── bmd.json │ ├── bnd.json │ ├── bob.json │ ├── brl.json │ ├── bsd.json │ ├── btn.json │ ├── bwp.json │ ├── byn.json │ ├── byr.json │ ├── bzd.json │ ├── cad.json │ ├── cdf.json │ ├── chf.json │ ├── clf.json │ ├── clp.json │ ├── cny.json │ ├── cop.json │ ├── crc.json │ ├── cuc.json │ ├── cup.json │ ├── cve.json │ ├── czk.json │ ├── djf.json │ ├── dkk.json │ ├── dop.json │ ├── dzd.json │ ├── egp.json │ ├── ern.json │ ├── etb.json │ ├── eur.json │ ├── fjd.json │ ├── fkp.json │ ├── gbp.json │ ├── gel.json │ ├── ghs.json │ ├── gip.json │ ├── gmd.json │ ├── gnf.json │ ├── gtq.json │ ├── gyd.json │ ├── hkd.json │ ├── hnl.json │ ├── hrk.json │ ├── htg.json │ ├── huf.json │ ├── idr.json │ ├── ils.json │ ├── inr.json │ ├── iqd.json │ ├── irr.json │ ├── isk.json │ ├── jmd.json │ ├── jod.json │ ├── jpy.json │ ├── kes.json │ ├── kgs.json │ ├── khr.json │ ├── kmf.json │ ├── kpw.json │ ├── krw.json │ ├── kwd.json │ ├── kyd.json │ ├── kzt.json │ ├── lak.json │ ├── lbp.json │ ├── lkr.json │ ├── lrd.json │ ├── lsl.json │ ├── ltl.json │ ├── lvl.json │ ├── lyd.json │ ├── mad.json │ ├── mdl.json │ ├── mga.json │ ├── mkd.json │ ├── mmk.json │ ├── mnt.json │ ├── mop.json │ ├── mro.json │ ├── mur.json │ ├── mvr.json │ ├── mwk.json │ ├── mxn.json │ ├── myr.json │ ├── mzn.json │ ├── nad.json │ ├── ngn.json │ ├── nio.json │ ├── nok.json │ ├── npr.json │ ├── nzd.json │ ├── omr.json │ ├── pab.json │ ├── pen.json │ ├── pgk.json │ ├── php.json │ ├── pkr.json │ ├── pln.json │ ├── pyg.json │ ├── qar.json │ ├── ron.json │ ├── rsd.json │ ├── rub.json │ ├── rwf.json │ ├── sar.json │ ├── sbd.json │ ├── scr.json │ ├── sdg.json │ ├── sek.json │ ├── sgd.json │ ├── shp.json │ ├── skk.json │ ├── sll.json │ ├── sos.json │ ├── srd.json │ ├── ssp.json │ ├── std.json │ ├── svc.json │ ├── syp.json │ ├── szl.json │ ├── thb.json │ ├── tjs.json │ ├── tmt.json │ ├── tnd.json │ ├── top.json │ ├── try.json │ ├── ttd.json │ ├── twd.json │ ├── tzs.json │ ├── uah.json │ ├── ugx.json │ ├── usd.json │ ├── uyu.json │ ├── uzs.json │ ├── vef.json │ ├── vnd.json │ ├── vuv.json │ ├── wst.json │ ├── xaf.json │ ├── xag.json │ ├── xau.json │ ├── xba.json │ ├── xbb.json │ ├── xbc.json │ ├── xbd.json │ ├── xcd.json │ ├── xdr.json │ ├── xof.json │ ├── xpd.json │ ├── xpf.json │ ├── xpt.json │ ├── xts.json │ ├── yer.json │ ├── zar.json │ ├── zmk.json │ └── zmw.json ├── shard.yml ├── spec ├── moola │ ├── currency_spec.cr │ ├── exchange_spec.cr │ └── money_spec.cr ├── moola_spec.cr └── spec_helper.cr └── src ├── moola.cr └── moola ├── currency.cr ├── exchange.cr └── money.cr /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dorkrawk/moola/fdc6bb5ad922473af41b3edfab82133e71b8ddc7/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Moola 2 | A Crystal library for dealing with money (inspired by [RubyMoney](https://github.com/RubyMoney/money)) 3 | 4 | ## Installation 5 | 6 | *tested with Crystal 0.28.0* 7 | 8 | Add this to your application's `shard.yml`: 9 | 10 | ```yaml 11 | dependencies: 12 | moola: 13 | github: dorkrawk/moola 14 | ``` 15 | 16 | ## Usage 17 | 18 | ### Basic Money object 19 | ``` 20 | money = Moola.new(42_00) # creates a new Moola::Money object 21 | money.format # "$42.00" 22 | money.cents # 4200 23 | money.zero? # false 24 | money.to_f # 42.0 25 | -money == Moola.new(-42_00) # true 26 | ``` 27 | 28 | ### Comparisons 29 | ``` 30 | Moola::Money.new(5_00) == Moola::Money.new(5_00) # true 31 | Moola::Money.new(5_00) == Moola::Money.new(7_00) # false 32 | Moola::Money.new(5_00, "USD") == Moola::Money.new(5_00, "EUR") # false 33 | [Moola::Money.new(5_00), Moola::Money.new(2_00), Moola::Money.new(7_00)].sort # sorted by amount 34 | ``` 35 | 36 | ### Arithmetic 37 | ``` 38 | Moola::Money.new(5_00) + Moola::Money.new(10_00) == Moola::Money.new(15_00) 39 | Moola::Money.new(15_00) + Moola::Money.new(12_00) == Moola::Money.new(3_00) 40 | Moola::Money.new(15_00) / 3 == Moola::Money.new(5_00) 41 | Moola::Money.new(5_00) * 3 == Moola::Money.new(15_00) 42 | ``` 43 | 44 | ### Conversion 45 | ``` 46 | Moola::Exchange.add_conversion(Moola::Currency.find("usd"), Moola::Currency.find("cad"), 1.3) 47 | money = Moola.new(1_00, "USD") 48 | money.convert_to(Moola::Currency.find("cad")) == Moola.new(1_30, "cad") 49 | ``` 50 | 51 | ## Testing 52 | 53 | ``` 54 | # from the project root... 55 | crystal spec 56 | ``` 57 | -------------------------------------------------------------------------------- /data/currencies/aed.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AED", 3 | "name": "United Arab Emirates Dirham", 4 | "symbol": "د.إ", 5 | "subunit": "Fils", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 25 11 | } -------------------------------------------------------------------------------- /data/currencies/afn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AFN", 3 | "name": "Afghan Afghani", 4 | "symbol": "؋", 5 | "subunit": "Pul", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/all.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ALL", 3 | "name": "Albanian Lek", 4 | "symbol": "L", 5 | "subunit": "Qintar", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/amd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AMD", 3 | "name": "Armenian Dram", 4 | "symbol": "դր.", 5 | "subunit": "Luma", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/ang.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ANG", 3 | "name": "Netherlands Antillean Gulden", 4 | "symbol": "ƒ", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/aoa.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AOA", 3 | "name": "Angolan Kwanza", 4 | "symbol": "Kz", 5 | "subunit": "Cêntimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/ars.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ARS", 3 | "name": "Argentine Peso", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/aud.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AUD", 3 | "name": "Australian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/awg.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AWG", 3 | "name": "Aruban Florin", 4 | "symbol": "ƒ", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/azn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "AZN", 3 | "name": "Azerbaijani Manat", 4 | "symbol": "₼", 5 | "subunit": "Qəpik", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/bam.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BAM", 3 | "name": "Bosnia and Herzegovina Convertible Mark", 4 | "symbol": "КМ", 5 | "subunit": "Fening", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/bbd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BBD", 3 | "name": "Barbadian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/bdt.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BDT", 3 | "name": "Bangladeshi Taka", 4 | "symbol": "৳", 5 | "subunit": "Paisa", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/bgn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BGN", 3 | "name": "Bulgarian Lev", 4 | "symbol": "лв.", 5 | "subunit": "Stotinka", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/bhd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BHD", 3 | "name": "Bahraini Dinar", 4 | "symbol": "ب.د", 5 | "subunit": "Fils", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/bif.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BIF", 3 | "name": "Burundian Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/bmd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BMD", 3 | "name": "Bermudian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/bnd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BND", 3 | "name": "Brunei Dollar", 4 | "symbol": "$", 5 | "subunit": "Sen", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/bob.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BOB", 3 | "name": "Bolivian Boliviano", 4 | "symbol": "Bs.", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/brl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BRL", 3 | "name": "Brazilian Real", 4 | "symbol": "R$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/bsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BSD", 3 | "name": "Bahamian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/btn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BTN", 3 | "name": "Bhutanese Ngultrum", 4 | "symbol": "Nu.", 5 | "subunit": "Chertrum", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/bwp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BWP", 3 | "name": "Botswana Pula", 4 | "symbol": "P", 5 | "subunit": "Thebe", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/byn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BYN", 3 | "name": "Belarusian Ruble", 4 | "symbol": "Br", 5 | "subunit": "Kapeyka", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": " ", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/byr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BYR", 3 | "name": "Belarusian Ruble", 4 | "symbol": "Br", 5 | "subunit": null, 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": " ", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/bzd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "BZD", 3 | "name": "Belize Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/cad.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CAD", 3 | "name": "Canadian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/cdf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CDF", 3 | "name": "Congolese Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/chf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CHF", 3 | "name": "Swiss Franc", 4 | "symbol": "CHF", 5 | "subunit": "Rappen", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/clf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CLF", 3 | "name": "Unidad de Fomento", 4 | "symbol": "UF", 5 | "subunit": "Peso", 6 | "subunit_to_unit": 10000, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": "." 10 | } -------------------------------------------------------------------------------- /data/currencies/clp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CLP", 3 | "name": "Chilean Peso", 4 | "symbol": "$", 5 | "subunit": "Peso", 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/cny.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CNY", 3 | "name": "Chinese Renminbi Yuan", 4 | "symbol": "¥", 5 | "subunit": "Fen", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/cop.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "COP", 3 | "name": "Colombian Peso", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 20 11 | } -------------------------------------------------------------------------------- /data/currencies/crc.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CRC", 3 | "name": "Costa Rican Colón", 4 | "symbol": "₡", 5 | "subunit": "Céntimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 500 11 | } -------------------------------------------------------------------------------- /data/currencies/cuc.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CUC", 3 | "name": "Cuban Convertible Peso", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/cup.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CUP", 3 | "name": "Cuban Peso", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/cve.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CVE", 3 | "name": "Cape Verdean Escudo", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/czk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "CZK", 3 | "name": "Czech Koruna", 4 | "symbol": "Kč", 5 | "subunit": "Haléř", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": " ", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/djf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "DJF", 3 | "name": "Djiboutian Franc", 4 | "symbol": "Fdj", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/dkk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "DKK", 3 | "name": "Danish Krone", 4 | "symbol": "kr.", 5 | "subunit": "Øre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/dop.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "DOP", 3 | "name": "Dominican Peso", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/dzd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "DZD", 3 | "name": "Algerian Dinar", 4 | "symbol": "د.ج", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/egp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "EGP", 3 | "name": "Egyptian Pound", 4 | "symbol": "ج.م", 5 | "subunit": "Piastre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 25 11 | } -------------------------------------------------------------------------------- /data/currencies/ern.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ERN", 3 | "name": "Eritrean Nakfa", 4 | "symbol": "Nfk", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/etb.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ETB", 3 | "name": "Ethiopian Birr", 4 | "symbol": "Br", 5 | "subunit": "Santim", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/eur.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "EUR", 3 | "name": "Euro", 4 | "symbol": "€", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/fjd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "FJD", 3 | "name": "Fijian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/fkp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "FKP", 3 | "name": "Falkland Pound", 4 | "symbol": "£", 5 | "subunit": "Penny", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/gbp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GBP", 3 | "name": "British Pound", 4 | "symbol": "£", 5 | "subunit": "Penny", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/gel.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GEL", 3 | "name": "Georgian Lari", 4 | "symbol": "ლ", 5 | "subunit": "Tetri", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/ghs.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GHS", 3 | "name": "Ghanaian Cedi", 4 | "symbol": "₵", 5 | "subunit": "Pesewa", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/gip.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GIP", 3 | "name": "Gibraltar Pound", 4 | "symbol": "£", 5 | "subunit": "Penny", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/gmd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GMD", 3 | "name": "Gambian Dalasi", 4 | "symbol": "D", 5 | "subunit": "Butut", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/gnf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GNF", 3 | "name": "Guinean Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/gtq.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GTQ", 3 | "name": "Guatemalan Quetzal", 4 | "symbol": "Q", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/gyd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "GYD", 3 | "name": "Guyanese Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/hkd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "HKD", 3 | "name": "Hong Kong Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/hnl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "HNL", 3 | "name": "Honduran Lempira", 4 | "symbol": "L", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/hrk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "HRK", 3 | "name": "Croatian Kuna", 4 | "symbol": "kn", 5 | "subunit": "Lipa", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/htg.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "HTG", 3 | "name": "Haitian Gourde", 4 | "symbol": "G", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/huf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "HUF", 3 | "name": "Hungarian Forint", 4 | "symbol": "Ft", 5 | "subunit": "Fillér", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/idr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "IDR", 3 | "name": "Indonesian Rupiah", 4 | "symbol": "Rp", 5 | "subunit": "Sen", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 5000 11 | } -------------------------------------------------------------------------------- /data/currencies/ils.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ILS", 3 | "name": "Israeli New Sheqel", 4 | "symbol": "₪", 5 | "subunit": "Agora", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/inr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "INR", 3 | "name": "Indian Rupee", 4 | "symbol": "₹", 5 | "subunit": "Paisa", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/iqd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "IQD", 3 | "name": "Iraqi Dinar", 4 | "symbol": "ع.د", 5 | "subunit": "Fils", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50000 11 | } -------------------------------------------------------------------------------- /data/currencies/irr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "IRR", 3 | "name": "Iranian Rial", 4 | "symbol": "﷼", 5 | "subunit": null, 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5000 11 | } -------------------------------------------------------------------------------- /data/currencies/isk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ISK", 3 | "name": "Icelandic Króna", 4 | "symbol": "kr", 5 | "subunit": null, 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/jmd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "JMD", 3 | "name": "Jamaican Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/jod.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "JOD", 3 | "name": "Jordanian Dinar", 4 | "symbol": "د.ا", 5 | "subunit": "Fils", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/jpy.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "JPY", 3 | "name": "Japanese Yen", 4 | "symbol": "¥", 5 | "subunit": null, 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/kes.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KES", 3 | "name": "Kenyan Shilling", 4 | "symbol": "KSh", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/kgs.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KGS", 3 | "name": "Kyrgyzstani Som", 4 | "symbol": "som", 5 | "subunit": "Tyiyn", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/khr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KHR", 3 | "name": "Cambodian Riel", 4 | "symbol": "៛", 5 | "subunit": "Sen", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5000 11 | } -------------------------------------------------------------------------------- /data/currencies/kmf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KMF", 3 | "name": "Comorian Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/kpw.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KPW", 3 | "name": "North Korean Won", 4 | "symbol": "₩", 5 | "subunit": "Chŏn", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/krw.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KRW", 3 | "name": "South Korean Won", 4 | "symbol": "₩", 5 | "subunit": null, 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/kwd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KWD", 3 | "name": "Kuwaiti Dinar", 4 | "symbol": "د.ك", 5 | "subunit": "Fils", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/kyd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KYD", 3 | "name": "Cayman Islands Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/kzt.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "KZT", 3 | "name": "Kazakhstani Tenge", 4 | "symbol": "〒", 5 | "subunit": "Tiyn", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/lak.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LAK", 3 | "name": "Lao Kip", 4 | "symbol": "₭", 5 | "subunit": "Att", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/lbp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LBP", 3 | "name": "Lebanese Pound", 4 | "symbol": "ل.ل", 5 | "subunit": "Piastre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 25000 11 | } -------------------------------------------------------------------------------- /data/currencies/lkr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LKR", 3 | "name": "Sri Lankan Rupee", 4 | "symbol": "₨", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/lrd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LRD", 3 | "name": "Liberian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/lsl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LSL", 3 | "name": "Lesotho Loti", 4 | "symbol": "L", 5 | "subunit": "Sente", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/ltl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LTL", 3 | "name": "Lithuanian Litas", 4 | "symbol": "Lt", 5 | "subunit": "Centas", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/lvl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LVL", 3 | "name": "Latvian Lats", 4 | "symbol": "Ls", 5 | "subunit": "Santīms", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/lyd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "LYD", 3 | "name": "Libyan Dinar", 4 | "symbol": "ل.د", 5 | "subunit": "Dirham", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/mad.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MAD", 3 | "name": "Moroccan Dirham", 4 | "symbol": "د.م.", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/mdl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MDL", 3 | "name": "Moldovan Leu", 4 | "symbol": "L", 5 | "subunit": "Ban", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/mga.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MGA", 3 | "name": "Malagasy Ariary", 4 | "symbol": "Ar", 5 | "subunit": "Iraimbilanja", 6 | "subunit_to_unit": 5, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/mkd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MKD", 3 | "name": "Macedonian Denar", 4 | "symbol": "ден", 5 | "subunit": "Deni", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/mmk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MMK", 3 | "name": "Myanmar Kyat", 4 | "symbol": "K", 5 | "subunit": "Pya", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/mnt.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MNT", 3 | "name": "Mongolian Tögrög", 4 | "symbol": "₮", 5 | "subunit": "Möngö", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 2000 11 | } -------------------------------------------------------------------------------- /data/currencies/mop.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MOP", 3 | "name": "Macanese Pataca", 4 | "symbol": "P", 5 | "subunit": "Avo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/mro.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MRO", 3 | "name": "Mauritanian Ouguiya", 4 | "symbol": "UM", 5 | "subunit": "Khoums", 6 | "subunit_to_unit": 5, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/mur.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MUR", 3 | "name": "Mauritian Rupee", 4 | "symbol": "₨", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/mvr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MVR", 3 | "name": "Maldivian Rufiyaa", 4 | "symbol": "MVR", 5 | "subunit": "Laari", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/mwk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MWK", 3 | "name": "Malawian Kwacha", 4 | "symbol": "MK", 5 | "subunit": "Tambala", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/mxn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MXN", 3 | "name": "Mexican Peso", 4 | "symbol": "$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/myr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MYR", 3 | "name": "Malaysian Ringgit", 4 | "symbol": "RM", 5 | "subunit": "Sen", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/mzn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "MZN", 3 | "name": "Mozambican Metical", 4 | "symbol": "MTn", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/nad.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "NAD", 3 | "name": "Namibian Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/ngn.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "NGN", 3 | "name": "Nigerian Naira", 4 | "symbol": "₦", 5 | "subunit": "Kobo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/nio.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "NIO", 3 | "name": "Nicaraguan Córdoba", 4 | "symbol": "C$", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/nok.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "NOK", 3 | "name": "Norwegian Krone", 4 | "symbol": "kr", 5 | "subunit": "Øre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/npr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "NPR", 3 | "name": "Nepalese Rupee", 4 | "symbol": "₨", 5 | "subunit": "Paisa", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/nzd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "NZD", 3 | "name": "New Zealand Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/omr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "OMR", 3 | "name": "Omani Rial", 4 | "symbol": "ر.ع.", 5 | "subunit": "Baisa", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/pab.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PAB", 3 | "name": "Panamanian Balboa", 4 | "symbol": "B/.", 5 | "subunit": "Centésimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/pen.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PEN", 3 | "name": "Peruvian Nuevo Sol", 4 | "symbol": "S/.", 5 | "subunit": "Céntimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/pgk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PGK", 3 | "name": "Papua New Guinean Kina", 4 | "symbol": "K", 5 | "subunit": "Toea", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/php.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PHP", 3 | "name": "Philippine Peso", 4 | "symbol": "₱", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/pkr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PKR", 3 | "name": "Pakistani Rupee", 4 | "symbol": "₨", 5 | "subunit": "Paisa", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/pln.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PLN", 3 | "name": "Polish Złoty", 4 | "symbol": "zł", 5 | "subunit": "Grosz", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": " ", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/pyg.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "PYG", 3 | "name": "Paraguayan Guaraní", 4 | "symbol": "₲", 5 | "subunit": "Céntimo", 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5000 11 | } -------------------------------------------------------------------------------- /data/currencies/qar.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "QAR", 3 | "name": "Qatari Riyal", 4 | "symbol": "ر.ق", 5 | "subunit": "Dirham", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/ron.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "RON", 3 | "name": "Romanian Leu", 4 | "symbol": "Lei", 5 | "subunit": "Bani", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/rsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "RSD", 3 | "name": "Serbian Dinar", 4 | "symbol": "РСД", 5 | "subunit": "Para", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/rub.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "RUB", 3 | "name": "Russian Ruble", 4 | "symbol": "₽", 5 | "subunit": "Kopeck", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/rwf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "RWF", 3 | "name": "Rwandan Franc", 4 | "symbol": "FRw", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/sar.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SAR", 3 | "name": "Saudi Riyal", 4 | "symbol": "ر.س", 5 | "subunit": "Hallallah", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/sbd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SBD", 3 | "name": "Solomon Islands Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/scr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SCR", 3 | "name": "Seychellois Rupee", 4 | "symbol": "₨", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/sdg.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SDG", 3 | "name": "Sudanese Pound", 4 | "symbol": "£", 5 | "subunit": "Piastre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/sek.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SEK", 3 | "name": "Swedish Krona", 4 | "symbol": "kr", 5 | "subunit": "Öre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ",", 9 | "thousands_separator": " ", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/sgd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SGD", 3 | "name": "Singapore Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/shp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SHP", 3 | "name": "Saint Helenian Pound", 4 | "symbol": "£", 5 | "subunit": "Penny", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/skk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SKK", 3 | "name": "Slovak Koruna", 4 | "symbol": "Sk", 5 | "subunit": "Halier", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/sll.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SLL", 3 | "name": "Sierra Leonean Leone", 4 | "symbol": "Le", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1000 11 | } -------------------------------------------------------------------------------- /data/currencies/sos.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SOS", 3 | "name": "Somali Shilling", 4 | "symbol": "Sh", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/srd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SRD", 3 | "name": "Surinamese Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/ssp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SSP", 3 | "name": "South Sudanese Pound", 4 | "symbol": "£", 5 | "subunit": "piaster", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/std.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "STD", 3 | "name": "São Tomé and Príncipe Dobra", 4 | "symbol": "Db", 5 | "subunit": "Cêntimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10000 11 | } -------------------------------------------------------------------------------- /data/currencies/svc.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SVC", 3 | "name": "Salvadoran Colón", 4 | "symbol": "₡", 5 | "subunit": "Centavo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/syp.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SYP", 3 | "name": "Syrian Pound", 4 | "symbol": "£S", 5 | "subunit": "Piastre", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/szl.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "SZL", 3 | "name": "Swazi Lilangeni", 4 | "symbol": "E", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/thb.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "THB", 3 | "name": "Thai Baht", 4 | "symbol": "฿", 5 | "subunit": "Satang", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/tjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TJS", 3 | "name": "Tajikistani Somoni", 4 | "symbol": "ЅМ", 5 | "subunit": "Diram", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/tmt.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TMT", 3 | "name": "Turkmenistani Manat", 4 | "symbol": "T", 5 | "subunit": "Tenge", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/tnd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TND", 3 | "name": "Tunisian Dinar", 4 | "symbol": "د.ت", 5 | "subunit": "Millime", 6 | "subunit_to_unit": 1000, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/top.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TOP", 3 | "name": "Tongan Paʻanga", 4 | "symbol": "T$", 5 | "subunit": "Seniti", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/try.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TRY", 3 | "name": "Turkish Lira", 4 | "symbol": "₺", 5 | "subunit": "kuruş", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/ttd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TTD", 3 | "name": "Trinidad and Tobago Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/twd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TWD", 3 | "name": "New Taiwan Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 50 11 | } -------------------------------------------------------------------------------- /data/currencies/tzs.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "TZS", 3 | "name": "Tanzanian Shilling", 4 | "symbol": "Sh", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5000 11 | } -------------------------------------------------------------------------------- /data/currencies/uah.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "UAH", 3 | "name": "Ukrainian Hryvnia", 4 | "symbol": "₴", 5 | "subunit": "Kopiyka", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/ugx.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "UGX", 3 | "name": "Ugandan Shilling", 4 | "symbol": "USh", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1000 11 | } -------------------------------------------------------------------------------- /data/currencies/usd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "USD", 3 | "name": "United States Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/uyu.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "UYU", 3 | "name": "Uruguayan Peso", 4 | "symbol": "$", 5 | "subunit": "Centésimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/uzs.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "UZS", 3 | "name": "Uzbekistan Som", 4 | "symbol": null, 5 | "subunit": "Tiyin", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/vef.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "VEF", 3 | "name": "Venezuelan Bolívar", 4 | "symbol": "Bs", 5 | "subunit": "Céntimo", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/vnd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "VND", 3 | "name": "Vietnamese Đồng", 4 | "symbol": "₫", 5 | "subunit": "Hào", 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ",", 9 | "thousands_separator": ".", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/vuv.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "VUV", 3 | "name": "Vanuatu Vatu", 4 | "symbol": "Vt", 5 | "subunit": null, 6 | "subunit_to_unit": 1, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/wst.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "WST", 3 | "name": "Samoan Tala", 4 | "symbol": "T", 5 | "subunit": "Sene", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/xaf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XAF", 3 | "name": "Central African Cfa Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/xag.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XAG", 3 | "name": "Silver (Troy Ounce)", 4 | "symbol": "oz t", 5 | "subunit": "oz", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xau.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XAU", 3 | "name": "Gold (Troy Ounce)", 4 | "symbol": "oz t", 5 | "subunit": "oz", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xba.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XBA", 3 | "name": "European Composite Unit", 4 | "symbol": "", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xbb.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XBB", 3 | "name": "European Monetary Unit", 4 | "symbol": "", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xbc.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XBC", 3 | "name": "European Unit of Account 9", 4 | "symbol": "", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xbd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XBD", 3 | "name": "European Unit of Account 17", 4 | "symbol": "", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xcd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XCD", 3 | "name": "East Caribbean Dollar", 4 | "symbol": "$", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 1 11 | } -------------------------------------------------------------------------------- /data/currencies/xdr.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XDR", 3 | "name": "Special Drawing Rights", 4 | "symbol": "SDR", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xof.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XOF", 3 | "name": "West African Cfa Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/xpd.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XPD", 3 | "name": "Palladium", 4 | "symbol": "oz t", 5 | "subunit": "oz", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": "," 10 | } -------------------------------------------------------------------------------- /data/currencies/xpf.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XPF", 3 | "name": "Cfp Franc", 4 | "symbol": "Fr", 5 | "subunit": "Centime", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/xpt.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "XPT", 3 | "name": "Platinum", 4 | "symbol": "oz t", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": "" 11 | } -------------------------------------------------------------------------------- /data/currencies/xts.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "xts", 3 | "name": "Codes specifically reserved for testing purposes", 4 | "symbol": "", 5 | "subunit": "", 6 | "subunit_to_unit": 1, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": "" 11 | } -------------------------------------------------------------------------------- /data/currencies/yer.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "YER", 3 | "name": "Yemeni Rial", 4 | "symbol": "﷼", 5 | "subunit": "Fils", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 100 11 | } -------------------------------------------------------------------------------- /data/currencies/zar.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ZAR", 3 | "name": "South African Rand", 4 | "symbol": "R", 5 | "subunit": "Cent", 6 | "subunit_to_unit": 100, 7 | "symbol_first": true, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 10 11 | } -------------------------------------------------------------------------------- /data/currencies/zmk.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ZMK", 3 | "name": "Zambian Kwacha", 4 | "symbol": "ZK", 5 | "subunit": "Ngwee", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /data/currencies/zmw.json: -------------------------------------------------------------------------------- 1 | { 2 | "iso_code": "ZMW", 3 | "name": "Zambian Kwacha", 4 | "symbol": "ZK", 5 | "subunit": "Ngwee", 6 | "subunit_to_unit": 100, 7 | "symbol_first": false, 8 | "decimal_mark": ".", 9 | "thousands_separator": ",", 10 | "smallest_denomination": 5 11 | } -------------------------------------------------------------------------------- /shard.yml: -------------------------------------------------------------------------------- 1 | name: moola 2 | version: 0.1.0 3 | 4 | authors: 5 | - Dave Schwantes 6 | -------------------------------------------------------------------------------- /spec/moola/currency_spec.cr: -------------------------------------------------------------------------------- 1 | require "../../spec_helper" 2 | 3 | describe Moola::Currency do 4 | 5 | # assumes that we at least have the USD currency (usd.json) in the system 6 | 7 | describe ".loaded_currencies" do 8 | it "returns a Hash of currencies containing usd" do 9 | Moola::Currency.loaded_currencies.keys.should contain("usd") 10 | end 11 | end 12 | 13 | describe ".all" do 14 | it "returns an Array of all Currency objects available" do 15 | Moola::Currency.all.should be_a(Array(Moola::Currency)) 16 | end 17 | end 18 | 19 | describe ".find" do 20 | it "returns a Currency based on the key" do 21 | Moola::Currency.find("usd").should be_a(Moola::Currency) 22 | end 23 | 24 | it "ignores key capitalization" do 25 | Moola::Currency.find("USD").should be_a(Moola::Currency) 26 | end 27 | 28 | it "raises an UnknownCurrencyError if a missing key is used" do 29 | expect_raises(Moola::UnknownCurrencyError) do 30 | Moola::Currency.find("bad_key") 31 | end 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /spec/moola/exchange_spec.cr: -------------------------------------------------------------------------------- 1 | require "../../spec_helper" 2 | 3 | describe Moola::Exchange do 4 | 5 | describe "self.add_conversion" do 6 | 7 | it "adds a conversion to the conversions" do 8 | Moola::Exchange.clear_conversions 9 | from = Moola::Currency.find("usd") 10 | to = Moola::Currency.find("cad") 11 | rate = 1.2 12 | Moola::Exchange.add_conversion(from, to, rate) 13 | Moola::Exchange.conversions[from][to].should eq rate 14 | end 15 | 16 | it "adds multiple conversions" do 17 | Moola::Exchange.clear_conversions 18 | from1 = Moola::Currency.find("usd") 19 | to1 = Moola::Currency.find("cad") 20 | rate1 = 1.2 21 | from2 = Moola::Currency.find("eur") 22 | to2 = Moola::Currency.find("gbp") 23 | rate2 = 2.2 24 | Moola::Exchange.add_conversion(from1, to1, rate1) 25 | Moola::Exchange.conversions[from1][to1].should eq rate1 26 | Moola::Exchange.add_conversion(from2, to2, rate2) 27 | Moola::Exchange.conversions[from2][to2].should eq rate2 28 | end 29 | 30 | it "adds additional conversions" do 31 | Moola::Exchange.clear_conversions 32 | from1 = Moola::Currency.find("usd") 33 | to1 = Moola::Currency.find("cad") 34 | rate1 = 1.2 35 | from2 = Moola::Currency.find("usd") 36 | to2 = Moola::Currency.find("gbp") 37 | rate2 = 2.2 38 | Moola::Exchange.add_conversion(from1, to1, rate1) 39 | Moola::Exchange.conversions[from1][to1].should eq rate1 40 | Moola::Exchange.add_conversion(from2, to2, rate2) 41 | Moola::Exchange.conversions[from1][to2].should eq rate2 42 | end 43 | end 44 | 45 | describe ".conversion_exists?" do 46 | 47 | it "returns true if a conversion exists in @@conversions" do 48 | Moola::Exchange.clear_conversions 49 | from = Moola::Currency.find("usd") 50 | to = Moola::Currency.find("cad") 51 | rate = 1.2 52 | Moola::Exchange.add_conversion(from, to, rate) 53 | Moola::Exchange.conversion_exists?(from, to).should eq true 54 | end 55 | 56 | it "returns false if a conversion does not exist in @@conversions" do 57 | Moola::Exchange.clear_conversions 58 | from = Moola::Currency.find("usd") 59 | to = Moola::Currency.find("cad") 60 | Moola::Exchange.conversion_exists?(from, to).should eq false 61 | end 62 | end 63 | 64 | describe ".convert" do 65 | 66 | it "returns a Money object with an amount equal to the converted amount" do 67 | Moola::Exchange.clear_conversions 68 | from = Moola::Currency.find("usd") 69 | to = Moola::Currency.find("cad") 70 | rate = 1.2 71 | Moola::Exchange.add_conversion(from, to, rate) 72 | from_money = Moola::Money.new(1_00, from) 73 | Moola::Exchange.convert(from_money, to).should eq Moola::Money.new(1_20, to) 74 | end 75 | 76 | it "throw an UnavailableConversionError if no conversion is available" do 77 | Moola::Exchange.clear_conversions 78 | from = Moola::Currency.find("usd") 79 | to = Moola::Currency.find("cad") 80 | from_money = Moola::Money.new(1_00, from) 81 | expect_raises(Moola::UnavailableConversionError) do 82 | Moola::Exchange.convert(from_money, to) 83 | end 84 | end 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /spec/moola/money_spec.cr: -------------------------------------------------------------------------------- 1 | require "../../spec_helper" 2 | 3 | describe Moola::Money do 4 | 5 | describe "#initialize" do 6 | it "accepts a currency iso code string" do 7 | money = Moola::Money.new(42_00, "CAD") 8 | money.currency.should eq(Moola::Currency.find("CAD")) 9 | end 10 | end 11 | 12 | describe "#zero?" do 13 | 14 | it "returns true if a Money's amount is 0" do 15 | money = Moola::Money.new(0) 16 | money.zero?.should eq(true) 17 | end 18 | 19 | it "returns false if Money is not 0" do 20 | money = Moola::Money.new(42_00) 21 | money.zero?.should eq(false) 22 | end 23 | end 24 | 25 | describe "#negative?" do 26 | it "returns true if a Money's amount is negative" do 27 | money = Moola::Money.new(-500) 28 | money.negative?.should eq(true) 29 | end 30 | 31 | it "returns true if a Money's amount is not negative" do 32 | money = Moola::Money.new(500) 33 | money.negative?.should eq(false) 34 | end 35 | 36 | it "returns false if a Money's amount is 0" do 37 | money = Moola::Money.new(0) 38 | money.negative?.should eq(false) 39 | end 40 | end 41 | 42 | describe "#to_f" do 43 | it "converst the amount to a Float64" do 44 | money = Moola::Money.new(42_99) 45 | money_f = money.to_f 46 | money_f.should eq(42.99) 47 | money_f.should be_a(Float64) 48 | end 49 | 50 | it "handles trailing 0s correctly" do 51 | money = Moola::Money.new(42_00) 52 | money.to_f.should eq(42.0) 53 | end 54 | end 55 | 56 | describe "#format" do 57 | 58 | it "returns a string representing the money amount" do 59 | money = Moola::Money.new(42_00) 60 | money.format.should eq("$42.00") 61 | end 62 | end 63 | 64 | describe "#convert_to" do 65 | 66 | it "converts as expected" do 67 | Moola::Exchange.clear_conversions 68 | from = Moola::Currency.find("usd") 69 | to = Moola::Currency.find("cad") 70 | rate = 1.2 71 | Moola::Exchange.add_conversion(from, to, rate) 72 | from_money = Moola::Money.new(1_00, from) 73 | from_money.convert_to(to).should eq Moola::Money.new(1_20, to) 74 | end 75 | end 76 | 77 | describe "#cents" do 78 | 79 | it "returns the amount for in cents for a Money" do 80 | money = Moola::Money.new(42_00) 81 | money.cents.should eq(4200) 82 | end 83 | end 84 | 85 | describe "#<" do 86 | it "can sort a list of Moneys" do 87 | [Moola::Money.new(500), Moola::Money.new(200), Moola::Money.new(700)].sort.should eq([Moola::Money.new(200), Moola::Money.new(500), Moola::Money.new(700)]) 88 | end 89 | 90 | it "raises a CompatabilityError when compaired to a Money with different currency" do 91 | small_usd = Moola::Money.new(5, Moola::Currency.find("usd")) 92 | big_cad = Moola::Money.new(6, Moola::Currency.find("cad")) 93 | expect_raises(Moola::CompatabilityError) do 94 | (small_usd < big_cad) 95 | end 96 | end 97 | end 98 | 99 | describe "#==" do 100 | it "returns false when compaired to a non-Money object" do 101 | money = Moola::Money.new(42_00) 102 | (money == "$").should eq false 103 | end 104 | 105 | it "returns true when compaired to any Money.zero with different currency" do 106 | zero_usd = Moola::Money.new(0, Moola::Currency.find("usd")) 107 | zero_cad = Moola::Money.new(0, Moola::Currency.find("cad")) 108 | (zero_usd == zero_cad).should eq true 109 | end 110 | end 111 | 112 | describe "#-" do 113 | 114 | it "returns a Money with the negative amount" do 115 | money = Moola::Money.new(42_00) 116 | neg_money = -money 117 | neg_money.amount.should eq(-4200) 118 | end 119 | end 120 | 121 | describe "#+" do 122 | 123 | it "addes two Moneys together" do 124 | money_sum = Moola::Money.new(5_00) + Moola::Money.new(10_00) 125 | money_sum.amount.should eq(15_00) 126 | end 127 | 128 | it "throws an error when two Moneys of different currency are added together" do 129 | expect_raises(Moola::CompatabilityError) do 130 | money_sum = Moola::Money.new(5_00, "USD") + Moola::Money.new(10_00, "CAD") 131 | end 132 | end 133 | end 134 | 135 | describe "#-" do 136 | 137 | it "subtracts two Moneys" do 138 | money_diff = Moola::Money.new(10_00) - Moola::Money.new(2_00) 139 | money_diff.amount.should eq(8_00) 140 | end 141 | 142 | it "throws an error when two Moneys of different currency are subtracted" do 143 | expect_raises(Moola::CompatabilityError) do 144 | money_sum = Moola::Money.new(10_00, "USD") + Moola::Money.new(2_00, "CAD") 145 | end 146 | end 147 | end 148 | 149 | describe "#*" do 150 | 151 | it "multiplies Money" do 152 | money_prod = Moola::Money.new(10_00) * 3 153 | money_prod.amount.should eq(30_00) 154 | end 155 | 156 | it "multiplies Money by float" do 157 | money_prod = Moola::Money.new(10_00) * 1.25 158 | money_prod.amount.should eq(12_50) 159 | end 160 | end 161 | 162 | describe "#*" do 163 | 164 | it "divides Money by value" do 165 | money_div = Moola::Money.new(10_00) / 2 166 | money_div.amount.should eq(5_00) 167 | end 168 | 169 | it "divides Money by value" do 170 | money_div = Moola::Money.new(10_00) / 3 171 | money_div.amount.should eq(3_33) 172 | end 173 | 174 | it "divides two Moneys" do 175 | money_div = Moola::Money.new(10_00) / Moola::Money.new(5_00) 176 | money_div.should eq(2) 177 | end 178 | end 179 | end 180 | -------------------------------------------------------------------------------- /spec/moola_spec.cr: -------------------------------------------------------------------------------- 1 | require "./spec_helper" 2 | 3 | describe Moola do 4 | describe ".new" do 5 | it "creates a new Molla::Money object" do 6 | money = Moola.new(42_00) 7 | money.should be_a(Moola::Money) 8 | money.amount.should eq(42_00) 9 | end 10 | 11 | it "creates a new Molla::Money object when passed a float" do 12 | money = Moola.new(42.42) 13 | money.should be_a(Moola::Money) 14 | money.amount.should eq(42_42) 15 | end 16 | 17 | it "creates a new Molla::Money object when passed a string of an int" do 18 | money = Moola.new("4200") 19 | money.should be_a(Moola::Money) 20 | money.amount.should eq(42_00) 21 | end 22 | 23 | it "creates a new Molla::Money object when passed a string of a float" do 24 | money = Moola.new("42.42") 25 | money.should be_a(Moola::Money) 26 | money.amount.should eq(42_42) 27 | end 28 | 29 | it "creates a new Moola::Money object with the Money DEFAULT_CURRENCY" do 30 | money = Moola.new(42.00) 31 | money.should be_a(Moola::Money) 32 | money.currency.should eq(Moola::Money::DEFAULT_CURRENCY) 33 | end 34 | 35 | it "creates a new Moola::Money object with a currency iso code string argument" do 36 | money = Moola.new(42.00, "CAD") 37 | money.should be_a(Moola::Money) 38 | money.currency.should eq(Moola::Currency.find("CAD")) 39 | end 40 | end 41 | 42 | describe ".zero" do 43 | 44 | it "creates a new Moola::Money object of $0" do 45 | money = Moola.zero 46 | money.should be_a(Moola::Money) 47 | money.amount.should eq(0) 48 | money.currency.should eq(Moola::Money::DEFAULT_CURRENCY) 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /spec/spec_helper.cr: -------------------------------------------------------------------------------- 1 | require "spec" 2 | require "../src/moola" 3 | -------------------------------------------------------------------------------- /src/moola.cr: -------------------------------------------------------------------------------- 1 | require "./moola/*" 2 | 3 | module Moola 4 | 5 | class InvalidAmount < Exception 6 | end 7 | 8 | class CompatabilityError < Exception 9 | end 10 | 11 | class UnknownCurrencyError < Exception 12 | end 13 | 14 | class UnavailableConversionError < Exception 15 | end 16 | 17 | def self.new(amount, currency_name=Money::DEFAULT_CURRENCY_NAME) 18 | clean_amount = clean_init_amount(amount) 19 | currency = Moola::Currency.find(currency_name) 20 | Money.new(clean_amount, currency) 21 | end 22 | 23 | def self.zero 24 | Money.new(0) 25 | end 26 | 27 | protected def self.clean_init_amount(amount) 28 | case amount 29 | when Int32 30 | amount 31 | when Float64 32 | (amount * 100).to_i32 33 | when String 34 | if amount.to_i? 35 | amount.to_i32 36 | elsif amount.to_f? 37 | self.clean_init_amount(amount.to_f64) 38 | else 39 | raise InvalidAmount.new("String doesn't contain valid amount") 40 | end 41 | else 42 | raise InvalidAmount.new 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /src/moola/currency.cr: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | module Moola 4 | class Currency 5 | 6 | CURRENCY_DATA_PATH = File.expand_path("../../../data/currencies", __FILE__) 7 | 8 | @@loaded_currencies = {} of String => Moola::Currency 9 | 10 | getter key 11 | 12 | JSON.mapping( 13 | iso_code: String, 14 | name: String, 15 | symbol: String, 16 | subunit: String, 17 | subunit_to_unit: Int32, 18 | symbol_first: Bool, 19 | decimal_mark: String, 20 | thousands_separator: String, 21 | smallest_denomination: Int32 22 | ) 23 | 24 | def self.find(key : String) : Moola::Currency 25 | clean_key = key.downcase 26 | self.loaded_currencies.fetch(clean_key) do |missed_key| 27 | raise UnknownCurrencyError.new("Can't find currency: #{missed_key}") 28 | end 29 | end 30 | 31 | def self.loaded_currencies 32 | return @@loaded_currencies unless @@loaded_currencies.empty? 33 | self.load_currencies 34 | @@loaded_currencies 35 | end 36 | 37 | def self.all 38 | self.loaded_currencies.values 39 | end 40 | 41 | def self.load_currencies 42 | Dir.glob("#{CURRENCY_DATA_PATH}/*.json") do |file_path| 43 | begin 44 | currency_json = File.read(file_path) 45 | currency = Moola::Currency.from_json(currency_json) 46 | @@loaded_currencies[currency.iso_code.downcase] = currency 47 | rescue ex 48 | # do nothing here to allow us to move on to the next currency file 49 | end 50 | end 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /src/moola/exchange.cr: -------------------------------------------------------------------------------- 1 | module Moola 2 | class Exchange 3 | @@conversions = {} of Moola::Currency => Hash(Moola::Currency, Float64) 4 | 5 | def self.conversions 6 | @@conversions 7 | end 8 | 9 | def self.clear_conversions 10 | @@conversions = {} of Moola::Currency => Hash(Moola::Currency, Float64) 11 | end 12 | 13 | def self.add_conversion(from : Moola::Currency, to : Moola::Currency, conversion_rate : Float64) 14 | from_hash = @@conversions[from]? || {} of Moola::Currency => Float64 15 | from_hash[to] = conversion_rate 16 | @@conversions[from] = from_hash 17 | end 18 | 19 | def self.conversion_exists?(from : Moola::Currency, to : Moola::Currency) 20 | @@conversions.keys.includes?(from) && @@conversions[from].keys.includes?(to) 21 | end 22 | 23 | def self.convert(money : Moola::Money, currency : Moola::Currency) 24 | if self.conversion_exists?(money.currency, currency) 25 | rate = @@conversions[money.currency][currency] 26 | converted_amount = (money.amount * rate).to_i32 27 | Money.new(converted_amount, currency) 28 | else 29 | raise UnavailableConversionError.new("No conversion available for #{money.currency.iso_code} -> #{currency.iso_code}") 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /src/moola/money.cr: -------------------------------------------------------------------------------- 1 | module Moola 2 | class Money 3 | include Comparable(Moola::Money) 4 | 5 | DEFAULT_CURRENCY_NAME = "USD" 6 | DEFAULT_CURRENCY = Moola::Currency.find(DEFAULT_CURRENCY_NAME) 7 | 8 | getter amount, currency 9 | 10 | def initialize(@amount : Int32, @currency : Moola::Currency = DEFAULT_CURRENCY) 11 | end 12 | 13 | def initialize(@amount : Int32, currency_name : String) 14 | @currency = Moola::Currency.find(currency_name) 15 | end 16 | 17 | def format 18 | currency_symbol = currency.symbol 19 | decimal_mark = currency.decimal_mark 20 | subunit_shift = Math.log(currency.subunit_to_unit, 10).to_i 21 | amount_str = amount.to_s 22 | unit_str = amount_str[0, amount_str.size - subunit_shift] 23 | subunit_str = amount_str[amount_str.size - subunit_shift, amount_str.size] 24 | formatted_value = "#{unit_str}#{decimal_mark}#{subunit_str}" 25 | if currency.symbol_first 26 | currency_symbol + formatted_value 27 | else 28 | formatted_value + currency_symbol 29 | end 30 | end 31 | 32 | def convert_to(new_currency : Moola::Currency) 33 | Moola::Exchange.convert(self, new_currency) 34 | end 35 | 36 | def zero? 37 | amount == 0 38 | end 39 | 40 | def negative? 41 | amount < 0 42 | end 43 | 44 | def abs 45 | Money.new(amount.abs, currency) 46 | end 47 | 48 | def cents 49 | amount 50 | end 51 | 52 | def to_s 53 | self.format 54 | end 55 | 56 | def to_f64 57 | amount / currency.subunit_to_unit.to_f64 58 | end 59 | 60 | def to_f32 61 | self.to_f64.to_f32 62 | end 63 | 64 | def to_f 65 | self.to_f64 66 | end 67 | 68 | def - 69 | Money.new(amount * -1, currency) 70 | end 71 | 72 | def <=>(other : Moola::Money) 73 | return 0 if zero? && other.zero? 74 | if currency == other.currency 75 | return 0 if amount == other.amount 76 | return -1 if amount < other.amount 77 | return 1 78 | else 79 | raise CompatabilityError.new 80 | end 81 | end 82 | 83 | def +(other) 84 | if other.is_a?(Money) 85 | if currency == other.currency 86 | new_amount = amount + other.amount 87 | Money.new(new_amount, currency) 88 | else 89 | raise CompatabilityError.new("Money must have the same currency in order to be added") 90 | end 91 | else 92 | raise CompatabilityError.new("Money must be added to Money") 93 | end 94 | end 95 | 96 | def -(other) 97 | if other.is_a?(Money) 98 | if currency == other.currency 99 | new_amount = amount - other.amount 100 | Money.new(new_amount, currency) 101 | else 102 | raise CompatabilityError.new("Money must have the same currency in order to be subtracted") 103 | end 104 | else 105 | raise CompatabilityError.new("Money must be subtracted from Money") 106 | end 107 | end 108 | 109 | def *(value) 110 | if value.is_a?(Number) 111 | new_amount = (amount * value).to_i32 112 | Money.new(new_amount, currency) 113 | else 114 | raise CompatabilityError.new("Money can only be multiplied by a number") 115 | end 116 | end 117 | 118 | def /(value) 119 | if value.is_a?(Number) 120 | new_amount = Moola.clean_init_amount(amount / value) 121 | Money.new(new_amount, currency) 122 | elsif value.is_a?(Moola::Money) 123 | amount.to_f64 / value.amount.to_f64 124 | else 125 | raise CompatabilityError.new("Money can only be divided by a number or other Money") 126 | end 127 | end 128 | end 129 | end 130 | --------------------------------------------------------------------------------