From 0eea3fe918c05bdd1bed1f28beefdddcd11ba7cb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 28 Feb 2020 11:59:47 +0100 Subject: [PATCH] =?utf8?q?ISO=204217:=20Mapping=20von=20W=C3=A4hrungsnamen?= =?utf8?q?=20auf=20Codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Helper/ISO4217.pm | 211 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 SL/Helper/ISO4217.pm diff --git a/SL/Helper/ISO4217.pm b/SL/Helper/ISO4217.pm new file mode 100644 index 000000000..89d996b06 --- /dev/null +++ b/SL/Helper/ISO4217.pm @@ -0,0 +1,211 @@ +package SL::Helper::ISO4217; + +use strict; +use warnings; +use utf8; + +use Exporter qw(import); +our @EXPORT_OK = qw(map_currency_name_to_code); + +use List::Util qw(first); + +my @currency_name_to_code_mappings = ( + [ 'AED', qr{^(?:UAE Dirham|AED)$}i ], + [ 'AFN', qr{^(?:Afghani|AFN)$}i ], + [ 'ALL', qr{^(?:Lek|ALL)$}i ], + [ 'AMD', qr{^(?:Armenian Dram|AMD)$}i ], + [ 'ANG', qr{^(?:Netherlands Antillean Guilder|ANG)$}i ], + [ 'AOA', qr{^(?:Kwanza|AOA)$}i ], + [ 'ARS', qr{^(?:Argentine Peso|ARS)$}i ], + [ 'AUD', qr{^(?:Australian Dollar|AUD)$}i ], + [ 'AWG', qr{^(?:Aruban Florin|AWG)$}i ], + [ 'AZN', qr{^(?:Azerbaijan Manat|AZN)$}i ], + [ 'BAM', qr{^(?:Convertible Mark|BAM)$}i ], + [ 'BBD', qr{^(?:Barbados Dollar|BBD)$}i ], + [ 'BDT', qr{^(?:Taka|BDT)$}i ], + [ 'BGN', qr{^(?:Bulgarian Lev|BGN)$}i ], + [ 'BHD', qr{^(?:Bahraini Dinar|BHD)$}i ], + [ 'BIF', qr{^(?:Burundi Franc|BIF)$}i ], + [ 'BMD', qr{^(?:Bermudian Dollar|BMD)$}i ], + [ 'BND', qr{^(?:Brunei Dollar|BND)$}i ], + [ 'BOB', qr{^(?:Boliviano|BOB)$}i ], + [ 'BOV', qr{^(?:US Dollar|BOV)$}i ], + [ 'BRL', qr{^(?:Brazilian Real|BRL)$}i ], + [ 'BSD', qr{^(?:Bahamian Dollar|BSD)$}i ], + [ 'BTN', qr{^(?:Ngultrum|BTN)$}i ], + [ 'BWP', qr{^(?:Pula|BWP)$}i ], + [ 'BYN', qr{^(?:Belarusian Ruble|BYN)$}i ], + [ 'BZD', qr{^(?:Belize Dollar|BZD)$}i ], + [ 'CAD', qr{^(?:Canadian Dollar|CAD)$}i ], + [ 'CDF', qr{^(?:Congolese Franc|CDF)$}i ], + [ 'CHE', qr{^(?:Syrian Pound|CHE)$}i ], + [ 'CHF', qr{^(?:Swiss Franc|CHF)$}i ], + [ 'CHW', qr{^(?:Syrian Pound|CHW)$}i ], + [ 'CLF', qr{^(?:Yuan Renminbi|CLF)$}i ], + [ 'CLP', qr{^(?:Chilean Peso|CLP)$}i ], + [ 'CNY', qr{^(?:Yuan Renminbi|CNY)$}i ], + [ 'COP', qr{^(?:Colombian Peso|COP)$}i ], + [ 'COU', qr{^(?:Comorian Franc |COU)$}i ], + [ 'CRC', qr{^(?:Costa Rican Colon|CRC)$}i ], + [ 'CUC', qr{^(?:Peso Convertible|CUC)$}i ], + [ 'CUP', qr{^(?:Cuban Peso|CUP)$}i ], + [ 'CVE', qr{^(?:Cabo Verde Escudo|CVE)$}i ], + [ 'CZK', qr{^(?:Czech Koruna|CZK)$}i ], + [ 'DJF', qr{^(?:Djibouti Franc|DJF)$}i ], + [ 'DKK', qr{^(?:Danish Krone|DKK)$}i ], + [ 'DOP', qr{^(?:Dominican Peso|DOP)$}i ], + [ 'DZD', qr{^(?:Algerian Dinar|DZD)$}i ], + [ 'EGP', qr{^(?:Egyptian Pound|EGP)$}i ], + [ 'ERN', qr{^(?:Nakfa|ERN)$}i ], + [ 'ETB', qr{^(?:Ethiopian Birr|ETB)$}i ], + [ 'EUR', qr{^(?:Euro|EUR|€)$}i ], + [ 'FJD', qr{^(?:Fiji Dollar|FJD)$}i ], + [ 'FKP', qr{^(?:Falkland Islands Pound|FKP)$}i ], + [ 'GBP', qr{^(?:Pound Sterling|GBP)$}i ], + [ 'GEL', qr{^(?:Lari|GEL)$}i ], + [ 'GHS', qr{^(?:Ghana Cedi|GHS)$}i ], + [ 'GIP', qr{^(?:Gibraltar Pound|GIP)$}i ], + [ 'GMD', qr{^(?:Dalasi|GMD)$}i ], + [ 'GNF', qr{^(?:Guinean Franc|GNF)$}i ], + [ 'GTQ', qr{^(?:Quetzal|GTQ)$}i ], + [ 'GYD', qr{^(?:Guyana Dollar|GYD)$}i ], + [ 'HKD', qr{^(?:Hong Kong Dollar|HKD)$}i ], + [ 'HNL', qr{^(?:Lempira|HNL)$}i ], + [ 'HRK', qr{^(?:Kuna|HRK)$}i ], + [ 'HTG', qr{^(?:Gourde|HTG)$}i ], + [ 'HUF', qr{^(?:Forint|HUF)$}i ], + [ 'IDR', qr{^(?:Rupiah|IDR)$}i ], + [ 'ILS', qr{^(?:New Israeli Sheqel|ILS)$}i ], + [ 'INR', qr{^(?:Indian Rupee|INR)$}i ], + [ 'IQD', qr{^(?:Iraqi Dinar|IQD)$}i ], + [ 'IRR', qr{^(?:Iranian Rial|IRR)$}i ], + [ 'ISK', qr{^(?:Iceland Krona|ISK)$}i ], + [ 'JMD', qr{^(?:Jamaican Dollar|JMD)$}i ], + [ 'JOD', qr{^(?:Jordanian Dinar|JOD)$}i ], + [ 'JPY', qr{^(?:Yen|JPY|¥)$}i ], + [ 'KES', qr{^(?:Kenyan Shilling|KES)$}i ], + [ 'KGS', qr{^(?:Som|KGS)$}i ], + [ 'KHR', qr{^(?:Riel|KHR)$}i ], + [ 'KMF', qr{^(?:Comorian Franc |KMF)$}i ], + [ 'KPW', qr{^(?:North Korean Won|KPW)$}i ], + [ 'KRW', qr{^(?:Won|KRW)$}i ], + [ 'KWD', qr{^(?:Kuwaiti Dinar|KWD)$}i ], + [ 'KYD', qr{^(?:Cayman Islands Dollar|KYD)$}i ], + [ 'KZT', qr{^(?:Tenge|KZT)$}i ], + [ 'LAK', qr{^(?:Lao Kip|LAK)$}i ], + [ 'LBP', qr{^(?:Lebanese Pound|LBP)$}i ], + [ 'LKR', qr{^(?:Sri Lanka Rupee|LKR)$}i ], + [ 'LRD', qr{^(?:Liberian Dollar|LRD)$}i ], + [ 'LSL', qr{^(?:Loti|LSL)$}i ], + [ 'LYD', qr{^(?:Libyan Dinar|LYD)$}i ], + [ 'MAD', qr{^(?:Moroccan Dirham|MAD)$}i ], + [ 'MDL', qr{^(?:Moldovan Leu|MDL)$}i ], + [ 'MGA', qr{^(?:Malagasy Ariary|MGA)$}i ], + [ 'MKD', qr{^(?:Denar|MKD)$}i ], + [ 'MMK', qr{^(?:Kyat|MMK)$}i ], + [ 'MNT', qr{^(?:Tugrik|MNT)$}i ], + [ 'MOP', qr{^(?:Pataca|MOP)$}i ], + [ 'MRU', qr{^(?:Ouguiya|MRU)$}i ], + [ 'MUR', qr{^(?:Mauritius Rupee|MUR)$}i ], + [ 'MVR', qr{^(?:Rufiyaa|MVR)$}i ], + [ 'MWK', qr{^(?:Malawi Kwacha|MWK)$}i ], + [ 'MXN', qr{^(?:Mexican Peso|MXN)$}i ], + [ 'MXV', qr{^(?:US Dollar|MXV)$}i ], + [ 'MYR', qr{^(?:Malaysian Ringgit|MYR)$}i ], + [ 'MZN', qr{^(?:Mozambique Metical|MZN)$}i ], + [ 'NAD', qr{^(?:Namibia Dollar|NAD)$}i ], + [ 'NGN', qr{^(?:Naira|NGN)$}i ], + [ 'NIO', qr{^(?:Cordoba Oro|NIO)$}i ], + [ 'NOK', qr{^(?:Norwegian Krone|NOK)$}i ], + [ 'NPR', qr{^(?:Nepalese Rupee|NPR)$}i ], + [ 'NZD', qr{^(?:New Zealand Dollar|NZD)$}i ], + [ 'OMR', qr{^(?:Rial Omani|OMR)$}i ], + [ 'PAB', qr{^(?:Balboa|PAB)$}i ], + [ 'PAB', qr{^(?:No universal currency|PAB)$}i ], + [ 'PEN', qr{^(?:Sol|PEN)$}i ], + [ 'PGK', qr{^(?:Kina|PGK)$}i ], + [ 'PHP', qr{^(?:Philippine Peso|PHP)$}i ], + [ 'PKR', qr{^(?:Pakistan Rupee|PKR)$}i ], + [ 'PLN', qr{^(?:Zloty|PLN)$}i ], + [ 'PYG', qr{^(?:Guarani|PYG)$}i ], + [ 'QAR', qr{^(?:Qatari Rial|QAR)$}i ], + [ 'RON', qr{^(?:Romanian Leu|RON)$}i ], + [ 'RSD', qr{^(?:Serbian Dinar|RSD)$}i ], + [ 'RUB', qr{^(?:Russian Ruble|RUB)$}i ], + [ 'RWF', qr{^(?:Rwanda Franc|RWF)$}i ], + [ 'SAR', qr{^(?:Saudi Riyal|SAR)$}i ], + [ 'SBD', qr{^(?:Solomon Islands Dollar|SBD)$}i ], + [ 'SCR', qr{^(?:Seychelles Rupee|SCR)$}i ], + [ 'SDG', qr{^(?:Sudanese Pound|SDG)$}i ], + [ 'SEK', qr{^(?:Swedish Krona|SEK)$}i ], + [ 'SGD', qr{^(?:Singapore Dollar|SGD)$}i ], + [ 'SHP', qr{^(?:Saint Helena Pound|SHP)$}i ], + [ 'SLL', qr{^(?:Leone|SLL)$}i ], + [ 'SOS', qr{^(?:Somali Shilling|SOS)$}i ], + [ 'SRD', qr{^(?:Surinam Dollar|SRD)$}i ], + [ 'SSP', qr{^(?:No universal currency|SSP)$}i ], + [ 'SSP', qr{^(?:South Sudanese Pound|SSP)$}i ], + [ 'STN', qr{^(?:Dobra|STN)$}i ], + [ 'SVC', qr{^(?:El Salvador Colon|SVC)$}i ], + [ 'SYP', qr{^(?:Syrian Pound|SYP)$}i ], + [ 'SZL', qr{^(?:Lilangeni|SZL)$}i ], + [ 'THB', qr{^(?:Baht|THB)$}i ], + [ 'TJS', qr{^(?:Somoni|TJS)$}i ], + [ 'TMT', qr{^(?:Turkmenistan New Manat|TMT)$}i ], + [ 'TND', qr{^(?:Tunisian Dinar|TND)$}i ], + [ 'TOP', qr{^(?:Pa’anga|TOP)$}i ], + [ 'TRY', qr{^(?:Turkish Lira|TRY)$}i ], + [ 'TTD', qr{^(?:Trinidad and Tobago Dollar|TTD)$}i ], + [ 'TWD', qr{^(?:New Taiwan Dollar|TWD)$}i ], + [ 'TZS', qr{^(?:Tanzanian Shilling|TZS)$}i ], + [ 'UAH', qr{^(?:Hryvnia|UAH)$}i ], + [ 'UGX', qr{^(?:Uganda Shilling|UGX)$}i ], + [ 'USD', qr{^(?:US Dollar|USD|\$)$}i ], + [ 'USN', qr{^(?:Peso Uruguayo|USN)$}i ], + [ 'UYI', qr{^(?:Unidad Previsional|UYI)$}i ], + [ 'UYU', qr{^(?:Peso Uruguayo|UYU)$}i ], + [ 'UYW', qr{^(?:Unidad Previsional|UYW)$}i ], + [ 'UZS', qr{^(?:Uzbekistan Sum|UZS)$}i ], + [ 'VES', qr{^(?:Bolívar Soberano|VES)$}i ], + [ 'VND', qr{^(?:Dong|VND)$}i ], + [ 'VUV', qr{^(?:Vatu|VUV)$}i ], + [ 'WST', qr{^(?:Tala|WST)$}i ], + [ 'XAF', qr{^(?:CFA Franc BEAC|XAF)$}i ], + [ 'XAG', qr{^(?:Silver|XAG)$}i ], + [ 'XAU', qr{^(?:Gold|XAU)$}i ], + [ 'XBA', qr{^(?:Bond Markets Unit European Composite Unit \(EURCO\)|XBA)$}i ], + [ 'XBB', qr{^(?:Bond Markets Unit European Monetary Unit \(E\.?M\.?U\.?-6\)|XBB)$}i ], + [ 'XBC', qr{^(?:Bond Markets Unit European Unit of Account 9 \(E\.?U\.?A\.?-9\)|XBC)$}i ], + [ 'XBD', qr{^(?:Bond Markets Unit European Unit of Account 17 \(E\.?U\.?A\.?-17\)|XBD)$}i ], + [ 'XCD', qr{^(?:East Caribbean Dollar|XCD)$}i ], + [ 'XCD', qr{^(?:No universal currency|XCD)$}i ], + [ 'XDR', qr{^(?:SDR \(Special Drawing Right\)|SDR|XDR)$}i ], + [ 'XOF', qr{^(?:CFA Franc BCEAO|XOF)$}i ], + [ 'XPD', qr{^(?:Palladium|XPD)$}i ], + [ 'XPF', qr{^(?:CFP Franc|XPF)$}i ], + [ 'XPT', qr{^(?:Platinum|XPT)$}i ], + [ 'XSU', qr{^(?:Sucre|XSU)$}i ], + [ 'XTS', qr{^(?:Codes specifically reserved for testing purposes|XTS)$}i ], + [ 'XUA', qr{^(?:ADB Unit of Account|XUA)$}i ], + [ 'XXX', qr{^(?:The codes assigned for transactions where no currency is involved|XXX)$}i ], + [ 'YER', qr{^(?:Yemeni Rial|YER)$}i ], + [ 'ZAR', qr{^(?:Rand|ZAR)$}i ], + [ 'ZMW', qr{^(?:Zambian Kwacha|ZMW)$}i ], + [ 'ZWL', qr{^(?:Zimbabwe Dollar|ZWL)$}i ], +); + +sub map_currency_name_to_code { + my ($currency) = @_; + + return undef if ($currency // '') eq ''; + + my $code = first { $currency =~ $_->[1] } @currency_name_to_code_mappings; + return $code->[0] if $code; + + no warnings 'once'; + $::lxdebug->message(LXDebug::WARN(), "ISO4217::map_currency_name_to_code: no mapping found for '$currency'"); + + return undef; +} + +1; -- 2.20.1