1 package SL::Helper::ISO4217;
7 use Exporter qw(import);
8 our @EXPORT_OK = qw(map_currency_name_to_code);
10 use List::Util qw(first);
12 my @currency_name_to_code_mappings = (
13 [ 'AED', qr{^(?:UAE Dirham|AED)$}i ],
14 [ 'AFN', qr{^(?:Afghani|AFN)$}i ],
15 [ 'ALL', qr{^(?:Lek|ALL)$}i ],
16 [ 'AMD', qr{^(?:Armenian Dram|AMD)$}i ],
17 [ 'ANG', qr{^(?:Netherlands Antillean Guilder|ANG)$}i ],
18 [ 'AOA', qr{^(?:Kwanza|AOA)$}i ],
19 [ 'ARS', qr{^(?:Argentine Peso|ARS)$}i ],
20 [ 'AUD', qr{^(?:Australian Dollar|AUD)$}i ],
21 [ 'AWG', qr{^(?:Aruban Florin|AWG)$}i ],
22 [ 'AZN', qr{^(?:Azerbaijan Manat|AZN)$}i ],
23 [ 'BAM', qr{^(?:Convertible Mark|BAM)$}i ],
24 [ 'BBD', qr{^(?:Barbados Dollar|BBD)$}i ],
25 [ 'BDT', qr{^(?:Taka|BDT)$}i ],
26 [ 'BGN', qr{^(?:Bulgarian Lev|BGN)$}i ],
27 [ 'BHD', qr{^(?:Bahraini Dinar|BHD)$}i ],
28 [ 'BIF', qr{^(?:Burundi Franc|BIF)$}i ],
29 [ 'BMD', qr{^(?:Bermudian Dollar|BMD)$}i ],
30 [ 'BND', qr{^(?:Brunei Dollar|BND)$}i ],
31 [ 'BOB', qr{^(?:Boliviano|BOB)$}i ],
32 [ 'BOV', qr{^(?:US Dollar|BOV)$}i ],
33 [ 'BRL', qr{^(?:Brazilian Real|BRL)$}i ],
34 [ 'BSD', qr{^(?:Bahamian Dollar|BSD)$}i ],
35 [ 'BTN', qr{^(?:Ngultrum|BTN)$}i ],
36 [ 'BWP', qr{^(?:Pula|BWP)$}i ],
37 [ 'BYN', qr{^(?:Belarusian Ruble|BYN)$}i ],
38 [ 'BZD', qr{^(?:Belize Dollar|BZD)$}i ],
39 [ 'CAD', qr{^(?:Canadian Dollar|CAD)$}i ],
40 [ 'CDF', qr{^(?:Congolese Franc|CDF)$}i ],
41 [ 'CHE', qr{^(?:Syrian Pound|CHE)$}i ],
42 [ 'CHF', qr{^(?:Swiss Franc|CHF)$}i ],
43 [ 'CHW', qr{^(?:Syrian Pound|CHW)$}i ],
44 [ 'CLF', qr{^(?:Yuan Renminbi|CLF)$}i ],
45 [ 'CLP', qr{^(?:Chilean Peso|CLP)$}i ],
46 [ 'CNY', qr{^(?:Yuan Renminbi|CNY)$}i ],
47 [ 'COP', qr{^(?:Colombian Peso|COP)$}i ],
48 [ 'COU', qr{^(?:Comorian Franc |COU)$}i ],
49 [ 'CRC', qr{^(?:Costa Rican Colon|CRC)$}i ],
50 [ 'CUC', qr{^(?:Peso Convertible|CUC)$}i ],
51 [ 'CUP', qr{^(?:Cuban Peso|CUP)$}i ],
52 [ 'CVE', qr{^(?:Cabo Verde Escudo|CVE)$}i ],
53 [ 'CZK', qr{^(?:Czech Koruna|CZK)$}i ],
54 [ 'DJF', qr{^(?:Djibouti Franc|DJF)$}i ],
55 [ 'DKK', qr{^(?:Danish Krone|DKK)$}i ],
56 [ 'DOP', qr{^(?:Dominican Peso|DOP)$}i ],
57 [ 'DZD', qr{^(?:Algerian Dinar|DZD)$}i ],
58 [ 'EGP', qr{^(?:Egyptian Pound|EGP)$}i ],
59 [ 'ERN', qr{^(?:Nakfa|ERN)$}i ],
60 [ 'ETB', qr{^(?:Ethiopian Birr|ETB)$}i ],
61 [ 'EUR', qr{^(?:Euro|EUR|€)$}i ],
62 [ 'FJD', qr{^(?:Fiji Dollar|FJD)$}i ],
63 [ 'FKP', qr{^(?:Falkland Islands Pound|FKP)$}i ],
64 [ 'GBP', qr{^(?:Pound Sterling|GBP)$}i ],
65 [ 'GEL', qr{^(?:Lari|GEL)$}i ],
66 [ 'GHS', qr{^(?:Ghana Cedi|GHS)$}i ],
67 [ 'GIP', qr{^(?:Gibraltar Pound|GIP)$}i ],
68 [ 'GMD', qr{^(?:Dalasi|GMD)$}i ],
69 [ 'GNF', qr{^(?:Guinean Franc|GNF)$}i ],
70 [ 'GTQ', qr{^(?:Quetzal|GTQ)$}i ],
71 [ 'GYD', qr{^(?:Guyana Dollar|GYD)$}i ],
72 [ 'HKD', qr{^(?:Hong Kong Dollar|HKD)$}i ],
73 [ 'HNL', qr{^(?:Lempira|HNL)$}i ],
74 [ 'HRK', qr{^(?:Kuna|HRK)$}i ],
75 [ 'HTG', qr{^(?:Gourde|HTG)$}i ],
76 [ 'HUF', qr{^(?:Forint|HUF)$}i ],
77 [ 'IDR', qr{^(?:Rupiah|IDR)$}i ],
78 [ 'ILS', qr{^(?:New Israeli Sheqel|ILS)$}i ],
79 [ 'INR', qr{^(?:Indian Rupee|INR)$}i ],
80 [ 'IQD', qr{^(?:Iraqi Dinar|IQD)$}i ],
81 [ 'IRR', qr{^(?:Iranian Rial|IRR)$}i ],
82 [ 'ISK', qr{^(?:Iceland Krona|ISK)$}i ],
83 [ 'JMD', qr{^(?:Jamaican Dollar|JMD)$}i ],
84 [ 'JOD', qr{^(?:Jordanian Dinar|JOD)$}i ],
85 [ 'JPY', qr{^(?:Yen|JPY|¥)$}i ],
86 [ 'KES', qr{^(?:Kenyan Shilling|KES)$}i ],
87 [ 'KGS', qr{^(?:Som|KGS)$}i ],
88 [ 'KHR', qr{^(?:Riel|KHR)$}i ],
89 [ 'KMF', qr{^(?:Comorian Franc |KMF)$}i ],
90 [ 'KPW', qr{^(?:North Korean Won|KPW)$}i ],
91 [ 'KRW', qr{^(?:Won|KRW)$}i ],
92 [ 'KWD', qr{^(?:Kuwaiti Dinar|KWD)$}i ],
93 [ 'KYD', qr{^(?:Cayman Islands Dollar|KYD)$}i ],
94 [ 'KZT', qr{^(?:Tenge|KZT)$}i ],
95 [ 'LAK', qr{^(?:Lao Kip|LAK)$}i ],
96 [ 'LBP', qr{^(?:Lebanese Pound|LBP)$}i ],
97 [ 'LKR', qr{^(?:Sri Lanka Rupee|LKR)$}i ],
98 [ 'LRD', qr{^(?:Liberian Dollar|LRD)$}i ],
99 [ 'LSL', qr{^(?:Loti|LSL)$}i ],
100 [ 'LYD', qr{^(?:Libyan Dinar|LYD)$}i ],
101 [ 'MAD', qr{^(?:Moroccan Dirham|MAD)$}i ],
102 [ 'MDL', qr{^(?:Moldovan Leu|MDL)$}i ],
103 [ 'MGA', qr{^(?:Malagasy Ariary|MGA)$}i ],
104 [ 'MKD', qr{^(?:Denar|MKD)$}i ],
105 [ 'MMK', qr{^(?:Kyat|MMK)$}i ],
106 [ 'MNT', qr{^(?:Tugrik|MNT)$}i ],
107 [ 'MOP', qr{^(?:Pataca|MOP)$}i ],
108 [ 'MRU', qr{^(?:Ouguiya|MRU)$}i ],
109 [ 'MUR', qr{^(?:Mauritius Rupee|MUR)$}i ],
110 [ 'MVR', qr{^(?:Rufiyaa|MVR)$}i ],
111 [ 'MWK', qr{^(?:Malawi Kwacha|MWK)$}i ],
112 [ 'MXN', qr{^(?:Mexican Peso|MXN)$}i ],
113 [ 'MXV', qr{^(?:US Dollar|MXV)$}i ],
114 [ 'MYR', qr{^(?:Malaysian Ringgit|MYR)$}i ],
115 [ 'MZN', qr{^(?:Mozambique Metical|MZN)$}i ],
116 [ 'NAD', qr{^(?:Namibia Dollar|NAD)$}i ],
117 [ 'NGN', qr{^(?:Naira|NGN)$}i ],
118 [ 'NIO', qr{^(?:Cordoba Oro|NIO)$}i ],
119 [ 'NOK', qr{^(?:Norwegian Krone|NOK)$}i ],
120 [ 'NPR', qr{^(?:Nepalese Rupee|NPR)$}i ],
121 [ 'NZD', qr{^(?:New Zealand Dollar|NZD)$}i ],
122 [ 'OMR', qr{^(?:Rial Omani|OMR)$}i ],
123 [ 'PAB', qr{^(?:Balboa|PAB)$}i ],
124 [ 'PAB', qr{^(?:No universal currency|PAB)$}i ],
125 [ 'PEN', qr{^(?:Sol|PEN)$}i ],
126 [ 'PGK', qr{^(?:Kina|PGK)$}i ],
127 [ 'PHP', qr{^(?:Philippine Peso|PHP)$}i ],
128 [ 'PKR', qr{^(?:Pakistan Rupee|PKR)$}i ],
129 [ 'PLN', qr{^(?:Zloty|PLN)$}i ],
130 [ 'PYG', qr{^(?:Guarani|PYG)$}i ],
131 [ 'QAR', qr{^(?:Qatari Rial|QAR)$}i ],
132 [ 'RON', qr{^(?:Romanian Leu|RON)$}i ],
133 [ 'RSD', qr{^(?:Serbian Dinar|RSD)$}i ],
134 [ 'RUB', qr{^(?:Russian Ruble|RUB)$}i ],
135 [ 'RWF', qr{^(?:Rwanda Franc|RWF)$}i ],
136 [ 'SAR', qr{^(?:Saudi Riyal|SAR)$}i ],
137 [ 'SBD', qr{^(?:Solomon Islands Dollar|SBD)$}i ],
138 [ 'SCR', qr{^(?:Seychelles Rupee|SCR)$}i ],
139 [ 'SDG', qr{^(?:Sudanese Pound|SDG)$}i ],
140 [ 'SEK', qr{^(?:Swedish Krona|SEK)$}i ],
141 [ 'SGD', qr{^(?:Singapore Dollar|SGD)$}i ],
142 [ 'SHP', qr{^(?:Saint Helena Pound|SHP)$}i ],
143 [ 'SLL', qr{^(?:Leone|SLL)$}i ],
144 [ 'SOS', qr{^(?:Somali Shilling|SOS)$}i ],
145 [ 'SRD', qr{^(?:Surinam Dollar|SRD)$}i ],
146 [ 'SSP', qr{^(?:No universal currency|SSP)$}i ],
147 [ 'SSP', qr{^(?:South Sudanese Pound|SSP)$}i ],
148 [ 'STN', qr{^(?:Dobra|STN)$}i ],
149 [ 'SVC', qr{^(?:El Salvador Colon|SVC)$}i ],
150 [ 'SYP', qr{^(?:Syrian Pound|SYP)$}i ],
151 [ 'SZL', qr{^(?:Lilangeni|SZL)$}i ],
152 [ 'THB', qr{^(?:Baht|THB)$}i ],
153 [ 'TJS', qr{^(?:Somoni|TJS)$}i ],
154 [ 'TMT', qr{^(?:Turkmenistan New Manat|TMT)$}i ],
155 [ 'TND', qr{^(?:Tunisian Dinar|TND)$}i ],
156 [ 'TOP', qr{^(?:Pa’anga|TOP)$}i ],
157 [ 'TRY', qr{^(?:Turkish Lira|TRY)$}i ],
158 [ 'TTD', qr{^(?:Trinidad and Tobago Dollar|TTD)$}i ],
159 [ 'TWD', qr{^(?:New Taiwan Dollar|TWD)$}i ],
160 [ 'TZS', qr{^(?:Tanzanian Shilling|TZS)$}i ],
161 [ 'UAH', qr{^(?:Hryvnia|UAH)$}i ],
162 [ 'UGX', qr{^(?:Uganda Shilling|UGX)$}i ],
163 [ 'USD', qr{^(?:US Dollar|USD|\$)$}i ],
164 [ 'USN', qr{^(?:Peso Uruguayo|USN)$}i ],
165 [ 'UYI', qr{^(?:Unidad Previsional|UYI)$}i ],
166 [ 'UYU', qr{^(?:Peso Uruguayo|UYU)$}i ],
167 [ 'UYW', qr{^(?:Unidad Previsional|UYW)$}i ],
168 [ 'UZS', qr{^(?:Uzbekistan Sum|UZS)$}i ],
169 [ 'VES', qr{^(?:Bolívar Soberano|VES)$}i ],
170 [ 'VND', qr{^(?:Dong|VND)$}i ],
171 [ 'VUV', qr{^(?:Vatu|VUV)$}i ],
172 [ 'WST', qr{^(?:Tala|WST)$}i ],
173 [ 'XAF', qr{^(?:CFA Franc BEAC|XAF)$}i ],
174 [ 'XAG', qr{^(?:Silver|XAG)$}i ],
175 [ 'XAU', qr{^(?:Gold|XAU)$}i ],
176 [ 'XBA', qr{^(?:Bond Markets Unit European Composite Unit \(EURCO\)|XBA)$}i ],
177 [ 'XBB', qr{^(?:Bond Markets Unit European Monetary Unit \(E\.?M\.?U\.?-6\)|XBB)$}i ],
178 [ 'XBC', qr{^(?:Bond Markets Unit European Unit of Account 9 \(E\.?U\.?A\.?-9\)|XBC)$}i ],
179 [ 'XBD', qr{^(?:Bond Markets Unit European Unit of Account 17 \(E\.?U\.?A\.?-17\)|XBD)$}i ],
180 [ 'XCD', qr{^(?:East Caribbean Dollar|XCD)$}i ],
181 [ 'XCD', qr{^(?:No universal currency|XCD)$}i ],
182 [ 'XDR', qr{^(?:SDR \(Special Drawing Right\)|SDR|XDR)$}i ],
183 [ 'XOF', qr{^(?:CFA Franc BCEAO|XOF)$}i ],
184 [ 'XPD', qr{^(?:Palladium|XPD)$}i ],
185 [ 'XPF', qr{^(?:CFP Franc|XPF)$}i ],
186 [ 'XPT', qr{^(?:Platinum|XPT)$}i ],
187 [ 'XSU', qr{^(?:Sucre|XSU)$}i ],
188 [ 'XTS', qr{^(?:Codes specifically reserved for testing purposes|XTS)$}i ],
189 [ 'XUA', qr{^(?:ADB Unit of Account|XUA)$}i ],
190 [ 'XXX', qr{^(?:The codes assigned for transactions where no currency is involved|XXX)$}i ],
191 [ 'YER', qr{^(?:Yemeni Rial|YER)$}i ],
192 [ 'ZAR', qr{^(?:Rand|ZAR)$}i ],
193 [ 'ZMW', qr{^(?:Zambian Kwacha|ZMW)$}i ],
194 [ 'ZWL', qr{^(?:Zimbabwe Dollar|ZWL)$}i ],
197 sub map_currency_name_to_code {
200 return undef if ($currency // '') eq '';
202 my $code = first { $currency =~ $_->[1] } @currency_name_to_code_mappings;
203 return $code->[0] if $code;
206 $::lxdebug->message(LXDebug::WARN(), "ISO4217::map_currency_name_to_code: no mapping found for '$currency'");