Added numericCode and numericCodeAsString to Country, using display name from i18n Region (if available) and sorting it by English name
This commit is contained in:
parent
2dfe338a8c
commit
8f2d0da57d
|
@ -1,255 +1,255 @@
|
|||
package net.codinux.invoicing.model.codes
|
||||
|
||||
enum class Country(val alpha2Code: String, val alpha3Code: String?, val englishName: String) {
|
||||
Afghanistan("AF", "AFG", "Afghanistan"),
|
||||
AlandIslands("AX", "ALA", "Åland Islands"),
|
||||
Albania("AL", "ALB", "Albania"),
|
||||
Algeria("DZ", "DZA", "Algeria"),
|
||||
AmericanSamoa("AS", "ASM", "American Samoa"),
|
||||
Andorra("AD", "AND", "Andorra"),
|
||||
Angola("AO", "AGO", "Angola"),
|
||||
Anguilla("AI", "AIA", "Anguilla"),
|
||||
Antarctica("AQ", "ATA", "Antarctica"),
|
||||
AntiguaAndBarbuda("AG", "ATG", "Antigua and Barbuda"),
|
||||
Argentina("AR", "ARG", "Argentina"),
|
||||
Armenia("AM", "ARM", "Armenia"),
|
||||
Aruba("AW", "ABW", "Aruba"),
|
||||
Australia("AU", "AUS", "Australia"),
|
||||
Austria("AT", "AUT", "Austria"),
|
||||
Azerbaijan("AZ", "AZE", "Azerbaijan"),
|
||||
Bahamas("BS", "BHS", "Bahamas (the)"),
|
||||
Bahrain("BH", "BHR", "Bahrain"),
|
||||
Bangladesh("BD", "BGD", "Bangladesh"),
|
||||
Barbados("BB", "BRB", "Barbados"),
|
||||
Belarus("BY", "BLR", "Belarus"),
|
||||
Belgium("BE", "BEL", "Belgium"),
|
||||
Belize("BZ", "BLZ", "Belize"),
|
||||
Benin("BJ", "BEN", "Benin"),
|
||||
Bermuda("BM", "BMU", "Bermuda"),
|
||||
Bhutan("BT", "BTN", "Bhutan"),
|
||||
Bolivia("BO", "BOL", "Bolivia (Plurinational State of)"),
|
||||
CaribbeanNetherlands("BQ", "BES", "Bonaire, Sint Eustatius and Saba"),
|
||||
BosniaAndHerzegovina("BA", "BIH", "Bosnia and Herzegovina"),
|
||||
Botswana("BW", "BWA", "Botswana"),
|
||||
BouvetIsland("BV", "BVT", "Bouvet Island"),
|
||||
Brazil("BR", "BRA", "Brazil"),
|
||||
BritishIndianOceanTerritory("IO", "IOT", "British Indian Ocean Territory (the)"),
|
||||
Brunei("BN", "BRN", "Brunei Darussalam"),
|
||||
Bulgaria("BG", "BGR", "Bulgaria"),
|
||||
BurkinaFaso("BF", "BFA", "Burkina Faso"),
|
||||
Burundi("BI", "BDI", "Burundi"),
|
||||
CapeVerde("CV", "CPV", "Cabo Verde"),
|
||||
Cambodia("KH", "KHM", "Cambodia"),
|
||||
Cameroon("CM", "CMR", "Cameroon"),
|
||||
Canada("CA", "CAN", "Canada"),
|
||||
CaymanIslands("KY", "CYM", "Cayman Islands (the)"),
|
||||
CentralAfricanRepublic("CF", "CAF", "Central African Republic (the)"),
|
||||
Chad("TD", "TCD", "Chad"),
|
||||
Chile("CL", "CHL", "Chile"),
|
||||
China("CN", "CHN", "China"),
|
||||
ChristmasIsland("CX", "CXR", "Christmas Island"),
|
||||
CocosKeelingIslands("CC", "CCK", "Cocos (Keeling) Islands (the)"),
|
||||
Colombia("CO", "COL", "Colombia"),
|
||||
Comoros("KM", "COM", "Comoros (the)"),
|
||||
Congo_DemocraticRepublic("CD", "COD", "Congo (the Democratic Republic of the)"),
|
||||
Congo("CG", "COG", "Congo (the)"),
|
||||
CookIslands("CK", "COK", "Cook Islands (the)"),
|
||||
CostaRica("CR", "CRI", "Costa Rica"),
|
||||
CoteDIvoire("CI", "CIV", "Côte d'Ivoire"),
|
||||
Croatia("HR", "HRV", "Croatia"),
|
||||
Cuba("CU", "CUB", "Cuba"),
|
||||
Curacao("CW", "CUW", "Curaçao"),
|
||||
Cyprus("CY", "CYP", "Cyprus"),
|
||||
Czechia("CZ", "CZE", "Czechia"),
|
||||
Denmark("DK", "DNK", "Denmark"),
|
||||
Djibouti("DJ", "DJI", "Djibouti"),
|
||||
Dominica("DM", "DMA", "Dominica"),
|
||||
DominicanRepublic("DO", "DOM", "Dominican Republic (the)"),
|
||||
Ecuador("EC", "ECU", "Ecuador"),
|
||||
Egypt("EG", "EGY", "Egypt"),
|
||||
ElSalvador("SV", "SLV", "El Salvador"),
|
||||
EquatorialGuinea("GQ", "GNQ", "Equatorial Guinea"),
|
||||
Eritrea("ER", "ERI", "Eritrea"),
|
||||
Estonia("EE", "EST", "Estonia"),
|
||||
Eswatini("SZ", "SWZ", "Eswatini"),
|
||||
Ethiopia("ET", "ETH", "Ethiopia"),
|
||||
FalklandIslands("FK", "FLK", "Falkland Islands (the) [Malvinas]"),
|
||||
FaroeIslands("FO", "FRO", "Faroe Islands (the)"),
|
||||
Fiji("FJ", "FJI", "Fiji"),
|
||||
Finland("FI", "FIN", "Finland"),
|
||||
France("FR", "FRA", "France"),
|
||||
FrenchGuiana("GF", "GUF", "French Guiana"),
|
||||
FrenchPolynesia("PF", "PYF", "French Polynesia"),
|
||||
FrenchSouthernTerritories("TF", "ATF", "French Southern Territories (the)"),
|
||||
Gabon("GA", "GAB", "Gabon"),
|
||||
Gambia("GM", "GMB", "Gambia (the)"),
|
||||
Georgia("GE", "GEO", "Georgia"),
|
||||
Germany("DE", "DEU", "Germany"),
|
||||
Ghana("GH", "GHA", "Ghana"),
|
||||
Gibraltar("GI", "GIB", "Gibraltar"),
|
||||
Greece("GR", "GRC", "Greece"),
|
||||
Greenland("GL", "GRL", "Greenland"),
|
||||
Grenada("GD", "GRD", "Grenada"),
|
||||
Guadeloupe("GP", "GLP", "Guadeloupe"),
|
||||
Guam("GU", "GUM", "Guam"),
|
||||
Guatemala("GT", "GTM", "Guatemala"),
|
||||
Guernsey("GG", "GGY", "Guernsey"),
|
||||
Guinea("GN", "GIN", "Guinea"),
|
||||
GuineaBissau("GW", "GNB", "Guinea-Bissau"),
|
||||
Guyana("GY", "GUY", "Guyana"),
|
||||
Haiti("HT", "HTI", "Haiti"),
|
||||
HeardAndMcDonaldIslands("HM", "HMD", "Heard Island and McDonald Islands"),
|
||||
VaticanCity("VA", "VAT", "Holy See (the)"),
|
||||
Honduras("HN", "HND", "Honduras"),
|
||||
HongKong("HK", "HKG", "Hong Kong"),
|
||||
Hungary("HU", "HUN", "Hungary"),
|
||||
Iceland("IS", "ISL", "Iceland"),
|
||||
India("IN", "IND", "India"),
|
||||
Indonesia("ID", "IDN", "Indonesia"),
|
||||
Iran("IR", "IRN", "Iran (Islamic Republic of)"),
|
||||
Iraq("IQ", "IRQ", "Iraq"),
|
||||
Ireland("IE", "IRL", "Ireland"),
|
||||
IsleOfMan("IM", "IMN", "Isle of Man"),
|
||||
Israel("IL", "ISR", "Israel"),
|
||||
Italy("IT", "ITA", "Italy"),
|
||||
Jamaica("JM", "JAM", "Jamaica"),
|
||||
Japan("JP", "JPN", "Japan"),
|
||||
Jersey("JE", "JEY", "Jersey"),
|
||||
Jordan("JO", "JOR", "Jordan"),
|
||||
Kazakhstan("KZ", "KAZ", "Kazakhstan"),
|
||||
Kenya("KE", "KEN", "Kenya"),
|
||||
Kiribati("KI", "KIR", "Kiribati"),
|
||||
NorthKorea("KP", "PRK", "Korea (the Democratic People's Republic of)"),
|
||||
SouthKorea("KR", "KOR", "Korea (the Republic of)"),
|
||||
Kuwait("KW", "KWT", "Kuwait"),
|
||||
Kyrgyzstan("KG", "KGZ", "Kyrgyzstan"),
|
||||
Laos("LA", "LAO", "Lao People's Democratic Republic (the)"),
|
||||
Latvia("LV", "LVA", "Latvia"),
|
||||
Lebanon("LB", "LBN", "Lebanon"),
|
||||
Lesotho("LS", "LSO", "Lesotho"),
|
||||
Liberia("LR", "LBR", "Liberia"),
|
||||
Libya("LY", "LBY", "Libya"),
|
||||
Liechtenstein("LI", "LIE", "Liechtenstein"),
|
||||
Lithuania("LT", "LTU", "Lithuania"),
|
||||
Luxembourg("LU", "LUX", "Luxembourg"),
|
||||
Macao("MO", "MAC", "Macao"),
|
||||
Madagascar("MG", "MDG", "Madagascar"),
|
||||
Malawi("MW", "MWI", "Malawi"),
|
||||
Malaysia("MY", "MYS", "Malaysia"),
|
||||
Maldives("MV", "MDV", "Maldives"),
|
||||
Mali("ML", "MLI", "Mali"),
|
||||
Malta("MT", "MLT", "Malta"),
|
||||
MarshallIslands("MH", "MHL", "Marshall Islands (the)"),
|
||||
Martinique("MQ", "MTQ", "Martinique"),
|
||||
Mauritania("MR", "MRT", "Mauritania"),
|
||||
Mauritius("MU", "MUS", "Mauritius"),
|
||||
Mayotte("YT", "MYT", "Mayotte"),
|
||||
Mexico("MX", "MEX", "Mexico"),
|
||||
Micronesia("FM", "FSM", "Micronesia (Federated States of)"),
|
||||
Moldova("MD", "MDA", "Moldova (the Republic of)"),
|
||||
Monaco("MC", "MCO", "Monaco"),
|
||||
Mongolia("MN", "MNG", "Mongolia"),
|
||||
Montenegro("ME", "MNE", "Montenegro"),
|
||||
Montserrat("MS", "MSR", "Montserrat"),
|
||||
Morocco("MA", "MAR", "Morocco"),
|
||||
Mozambique("MZ", "MOZ", "Mozambique"),
|
||||
MyanmarBurma("MM", "MMR", "Myanmar"),
|
||||
Namibia("NA", "NAM", "Namibia"),
|
||||
Nauru("NR", "NRU", "Nauru"),
|
||||
Nepal("NP", "NPL", "Nepal"),
|
||||
Netherlands("NL", "NLD", "Netherlands (the)"),
|
||||
NewCaledonia("NC", "NCL", "New Caledonia"),
|
||||
NewZealand("NZ", "NZL", "New Zealand"),
|
||||
Nicaragua("NI", "NIC", "Nicaragua"),
|
||||
Niger("NE", "NER", "Niger (the)"),
|
||||
Nigeria("NG", "NGA", "Nigeria"),
|
||||
Niue("NU", "NIU", "Niue"),
|
||||
NorfolkIsland("NF", "NFK", "Norfolk Island"),
|
||||
NorthMacedonia("MK", "MKD", "North Macedonia"),
|
||||
NorthernMarianaIslands("MP", "MNP", "Northern Mariana Islands (the)"),
|
||||
Norway("NO", "NOR", "Norway"),
|
||||
Oman("OM", "OMN", "Oman"),
|
||||
Pakistan("PK", "PAK", "Pakistan"),
|
||||
Palau("PW", "PLW", "Palau"),
|
||||
Palestine("PS", "PSE", "Palestine, State of"),
|
||||
Panama("PA", "PAN", "Panama"),
|
||||
PapuaNewGuinea("PG", "PNG", "Papua New Guinea"),
|
||||
Paraguay("PY", "PRY", "Paraguay"),
|
||||
Peru("PE", "PER", "Peru"),
|
||||
Philippines("PH", "PHL", "Philippines (the)"),
|
||||
PitcairnIslands("PN", "PCN", "Pitcairn"),
|
||||
Poland("PL", "POL", "Poland"),
|
||||
Portugal("PT", "PRT", "Portugal"),
|
||||
PuertoRico("PR", "PRI", "Puerto Rico"),
|
||||
Qatar("QA", "QAT", "Qatar"),
|
||||
Reunion("RE", "REU", "Réunion"),
|
||||
Romania("RO", "ROU", "Romania"),
|
||||
Russia("RU", "RUS", "Russian Federation (the)"),
|
||||
Rwanda("RW", "RWA", "Rwanda"),
|
||||
SaintBarthelemy("BL", "BLM", "Saint Barthélemy"),
|
||||
SaintHelena("SH", "SHN", "Saint Helena, Ascension and Tristan da Cunha"),
|
||||
SaintKittsAndNevis("KN", "KNA", "Saint Kitts and Nevis"),
|
||||
SaintLucia("LC", "LCA", "Saint Lucia"),
|
||||
SaintMartin("MF", "MAF", "Saint Martin (French part)"),
|
||||
SaintPierreAndMiquelon("PM", "SPM", "Saint Pierre and Miquelon"),
|
||||
SaintVincentAndGrenadines("VC", "VCT", "Saint Vincent and the Grenadines"),
|
||||
Samoa("WS", "WSM", "Samoa"),
|
||||
SanMarino("SM", "SMR", "San Marino"),
|
||||
SaoTomeAndPrincipe("ST", "STP", "Sao Tome and Principe"),
|
||||
SaudiArabia("SA", "SAU", "Saudi Arabia"),
|
||||
Senegal("SN", "SEN", "Senegal"),
|
||||
Serbia("RS", "SRB", "Serbia"),
|
||||
Seychelles("SC", "SYC", "Seychelles"),
|
||||
SierraLeone("SL", "SLE", "Sierra Leone"),
|
||||
Singapore("SG", "SGP", "Singapore"),
|
||||
SintMaarten("SX", "SXM", "Sint Maarten (Dutch part)"),
|
||||
Slovakia("SK", "SVK", "Slovakia"),
|
||||
Slovenia("SI", "SVN", "Slovenia"),
|
||||
SolomonIslands("SB", "SLB", "Solomon Islands"),
|
||||
Somalia("SO", "SOM", "Somalia"),
|
||||
SouthAfrica("ZA", "ZAF", "South Africa"),
|
||||
SouthGeorgiaAndSouthSandwichIslands("GS", "SGS", "South Georgia and the South Sandwich Islands"),
|
||||
SouthSudan("SS", "SSD", "South Sudan"),
|
||||
Spain("ES", "ESP", "Spain"),
|
||||
SriLanka("LK", "LKA", "Sri Lanka"),
|
||||
Sudan("SD", "SDN", "Sudan (the)"),
|
||||
Suriname("SR", "SUR", "Suriname"),
|
||||
SvalbardAndJanMayen("SJ", "SJM", "Svalbard and Jan Mayen"),
|
||||
Sweden("SE", "SWE", "Sweden"),
|
||||
Switzerland("CH", "CHE", "Switzerland"),
|
||||
Syria("SY", "SYR", "Syrian Arab Republic (the)"),
|
||||
Taiwan("TW", "TWN", "Taiwan (Province of China)"),
|
||||
Tajikistan("TJ", "TJK", "Tajikistan"),
|
||||
Tanzania("TZ", "TZA", "Tanzania, the United Republic of"),
|
||||
Thailand("TH", "THA", "Thailand"),
|
||||
TimorLeste("TL", "TLS", "Timor-Leste"),
|
||||
Togo("TG", "TGO", "Togo"),
|
||||
Tokelau("TK", "TKL", "Tokelau"),
|
||||
Tonga("TO", "TON", "Tonga"),
|
||||
TrinidadAndTobago("TT", "TTO", "Trinidad and Tobago"),
|
||||
Tunisia("TN", "TUN", "Tunisia"),
|
||||
Turkiye("TR", "TUR", "Türkiye"),
|
||||
Turkmenistan("TM", "TKM", "Turkmenistan"),
|
||||
TurksAndCaicosIslands("TC", "TCA", "Turks and Caicos Islands (the)"),
|
||||
Tuvalu("TV", "TUV", "Tuvalu"),
|
||||
Uganda("UG", "UGA", "Uganda"),
|
||||
Ukraine("UA", "UKR", "Ukraine"),
|
||||
UnitedArabEmirates("AE", "ARE", "United Arab Emirates (the)"),
|
||||
UnitedKingdom("GB", "GBR", "United Kingdom of Great Britain and Northern Ireland (the)"),
|
||||
USOutlyingIslands("UM", "UMI", "United States Minor Outlying Islands (the)"),
|
||||
UnitedStates("US", "USA", "United States of America (the)"),
|
||||
Uruguay("UY", "URY", "Uruguay"),
|
||||
Uzbekistan("UZ", "UZB", "Uzbekistan"),
|
||||
Vanuatu("VU", "VUT", "Vanuatu"),
|
||||
Venezuela("VE", "VEN", "Venezuela (Bolivarian Republic of)"),
|
||||
Vietnam("VN", "VNM", "Viet Nam"),
|
||||
BritishVirginIslands("VG", "VGB", "Virgin Islands (British)"),
|
||||
USVirginIslands("VI", "VIR", "Virgin Islands (U.S.)"),
|
||||
WallisAndFutuna("WF", "WLF", "Wallis and Futuna"),
|
||||
WesternSahara("EH", "ESH", "Western Sahara*"),
|
||||
Yemen("YE", "YEM", "Yemen"),
|
||||
Zambia("ZM", "ZMB", "Zambia"),
|
||||
Zimbabwe("ZW", "ZWE", "Zimbabwe"),
|
||||
Kosovo("1A", null, "Kosovo"),
|
||||
NorthernIreland("XI", null, "United Kingdom (Northern Ireland)"),
|
||||
enum class Country(val alpha2Code: String, val alpha3Code: String, val numericCode: Int?, val numericCodeAsString: String?, val englishName: String) {
|
||||
Afghanistan("AF", "AFG", 4, "004", "Afghanistan"),
|
||||
AlandIslands("AX", "ALA", 248, "248", "Åland Islands"),
|
||||
Albania("AL", "ALB", 8, "008", "Albania"),
|
||||
Algeria("DZ", "DZA", 12, "012", "Algeria"),
|
||||
AmericanSamoa("AS", "ASM", 16, "016", "American Samoa"),
|
||||
Andorra("AD", "AND", 20, "020", "Andorra"),
|
||||
Angola("AO", "AGO", 24, "024", "Angola"),
|
||||
Anguilla("AI", "AIA", 660, "660", "Anguilla"),
|
||||
Antarctica("AQ", "ATA", 10, "010", "Antarctica"),
|
||||
AntiguaAndBarbuda("AG", "ATG", 28, "028", "Antigua & Barbuda"),
|
||||
Argentina("AR", "ARG", 32, "032", "Argentina"),
|
||||
Armenia("AM", "ARM", 51, "051", "Armenia"),
|
||||
Aruba("AW", "ABW", 533, "533", "Aruba"),
|
||||
Australia("AU", "AUS", 36, "036", "Australia"),
|
||||
Austria("AT", "AUT", 40, "040", "Austria"),
|
||||
Azerbaijan("AZ", "AZE", 31, "031", "Azerbaijan"),
|
||||
Bahamas("BS", "BHS", 44, "044", "Bahamas"),
|
||||
Bahrain("BH", "BHR", 48, "048", "Bahrain"),
|
||||
Bangladesh("BD", "BGD", 50, "050", "Bangladesh"),
|
||||
Barbados("BB", "BRB", 52, "052", "Barbados"),
|
||||
Belarus("BY", "BLR", 112, "112", "Belarus"),
|
||||
Belgium("BE", "BEL", 56, "056", "Belgium"),
|
||||
Belize("BZ", "BLZ", 84, "084", "Belize"),
|
||||
Benin("BJ", "BEN", 204, "204", "Benin"),
|
||||
Bermuda("BM", "BMU", 60, "060", "Bermuda"),
|
||||
Bhutan("BT", "BTN", 64, "064", "Bhutan"),
|
||||
Bolivia("BO", "BOL", 68, "068", "Bolivia"),
|
||||
BosniaAndHerzegovina("BA", "BIH", 70, "070", "Bosnia & Herzegovina"),
|
||||
Botswana("BW", "BWA", 72, "072", "Botswana"),
|
||||
BouvetIsland("BV", "BVT", 74, "074", "Bouvet Island"),
|
||||
Brazil("BR", "BRA", 76, "076", "Brazil"),
|
||||
BritishIndianOceanTerritory("IO", "IOT", 86, "086", "British Indian Ocean Territory"),
|
||||
BritishVirginIslands("VG", "VGB", 92, "092", "British Virgin Islands"),
|
||||
Brunei("BN", "BRN", 96, "096", "Brunei"),
|
||||
Bulgaria("BG", "BGR", 100, "100", "Bulgaria"),
|
||||
BurkinaFaso("BF", "BFA", 854, "854", "Burkina Faso"),
|
||||
Burundi("BI", "BDI", 108, "108", "Burundi"),
|
||||
Cambodia("KH", "KHM", 116, "116", "Cambodia"),
|
||||
Cameroon("CM", "CMR", 120, "120", "Cameroon"),
|
||||
Canada("CA", "CAN", 124, "124", "Canada"),
|
||||
CapeVerde("CV", "CPV", 132, "132", "Cape Verde"),
|
||||
CaribbeanNetherlands("BQ", "BES", 535, "535", "Caribbean Netherlands"),
|
||||
CaymanIslands("KY", "CYM", 136, "136", "Cayman Islands"),
|
||||
CentralAfricanRepublic("CF", "CAF", 140, "140", "Central African Republic"),
|
||||
Chad("TD", "TCD", 148, "148", "Chad"),
|
||||
Chile("CL", "CHL", 152, "152", "Chile"),
|
||||
China("CN", "CHN", 156, "156", "China"),
|
||||
ChristmasIsland("CX", "CXR", 162, "162", "Christmas Island"),
|
||||
CocosKeelingIslands("CC", "CCK", 166, "166", "Cocos (Keeling) Islands"),
|
||||
Colombia("CO", "COL", 170, "170", "Colombia"),
|
||||
Comoros("KM", "COM", 174, "174", "Comoros"),
|
||||
Congo("CG", "COG", 178, "178", "Congo - Brazzaville"),
|
||||
Congo_DemocraticRepublic("CD", "COD", 180, "180", "Congo - Kinshasa"),
|
||||
CookIslands("CK", "COK", 184, "184", "Cook Islands"),
|
||||
CostaRica("CR", "CRI", 188, "188", "Costa Rica"),
|
||||
CoteDIvoire("CI", "CIV", 384, "384", "Côte d’Ivoire"),
|
||||
Croatia("HR", "HRV", 191, "191", "Croatia"),
|
||||
Cuba("CU", "CUB", 192, "192", "Cuba"),
|
||||
Curacao("CW", "CUW", 531, "531", "Curaçao"),
|
||||
Cyprus("CY", "CYP", 196, "196", "Cyprus"),
|
||||
Czechia("CZ", "CZE", 203, "203", "Czechia"),
|
||||
Denmark("DK", "DNK", 208, "208", "Denmark"),
|
||||
Djibouti("DJ", "DJI", 262, "262", "Djibouti"),
|
||||
Dominica("DM", "DMA", 212, "212", "Dominica"),
|
||||
DominicanRepublic("DO", "DOM", 214, "214", "Dominican Republic"),
|
||||
Ecuador("EC", "ECU", 218, "218", "Ecuador"),
|
||||
Egypt("EG", "EGY", 818, "818", "Egypt"),
|
||||
ElSalvador("SV", "SLV", 222, "222", "El Salvador"),
|
||||
EquatorialGuinea("GQ", "GNQ", 226, "226", "Equatorial Guinea"),
|
||||
Eritrea("ER", "ERI", 232, "232", "Eritrea"),
|
||||
Estonia("EE", "EST", 233, "233", "Estonia"),
|
||||
Eswatini("SZ", "SWZ", 748, "748", "Eswatini"),
|
||||
Ethiopia("ET", "ETH", 231, "231", "Ethiopia"),
|
||||
FalklandIslands("FK", "FLK", 238, "238", "Falkland Islands"),
|
||||
FaroeIslands("FO", "FRO", 234, "234", "Faroe Islands"),
|
||||
Fiji("FJ", "FJI", 242, "242", "Fiji"),
|
||||
Finland("FI", "FIN", 246, "246", "Finland"),
|
||||
France("FR", "FRA", 250, "250", "France"),
|
||||
FrenchGuiana("GF", "GUF", 254, "254", "French Guiana"),
|
||||
FrenchPolynesia("PF", "PYF", 258, "258", "French Polynesia"),
|
||||
FrenchSouthernTerritories("TF", "ATF", 260, "260", "French Southern Territories"),
|
||||
Gabon("GA", "GAB", 266, "266", "Gabon"),
|
||||
Gambia("GM", "GMB", 270, "270", "Gambia"),
|
||||
Georgia("GE", "GEO", 268, "268", "Georgia"),
|
||||
Germany("DE", "DEU", 276, "276", "Germany"),
|
||||
Ghana("GH", "GHA", 288, "288", "Ghana"),
|
||||
Gibraltar("GI", "GIB", 292, "292", "Gibraltar"),
|
||||
Greece("GR", "GRC", 300, "300", "Greece"),
|
||||
Greenland("GL", "GRL", 304, "304", "Greenland"),
|
||||
Grenada("GD", "GRD", 308, "308", "Grenada"),
|
||||
Guadeloupe("GP", "GLP", 312, "312", "Guadeloupe"),
|
||||
Guam("GU", "GUM", 316, "316", "Guam"),
|
||||
Guatemala("GT", "GTM", 320, "320", "Guatemala"),
|
||||
Guernsey("GG", "GGY", 831, "831", "Guernsey"),
|
||||
Guinea("GN", "GIN", 324, "324", "Guinea"),
|
||||
GuineaBissau("GW", "GNB", 624, "624", "Guinea-Bissau"),
|
||||
Guyana("GY", "GUY", 328, "328", "Guyana"),
|
||||
Haiti("HT", "HTI", 332, "332", "Haiti"),
|
||||
HeardAndMcDonaldIslands("HM", "HMD", 334, "334", "Heard & McDonald Islands"),
|
||||
Honduras("HN", "HND", 340, "340", "Honduras"),
|
||||
HongKong("HK", "HKG", 344, "344", "Hong Kong SAR China"),
|
||||
Hungary("HU", "HUN", 348, "348", "Hungary"),
|
||||
Iceland("IS", "ISL", 352, "352", "Iceland"),
|
||||
India("IN", "IND", 356, "356", "India"),
|
||||
Indonesia("ID", "IDN", 360, "360", "Indonesia"),
|
||||
Iran("IR", "IRN", 364, "364", "Iran"),
|
||||
Iraq("IQ", "IRQ", 368, "368", "Iraq"),
|
||||
Ireland("IE", "IRL", 372, "372", "Ireland"),
|
||||
IsleOfMan("IM", "IMN", 833, "833", "Isle of Man"),
|
||||
Israel("IL", "ISR", 376, "376", "Israel"),
|
||||
Italy("IT", "ITA", 380, "380", "Italy"),
|
||||
Jamaica("JM", "JAM", 388, "388", "Jamaica"),
|
||||
Japan("JP", "JPN", 392, "392", "Japan"),
|
||||
Jersey("JE", "JEY", 832, "832", "Jersey"),
|
||||
Jordan("JO", "JOR", 400, "400", "Jordan"),
|
||||
Kazakhstan("KZ", "KAZ", 398, "398", "Kazakhstan"),
|
||||
Kenya("KE", "KEN", 404, "404", "Kenya"),
|
||||
Kiribati("KI", "KIR", 296, "296", "Kiribati"),
|
||||
Kosovo("1A", "1A", null, null, "Kosovo"),
|
||||
Kuwait("KW", "KWT", 414, "414", "Kuwait"),
|
||||
Kyrgyzstan("KG", "KGZ", 417, "417", "Kyrgyzstan"),
|
||||
Laos("LA", "LAO", 418, "418", "Laos"),
|
||||
Latvia("LV", "LVA", 428, "428", "Latvia"),
|
||||
Lebanon("LB", "LBN", 422, "422", "Lebanon"),
|
||||
Lesotho("LS", "LSO", 426, "426", "Lesotho"),
|
||||
Liberia("LR", "LBR", 430, "430", "Liberia"),
|
||||
Libya("LY", "LBY", 434, "434", "Libya"),
|
||||
Liechtenstein("LI", "LIE", 438, "438", "Liechtenstein"),
|
||||
Lithuania("LT", "LTU", 440, "440", "Lithuania"),
|
||||
Luxembourg("LU", "LUX", 442, "442", "Luxembourg"),
|
||||
Macao("MO", "MAC", 446, "446", "Macao SAR China"),
|
||||
Madagascar("MG", "MDG", 450, "450", "Madagascar"),
|
||||
Malawi("MW", "MWI", 454, "454", "Malawi"),
|
||||
Malaysia("MY", "MYS", 458, "458", "Malaysia"),
|
||||
Maldives("MV", "MDV", 462, "462", "Maldives"),
|
||||
Mali("ML", "MLI", 466, "466", "Mali"),
|
||||
Malta("MT", "MLT", 470, "470", "Malta"),
|
||||
MarshallIslands("MH", "MHL", 584, "584", "Marshall Islands"),
|
||||
Martinique("MQ", "MTQ", 474, "474", "Martinique"),
|
||||
Mauritania("MR", "MRT", 478, "478", "Mauritania"),
|
||||
Mauritius("MU", "MUS", 480, "480", "Mauritius"),
|
||||
Mayotte("YT", "MYT", 175, "175", "Mayotte"),
|
||||
Mexico("MX", "MEX", 484, "484", "Mexico"),
|
||||
Micronesia("FM", "FSM", 583, "583", "Micronesia"),
|
||||
Moldova("MD", "MDA", 498, "498", "Moldova"),
|
||||
Monaco("MC", "MCO", 492, "492", "Monaco"),
|
||||
Mongolia("MN", "MNG", 496, "496", "Mongolia"),
|
||||
Montenegro("ME", "MNE", 499, "499", "Montenegro"),
|
||||
Montserrat("MS", "MSR", 500, "500", "Montserrat"),
|
||||
Morocco("MA", "MAR", 504, "504", "Morocco"),
|
||||
Mozambique("MZ", "MOZ", 508, "508", "Mozambique"),
|
||||
MyanmarBurma("MM", "MMR", 104, "104", "Myanmar (Burma)"),
|
||||
Namibia("NA", "NAM", 516, "516", "Namibia"),
|
||||
Nauru("NR", "NRU", 520, "520", "Nauru"),
|
||||
Nepal("NP", "NPL", 524, "524", "Nepal"),
|
||||
Netherlands("NL", "NLD", 528, "528", "Netherlands"),
|
||||
NewCaledonia("NC", "NCL", 540, "540", "New Caledonia"),
|
||||
NewZealand("NZ", "NZL", 554, "554", "New Zealand"),
|
||||
Nicaragua("NI", "NIC", 558, "558", "Nicaragua"),
|
||||
Niger("NE", "NER", 562, "562", "Niger"),
|
||||
Nigeria("NG", "NGA", 566, "566", "Nigeria"),
|
||||
Niue("NU", "NIU", 570, "570", "Niue"),
|
||||
NorfolkIsland("NF", "NFK", 574, "574", "Norfolk Island"),
|
||||
NorthKorea("KP", "PRK", 408, "408", "North Korea"),
|
||||
NorthMacedonia("MK", "MKD", 807, "807", "North Macedonia"),
|
||||
NorthernIreland("XI", "XI", null, null, "United Kingdom (Northern Ireland)"),
|
||||
NorthernMarianaIslands("MP", "MNP", 580, "580", "Northern Mariana Islands"),
|
||||
Norway("NO", "NOR", 578, "578", "Norway"),
|
||||
Oman("OM", "OMN", 512, "512", "Oman"),
|
||||
Pakistan("PK", "PAK", 586, "586", "Pakistan"),
|
||||
Palau("PW", "PLW", 585, "585", "Palau"),
|
||||
Palestine("PS", "PSE", 275, "275", "Palestinian Territories"),
|
||||
Panama("PA", "PAN", 591, "591", "Panama"),
|
||||
PapuaNewGuinea("PG", "PNG", 598, "598", "Papua New Guinea"),
|
||||
Paraguay("PY", "PRY", 600, "600", "Paraguay"),
|
||||
Peru("PE", "PER", 604, "604", "Peru"),
|
||||
Philippines("PH", "PHL", 608, "608", "Philippines"),
|
||||
PitcairnIslands("PN", "PCN", 612, "612", "Pitcairn Islands"),
|
||||
Poland("PL", "POL", 616, "616", "Poland"),
|
||||
Portugal("PT", "PRT", 620, "620", "Portugal"),
|
||||
PuertoRico("PR", "PRI", 630, "630", "Puerto Rico"),
|
||||
Qatar("QA", "QAT", 634, "634", "Qatar"),
|
||||
Reunion("RE", "REU", 638, "638", "Réunion"),
|
||||
Romania("RO", "ROU", 642, "642", "Romania"),
|
||||
Russia("RU", "RUS", 643, "643", "Russia"),
|
||||
Rwanda("RW", "RWA", 646, "646", "Rwanda"),
|
||||
SaintBarthelemy("BL", "BLM", 652, "652", "St. Barthélemy"),
|
||||
SaintHelena("SH", "SHN", 654, "654", "St. Helena"),
|
||||
SaintKittsAndNevis("KN", "KNA", 659, "659", "St. Kitts & Nevis"),
|
||||
SaintLucia("LC", "LCA", 662, "662", "St. Lucia"),
|
||||
SaintMartin("MF", "MAF", 663, "663", "St. Martin"),
|
||||
SaintPierreAndMiquelon("PM", "SPM", 666, "666", "St. Pierre & Miquelon"),
|
||||
SaintVincentAndGrenadines("VC", "VCT", 670, "670", "St. Vincent & Grenadines"),
|
||||
Samoa("WS", "WSM", 882, "882", "Samoa"),
|
||||
SanMarino("SM", "SMR", 674, "674", "San Marino"),
|
||||
SaoTomeAndPrincipe("ST", "STP", 678, "678", "São Tomé & Príncipe"),
|
||||
SaudiArabia("SA", "SAU", 682, "682", "Saudi Arabia"),
|
||||
Senegal("SN", "SEN", 686, "686", "Senegal"),
|
||||
Serbia("RS", "SRB", 688, "688", "Serbia"),
|
||||
Seychelles("SC", "SYC", 690, "690", "Seychelles"),
|
||||
SierraLeone("SL", "SLE", 694, "694", "Sierra Leone"),
|
||||
Singapore("SG", "SGP", 702, "702", "Singapore"),
|
||||
SintMaarten("SX", "SXM", 534, "534", "Sint Maarten"),
|
||||
Slovakia("SK", "SVK", 703, "703", "Slovakia"),
|
||||
Slovenia("SI", "SVN", 705, "705", "Slovenia"),
|
||||
SolomonIslands("SB", "SLB", 90, "090", "Solomon Islands"),
|
||||
Somalia("SO", "SOM", 706, "706", "Somalia"),
|
||||
SouthAfrica("ZA", "ZAF", 710, "710", "South Africa"),
|
||||
SouthGeorgiaAndSouthSandwichIslands("GS", "SGS", 239, "239", "South Georgia & South Sandwich Islands"),
|
||||
SouthKorea("KR", "KOR", 410, "410", "South Korea"),
|
||||
SouthSudan("SS", "SSD", 728, "728", "South Sudan"),
|
||||
Spain("ES", "ESP", 724, "724", "Spain"),
|
||||
SriLanka("LK", "LKA", 144, "144", "Sri Lanka"),
|
||||
Sudan("SD", "SDN", 729, "729", "Sudan"),
|
||||
Suriname("SR", "SUR", 740, "740", "Suriname"),
|
||||
SvalbardAndJanMayen("SJ", "SJM", 744, "744", "Svalbard & Jan Mayen"),
|
||||
Sweden("SE", "SWE", 752, "752", "Sweden"),
|
||||
Switzerland("CH", "CHE", 756, "756", "Switzerland"),
|
||||
Syria("SY", "SYR", 760, "760", "Syria"),
|
||||
Taiwan("TW", "TWN", 158, "158", "Taiwan"),
|
||||
Tajikistan("TJ", "TJK", 762, "762", "Tajikistan"),
|
||||
Tanzania("TZ", "TZA", 834, "834", "Tanzania"),
|
||||
Thailand("TH", "THA", 764, "764", "Thailand"),
|
||||
TimorLeste("TL", "TLS", 626, "626", "Timor-Leste"),
|
||||
Togo("TG", "TGO", 768, "768", "Togo"),
|
||||
Tokelau("TK", "TKL", 772, "772", "Tokelau"),
|
||||
Tonga("TO", "TON", 776, "776", "Tonga"),
|
||||
TrinidadAndTobago("TT", "TTO", 780, "780", "Trinidad & Tobago"),
|
||||
Tunisia("TN", "TUN", 788, "788", "Tunisia"),
|
||||
Turkiye("TR", "TUR", 792, "792", "Türkiye"),
|
||||
Turkmenistan("TM", "TKM", 795, "795", "Turkmenistan"),
|
||||
TurksAndCaicosIslands("TC", "TCA", 796, "796", "Turks & Caicos Islands"),
|
||||
Tuvalu("TV", "TUV", 798, "798", "Tuvalu"),
|
||||
USOutlyingIslands("UM", "UMI", 581, "581", "U.S. Outlying Islands"),
|
||||
USVirginIslands("VI", "VIR", 850, "850", "U.S. Virgin Islands"),
|
||||
Uganda("UG", "UGA", 800, "800", "Uganda"),
|
||||
Ukraine("UA", "UKR", 804, "804", "Ukraine"),
|
||||
UnitedArabEmirates("AE", "ARE", 784, "784", "United Arab Emirates"),
|
||||
UnitedKingdom("GB", "GBR", 826, "826", "United Kingdom"),
|
||||
UnitedStates("US", "USA", 840, "840", "United States"),
|
||||
Uruguay("UY", "URY", 858, "858", "Uruguay"),
|
||||
Uzbekistan("UZ", "UZB", 860, "860", "Uzbekistan"),
|
||||
Vanuatu("VU", "VUT", 548, "548", "Vanuatu"),
|
||||
VaticanCity("VA", "VAT", 336, "336", "Vatican City"),
|
||||
Venezuela("VE", "VEN", 862, "862", "Venezuela"),
|
||||
Vietnam("VN", "VNM", 704, "704", "Vietnam"),
|
||||
WallisAndFutuna("WF", "WLF", 876, "876", "Wallis & Futuna"),
|
||||
WesternSahara("EH", "ESH", 732, "732", "Western Sahara"),
|
||||
Yemen("YE", "YEM", 887, "887", "Yemen"),
|
||||
Zambia("ZM", "ZMB", 894, "894", "Zambia"),
|
||||
Zimbabwe("ZW", "ZWE", 716, "716", "Zimbabwe"),
|
||||
}
|
|
@ -23,13 +23,15 @@ class CodeGenerator {
|
|||
val matchedCodeLists = cefCodeLists.associateBy { it.type }.mapValues { it.value to zugferdCodeListsByType[it.key] }
|
||||
|
||||
matchedCodeLists.forEach { (type, codeLists) ->
|
||||
val (columns, rows) = (if (type == CodeListType.IsoCurrencyCodes) mergeCurrencyData(codeLists.first, codeLists.second!!) else {
|
||||
addFrequentlyUsedColumn(reorder(map(filter(
|
||||
// Factur-X (= codeLists.second) has the better column names and often also a Description column
|
||||
if (codeLists.second != null) codeLists.second!!.columns to codeLists.second!!.rows
|
||||
else codeLists.first.columns to codeLists.first.rows
|
||||
))))
|
||||
})
|
||||
val (columns, rows) = (if (type == CodeListType.IsoCountryCodes) mergeCountryData(codeLists.first, codeLists.second!!)
|
||||
else if (type == CodeListType.IsoCurrencyCodes) mergeCurrencyData(codeLists.first, codeLists.second!!)
|
||||
else {
|
||||
addFrequentlyUsedColumn(reorder(map(filter(
|
||||
// Factur-X (= codeLists.second) has the better column names and often also a Description column
|
||||
if (codeLists.second != null) codeLists.second!!.columns to codeLists.second!!.rows
|
||||
else codeLists.first.columns to codeLists.first.rows
|
||||
))))
|
||||
})
|
||||
|
||||
|
||||
File(outputDirectory, type.className + ".kt").bufferedWriter().use { writer ->
|
||||
|
@ -38,7 +40,7 @@ class CodeGenerator {
|
|||
writer.appendLine("enum class ${type.className}(${columns.joinToString(", ") { "val ${getPropertyName(it)}: ${getDataType(it, columns, rows)}" } }) {")
|
||||
|
||||
rows.forEach { row ->
|
||||
writer.appendLine("\t${getEnumName(type, columns, row.values)}(${row.values.joinToString(", ") { getPropertyValue(it, type != CodeListType.IsoCurrencyCodes) } }),")
|
||||
writer.appendLine("\t${getEnumName(type, columns, row)}(${row.values.joinToString(", ") { getPropertyValue(it, type !in listOf(CodeListType.IsoCountryCodes, CodeListType.IsoCurrencyCodes)) } }),")
|
||||
}
|
||||
writer.append("}")
|
||||
}
|
||||
|
@ -85,12 +87,11 @@ class CodeGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* For Countries move englishNames column to the end, so that alpha2Code and alpha3Code are the first and second column.
|
||||
* For SchemeIdentifier move the schemeId column, which in most cases is null, to the end, so that the code is the first column.
|
||||
*/
|
||||
private fun reorder(columnsAndRows: Pair<List<Column>, List<Row>>): Pair<List<Column>, List<Row>> {
|
||||
val (columns, rows) = columnsAndRows
|
||||
val reorderFirstColumn = columns.first().name in listOf("English Name", "Scheme ID")
|
||||
val reorderFirstColumn = columns.first().name in listOf("Scheme ID")
|
||||
|
||||
if (reorderFirstColumn) {
|
||||
val reorderedColumns = columns.toMutableList().apply {
|
||||
|
@ -109,6 +110,27 @@ class CodeGenerator {
|
|||
return columnsAndRows
|
||||
}
|
||||
|
||||
private fun mergeCountryData(cefCodeList: CodeList, zugferdCodeList: net.codinux.invoicing.parser.excel.CodeList): Pair<List<Column>, List<Row>> {
|
||||
val columns = listOf(
|
||||
Column(0, "alpha2Code", "String", "alpha2Code"),
|
||||
Column(1, "alpha3Code", "String", "alpha3Code"),
|
||||
Column(2, "numericCode", "Int", "numericCode"),
|
||||
Column(3, "numericCodeAsString", "String", "numericCodeAsString"),
|
||||
Column(4, "englishName", "String", "englishName"),
|
||||
)
|
||||
|
||||
val cefByIsoCode = cefCodeList.rows.associateBy { it.values[0] }
|
||||
val zugferdByIsoCode = zugferdCodeList.rows.groupBy { it.values[2] }
|
||||
|
||||
val rows = cefByIsoCode.map { (isoCode, cefRow) ->
|
||||
val values = zugferdByIsoCode[isoCode]!!.first().values
|
||||
val i18nRegion = i18nRegionsByCode[isoCode]
|
||||
Row(listOf(isoCode, i18nRegion?.alpha3Code ?: values[2], i18nRegion?.numericCode, i18nRegion?.numericCodeAsString, i18nRegion?.englishName ?: values[0]), false, fixCountryName(i18nRegion?.name ?: values[0]))
|
||||
}
|
||||
|
||||
return columns to rows.sortedBy { it.enumName!! } // sort by englishName
|
||||
}
|
||||
|
||||
private fun mergeCurrencyData(cefCodeList: CodeList, zugferdCodeList: net.codinux.invoicing.parser.excel.CodeList): Pair<List<Column>, List<Row>> {
|
||||
val columns = listOf(
|
||||
Column(0, "alpha3Code", "String", "alpha3Code"),
|
||||
|
@ -194,9 +216,11 @@ class CodeGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getEnumName(type: CodeListType, columns: List<Column>, row: List<Any?>): String {
|
||||
private fun getEnumName(type: CodeListType, columns: List<Column>, row: Row): String {
|
||||
val values = row.values
|
||||
val firstColumn = values[0]
|
||||
|
||||
// Mime types
|
||||
val firstColumn = row[0]
|
||||
if (firstColumn == "application/pdf") return "PDF"
|
||||
else if (firstColumn == "image/png") return "PNG"
|
||||
else if (firstColumn == "image/jpeg") return "JPEG"
|
||||
|
@ -204,10 +228,10 @@ class CodeGenerator {
|
|||
else if (firstColumn == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") return "ExcelSpreadsheet"
|
||||
else if (firstColumn == "application/vnd.oasis.opendocument.spreadsheet") return "OpenDocumentSpreadsheet"
|
||||
|
||||
val column = if (type == CodeListType.IsoCountryCodes) i18nRegionsByCode[firstColumn]?.name ?: fixCountryName(row[2])
|
||||
else if (type == CodeListType.IsoCurrencyCodes) i18nCurrenciesByCode[firstColumn]?.name ?: fixCurrencyName(row[3]) // as fallback use currency's English name from Zugferd list
|
||||
else if (columns.first().name == "Scheme ID") row[1] // ISO 6523 Scheme Identifier codes
|
||||
else row[0] // default case: the code is in the first column
|
||||
val column = if (type == CodeListType.IsoCountryCodes) row.enumName
|
||||
else if (type == CodeListType.IsoCurrencyCodes) i18nCurrenciesByCode[firstColumn]?.name ?: fixCurrencyName(values[3]) // as fallback use currency's English name from Zugferd list
|
||||
else if (columns.first().name == "Scheme ID") values[1] // ISO 6523 Scheme Identifier codes
|
||||
else firstColumn // default case: the code is in the first column
|
||||
|
||||
val name = (column?.toString() ?: "").replace(' ', '_').replace('/', '_').replace('.', '_').replace(',', '_')
|
||||
.replace('-', '_').replace('(', '_').replace(')', '_').replace('[', '_').replace(']', '_')
|
||||
|
|
|
@ -2,7 +2,8 @@ package net.codinux.invoicing.parser.model
|
|||
|
||||
class Row(
|
||||
values: List<Any?>,
|
||||
val isFrequentlyUsedValue: Boolean = false
|
||||
val isFrequentlyUsedValue: Boolean = false,
|
||||
var enumName: String? = null
|
||||
) {
|
||||
|
||||
val values: List<Any?> = values.toMutableList()
|
||||
|
|
Loading…
Reference in New Issue