Fix loading documents for export by document type

This commit is contained in:
Jonathan Jenne 2022-03-04 10:48:43 +01:00
parent 7f817ffce1
commit c11cba9cf3

View File

@ -303,7 +303,7 @@ Namespace Winline
End Try End Try
End Function End Function
Public Function TryGetArticlePrice(pArticle As String, pAccountNumber As String, pQuantity As String, pDocumentDate As Date, pMandator As Mandator, pTemplate As Template) As Double Public Async Function TryGetArticlePrice(pArticle As String, pAccountNumber As String, pQuantity As String, pDocumentDate As Date, pMandator As Mandator, pTemplate As Template) As Task(Of Double)
Try Try
Dim oYear As Integer = Config.GetWinLineYear() Dim oYear As Integer = Config.GetWinLineYear()
Dim oSQL As String = $" Dim oSQL As String = $"
@ -322,7 +322,7 @@ Namespace Winline
'Multitool/{pTemplate.Name}', 'Multitool/{pTemplate.Name}',
'CalcPricing' 'CalcPricing'
" "
Dim oTable As DataTable = Database.GetDatatable(oSQL) Dim oTable As DataTable = Await Database.GetDatatableAsync(oSQL)
If oTable.Rows.Count = 0 Then If oTable.Rows.Count = 0 Then
Logger.Debug("Price for article [{0}] and Account [{1}] was not found in Mandator: [{2}]", pArticle, pAccountNumber, pMandator.Id) Logger.Debug("Price for article [{0}] and Account [{1}] was not found in Mandator: [{2}]", pArticle, pAccountNumber, pMandator.Id)
@ -574,28 +574,28 @@ Namespace Winline
Dim oTypeConstraint Dim oTypeConstraint
Select Case pDocumentType Select Case pDocumentType
Case DocumentType.OutgoingOffer Case DocumentType.OutgoingOffer
oTypeConstraint = $"T.c137 = 1 AND c139 = 1 AND "
Case DocumentType.OutgoingOffer
oTypeConstraint = $"T.c137 = 1 AND c139 = 2 AND "
Case DocumentType.OutgoingDeliveryNote
oTypeConstraint = $"T.c137 = 1 AND (c139 = 3 OR c139 = -3) AND "
Case DocumentType.OutgoingInvoice
oTypeConstraint = $"T.c137 = 1 AND c139 = 4 AND "
Case DocumentType.IncomingOffer
oTypeConstraint = $"T.c137 = 2 AND c139 = 1 AND " oTypeConstraint = $"T.c137 = 2 AND c139 = 1 AND "
Case DocumentType.IncomingOrder Case DocumentType.OutgoingOffer
oTypeConstraint = $"T.c137 = 2 AND c139 = 2 AND " oTypeConstraint = $"T.c137 = 2 AND c139 = 2 AND "
Case DocumentType.OutgoingDeliveryNote
oTypeConstraint = $"T.c137 = 2 AND (c139 = 3 OR c139 = -3) AND "
Case DocumentType.OutgoingInvoice
oTypeConstraint = $"T.c137 = 2 AND c139 = 4 AND "
Case DocumentType.IncomingOffer
oTypeConstraint = $"T.c137 = 3 AND c139 = 1 AND "
Case DocumentType.IncomingOrder
oTypeConstraint = $"T.c137 = 3 AND c139 = 2 AND "
Case DocumentType.IncomingDeliveryNote Case DocumentType.IncomingDeliveryNote
oTypeConstraint = $"T.c137 = 2 AND c139 = 3 AND " oTypeConstraint = $"T.c137 = 3 AND c139 = 3 AND "
Case DocumentType.IncomingInvoice Case DocumentType.IncomingInvoice
oTypeConstraint = $"T.c137 = 2 AND c139 = 4 AND " oTypeConstraint = $"T.c137 = 3 AND c139 = 4 AND "
Case Else Case Else
oTypeConstraint = "" oTypeConstraint = ""