From 0fee6511143e833a2464cc59ea67869965a134c5 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 4 Dec 2024 22:06:58 +0100 Subject: [PATCH] Mapped Mime type names --- .../kotlin/net/codinux/invoicing/model/codes/Mime.kt | 12 ++++++------ .../net/codinux/invoicing/parser/CodeGenerator.kt | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Mime.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Mime.kt index cf85a4a..46c1077 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Mime.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/model/codes/Mime.kt @@ -1,10 +1,10 @@ package net.codinux.invoicing.model.codes enum class Mime(val code: String) { - application_pdf("application/pdf"), - image_png("image/png"), - image_jpeg("image/jpeg"), - text_csv("text/csv"), - application_vnd_openxmlformats_officedocument_spreadsheetml_sheet("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), - application_vnd_oasis_opendocument_spreadsheet("application/vnd.oasis.opendocument.spreadsheet"), + PDF("application/pdf"), + PNG("image/png"), + JPEG("image/jpeg"), + CSV("text/csv"), + ExcelSpreadsheet("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), + OpenDocumentSpreadsheet("application/vnd.oasis.opendocument.spreadsheet"), } \ 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 b7c98a4..dffa75e 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 @@ -137,6 +137,15 @@ class CodeGenerator { } private fun getEnumName(columns: List, row: List): String { + // 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" + else if (firstColumn == "text/csv") return "CSV" + else if (firstColumn == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") return "ExcelSpreadsheet" + else if (firstColumn == "application/vnd.oasis.opendocument.spreadsheet") return "OpenDocumentSpreadsheet" + val column = 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 if (columns.first().name == "Country") row[2] // Currency codes, but does not work yet due to duplicate Keys / Alpha3-Codes