This commit is contained in:
2026-03-20 14:42:11 +01:00
parent da3977eea2
commit 6281733780

View File

@@ -1153,6 +1153,7 @@ Public Class cMSEAPI
Dim invoiceID As Integer = 0 Dim invoiceID As Integer = 0
Dim invoiceDate As String Dim invoiceDate As String
Dim customerID As Integer = 0 Dim customerID As Integer = 0
Dim Country As String = ""
Dim total_amount_euro As Double = 0 Dim total_amount_euro As Double = 0
Dim total_vat_amount_euro As Double = 0 Dim total_vat_amount_euro As Double = 0
@@ -1166,22 +1167,30 @@ Public Class cMSEAPI
invoiceDate = currentRow(3).ToString() invoiceDate = currentRow(3).ToString()
End If End If
' Country
If Not IsDBNull(currentRow(13)) Then
Country = currentRow(13).ToString()
End If
' CustomerID ' CustomerID
If Not IsDBNull(currentRow(4)) Then If Not IsDBNull(currentRow(4)) Then
Integer.TryParse(currentRow(4).ToString(), customerID) Integer.TryParse(currentRow(4).ToString(), customerID)
End If End If
' Amounts ' Amounts
If Not IsDBNull(currentRow(37)) Then If Not IsDBNull(currentRow(35)) Then
Double.TryParse(currentRow(37).ToString(), total_amount_euro) Double.TryParse(currentRow(35).ToString(), total_amount_euro)
End If End If
If Not IsDBNull(currentRow(36)) Then If Not IsDBNull(currentRow(36)) Then
Double.TryParse(currentRow(36).ToString(), total_vat_amount_euro) Double.TryParse(currentRow(36).ToString().Replace(".", ","), total_vat_amount_euro)
End If End If
Dim inv As New cMSEInvoices(invoiceID, invoiceDate, customerID)
Dim inv As New cMSEInvoices(invoiceDate, Country, customerID)
inv.invoice_id = invoiceID
If lngRecordCount = 2 Then If lngRecordCount = 2 Then
MDMEinarb.invoicedate = invoiceDate MDMEinarb.invoicedate = invoiceDate
@@ -1235,28 +1244,36 @@ Public Class cMSEAPI
Public Function importInvoicesPDF_alternative(dateiname As String, uploadToDs As Boolean) As String 'if the API do not return any invoices, we get the invoices via Filetransfer! Public Function importInvoicesPDF_alternative(dateiname As String, uploadToDs As Boolean) As String 'if the API do not return any invoices, we get the invoices via Filetransfer!
Try Try
'Aufbau Dateiname -> Rechnungsdatum_Kundennummer_ 'Aufbau Dateiname -> Rechnungsdatum_RechnungsNr_Kundennummer_
Dim isVat As Boolean = False Dim isVat As Boolean = False
Dim nameString = checkNullStr(dateiname) Dim nameString = checkNullStr(dateiname)
Dim nameWithoutExt As String = System.IO.Path.GetFileNameWithoutExtension(nameString) Dim nameWithoutExt As String = System.IO.Path.GetFileNameWithoutExtension(nameString)
Dim parts() As String = nameWithoutExt.Split("_"c) Dim parts() As String = nameWithoutExt.Split("_"c)
Dim invoiceDate As Date = Date.MinValue Dim invoiceDate As String
Dim customerNo As Integer = 0 Dim customerNo As Integer = 0
Dim invoiceNo As Integer = 0 Dim invoiceNo As Integer = 0
Dim country As String = "" Dim country As String = ""
If parts.Length >= 2 Then If parts.Length >= 2 Then
Dim rawDate As String = parts(0)
Date.TryParse(parts(0).ToString(), invoiceDate) Dim parsedDate As Date
Integer.TryParse(parts(1).ToString(), customerNo) If Date.TryParseExact(rawDate, "yyyyMMdd",
Globalization.CultureInfo.InvariantCulture,
Globalization.DateTimeStyles.None,
parsedDate) Then
invoiceDate = parsedDate.ToString("yyyy-MM-dd")
End If
Integer.TryParse(parts(1).ToString(), invoiceNo)
End If End If
' Optional invoice number ' Optional invoice number
If parts.Length >= 3 Then If parts.Length >= 3 Then
Integer.TryParse(parts(2).ToString(), invoiceNo) Integer.TryParse(parts(2).ToString(), customerNo)
End If End If
'country 'country
If parts.Length >= 4 Then If parts.Length >= 4 Then
@@ -1271,18 +1288,25 @@ Public Class cMSEAPI
If isVat Then If isVat Then
Dim inv As New cMSEInvoices(invoiceDate, customerNo, invoiceNo, country) Dim inv As New cMSEInvoices(invoiceDate, country, customerNo)
inv.name = nameString
If inv.hasEntry Then
inv.name = nameWithoutExt & ".pdf"
inv.invoice_nr = invoiceNo
If Not inv.archiv AndAlso isVat Then inv.SAVEBYCountry() 'bereits archiverte REchnungen nicht überschreiben!!!! If Not inv.archiv AndAlso isVat Then inv.SAVEBYCountry() 'bereits archiverte REchnungen nicht überschreiben!!!!
If inv.daId Is Nothing AndAlso uploadToDs AndAlso isVat Then If inv.daId Is Nothing AndAlso uploadToDs AndAlso isVat Then
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "MSE", Now.Year, Now.ToString("yyyyMMdd"), dateiname) Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "MSE", Now.Year, Now.ToString("yyyyMMdd"), nameWithoutExt & ".pdf")
DS.uploadDataToDATENSERVER(PDFRECHNUNGENPFAD_VERARBEITUNG & "\" & dateiname,,,,,, True) DS.uploadDataToDATENSERVER(PDFRECHNUNGENPFAD_VERARBEITUNG & "\" & nameWithoutExt & ".pdf",,,,,, True)
SQL.doSQL("Update [tblMSEInvoices] SET [daId]='" & DS.da_id & "' where [name] = '" & dateiname & "'", "FMZOLL") SQL.doSQL("Update [tblMSEInvoices] SET [daId]='" & DS.da_id & "' where [name] = '" & nameWithoutExt & ".pdf" & "'", "FMZOLL")
End If End If
End If End If
End If
Catch ex As WebException Catch ex As WebException
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
@@ -1709,11 +1733,10 @@ Public Class cMSEInvoices
' Dim inv As New cMSEInvoices(invoiceDate, customerNo, invoiceNo, country) ' Dim inv As New cMSEInvoices(invoiceDate, customerNo, invoiceNo, country)
Sub New(invoice_date As String, customer_number As Integer, invoice_nr As Integer, country As String) Sub New(invoice_date As String, country As String, customer_number As Integer)
Me.country = country Me.country = country
Me.invoice_date = invoice_date Me.invoice_date = invoice_date
Me.customer_number = customer_number Me.customer_number = customer_number
Me.invoice_nr = invoice_nr
LOADBYCOUNTRY() LOADBYCOUNTRY()
End Sub End Sub
@@ -1845,11 +1868,10 @@ Public Class cMSEInvoices
Try Try
hasEntry = False hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL() Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT * FROM tblMSEInvoices WHERE customer_number=@customer_number AND country = @country AND invoice_date = @invoice_date AND invoice_nr = @invoice_nr", conn) Using cmd As New SqlCommand("SELECT * FROM tblMSEInvoices WHERE customer_number=@customer_number AND country = @country AND invoice_date = @invoice_date", conn)
cmd.Parameters.AddWithValue("@customer_number", customer_number) cmd.Parameters.AddWithValue("@customer_number", customer_number)
cmd.Parameters.AddWithValue("@country", country) cmd.Parameters.AddWithValue("@country", country)
cmd.Parameters.AddWithValue("@invoice_date", invoice_date) cmd.Parameters.AddWithValue("@invoice_date", invoice_date)
cmd.Parameters.AddWithValue("@invoice_nr", invoice_nr)
Dim dr = cmd.ExecuteReader() Dim dr = cmd.ExecuteReader()
If dr.Read Then If dr.Read Then
For Each li In getParameterList() For Each li In getParameterList()
@@ -1908,7 +1930,7 @@ Public Class cMSEInvoices
End If End If
Next Next
str = str.Substring(0, str.Length - 1) 'wg. ',' str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE tblMSEInvoices SET " & str & " WHERE customer_number=@customer_number AND country = @country AND invoice_date = @invoice_date AND invoice_nr = @invoice_nr ") Return (" UPDATE tblMSEInvoices SET " & str & " WHERE customer_number=@customer_number AND country = @country AND invoice_date = @invoice_date")
Catch ex As Exception Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)