only mark fields with missing account as error if required, re-add selected field for checkboxes in file list, make automatic price calculation configurable

This commit is contained in:
Jonathan Jenne 2022-04-20 14:03:04 +02:00
parent 17d5f5ca1b
commit 1c3d5dd543
4 changed files with 31 additions and 12 deletions

View File

@ -5,4 +5,5 @@ Public Class Config
Public Property ConnectionString As String = ""
Public Property LastUsedMandator As String = ""
Public Property Debug As Boolean = False
Public Property AutomaticPriceCalculation As Boolean = True
End Class

View File

@ -21,9 +21,14 @@ Namespace Documents
Public Property Imported As Boolean = False
''' <summary>
''' This is used for saving the selected state via checkbox, don't remove!
''' </summary>
Public Property Selected As Boolean = False
Public ReadOnly Property HasErrors As Boolean
Get
Return Mandator Is Nothing Or Rows.Any(Function(r As DocumentRow) r.HasErrors)
Return Errors.Count > 0
End Get
End Property

View File

@ -15,6 +15,7 @@ Namespace Documents
Private ReadOnly Winline As WinlineData
Private ReadOnly MappingConfig As MappingConfig
Private ReadOnly TemplateConfig As TemplateConfig
Private ReadOnly ApplicationConfig As Config
Public Property Files As New List(Of Document)
@ -44,11 +45,12 @@ Namespace Documents
End Sub
End Class
Public Sub New(pLogConfig As LogConfig, pWinline As WinlineData, pMappingConfig As MappingConfig, pTemplateConfig As TemplateConfig)
Public Sub New(pLogConfig As LogConfig, pWinline As WinlineData, pMappingConfig As MappingConfig, pTemplateConfig As TemplateConfig, pApplicationConfig As Config)
MyBase.New(pLogConfig)
Winline = pWinline
MappingConfig = pMappingConfig
TemplateConfig = pTemplateConfig
ApplicationConfig = pApplicationConfig
End Sub
Public Async Function LoadFiles(pTemplate As Template, pMandator As Mandator) As Task(Of Boolean)
@ -273,8 +275,10 @@ Namespace Documents
.RunningFunction = "Preis-Funktionen"
})
' These functions will only be applied if the document does not have errors
pDocument = Await MaybeApplyPriceFunctions(pDocument, oMandator, pTemplate)
If ApplicationConfig.AutomaticPriceCalculation = True Then
' These functions will only be applied if the document does not have errors
pDocument = Await MaybeApplyPriceFunctions(pDocument, oMandator, pTemplate)
End If
RaiseEvent FileLoadProgress(Me, New FileLoadProgressInfo(FilesTotal, FilesLoaded) With {
.RunningFunction = "Feld-Funktionen"
@ -567,7 +571,11 @@ Namespace Documents
'})
End If
Else
oNumberItem.Error = FieldError.AccountNotFound
' If no account was found and the field is required,
' mark it as error. Otherwise, do nothing.
If oNumberItem.IsRequired Then
oNumberItem.Error = FieldError.AccountNotFound
End If
End If
End Sub

View File

@ -91,7 +91,7 @@ Public Class frmImportMain
lookupMandator.ForceInitialize()
lookupMandator.Properties.View.BestFitColumns()
DocumentLoader = New Documents.DocumentLoader(LogConfig, Winline, My.MappingConfiguration, My.TemplateConfiguration)
DocumentLoader = New Documents.DocumentLoader(LogConfig, Winline, My.MappingConfiguration, My.TemplateConfiguration, ConfigManager.Config)
DocumentCleaner = New Documents.DocumentCleaner(LogConfig, CurrentTemplate)
GridLoader = New GridLoader(LogConfig)
@ -600,19 +600,21 @@ Public Class frmImportMain
Next
txtCurrentFile.Caption = String.Format(My.Resources.frmImportMainExtra.Aktuelle_Datei___0_, pDocument.FileName)
txtErrors.Caption = String.Format("Fehler: {0}", pDocument.Errors.Count)
CurrentDocument = pDocument
If pDocument.Errors.Count > 0 Then
txtErrors.Caption = String.Format("Fehler: {0}", pDocument.Errors.Count)
txtErrors.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
Else
txtErrors.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End If
SetDocumentButtonsEnabled(True)
If CurrentDocument.HasErrors = True Then
If pDocument.HasErrors = True Then
btnCalculatePrices.Enabled = False
Else
btnCalculatePrices.Enabled = True
End If
If CurrentDocument.Mandator Is Nothing Then
If pDocument.Mandator Is Nothing Then
RibbonPageGroupEdit.Enabled = False
RibbonPageGroupTransfer.Enabled = False
CurrentDocumentReadOnly = True
@ -624,6 +626,9 @@ Public Class frmImportMain
CurrentDocumentReadOnly = False
End If
CurrentDocument = pDocument
SetDocumentButtonsEnabled(True)
Catch ex As Exception
SetDocumentButtonsEnabled(False)
Logger.Error(ex)