Modules.Interfaces & Modules.Jobs: Neue eInvoice Spezifikation "ebInterface 6.1" implementiert

Logik zum Abfragen von Attributen von root ergänzt
This commit is contained in:
2026-09-07 16:59:58 +02:00
parent 4dc454403b
commit 676b43bbe1
6 changed files with 3550 additions and 3 deletions

View File

@@ -275,6 +275,121 @@ Public Class PropertyValues
Return oResult
End Function
Public Function CheckRootAttributeValues(pDocument As Object, pPropertyMap As Dictionary(Of String, XmlItemProperty), pMessageId As String, pCheckResult As CheckPropertyValuesResult) As CheckPropertyValuesResult
If pPropertyMap Is Nothing Then
Return pCheckResult
End If
' PropertyMap items with `IsGrouped = False` are handled normally
Dim oRootAttributeProperties As Dictionary(Of String, XmlItemProperty) = pPropertyMap.
ToDictionary(Function(Item) Item.Key,
Function(Item) Item.Value)
For Each oItem As KeyValuePair(Of String, XmlItemProperty) In oRootAttributeProperties
Dim oTableColumn As String = oItem.Value.TableColumn
Dim oPropertyDescription As String = oItem.Value.Description
Dim oPropertyPath As String = oItem.Value.XMLPath
Dim oPropertyValue As Object = Nothing
Dim oTableName = oItem.Value.TableName
Dim oIsRequired = oItem.Value.IsRequired
Dim oDescription = oItem.Value.Description
Dim oItemType = oItem.Value.ItemType
Dim oEN16931_ID = oItem.Value.EN16931_ID
Try
oPropertyValue = GetRootAttributeValue(pDocument, oItem.Key)
Catch ex As Exception
_logger.Error(ex)
oPropertyValue = Nothing
End Try
If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then
If oItem.Value.IsRequired Then
_logger.Warn("Column [{0}] is empty, but marked as required! Adding MissingProperty.", oTableColumn)
Dim oMissingProperty = New MissingProperty With
{
.EN16931_ID = oEN16931_ID,
.Description = oPropertyDescription,
.XMLPath = oPropertyPath
}
pCheckResult.MissingProperties.Add(oMissingProperty)
Continue For
Else
_logger.Debug("oPropertyValue for Column [{0}] is empty or not found. Skipping.", oTableColumn)
Continue For
End If
End If
If pDocument.Specification = "EBINTERFACE_61" Then
' ebInterface DocumentType in UNTDID 1001 — Document type
If oTableColumn = "INVOICE_TYPE" Then
oPropertyValue = GetUNTDID1001_DocumentType(oPropertyValue)
End If
End If
pCheckResult.ValidProperties.Add(New ValidProperty() With {
.MessageId = pMessageId,
.Description = oPropertyDescription,
.Value = oPropertyValue,
.GroupCounter = 0,
.TableName = oTableName,
.TableColumn = oTableColumn,
.IsRequired = oIsRequired,
.XMLPath = oPropertyPath,
.ItemType = oItemType,
.EN16931_ID = oEN16931_ID
})
Next
Return pCheckResult
End Function
Private Function GetUNTDID1001_DocumentType(oPropertyValue As String) As String
Select Case oPropertyValue
Case "CreditMemo"
Return 1
Case "FinalSettlement"
Return 1
Case "Invoice"
Return 380
Case "InvoiceForAdvancePayment"
Return 1
Case "InvoiceForPartialDelivery"
Return 1
Case "SelfBilling"
Return 1
Case "SubsequentCredit"
Return 1
Case "SubsequentDebit"
Return 1
Case Else
Return 380
End Select
End Function
Private Function GetRootAttributeValue(pDocument As Object, pXmlPath As String) As String
If pDocument.XElementObject Is Nothing Then
Return Nothing
End If
Try
Dim attributeName As String = pXmlPath.Replace("root.", "")
Dim attributeValue As String = pDocument.XElementObject.Attribute(attributeName).Value
Return attributeValue
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Public Function GetPropValue(Obj As Object, PropertyName As String) As List(Of Object)
Dim oNameParts As String() = PropertyName.Split("."c)