From 3df54fa62cbc1f762b0ebebc1c1ef04bee6282d5 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 16 Dec 2022 09:29:34 +0100 Subject: [PATCH] Jobs/Interfaces: add options for enabling / disabling zugferd schemas --- Interfaces/ZUGFeRDInterface.vb | 26 ++++++++++++++++++-------- Jobs/ZUGFeRD/WorkerArgs.vb | 2 ++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Interfaces/ZUGFeRDInterface.vb b/Interfaces/ZUGFeRDInterface.vb index 344d4f01..190f11b9 100644 --- a/Interfaces/ZUGFeRDInterface.vb +++ b/Interfaces/ZUGFeRDInterface.vb @@ -35,6 +35,8 @@ Public Class ZUGFeRDInterface Public Class ZugferdOptions Public Property AllowFacturX_Filename As Boolean = True Public Property AllowXRechnung_Filename As Boolean = True + Public Property AllowZugferd_1_0_Schema As Boolean = True + Public Property AllowZugferd_2_x_Schema As Boolean = True End Class ''' @@ -220,14 +222,21 @@ Public Class ZUGFeRDInterface Dim oReader As XmlReader Dim oResult = Nothing - Dim oTypes As New List(Of Type) From { - GetType(ZUGFeRD.Version1_0.CrossIndustryDocumentType), - GetType(ZUGFeRD.Version2_0.CrossIndustryInvoiceType), - GetType(ZUGFeRD.Version2_1_1.CrossIndustryInvoiceType), - GetType(ZUGFeRD.Version2_2_FacturX.CrossIndustryInvoiceType) - } + Dim oAllowedTypes As New List(Of Type) - For Each oType In oTypes + If _Options.AllowZugferd_1_0_Schema Then + oAllowedTypes.Add(GetType(ZUGFeRD.Version1_0.CrossIndustryDocumentType)) + End If + + If _Options.AllowZugferd_2_x_Schema Then + oAllowedTypes.AddRange(New List(Of Type) From { + GetType(ZUGFeRD.Version2_0.CrossIndustryInvoiceType), + GetType(ZUGFeRD.Version2_1_1.CrossIndustryInvoiceType), + GetType(ZUGFeRD.Version2_2_FacturX.CrossIndustryInvoiceType) + }) + End If + + For Each oType In oAllowedTypes _logger.Debug("Trying Type [{0}]", oType.FullName) Dim oSerializer As New XmlSerializer(oType) @@ -251,7 +260,8 @@ Public Class ZUGFeRDInterface Catch ex As Exception _logger.Error(ex) - Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, "Datei ist eine ungültige ZUGFeRD Datei.") + Dim oMessage = "Datei ist eine ungültige ZUGFeRD Datei oder das Format wird nicht unterstüzt, oder das Format ist deaktiviert." + Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, oMessage) End Try End Function diff --git a/Jobs/ZUGFeRD/WorkerArgs.vb b/Jobs/ZUGFeRD/WorkerArgs.vb index a34a90b0..ba9ac70d 100644 --- a/Jobs/ZUGFeRD/WorkerArgs.vb +++ b/Jobs/ZUGFeRD/WorkerArgs.vb @@ -26,4 +26,6 @@ Public Class WorkerArgs Public AllowFacturX As Boolean = True Public AllowXRechnung As Boolean = True + Public AllowZugferd10 As Boolean = True + Public AllowZugferd2x As Boolean = True End Class \ No newline at end of file