Compare commits
3 Commits
b6801ab486
...
aff92e2b34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aff92e2b34 | ||
|
|
648666ef8c | ||
|
|
8180c65ccd |
@@ -5,7 +5,6 @@ Imports MultiTool.Common.Winline.Entities
|
||||
Namespace Documents
|
||||
Public Class Document
|
||||
Public File As FileInfo
|
||||
Public Property Type As DocumentType
|
||||
Public Schema As Template
|
||||
Public Mandator As Mandator
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
Namespace Documents
|
||||
Public Enum DocumentType
|
||||
Order ' Auftrag
|
||||
OrderResponse ' Bestellbestätigung
|
||||
DispatchNotification ' Lieferavis/ Eingangs Lieferschein
|
||||
Invoice ' Rechnung
|
||||
End Enum
|
||||
End Namespace
|
||||
@@ -107,7 +107,6 @@
|
||||
<Compile Include="Documents\Document.vb" />
|
||||
<Compile Include="Documents\DocumentCleaner.vb" />
|
||||
<Compile Include="Documents\DocumentRow.vb" />
|
||||
<Compile Include="Documents\DocumentType.vb" />
|
||||
<Compile Include="Documents\DocumentLoader.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="IDictionaryEx.vb" />
|
||||
@@ -140,6 +139,7 @@
|
||||
<Compile Include="Report\ReportPosition.vb" />
|
||||
<Compile Include="Report\ReportSource.vb" />
|
||||
<Compile Include="Winline\Entities\ExportDocument.vb" />
|
||||
<Compile Include="Winline\Entities\PackingUnit.vb" />
|
||||
<Compile Include="Winline\Entities\Response.vb" />
|
||||
<Compile Include="Templates\Template.vb" />
|
||||
<Compile Include="Templates\TemplateLoader.vb" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports MultiTool.Common.Winline.WinlineData
|
||||
|
||||
Namespace Templates
|
||||
|
||||
@@ -21,6 +22,41 @@ Namespace Templates
|
||||
Public Property OutputDirectory As String
|
||||
Public Property ArchiveDirectory As String
|
||||
|
||||
Public ReadOnly Property DocType As DocumentType
|
||||
Get
|
||||
Dim oDocType As String = GetParameter("DOCTYPE")
|
||||
Dim oPreselectedDocType As Integer = 0
|
||||
|
||||
If oDocType IsNot Nothing Then
|
||||
Integer.TryParse(oDocType, oPreselectedDocType)
|
||||
End If
|
||||
|
||||
Return [Enum].Parse(GetType(DocumentType), oPreselectedDocType)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property DocTypeCategory As DocumentTypeCategory
|
||||
Get
|
||||
Select Case DocType
|
||||
Case DocumentType.IncomingOffer,
|
||||
DocumentType.IncomingOrder,
|
||||
DocumentType.IncomingDeliveryNote,
|
||||
DocumentType.IncomingInvoice
|
||||
Return DocumentTypeCategory.Outgoing
|
||||
|
||||
Case DocumentType.OutgoingOffer,
|
||||
DocumentType.OutgoingOrder,
|
||||
DocumentType.OutgoingDeliveryNote,
|
||||
DocumentType.OutgoingInvoice
|
||||
Return DocumentTypeCategory.Incoming
|
||||
|
||||
Case Else
|
||||
Return DocumentTypeCategory.Undefined
|
||||
|
||||
End Select
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property OutputReportDirectory
|
||||
Get
|
||||
Return IO.Path.Combine(OutputDirectory, "Reports")
|
||||
@@ -39,6 +75,7 @@ Namespace Templates
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
Public Function GetParameter(pName As String) As String
|
||||
Dim oParam1 As String = Utils.NotNull(Parameter1, String.Empty)
|
||||
Dim oParam2 As String = Utils.NotNull(Parameter2, String.Empty)
|
||||
|
||||
@@ -259,21 +259,25 @@ Namespace Templates
|
||||
End Function
|
||||
|
||||
Private Function CreateVirtualColumns(pTemplate As Template, pTemplateConfig As TemplateConfig) As Template
|
||||
For Each oConfigItem In pTemplateConfig.Items
|
||||
Dim oTemplateItems = pTemplateConfig.Items.
|
||||
Where(Function(item) item.Template = pTemplate.Name).
|
||||
ToList()
|
||||
|
||||
For Each oItem In oTemplateItems
|
||||
' Find the table that relates to this config item
|
||||
Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oConfigItem.Table).FirstOrDefault()
|
||||
Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oItem.Table).FirstOrDefault()
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Table [{0}] for item [{1}] does exist in this Template!", oConfigItem.Table, oConfigItem.Name)
|
||||
Logger.Warn("Table [{0}] for item [{1}] does exist in this Template!", oItem.Table, oItem.Name)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oColumnExists = oTable.Columns.Any(Function(column) column.Name = oConfigItem.Name)
|
||||
Dim oColumnExists = oTable.Columns.Any(Function(column) column.Name = oItem.Name)
|
||||
|
||||
If oColumnExists = False And oConfigItem.IsVirtual = True Then
|
||||
If oColumnExists = False And oItem.IsVirtual = True Then
|
||||
oTable.Columns.Add(New Template.Column() With {
|
||||
.Name = oConfigItem.Name,
|
||||
.Config = oConfigItem,
|
||||
.Name = oItem.Name,
|
||||
.Config = oItem,
|
||||
.DataType = Constants.ColumnType.String,
|
||||
.IsRequired = False
|
||||
})
|
||||
|
||||
25
MultiTool.Common/Winline/Entities/PackingUnit.vb
Normal file
25
MultiTool.Common/Winline/Entities/PackingUnit.vb
Normal file
@@ -0,0 +1,25 @@
|
||||
Namespace Winline.Entities
|
||||
Public Class PackingUnit
|
||||
Public Property Name As String
|
||||
Public Property Description As String
|
||||
Public Property Description2 As String
|
||||
Public Property Unit As Integer
|
||||
Public Property Factor As Decimal
|
||||
Public Property Flag As Integer
|
||||
|
||||
Public Property Mandator As Mandator
|
||||
|
||||
Public Overrides Function GetHashCode() As Integer
|
||||
Return Name.GetHashCode()
|
||||
End Function
|
||||
|
||||
Public Overrides Function Equals(obj As Object) As Boolean
|
||||
Return DirectCast(obj, PackingUnit).Name = Name
|
||||
End Function
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return Name
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -17,6 +17,7 @@ Namespace Winline
|
||||
|
||||
Public Property Articles As New List(Of Article)
|
||||
Public Property Accounts As New List(Of Account)
|
||||
Public Property PackingUnits As New List(Of PackingUnit)
|
||||
Public Property Mandators As New List(Of Mandator)
|
||||
Public Property DocumentKinds As New List(Of DocumentKind)
|
||||
|
||||
@@ -30,16 +31,27 @@ Namespace Winline
|
||||
MappingConfig = pMappingConfig
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Winline Doctype.
|
||||
'''
|
||||
''' Used for filtering Documents when exporting and determining the type of document (sales/purchasing)
|
||||
''' </summary>
|
||||
Public Enum DocumentType
|
||||
Undefined
|
||||
OutgoingOffer
|
||||
OutgoingOrder
|
||||
OutgoingDeliveryNote
|
||||
OutgoingInvoice
|
||||
IncomingOffer
|
||||
IncomingOrder
|
||||
IncomingDeliveryNote
|
||||
IncomingInvoice
|
||||
Undefined = 0
|
||||
OutgoingOffer = 1
|
||||
OutgoingOrder = 2
|
||||
OutgoingDeliveryNote = 3
|
||||
OutgoingInvoice = 4
|
||||
IncomingOffer = 5
|
||||
IncomingOrder = 6
|
||||
IncomingDeliveryNote = 7
|
||||
IncomingInvoice = 8
|
||||
End Enum
|
||||
|
||||
Public Enum DocumentTypeCategory
|
||||
Undefined = 0
|
||||
Outgoing = 1
|
||||
Incoming = 2
|
||||
End Enum
|
||||
|
||||
Public Class GetDocumentArgs
|
||||
@@ -93,6 +105,57 @@ Namespace Winline
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadPackingUnits(pMandator As Mandator) As Task
|
||||
Logger.Info("Loading Packing Units for Mandator [{0}]", pMandator)
|
||||
Dim oYear = Config.GetWinLineYear()
|
||||
|
||||
Try
|
||||
Dim oSQL = $"
|
||||
SELECT DISTINCT
|
||||
[c002], -- Name
|
||||
[c003], -- Description
|
||||
[c004], -- Description 2
|
||||
[c005], -- Unit
|
||||
[c006], -- Value/Factor
|
||||
[c007] -- Flag (?)
|
||||
FROM [{pMandator.Server}].[{pMandator.Database}].[dbo].[t346]
|
||||
WHERE
|
||||
mesocomp = '{pMandator.Id}'
|
||||
AND mesoyear = {oYear}"
|
||||
Dim oTable = Await Database.GetDatatableAsync(oSQL)
|
||||
Dim oPackingUnits As New List(Of PackingUnit)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oName As String = ItemEx(oRow, "c002", String.Empty)
|
||||
Dim oDescription As String = ItemEx(oRow, "c003", String.Empty)
|
||||
Dim oDescription2 As String = ItemEx(oRow, "c004", String.Empty)
|
||||
Dim oUnit As Decimal = ItemEx(oRow, "c005", 0.0)
|
||||
Dim oFactor As Decimal = ItemEx(oRow, "c006", 0.0)
|
||||
Dim oFlag As Integer = ItemEx(oRow, "c007", 0)
|
||||
|
||||
oPackingUnits.Add(New PackingUnit With {
|
||||
.Name = oName,
|
||||
.Description = oDescription,
|
||||
.Description2 = oDescription2,
|
||||
.Unit = oUnit,
|
||||
.Factor = oFactor,
|
||||
.Flag = oFlag,
|
||||
.Mandator = pMandator
|
||||
})
|
||||
Next
|
||||
PackingUnits.AddRange(oPackingUnits)
|
||||
|
||||
If oPackingUnits.Count = 0 Then
|
||||
Logger.Warn("No Packing Units loaded for Mandator [{0}]", pMandator)
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] Packing Units loaded for Mandator [{1}]", oPackingUnits.Count, pMandator)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not load Packing Units for Mandator [{0}]", pMandator)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadAccounts(pMandator As Mandator) As Task
|
||||
Logger.Info("Loading Accounts for Mandator [{0}]", pMandator)
|
||||
Dim oYear = Config.GetWinLineYear()
|
||||
@@ -370,6 +433,11 @@ Namespace Winline
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oPrice As Double = oRow.Item("PRICE")
|
||||
Dim oPackingUnit As PackingUnit = MaybeGetPackingUnit(pTemplate, oRow, pMandator)
|
||||
|
||||
If oPackingUnit IsNot Nothing AndAlso oPackingUnit.Factor > 0 Then
|
||||
oPrice *= oPackingUnit.Factor
|
||||
End If
|
||||
|
||||
Return oPrice
|
||||
|
||||
@@ -381,6 +449,30 @@ Namespace Winline
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function MaybeGetPackingUnit(pTemplate As Template, oRow As DataRow, pMandator As Mandator) As PackingUnit
|
||||
Dim oPackingUnit As PackingUnit = Nothing
|
||||
|
||||
Select Case pTemplate.DocTypeCategory
|
||||
Case DocumentTypeCategory.Incoming
|
||||
Dim oPackingUnitPurchasingName = oRow.ItemEx("PACKINGUNIT_PURCHASING", "")
|
||||
Dim oPackingUnitPurchasing = PackingUnits.
|
||||
Where(Function(unit) unit.Name.Equals(oPackingUnitPurchasingName) And unit.Mandator.Equals(pMandator)).
|
||||
FirstOrDefault()
|
||||
|
||||
oPackingUnit = oPackingUnitPurchasing
|
||||
|
||||
Case DocumentTypeCategory.Outgoing
|
||||
Dim oPackingUnitSalesName = oRow.ItemEx("PACKINGUNIT_SALES", "")
|
||||
Dim oPackingUnitSales = PackingUnits.
|
||||
Where(Function(unit) unit.Name.Equals(oPackingUnitSalesName) And unit.Mandator.Equals(pMandator)).
|
||||
FirstOrDefault()
|
||||
|
||||
oPackingUnit = oPackingUnitSales
|
||||
End Select
|
||||
|
||||
Return oPackingUnit
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' This function is completely SCHAUM related.
|
||||
''' </summary>
|
||||
|
||||
@@ -89,14 +89,7 @@ Public Class frmExportMain
|
||||
Cast(Of WinlineData.DocumentType)().
|
||||
Select(AddressOf MapDocumentTypeFromEnum).
|
||||
ToList()
|
||||
|
||||
Dim oDocType = CurrentTemplate.GetParameter("DOCTYPE")
|
||||
Dim oPreselectedDocType As Integer = 0
|
||||
If oDocType IsNot Nothing Then
|
||||
Integer.TryParse(oDocType, oPreselectedDocType)
|
||||
End If
|
||||
|
||||
comboDocumentType.EditValue = oPreselectedDocType
|
||||
comboDocumentType.EditValue = DirectCast(CurrentTemplate.DocType, Integer)
|
||||
|
||||
If ConfigManager.Config.LastUsedMandator <> "" Then
|
||||
lookupMandator.EditValue = Winline.Mandators.
|
||||
|
||||
@@ -74,6 +74,7 @@ Public Class frmMain
|
||||
|
||||
SplashScreenManager.SetWaitFormDescription("Lade Winline Stammdaten")
|
||||
My.Winline = New WinlineData(LogConfig, Database, My.GeneralConfiguration, My.MappingConfiguration, My.MandatorConfiguration)
|
||||
Await LoadWinlineData(My.Winline)
|
||||
|
||||
txtVersion.Caption = String.Format(My.Resources.frmMainExtra.Version___0_, My.Application.Info.Version.ToString)
|
||||
txtCulture.Caption = String.Format(My.Resources.frmMainExtra.Sprache___0_, My.Application.UICulture.ToString)
|
||||
@@ -98,6 +99,8 @@ Public Class frmMain
|
||||
Await Winline.LoadArticles(oMandator)
|
||||
SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Belegarten, oMandator.Id))
|
||||
Await Winline.LoadDocumentKinds(oMandator)
|
||||
SplashScreenManager.SetWaitFormDescription(String.Format("Lade {0}/Colli", oMandator.Id))
|
||||
Await Winline.LoadPackingUnits(oMandator)
|
||||
Next
|
||||
|
||||
My.Winline = Winline
|
||||
|
||||
Reference in New Issue
Block a user