Modules.Interface + Modules.Jobs: ITEM_TYPE = 4 / Description enthält jetzt BT-Feld-Info / Kommentare / Abfrage BT-Felder

This commit is contained in:
PitzM 2025-07-07 10:49:15 +02:00
parent 262805d112
commit e8ebc30225
4 changed files with 40 additions and 33 deletions

View File

@ -248,7 +248,7 @@ Public Class ZUGFeRDInterface
Throw ex Throw ex
Catch ex As Exception Catch ex As Exception
_logger.Warn("Error while validating ZUGFeRD file with GDPicture") _logger.Warn("Error while validating eInvoice file with GDPicture")
_logger.Error(ex) _logger.Error(ex)
Throw ex Throw ex
End Try End Try
@ -277,7 +277,7 @@ Public Class ZUGFeRDInterface
Throw ex Throw ex
Catch ex As Exception Catch ex As Exception
_logger.Warn("Error while validating ZUGFeRD file with GDPicture") _logger.Warn("Error while validating eInvoice file with GDPicture")
_logger.Error(ex) _logger.Error(ex)
Throw ex Throw ex
End Try End Try
@ -442,7 +442,7 @@ Public Class ZUGFeRDInterface
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
Dim oMessage = "Datei ist eine ungültige ZUGFeRD Datei oder das Format wird nicht unterstüzt, oder das Format ist deaktiviert." 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) Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, oMessage)
End Try End Try
End Function End Function

View File

@ -3,6 +3,6 @@
DateType '1 DateType '1
MoneyType '2 MoneyType '2
FileType '3 FileType '3
ListType '4 ListType '4 - vgl. Währung
End Enum End Enum

View File

@ -130,7 +130,7 @@ Public Class PropertyValues
End If End If
If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then
If oColumn.Key.IsRequired Then If oColumn.Key.IsRequired Then
_logger.Warn($"{MessageId} # oPropertyValue for column [{oTableColumn}] is empty or not found but is required. Continuing with Empty String.") _logger.Warn($"{MessageId} - oPropertyValue for column [{oTableColumn}] is empty or not found but is required. Continuing with Empty String.")
Dim oMissingProperty = New MissingProperty() With { Dim oMissingProperty = New MissingProperty() With {
.EN16931_ID = oEN16931Value, .EN16931_ID = oEN16931Value,
.Description = oPropertyDescription, .Description = oPropertyDescription,
@ -138,7 +138,7 @@ Public Class PropertyValues
} }
oResult.MissingProperties.Add(oMissingProperty) oResult.MissingProperties.Add(oMissingProperty)
Else Else
_logger.Debug($"{MessageId} # oPropertyValue for column [{oTableColumn}] is empty or not found. Continuing with Empty String.") _logger.Debug($"{MessageId} - oPropertyValue for column [{oTableColumn}] is empty or not found. Continuing with Empty String.")
End If End If
oPropertyValue = String.Empty oPropertyValue = String.Empty
@ -183,11 +183,12 @@ Public Class PropertyValues
Dim oIsRequired = oItem.Value.IsRequired Dim oIsRequired = oItem.Value.IsRequired
Dim oDescription = oItem.Value.Description Dim oDescription = oItem.Value.Description
Dim oItemType = oItem.Value.ItemType Dim oItemType = oItem.Value.ItemType
Dim oEN16931_ID = oItem.Value.EN16931_ID
Try Try
oPropertyValueList = GetPropValue(pDocument, oItem.Key) oPropertyValueList = GetPropValue(pDocument, oItem.Key)
Catch ex As Exception Catch ex As Exception
_logger.Warn("{2} # Unknown error occurred while fetching specification [{0}] in group [{1}]:", oTableColumn, oItem.Value.GroupScope, MessageId) _logger.Warn("{2} - Unknown error occurred while fetching specification [{0}] in group [{1}]:", oTableColumn, oItem.Value.GroupScope, MessageId)
_logger.Warn("ERROR-MESSAGE [{0}]", ex.Message) _logger.Warn("ERROR-MESSAGE [{0}]", ex.Message)
_logger.Error(ex) _logger.Error(ex)
oPropertyValueList = New List(Of Object) oPropertyValueList = New List(Of Object)
@ -219,7 +220,7 @@ Public Class PropertyValues
If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then
If oItem.Value.IsRequired Then If oItem.Value.IsRequired Then
_logger.Warn("{0} # Specification [{1}] is empty, but marked as required! Skipping.", MessageId, oTableColumn) _logger.Warn("Specification [{1}] is empty, but marked as required! Skipping.", oTableColumn)
Dim oMissingProperty = New MissingProperty With Dim oMissingProperty = New MissingProperty With
{ {
.Description = oPropertyDescription, .Description = oPropertyDescription,
@ -228,14 +229,14 @@ Public Class PropertyValues
oResult.MissingProperties.Add(oMissingProperty) oResult.MissingProperties.Add(oMissingProperty)
Continue For Continue For
Else Else
_logger.Debug("{0} # oPropertyValue for specification [{1}] is empty or not found. Skipping.", MessageId, oTableColumn) _logger.Debug("oPropertyValue for specification [{1}] is empty or not found. Skipping.", oTableColumn)
Continue For Continue For
End If End If
End If End If
' Statt dem Zahlenwert des Enums, wollen wir die Währunsgbezeichnung ' Statt dem Zahlenwert des Enums, wollen wir die Währungsbezeichnung
If oTableColumn = "INVOICE_CURRENCY" Then If oTableColumn = "INVOICE_CURRENCY" Or oItemType = 4 Then
oPropertyValue = oPropertyValue.ToString() oPropertyValue = oPropertyValue.ToString()
End If End If
@ -247,7 +248,8 @@ Public Class PropertyValues
.TableColumn = oTableColumn, .TableColumn = oTableColumn,
.IsRequired = oIsRequired, .IsRequired = oIsRequired,
.XMLPath = oPropertyPath, .XMLPath = oPropertyPath,
.ItemType = oItemType .ItemType = oItemType,
.EN16931_ID = oEN16931_ID
}) })
Next Next

View File

@ -166,8 +166,6 @@ Public Class ImportZUGFeRDFiles
' Start a new transaction for each file group. ' Start a new transaction for each file group.
' This way we can rollback database changes for the whole filegroup in case something goes wrong. ' This way we can rollback database changes for the whole filegroup in case something goes wrong.
Dim oSQLConnection As SqlConnection = _mssql.GetConnection() Dim oSQLConnection As SqlConnection = _mssql.GetConnection()
Dim oSQLTransaction As SqlTransaction = oSQLConnection?.BeginTransaction() Dim oSQLTransaction As SqlTransaction = oSQLConnection?.BeginTransaction()
Dim oConnections As New DatabaseConnections() With { Dim oConnections As New DatabaseConnections() With {
@ -220,7 +218,7 @@ Public Class ImportZUGFeRDFiles
End If End If
If oResult.ZugferdFileFound = True Then If oResult.ZugferdFileFound = True Then
_logger.Debug("Zugferd File found") _logger.Debug("eInvoice File found")
oMD5CheckSum = oResult.MD5Checksum oMD5CheckSum = oResult.MD5Checksum
oZUGFeRDCount = oResult.ZugferdFileCount oZUGFeRDCount = oResult.ZugferdFileCount
oEmailAttachmentFiles.AddRange(oResult.EmailAttachmentFiles) oEmailAttachmentFiles.AddRange(oResult.EmailAttachmentFiles)
@ -337,7 +335,7 @@ Public Class ImportZUGFeRDFiles
Dim oBody = String.Format(EmailStrings.EMAIL_TOO_MUCH_FERDS, oEmailData.Subject) Dim oBody = String.Format(EmailStrings.EMAIL_TOO_MUCH_FERDS, oEmailData.Subject)
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "TooMuchFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.TooMuchFerdsException, "", "") _email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "TooMuchFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.TooMuchFerdsException, "", "")
AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction) AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt mehr als ein eInvoice-Dokument", "", oSQLTransaction)
Catch ex As NoFerdsException Catch ex As NoFerdsException
_logger.Error(ex) _logger.Error(ex)
@ -350,7 +348,7 @@ Public Class ImportZUGFeRDFiles
Dim oBody = String.Format(EmailStrings.EMAIL_NO_FERDS, oEmailData.Subject) Dim oBody = String.Format(EmailStrings.EMAIL_NO_FERDS, oEmailData.Subject)
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.NoFerdsException, "", "") _email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.NoFerdsException, "", "")
AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction) AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt keine eInvoice-Dokumente", "", oSQLTransaction)
Catch ex As MissingValueException Catch ex As MissingValueException
_logger.Error(ex) _logger.Error(ex)
@ -369,7 +367,7 @@ Public Class ImportZUGFeRDFiles
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId) Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, oOrgFilename, oMissingFieldList) _email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, oOrgFilename, oMissingFieldList)
AddRejectedState(oMessageId, oRejectionCodeString, "Es fehlten ZugferdSpezifikationen", "", oSQLTransaction) AddRejectedState(oMessageId, oRejectionCodeString, "Es fehlten eInvoice-Spezifikationen", "", oSQLTransaction)
Catch ex As FileSizeLimitReachedException Catch ex As FileSizeLimitReachedException
_logger.Error(ex) _logger.Error(ex)
@ -402,7 +400,7 @@ Public Class ImportZUGFeRDFiles
Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex) Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex)
Dim oEmailData As New EmailData With { Dim oEmailData As New EmailData With {
.From = oArgs.ExceptionEmailAddress, .From = oArgs.ExceptionEmailAddress,
.Subject = $"OutOfMemoryException im ZUGFeRD-Parser @ {oMessageId}" .Subject = $"OutOfMemoryException im eInvoice-Parser @ {oMessageId}"
} }
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "OutOfMemoryException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace) _email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "OutOfMemoryException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace)
@ -425,7 +423,7 @@ Public Class ImportZUGFeRDFiles
Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex) Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex)
Dim oEmailData As New EmailData With { Dim oEmailData As New EmailData With {
.From = oArgs.ExceptionEmailAddress, .From = oArgs.ExceptionEmailAddress,
.Subject = $"UnhandledException im ZUGFeRD-Parser @ {oMessageId}" .Subject = $"UnhandledException im eInvoice-Parser @ {oMessageId}"
} }
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnhandledException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace) _email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnhandledException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace)
@ -481,7 +479,7 @@ Public Class ImportZUGFeRDFiles
Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex) Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex)
Dim oEmailData As New EmailData With { Dim oEmailData As New EmailData With {
.From = oArgs.ExceptionEmailAddress, .From = oArgs.ExceptionEmailAddress,
.Subject = $"FileMoveException im ZUGFeRD-Parser @ {oMessageId}" .Subject = $"FileMoveException im eInvoice-Parser @ {oMessageId}"
} }
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileMoveException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace) _email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileMoveException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace)
@ -567,21 +565,21 @@ Public Class ImportZUGFeRDFiles
Catch ex As ZUGFeRDExecption Catch ex As ZUGFeRDExecption
Select Case ex.ErrorType Select Case ex.ErrorType
Case ZUGFeRDInterface.ErrorType.NoZugferd Case ZUGFeRDInterface.ErrorType.NoZugferd
_logger.Info("File [{0}] is not a valid ZUGFeRD document. Skipping.", pFile.Name) _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
oResult.EmailAttachmentFiles.Add(pFile) oResult.EmailAttachmentFiles.Add(pFile)
Return oResult Return oResult
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
_logger.Info("File [{0}/{1}] is an unsupported ZUFeRD document format!", pFile.Name, ex.XmlFile) _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile) Throw New UnsupportedFerdException(ex.XmlFile)
Case ZUGFeRDInterface.ErrorType.NoValidZugferd Case ZUGFeRDInterface.ErrorType.NoValidZugferd
_logger.Info("File [{0}] is an Incorrectly formatted ZUGFeRD document!", pFile.Name) _logger.Info("File [{0}] is an Incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException() Throw New InvalidFerdException()
Case Else Case Else
_logger.Warn("Unexpected Error occurred while extracting ZUGFeRD Information from file {0}", pFile.Name) _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex Throw ex
End Select End Select
@ -639,21 +637,21 @@ Public Class ImportZUGFeRDFiles
Catch ex As ZUGFeRDExecption Catch ex As ZUGFeRDExecption
Select Case ex.ErrorType Select Case ex.ErrorType
Case ZUGFeRDInterface.ErrorType.NoZugferd Case ZUGFeRDInterface.ErrorType.NoZugferd
_logger.Info("File [{0}] is not a valid ZUGFeRD document. Skipping.", pFile.Name) _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
oResult.EmailAttachmentFiles.Add(pFile) oResult.EmailAttachmentFiles.Add(pFile)
Return oResult Return oResult
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
_logger.Info("File [{0}/{1}] is an unsupported ZUFeRD document format!", pFile.Name, ex.XmlFile) _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile) Throw New UnsupportedFerdException(ex.XmlFile)
Case ZUGFeRDInterface.ErrorType.NoValidZugferd Case ZUGFeRDInterface.ErrorType.NoValidZugferd
_logger.Info("File [{0}] is an Incorrectly formatted ZUGFeRD document!", pFile.Name) _logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException() Throw New InvalidFerdException()
Case Else Case Else
_logger.Warn("Unexpected Error occurred while extracting ZUGFeRD Information from file {0}", pFile.Name) _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex Throw ex
End Select End Select
End Try End Try
@ -1117,7 +1115,7 @@ Public Class ImportZUGFeRDFiles
' Erste Zeile enthält die Spezifikation ' Erste Zeile enthält die Spezifikation
Dim oFirstRow As DataRow = oDataTable.NewRow() Dim oFirstRow As DataRow = oDataTable.NewRow()
oFirstRow("REFERENCE_GUID") = pMessageId oFirstRow("REFERENCE_GUID") = pMessageId
oFirstRow("ITEM_DESCRIPTION") = "ZUGFeRDSpezifikation" oFirstRow("ITEM_DESCRIPTION") = "Verwendete Spezifikation der E-Rechnung"
oFirstRow("ITEM_VALUE") = pDocument.Specification oFirstRow("ITEM_VALUE") = pDocument.Specification
oFirstRow("GROUP_COUNTER") = 0 oFirstRow("GROUP_COUNTER") = 0
oFirstRow("SPEC_NAME") = "ZUGFERD_SPECIFICATION" oFirstRow("SPEC_NAME") = "ZUGFERD_SPECIFICATION"
@ -1129,7 +1127,7 @@ Public Class ImportZUGFeRDFiles
' Zweite Zeile enthält das verwendete XML Schema ' Zweite Zeile enthält das verwendete XML Schema
Dim oSecondRow As DataRow = oDataTable.NewRow() Dim oSecondRow As DataRow = oDataTable.NewRow()
oSecondRow("REFERENCE_GUID") = pMessageId oSecondRow("REFERENCE_GUID") = pMessageId
oSecondRow("ITEM_DESCRIPTION") = "ZUGFeRDXMLSchema" oSecondRow("ITEM_DESCRIPTION") = "Verwendetes XML-Schema (XSD) der E-Rechnung"
oSecondRow("ITEM_VALUE") = pDocument.UsedXMLSchema oSecondRow("ITEM_VALUE") = pDocument.UsedXMLSchema
oSecondRow("GROUP_COUNTER") = 0 oSecondRow("GROUP_COUNTER") = 0
oSecondRow("SPEC_NAME") = "ZUGFERD_XML_SCHEMA" oSecondRow("SPEC_NAME") = "ZUGFERD_XML_SCHEMA"
@ -1141,7 +1139,7 @@ Public Class ImportZUGFeRDFiles
' Dritte Zeile enthält das verwendete Datei-Format des Belegs (PDF/XML) ' Dritte Zeile enthält das verwendete Datei-Format des Belegs (PDF/XML)
Dim oThirdRow As DataRow = oDataTable.NewRow() Dim oThirdRow As DataRow = oDataTable.NewRow()
oThirdRow("REFERENCE_GUID") = pMessageId oThirdRow("REFERENCE_GUID") = pMessageId
oThirdRow("ITEM_DESCRIPTION") = "ReceiptFileType" oThirdRow("ITEM_DESCRIPTION") = "Dateityp der E-Rechnung"
oThirdRow("ITEM_VALUE") = pDocument.ReceiptFileType oThirdRow("ITEM_VALUE") = pDocument.ReceiptFileType
oThirdRow("GROUP_COUNTER") = 0 oThirdRow("GROUP_COUNTER") = 0
oThirdRow("SPEC_NAME") = "RECEIPT_FILE_TYPE" oThirdRow("SPEC_NAME") = "RECEIPT_FILE_TYPE"
@ -1174,9 +1172,16 @@ Public Class ImportZUGFeRDFiles
_logger.Warn("Value for field [{0}] is longer than 900 characters, will be truncated!", oProperty.TableColumn) _logger.Warn("Value for field [{0}] is longer than 900 characters, will be truncated!", oProperty.TableColumn)
End If End If
Dim oDescription As String
If oProperty.EN16931_ID IsNot Nothing AndAlso oProperty.EN16931_ID.Length > 1 Then
oDescription = oProperty.EN16931_ID + " (" + oProperty.Description + ")"
Else
oDescription = oProperty.Description
End If
Dim oNewRow As DataRow = oDataTable.NewRow() Dim oNewRow As DataRow = oDataTable.NewRow()
oNewRow("REFERENCE_GUID") = pMessageId oNewRow("REFERENCE_GUID") = pMessageId
oNewRow("ITEM_DESCRIPTION") = oProperty.Description oNewRow("ITEM_DESCRIPTION") = oDescription
oNewRow("ITEM_VALUE") = oProperty.Value.Truncate(900) oNewRow("ITEM_VALUE") = oProperty.Value.Truncate(900)
oNewRow("GROUP_COUNTER") = oGroupCounterValue oNewRow("GROUP_COUNTER") = oGroupCounterValue
oNewRow("SPEC_NAME") = oProperty.TableColumn oNewRow("SPEC_NAME") = oProperty.TableColumn