diff --git a/Interfaces/Interfaces.vbproj b/Interfaces/Interfaces.vbproj
index 27e501ce..4668da2e 100644
--- a/Interfaces/Interfaces.vbproj
+++ b/Interfaces/Interfaces.vbproj
@@ -226,6 +226,7 @@
+
@@ -247,6 +248,7 @@
+
diff --git a/Interfaces/ZUGFeRDInterface.vb b/Interfaces/ZUGFeRDInterface.vb
index 64f463c0..f6abb30a 100644
--- a/Interfaces/ZUGFeRDInterface.vb
+++ b/Interfaces/ZUGFeRDInterface.vb
@@ -43,7 +43,7 @@ Public Class ZUGFeRDInterface
Private AllowedFilenames As New List(Of String)
- Public Enum ErrorType
+ Public Enum ErrorType1
NoValidFile
NoZugferd
NoValidZugferd
@@ -51,6 +51,7 @@ Public Class ZUGFeRDInterface
UnsupportedFormat
FileTooBig
UnknownError
+ NotInUse
End Enum
Public ReadOnly Property FileGroup As FileGroups
@@ -171,6 +172,7 @@ Public Class ZUGFeRDInterface
Public Function GetSerializedXMLContentFromFile(oFileInfo As FileInfo) As ZugferdResult
Dim oResult = New ZugferdResult()
+ Dim oMessage As String = String.Empty
Try
Dim oFileSize As Integer = oFileInfo.Length
@@ -195,7 +197,7 @@ Public Class ZUGFeRDInterface
Catch ex As Exception
_logger.Error(ex)
- Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, "Datei ist eine ungültige XML Datei.")
+ Throw New ZUGFeRDExecption(ErrorCodes.UnsupportedFerdException, "Datei ist eine ungültige XML Datei.")
End Try
If oResult.ValidationErrors.Any() Then
@@ -211,7 +213,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it
'''
'''
- '''
Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As ZugferdResult
Dim oResult = ValidateZUGFeRDFileWithGDPicture(Path)
oResult = ValidateZUGFeRDDocument(oResult)
@@ -229,7 +230,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it
'''
'''
- '''
Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As ZugferdResult
Dim oResult = ValidateZUGFeRDFileWithGDPicture(Stream)
oResult = ValidateZUGFeRDDocument(oResult)
@@ -252,7 +252,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it
'''
'''
- '''
''' The embedded xml data as an XPath document
Public Function ValidateZUGFeRDFileWithGDPicture(pStream As Stream) As ZugferdResult
Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
@@ -281,7 +280,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it
'''
'''
- '''
''' The embedded xml data as an XPath document
Public Function ValidateZUGFeRDFileWithGDPicture(pPath As String) As ZugferdResult
Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
@@ -307,12 +305,8 @@ Public Class ZUGFeRDInterface
End Function
Private Function HandleEmbeddedFiles(pResults As List(Of PDFEmbeds.EmbeddedFile)) As ZugferdResult
- If pResults Is Nothing Then
- Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil die Attachments nicht gelesen werden konnten.")
- End If
-
- If pResults.Count = 0 Then
- Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil sie keine Attachments enthält.")
+ If pResults Is Nothing OrElse pResults.Count = 0 Then
+ Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdNoXMLAttachmentFound, "Die Datei ist keine gültige ZUGFeRD-Datei, es wurde kein passender XML-Anhang gefunden.")
End If
' Find the first file which filename matches the valid filenames for embedded invoice files
@@ -321,7 +315,7 @@ Public Class ZUGFeRDInterface
FirstOrDefault()
If oValidResult Is Nothing Then
- Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil keine entsprechende XML-Datei gefunden wurde.")
+ Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdNoXMLAttachmentFound, "Die Datei ist keine ZUGFeRD Datei, weil keine passende XML-Datei gefunden wurde.")
End If
' Search the embedded files for the ones which are allowed as per the configuration.
@@ -331,7 +325,7 @@ Public Class ZUGFeRDInterface
FirstOrDefault()
If oAllowedResult Is Nothing Then
- Throw New ZUGFeRDExecption(ErrorType.UnsupportedFormat, "Datei ist eine ZUGFeRD Datei, aber das Format wird nicht unterstützt.", oAllowedResult.FileName)
+ Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdNoXMLAttachmentFound, "Datei enthält einen XML-Anhang mit einem ungültigen Dateinamen.", oAllowedResult.FileName)
End If
Try
@@ -349,7 +343,7 @@ Public Class ZUGFeRDInterface
Catch ex As Exception
_logger.Error(ex)
- Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, "Datei ist eine ungültige ZUGFeRD Datei.")
+ Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdException, "XML-Datei konnte nicht gelesen werden.")
End Try
End Function
@@ -456,8 +450,7 @@ Public Class ZUGFeRDInterface
Next
If oObject Is Nothing Then
- 'Throw New ApplicationException("No Types matched the given document. Document could not be serialized.")
- Throw New ZUGFeRDExecption(ErrorType.UnsupportedFormat, "Unsupported Format")
+ Throw New ZUGFeRDExecption(ErrorCodes.UnsupportedFerdException, "Unsupported Format")
End If
pResult.Specification = oSpecification
@@ -472,8 +465,8 @@ Public Class ZUGFeRDInterface
Catch ex As Exception
_logger.Error(ex)
- Dim oMessage = "Datei ist eine ungültige eInvoice Datei oder das Format wird nicht unterstüzt, oder das Format ist deaktiviert."
- Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, oMessage)
+ Dim oMessage = "Datei ist eine ungültige Datei oder das Format wird nicht unterstüzt, oder das Format ist deaktiviert."
+ Throw New ZUGFeRDExecption(ErrorCodes.UnsupportedFerdException, oMessage)
End Try
End Function
End Class
diff --git a/Interfaces/ZUGFeRDInterface/Enums/ErrorCodes.vb b/Interfaces/ZUGFeRDInterface/Enums/ErrorCodes.vb
new file mode 100644
index 00000000..97806e80
--- /dev/null
+++ b/Interfaces/ZUGFeRDInterface/Enums/ErrorCodes.vb
@@ -0,0 +1,14 @@
+Public Enum ErrorCodes
+ NotInUse = 0
+ ValidationException = 20001
+ MD5HashException = 20002
+ UnsupportedFerdException = 20003
+ InvalidFerdException = 20004
+ TooMuchFerdsException = 20005
+ InvalidFerdNoXMLAttachmentFound = 20006
+ MissingValueException = 20007
+ FileSizeLimitReachedException = 20008
+ OutOfMemoryException = 20009
+ UnhandledException = 20010
+ FileMoveException = 200011
+End Enum
diff --git a/Interfaces/ZUGFeRDInterface/Exceptions.vb b/Interfaces/ZUGFeRDInterface/Exceptions.vb
index 1efedde1..79af3acd 100644
--- a/Interfaces/ZUGFeRDInterface/Exceptions.vb
+++ b/Interfaces/ZUGFeRDInterface/Exceptions.vb
@@ -4,7 +4,11 @@ Public Class Exceptions
Public Class ZUGFeRDExecption
Inherits ApplicationException
- Public ReadOnly Property ErrorType() As ZUGFeRDInterface.ErrorType
+ Public ReadOnly Property ErrorCode() As ErrorCodes
+
+ Public ReadOnly Property Param1 As String = String.Empty
+
+ Public ReadOnly Property Param2 As String = String.Empty
'''
''' Contains the name of the extracted xml file if already extracted.
@@ -12,18 +16,37 @@ Public Class Exceptions
''' A filename like zugferd-invoice.xml
Public ReadOnly Property XmlFile As String = String.Empty
- Public Sub New(ErrorType As ZUGFeRDInterface.ErrorType, Message As String)
+ Public Sub New(pErrorCode As ErrorCodes, Message As String)
MyBase.New(Message)
- _ErrorType = ErrorType
+ _ErrorCode = pErrorCode
End Sub
- Public Sub New(ErrorType As ZUGFeRDInterface.ErrorType, Message As String, pXmlFileName As String)
+ Public Sub New(pErrorCode As ErrorCodes, Message As String, pXmlFileName As String)
MyBase.New(Message)
- _ErrorType = ErrorType
+ _ErrorCode = pErrorCode
_XmlFile = pXmlFileName
End Sub
+
+ Public Sub New(pErrorCode As ErrorCodes, Param1 As String, Param2 As String, Message As String)
+ MyBase.New(Message)
+
+ _ErrorCode = pErrorCode
+ _Param1 = Param1
+ _Param2 = Param2
+
+ End Sub
+
+ Public Sub New(pErrorCode As ErrorCodes, Param1 As String, Param2 As String, Message As String, pXmlFileName As String)
+ MyBase.New(Message)
+
+ _ErrorCode = pErrorCode
+ _Param1 = Param1
+ _Param2 = Param2
+ _XmlFile = pXmlFileName
+
+ End Sub
End Class
Public Class ValidationException
@@ -31,8 +54,13 @@ Public Class Exceptions
Public ValidationErrors As List(Of ZugferdValidationError)
+ Public Property ErrorCode() As ErrorCodes
+
Public Sub New()
MyBase.New("ZUGFeRD document found but validation failed!")
+
+ _ErrorCode = ErrorCodes.ValidationException
End Sub
+
End Class
End Class
diff --git a/Interfaces/ZUGFeRDInterface/RejectionStringRow.vb b/Interfaces/ZUGFeRDInterface/RejectionStringRow.vb
new file mode 100644
index 00000000..71fb9c1e
--- /dev/null
+++ b/Interfaces/ZUGFeRDInterface/RejectionStringRow.vb
@@ -0,0 +1,8 @@
+Public Class RejectionStringRow
+ Public ModuleName As String
+ Public Title As String
+ Public Caption As String
+ Public Language As String
+ Public String1 As String
+
+End Class
diff --git a/Interfaces/ZUGFeRDInterface/Validator.vb b/Interfaces/ZUGFeRDInterface/Validator.vb
index 8a4279d6..5a7e50e4 100644
--- a/Interfaces/ZUGFeRDInterface/Validator.vb
+++ b/Interfaces/ZUGFeRDInterface/Validator.vb
@@ -30,7 +30,7 @@ Public Class Validator
.ElementName = oNode.Name.LocalName,
.ElementValue = oNode.Value,
.ErrorMessage = "Value could not be parsed as Decimal.",
- .ErrorMessageDE = "Der Wert konnte nicht in eine Dezimalzahl umgewandelt werden."
+ .ErrorMessageDE = "Der Wert ist keine Dezimalzahl."
})
End If
Next
diff --git a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb
index 85552ae1..27292537 100644
--- a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb
+++ b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb
@@ -559,36 +559,46 @@ Public Class ImportZUGFeRDFiles
Try
oDocument = _zugferd.GetSerializedXMLContentFromFile(pFile)
+ oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_XML
Catch ex As ValidationException
Throw ex
Catch ex As ZUGFeRDExecption
- Select Case ex.ErrorType
- Case ZUGFeRDInterface.ErrorType.NoZugferd
- _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
- oResult.EmailAttachmentFiles.Add(pFile)
- Return oResult
+ If ex.ErrorCode > 0 Then
+ _logger.Info("New Rejection Logik")
- Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
- _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
- Throw New UnsupportedFerdException(ex.XmlFile)
+ Select Case ex.ErrorCode
+ Case ErrorCode.NoFerdsException
+ _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
- Case ZUGFeRDInterface.ErrorType.NoValidZugferd
- _logger.Info("File [{0}] is an Incorrectly formatted eInvoice document!", pFile.Name)
- Throw New InvalidFerdException()
+ oResult.EmailAttachmentFiles.Add(pFile)
+ Return oResult
- Case Else
- _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
- Throw ex
- End Select
+ Case ErrorCode.UnsupportedFerdException
+ _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
+ Throw New UnsupportedFerdException(ex.XmlFile)
+ Case ErrorCode.InvalidFerdException
+ _logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
+ Throw New InvalidFerdException()
+
+ Case Else
+ _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
+ Throw ex
+
+ End Select
+ End If
End Try
Try
- oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_XML
- Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
+ Dim sqlResult As Boolean = False
+
+ If oDocument IsNot Nothing Then
+ sqlResult = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
+ End If
+
Catch ex As Exception
Throw ex
End Try
@@ -631,30 +641,37 @@ Public Class ImportZUGFeRDFiles
Try
oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(pFile.FullName)
+ oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_PDF
Catch ex As ValidationException
Throw ex
Catch ex As ZUGFeRDExecption
- Select Case ex.ErrorType
- Case ZUGFeRDInterface.ErrorType.NoZugferd
- _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
+ If ex.ErrorCode > 0 Then
+ _logger.Info("New Rejection Logik")
- oResult.EmailAttachmentFiles.Add(pFile)
- Return oResult
+ Select Case ex.ErrorCode
+ Case ErrorCode.NoFerdsException
+ _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
- Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
- _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
- Throw New UnsupportedFerdException(ex.XmlFile)
+ oResult.EmailAttachmentFiles.Add(pFile)
+ Return oResult
- Case ZUGFeRDInterface.ErrorType.NoValidZugferd
- _logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
- Throw New InvalidFerdException()
+ Case ErrorCode.UnsupportedFerdException
+ _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
+ Throw New UnsupportedFerdException(ex.XmlFile)
+
+ Case ErrorCode.InvalidFerdException
+ _logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
+ Throw New InvalidFerdException()
+
+ Case Else
+ _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
+ Throw ex
+
+ End Select
+ End If
- Case Else
- _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
- Throw ex
- End Select
End Try
' Check if there are more than one ZUGFeRD files
@@ -677,7 +694,6 @@ Public Class ImportZUGFeRDFiles
End If
Try
- oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_PDF
Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
Catch ex As Exception
Throw ex