fix bug in Runningnumber versioning, improve handling of optional fields with functions

This commit is contained in:
Jonathan Jenne
2022-05-13 15:03:25 +02:00
parent e168c65ca9
commit dc657c32a5
2 changed files with 35 additions and 21 deletions

View File

@@ -536,7 +536,7 @@ Namespace Winline
AND [mesocomp] = '{pMandator.Id}' AND [mesoyear] = {oYear}"
Dim oTable As DataTable = Database.GetDatatable(oSQL)
' EAN not found in this Mandator, continue to next one
' EAN not found in this Mandator
If oTable.Rows.Count = 0 Then
Logger.Debug("EAN [{0}] was not found in Mandator: [{1}]", pEAN, pMandator.Id)
Return Nothing
@@ -941,10 +941,10 @@ Namespace Winline
Logger.Debug("Running number [{0}] does not exist yet. Returning.", pRunningNumber)
Return pRunningNumber
Else
Logger.Debug("Running number [{0}] already exists. Checking again.")
Logger.Debug("Running number [{0}] already exists. Checking again.", pRunningNumber)
Dim oVersionResult = FileEx.GetVersionedString(pRunningNumber, "~"c)
Dim oFinalLength As Integer = oVersionResult.Item1.Count + oVersionResult.Item2.ToString.Count + 1
Dim oNewVersion = oVersionResult.Item2 + 1
Dim oFinalLength As Integer = oVersionResult.Item1.Count + oNewVersion.ToString.Count + 1
If oFinalLength > RunningNumberMaximumLength Then
Logger.Warn("Running number is too long ({0} chars total) and cannot be versioned. Versioning needs at least 2 characters.", oFinalLength)
@@ -952,7 +952,7 @@ Namespace Winline
Return pRunningNumber
End If
Return Await GetVersionedRunningNumberAsync(pDocument, pMandator, pAccountNumber, $"{oVersionResult.Item1}~{oVersionResult.Item2}")
Return Await GetVersionedRunningNumberAsync(pDocument, pMandator, pAccountNumber, $"{oVersionResult.Item1}~{oNewVersion}")
End If
Catch ex As MultiToolException