diff --git a/Interfaces/ZUGFeRDInterface.vb b/Interfaces/ZUGFeRDInterface.vb index 6aa01922..f2bc7431 100644 --- a/Interfaces/ZUGFeRDInterface.vb +++ b/Interfaces/ZUGFeRDInterface.vb @@ -5,6 +5,7 @@ Imports System.Xml.XPath Imports System.Xml.Xsl Imports DigitalData.Modules.Interfaces.Exceptions Imports DigitalData.Modules.Interfaces.ZUGFeRD +Imports DigitalData.Modules.Interfaces.ZUGFeRDInterface Imports DigitalData.Modules.Logging Imports GdPicture14 @@ -101,6 +102,17 @@ Public Class ZUGFeRDInterface AllowedFilenames = oAllowedFilenames End Sub + Public Function FilterPropertyMap(pPropertyMap As Dictionary(Of String, XmlItemProperty), pSpecification As String) As Dictionary(Of String, XmlItemProperty) + If pSpecification = ZUGFERD_SPEC_10 Then + Return pPropertyMap. + Where(Function(kv) kv.Value.Specification = pSpecification Or kv.Value.Specification = ZUGFERD_SPEC_DEFAULT). + ToDictionary(Function(kv) kv.Key, Function(kv) kv.Value) + Else + Return pPropertyMap. + Where(Function(kv) kv.Value.Specification = pSpecification). + ToDictionary(Function(kv) kv.Key, Function(kv) kv.Value) + End If + End Function ''' ''' Validates a ZUGFeRD File and extracts the XML Document from it diff --git a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb index 50c8a7c8..5ffe0cb9 100644 --- a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -299,7 +299,8 @@ Public Class ImportZUGFeRDFiles ' Check the document against the configured property map and return: ' - a List of valid properties ' - a List of missing properties - Dim oPropertyMap = GetPropertyMapFor(oArgs, oDocument.Specification) + + Dim oPropertyMap = _zugferd.FilterPropertyMap(oArgs.PropertyMap, oDocument.Specification) Dim oCheckResult = _zugferd.PropertyValues.CheckPropertyValues(oDocument.SchemaObject, oPropertyMap, oMessageId) _logger.Info("Properties checked: [{0}] missing properties / [{1}] valid properties found.", oCheckResult.MissingProperties.Count, oCheckResult.ValidProperties.Count) @@ -619,20 +620,6 @@ Public Class ImportZUGFeRDFiles _firebird.ExecuteNonQueryWithConnection(oCommand, pConnections.FirebirdConnection, Firebird.TransactionMode.ExternalTransaction, pConnections.FirebirdTransaction) End Sub - Private Function GetPropertyMapFor(pWorkerArgs As WorkerArgs, pSpecification As String) As Dictionary(Of String, XmlItemProperty) - Dim oPropertyMap = DoGetPropertyMapFor(pWorkerArgs, pSpecification) - - _logger.Debug("Found [{0}] Properties for Specification [{1}].", oPropertyMap.Count, pSpecification) - - ' If no properties were found, fall back to the default specification before giving up - If oPropertyMap.Count = 0 Then - _logger.Warn("No Properties found for Specification [{0}]. Loading default property map!", pSpecification) - Return DoGetPropertyMapFor(pWorkerArgs, ZUGFeRDInterface.ZUGFERD_SPEC_DEFAULT) - End If - - Return oPropertyMap - End Function - Private Function DoGetPropertyMapFor(pWorkerArgs As WorkerArgs, pSpecification As String) As Dictionary(Of String, XmlItemProperty) Return pWorkerArgs.PropertyMap. Where(Function(kv) kv.Value.Specification = pSpecification).