From 143823aae21fb505620e3fc3c8b93f94a89c2f1d Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 24 May 2022 16:10:34 +0200 Subject: [PATCH] First attempt at fixing documenttype dependent export status --- .../Winline/Entities/ExportDocument.vb | 10 ++++-- MultiTool.Common/Winline/WinlineData.vb | 33 ++++++++++++++++--- MultiTool.Form/frmExportMain.vb | 2 -- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/MultiTool.Common/Winline/Entities/ExportDocument.vb b/MultiTool.Common/Winline/Entities/ExportDocument.vb index df37c67..3967abd 100644 --- a/MultiTool.Common/Winline/Entities/ExportDocument.vb +++ b/MultiTool.Common/Winline/Entities/ExportDocument.vb @@ -1,4 +1,6 @@ -Namespace Winline.Entities +Imports MultiTool.Common.Winline.WinlineData + +Namespace Winline.Entities Public Class ExportDocument Public Property Schema As Templates.Template @@ -9,6 +11,9 @@ End Get End Property + + + Public Property Kind As DocumentKind Public Property RunningNumber As String Public Property Number As String @@ -18,8 +23,9 @@ Public Property GrossAmount As Double Public Property IsSelected As Boolean = False - Public Property IsExported As Boolean = False + Public Property IsExported As Boolean + Public Property ExportType As Integer Public Property FilenameExport As String Public Property ExportedWhen As Date Public Property ExportedWho As String diff --git a/MultiTool.Common/Winline/WinlineData.vb b/MultiTool.Common/Winline/WinlineData.vb index df1adb9..889b6a3 100644 --- a/MultiTool.Common/Winline/WinlineData.vb +++ b/MultiTool.Common/Winline/WinlineData.vb @@ -896,7 +896,7 @@ Namespace Winline For Each oRow As DataRow In oTable.Rows Try - Dim oDocument = GetDocumentFromDataRow(oRow) + Dim oDocument = GetDocumentFromDataRow(oRow, pDocumentType) oDocument.Schema = pTemplate oDocuments.Add(oDocument) @@ -1001,17 +1001,20 @@ Namespace Winline End Try End Function - Private Function GetDocumentFromDataRow(pDataRow As DataRow) As ExportDocument + Private Function GetDocumentFromDataRow(pDataRow As DataRow, pDocumentType As DocumentType) As ExportDocument Dim oAccountNumber = pDataRow.Item("ACCOUNT_NUMBER") Dim oRunningNumber As String = pDataRow.Item("RUNNING_NUMBER") Dim oDocumentType As Integer = pDataRow.Item("DOCUMENT_TYPE") Dim oDocumentKind As Integer = pDataRow.Item("DOCUMENT_KIND") Dim oGrossAmount As Double = pDataRow.Item("GROSS_AMOUNT") Dim oNetAmount As Double = pDataRow.Item("NET_AMOUNT") - Dim oExported As Boolean = pDataRow.ItemEx("ALREADY_EXPORTED", False) + + Dim oExportedType As Integer = pDataRow.ItemEx("ALREADY_EXPORTED", 0) Dim oExportedWho As String = pDataRow.ItemEx("EXPORTED_WHO", "") Dim oExportedWhen As Date = pDataRow.ItemEx(Of Date)("EXPORTED_WHEN", Nothing) Dim oExportFile As String = pDataRow.ItemEx("EXPORTED_FILE", "") + Dim oDocumentType2 As Integer = 0 + Dim oIsExported As Boolean = False Dim oDocumentNumber As String = Nothing Dim oDocumentDate As Date = Nothing @@ -1030,21 +1033,40 @@ Namespace Winline oDocumentNumber = pDataRow.Item("OFFER_NUMBER") oDocumentDate = pDataRow.Item("OFFER_DATE") oDocumentDateColumn = "c027" + oDocumentType2 = Math.Abs(oDocumentType) + Case 2, -2 oDocumentNumber = pDataRow.Item("ORDER_NUMBER") oDocumentDate = pDataRow.Item("ORDER_DATE") oDocumentDateColumn = "c028" + oDocumentType2 = Math.Abs(oDocumentType) + Case 3, -3 oDocumentNumber = pDataRow.Item("DELIVERY_NUMBER") oDocumentDate = pDataRow.Item("DELIVERY_DATE") oDocumentDateColumn = "c029" + oDocumentType2 = Math.Abs(oDocumentType) + Case 4, -4 oDocumentNumber = pDataRow.Item("INVOICE_NUMBER") oDocumentDate = pDataRow.Item("INVOICE_DATE") oDocumentDateColumn = "c032" + oDocumentType2 = Math.Abs(oDocumentType) End Select + '--- + If oExportedType = 1 AndAlso (pDocumentType = DocumentType.IncomingOffer Or pDocumentType = DocumentType.OutgoingOffer) Then + oIsExported = True + ElseIf oExportedType = 2 AndAlso (pDocumentType = DocumentType.IncomingOrder Or pDocumentType = DocumentType.OutgoingOrder) Then + oIsExported = True + ElseIf oExportedType = 3 AndAlso (pDocumentType = DocumentType.IncomingDeliveryNote Or pDocumentType = DocumentType.OutgoingDeliveryNote) Then + oIsExported = True + ElseIf oExportedType = 4 AndAlso (pDocumentType = DocumentType.IncomingInvoice Or pDocumentType = DocumentType.OutgoingInvoice) Then + oIsExported = True + End If + '--- + Dim oDocument As New ExportDocument With { .Account = oAccount, .RunningNumber = oRunningNumber, @@ -1054,10 +1076,11 @@ Namespace Winline .Kind = oKind, .GrossAmount = oGrossAmount, .NetAmount = oNetAmount, - .IsExported = oExported, .ExportedWhen = oExportedWhen, .ExportedWho = oExportedWho, - .FilenameExport = oExportFile + .FilenameExport = oExportFile, + .ExportType = oDocumentType2, + .IsExported = oIsExported } Return oDocument diff --git a/MultiTool.Form/frmExportMain.vb b/MultiTool.Form/frmExportMain.vb index fddb9d1..0dbfc46 100644 --- a/MultiTool.Form/frmExportMain.vb +++ b/MultiTool.Form/frmExportMain.vb @@ -244,8 +244,6 @@ Public Class frmExportMain If oFinalSqlResult = False Then Throw New DatabaseException("FinalSQL was not executed successfully!") End If - - oDocument.IsExported = True Next MsgBox($"{oExportCount} Dateien wurden erfolgreich exportiert!", MsgBoxStyle.Information, Text)