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:
dankito 2024-12-13 00:34:28 +01:00
parent 2dfe338a8c
commit 8f2d0da57d
3 changed files with 294 additions and 269 deletions

View File

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

View File

@ -23,7 +23,9 @@ class CodeGenerator {
val matchedCodeLists = cefCodeLists.associateBy { it.type }.mapValues { it.value to zugferdCodeListsByType[it.key] } val matchedCodeLists = cefCodeLists.associateBy { it.type }.mapValues { it.value to zugferdCodeListsByType[it.key] }
matchedCodeLists.forEach { (type, codeLists) -> matchedCodeLists.forEach { (type, codeLists) ->
val (columns, rows) = (if (type == CodeListType.IsoCurrencyCodes) mergeCurrencyData(codeLists.first, codeLists.second!!) else { 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( addFrequentlyUsedColumn(reorder(map(filter(
// Factur-X (= codeLists.second) has the better column names and often also a Description column // 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 if (codeLists.second != null) codeLists.second!!.columns to codeLists.second!!.rows
@ -38,7 +40,7 @@ class CodeGenerator {
writer.appendLine("enum class ${type.className}(${columns.joinToString(", ") { "val ${getPropertyName(it)}: ${getDataType(it, columns, rows)}" } }) {") writer.appendLine("enum class ${type.className}(${columns.joinToString(", ") { "val ${getPropertyName(it)}: ${getDataType(it, columns, rows)}" } }) {")
rows.forEach { row -> 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("}") 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. * 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>> { private fun reorder(columnsAndRows: Pair<List<Column>, List<Row>>): Pair<List<Column>, List<Row>> {
val (columns, rows) = columnsAndRows 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) { if (reorderFirstColumn) {
val reorderedColumns = columns.toMutableList().apply { val reorderedColumns = columns.toMutableList().apply {
@ -109,6 +110,27 @@ class CodeGenerator {
return columnsAndRows 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>> { private fun mergeCurrencyData(cefCodeList: CodeList, zugferdCodeList: net.codinux.invoicing.parser.excel.CodeList): Pair<List<Column>, List<Row>> {
val columns = listOf( val columns = listOf(
Column(0, "alpha3Code", "String", "alpha3Code"), 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 // Mime types
val firstColumn = row[0]
if (firstColumn == "application/pdf") return "PDF" if (firstColumn == "application/pdf") return "PDF"
else if (firstColumn == "image/png") return "PNG" else if (firstColumn == "image/png") return "PNG"
else if (firstColumn == "image/jpeg") return "JPEG" 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.openxmlformats-officedocument.spreadsheetml.sheet") return "ExcelSpreadsheet"
else if (firstColumn == "application/vnd.oasis.opendocument.spreadsheet") return "OpenDocumentSpreadsheet" else if (firstColumn == "application/vnd.oasis.opendocument.spreadsheet") return "OpenDocumentSpreadsheet"
val column = if (type == CodeListType.IsoCountryCodes) i18nRegionsByCode[firstColumn]?.name ?: fixCountryName(row[2]) val column = if (type == CodeListType.IsoCountryCodes) row.enumName
else if (type == CodeListType.IsoCurrencyCodes) i18nCurrenciesByCode[firstColumn]?.name ?: fixCurrencyName(row[3]) // as fallback use currency's English name from Zugferd list 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") row[1] // ISO 6523 Scheme Identifier codes else if (columns.first().name == "Scheme ID") values[1] // ISO 6523 Scheme Identifier codes
else row[0] // default case: the code is in the first column else firstColumn // default case: the code is in the first column
val name = (column?.toString() ?: "").replace(' ', '_').replace('/', '_').replace('.', '_').replace(',', '_') val name = (column?.toString() ?: "").replace(' ', '_').replace('/', '_').replace('.', '_').replace(',', '_')
.replace('-', '_').replace('(', '_').replace(')', '_').replace('[', '_').replace(']', '_') .replace('-', '_').replace('(', '_').replace(')', '_').replace('[', '_').replace(']', '_')

View File

@ -2,7 +2,8 @@ package net.codinux.invoicing.parser.model
class Row( class Row(
values: List<Any?>, values: List<Any?>,
val isFrequentlyUsedValue: Boolean = false val isFrequentlyUsedValue: Boolean = false,
var enumName: String? = null
) { ) {
val values: List<Any?> = values.toMutableList() val values: List<Any?> = values.toMutableList()