From cef656505358ac80bba5150aff15a27e931e04c6 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 12 Dec 2024 22:19:51 +0100 Subject: [PATCH] Fixing name for the few currencies not known to k-i18n Currency --- .../codinux/invoicing/model/codes/Currency.kt | 22 +++++++++---------- .../codinux/invoicing/parser/CodeGenerator.kt | 8 ++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Currency.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Currency.kt index eae4a68..fdfb7b9 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Currency.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Currency.kt @@ -6,7 +6,7 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng Lek("ALL", "ALL", "Lek", setOf("ALBANIA"), false), ArmenianDram("AMD", "AMD", "Armenian Dram", setOf("ARMENIA"), false), NetherlandsAntilleanGuilder("ANG", "ANG", "Netherlands Antillean Guilder", setOf("CURAÇAO", "SINT MAARTEN (DUTCH PART)"), false), - AOA("AOA", "AOA", "Kwanza", setOf("ANGOLA"), false), + Kwanza("AOA", "AOA", "Kwanza", setOf("ANGOLA"), false), ArgentinePeso("ARS", "ARS", "Argentine Peso", setOf("ARGENTINA"), false), AustralianDollar("AUD", "A$", "Australian Dollar", setOf("AUSTRALIA", "CHRISTMAS ISLAND", "COCOS (KEELING) ISLANDS (THE)", "HEARD ISLAND AND McDONALD ISLANDS", "KIRIBATI", "NAURU", "NORFOLK ISLAND", "TUVALU"), false), ArubanFlorin("AWG", "AWG", "Aruban Florin", setOf("ARUBA"), false), @@ -25,7 +25,7 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng BahamianDollar("BSD", "BSD", "Bahamian Dollar", setOf("BAHAMAS (THE)"), false), Ngultrum("BTN", "BTN", "Ngultrum", setOf("BHUTAN"), false), Pula("BWP", "BWP", "Pula", setOf("BOTSWANA"), false), - BYN("BYN", "BYN", "Belarusian Ruble", setOf("BELARUS"), false), + BelarusianRuble("BYN", "BYN", "Belarusian Ruble", setOf("BELARUS"), false), BelizeDollar("BZD", "BZD", "Belize Dollar", setOf("BELIZE"), false), CanadianDollar("CAD", "CA$", "Canadian Dollar", setOf("CANADA"), false), CongoleseFranc("CDF", "CDF", "Congolese Franc", setOf("CONGO (THE DEMOCRATIC REPUBLIC OF THE)"), false), @@ -86,7 +86,7 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng LebanesePound("LBP", "LBP", "Lebanese Pound", setOf("LEBANON"), false), SriLankaRupee("LKR", "LKR", "Sri Lanka Rupee", setOf("SRI LANKA"), false), LiberianDollar("LRD", "LRD", "Liberian Dollar", setOf("LIBERIA"), false), - LSL("LSL", "LSL", "Loti", setOf("LESOTHO"), false), + Loti("LSL", "LSL", "Loti", setOf("LESOTHO"), false), LibyanDinar("LYD", "LYD", "Libyan Dinar", setOf("LIBYA"), false), MoroccanDirham("MAD", "MAD", "Moroccan Dirham", setOf("MOROCCO", "WESTERN SAHARA"), false), MoldovanLeu("MDL", "MDL", "Moldovan Leu", setOf("MOLDOVA (THE REPUBLIC OF)"), false), @@ -99,7 +99,7 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng MauritiusRupee("MUR", "MUR", "Mauritius Rupee", setOf("MAURITIUS"), false), Rufiyaa("MVR", "MVR", "Rufiyaa", setOf("MALDIVES"), false), MalawiKwacha("MWK", "MWK", "Malawi Kwacha", setOf("MALAWI"), false), - MXN("MXN", "MX$", "Mexican Peso", setOf("MEXICO"), false), + MexicanPeso("MXN", "MX$", "Mexican Peso", setOf("MEXICO"), false), MexicanUnidadDeInversionUDI("MXV", "MXV", "Mexican Unidad de Inversion (UDI)", setOf("MEXICO"), false), MalaysianRinggit("MYR", "MYR", "Malaysian Ringgit", setOf("MALAYSIA"), false), MozambiqueMetical("MZN", "MZN", "Mozambique Metical", setOf("MOZAMBIQUE"), false), @@ -111,25 +111,25 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng NewZealandDollar("NZD", "NZ$", "New Zealand Dollar", setOf("COOK ISLANDS (THE)", "NEW ZEALAND", "NIUE", "PITCAIRN", "TOKELAU"), false), RialOmani("OMR", "OMR", "Rial Omani", setOf("OMAN"), false), Balboa("PAB", "PAB", "Balboa", setOf("PANAMA"), false), - PEN("PEN", "PEN", "Sol", setOf("PERU"), false), + Sol("PEN", "PEN", "Sol", setOf("PERU"), false), Kina("PGK", "PGK", "Kina", setOf("PAPUA NEW GUINEA"), false), PhilippinePeso("PHP", "₱", "Philippine Peso", setOf("PHILIPPINES (THE)"), false), PakistanRupee("PKR", "PKR", "Pakistan Rupee", setOf("PAKISTAN"), false), - PLN("PLN", "PLN", "Zloty", setOf("POLAND"), true), + Zloty("PLN", "PLN", "Zloty", setOf("POLAND"), true), Guarani("PYG", "PYG", "Guarani", setOf("PARAGUAY"), false), QatariRial("QAR", "QAR", "Qatari Rial", setOf("QATAR"), false), RomanianLeu("RON", "RON", "Romanian Leu", setOf("ROMANIA"), false), SerbianDinar("RSD", "RSD", "Serbian Dinar", setOf("SERBIA"), false), - RUB("RUB", "RUB", "Russian Ruble", setOf("RUSSIAN FEDERATION (THE)"), false), + RussianRuble("RUB", "RUB", "Russian Ruble", setOf("RUSSIAN FEDERATION (THE)"), false), RwandaFranc("RWF", "RWF", "Rwanda Franc", setOf("RWANDA"), false), SaudiRiyal("SAR", "SAR", "Saudi Riyal", setOf("SAUDI ARABIA"), false), SolomonIslandsDollar("SBD", "SBD", "Solomon Islands Dollar", setOf("SOLOMON ISLANDS"), false), SeychellesRupee("SCR", "SCR", "Seychelles Rupee", setOf("SEYCHELLES"), false), - SDG("SDG", "SDG", "Sudanese Pound", setOf("SUDAN (THE)"), false), + SudanesePound("SDG", "SDG", "Sudanese Pound", setOf("SUDAN (THE)"), false), SwedishKrona("SEK", "SEK", "Swedish Krona", setOf("SWEDEN"), true), SingaporeDollar("SGD", "SGD", "Singapore Dollar", setOf("SINGAPORE"), false), SaintHelenaPound("SHP", "SHP", "Saint Helena Pound", setOf("SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA"), false), - SLE("SLE", "SLE", "Sierra Leone (new valuation 2022)", setOf("SIERRA LEONE (new valuation 2022)"), false), + SierraLeone_NewValuation2022("SLE", "SLE", "Sierra Leone (new valuation 2022)", setOf("SIERRA LEONE (new valuation 2022)"), false), SomaliShilling("SOS", "SOS", "Somali Shilling", setOf("SOMALIA"), false), SurinamDollar("SRD", "SRD", "Surinam Dollar", setOf("SURINAME"), false), SouthSudanesePound("SSP", "SSP", "South Sudanese Pound", setOf("SOUTH SUDAN"), false), @@ -154,7 +154,7 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng PesoUruguayo("UYU", "UYU", "Peso Uruguayo", setOf("URUGUAY"), false), UnidadPrevisional("UYW", null, "Unidad Previsional", setOf("URUGUAY"), false), UzbekistanSum("UZS", "UZS", "Uzbekistan Sum", setOf("UZBEKISTAN"), false), - VED("VED", "VED", "Bolívar Soberano, new valuation", emptySet(), false), + BolivarSoberano_NewValuation("VED", "VED", "Bolívar Soberano, new valuation", emptySet(), false), BolivarSoberano("VES", "VES", "Bolívar Soberano", setOf("VENEZUELA (BOLIVARIAN REPUBLIC OF)"), false), Dong("VND", "₫", "Dong", setOf("VIET NAM"), false), Vatu("VUV", "VUV", "Vatu", setOf("VANUATU"), false), @@ -180,5 +180,5 @@ enum class Currency(val alpha3Code: String, val currencySymbol: String?, val eng Rand("ZAR", "ZAR", "Rand", setOf("LESOTHO", "NAMIBIA", "SOUTH AFRICA"), false), ZambianKwacha("ZMW", "ZMW", "Zambian Kwacha", setOf("ZAMBIA"), false), ZimbabweGold("ZWG", null, "Zimbabwe Gold", emptySet(), false), - ZWL("ZWL", "ZWL", "Zimbabwe Dollar", setOf("ZIMBABWE"), false), + ZimbabweDollar("ZWL", "ZWL", "Zimbabwe Dollar", setOf("ZIMBABWE"), false), } \ No newline at end of file diff --git a/e-invoice-spec-parser/src/main/kotlin/net/codinux/invoicing/parser/CodeGenerator.kt b/e-invoice-spec-parser/src/main/kotlin/net/codinux/invoicing/parser/CodeGenerator.kt index debb65f..600e743 100644 --- a/e-invoice-spec-parser/src/main/kotlin/net/codinux/invoicing/parser/CodeGenerator.kt +++ b/e-invoice-spec-parser/src/main/kotlin/net/codinux/invoicing/parser/CodeGenerator.kt @@ -194,7 +194,7 @@ 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.IsoCurrencyCodes) i18nCurrenciesByCode[firstColumn]?.name ?: row[2] // as fallback use currency's English name from Zugferd list + val column = if (type == CodeListType.IsoCurrencyCodes) i18nCurrenciesByCode[firstColumn]?.name ?: fixCurrencyName(row[2]) // 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 == "English Name") row[1] // Country codes else row[0] // default case: the code is in the first column @@ -208,4 +208,10 @@ class CodeGenerator { else name } + private fun fixCurrencyName(currencyName: Any?): String = when (currencyName) { + "Sierra Leone (new valuation 2022)" -> "SierraLeone_NewValuation2022" + "Bolívar Soberano, new valuation" -> "BolivarSoberano_NewValuation" + else -> currencyName.toString().replace(" ", "") + } + } \ No newline at end of file