Einarbeitung SDL, Mailsender, etc.
This commit is contained in:
@@ -302,7 +302,7 @@ Public Class frmNachrichtenVerarbeitung_MDM_divers
|
||||
|
||||
End Function
|
||||
|
||||
Private Function createIDSInvoice(Dateiname As String, Type As String, Optional isMail As Boolean = False)
|
||||
Private Function createIDSInvoice(Dateiname As String, Type As String, Optional isMail As Boolean = False, Optional isNewFormat As Boolean = False)
|
||||
|
||||
Dim Zielpfad = ids.VERARBEITUNG_PFAD
|
||||
Dim customerNo = ""
|
||||
@@ -371,18 +371,23 @@ Public Class frmNachrichtenVerarbeitung_MDM_divers
|
||||
End Select
|
||||
|
||||
End If
|
||||
|
||||
If Dateiname.Contains(dateString) Then
|
||||
dateNo = Dateiname.Substring(Dateiname.IndexOf(dateString) + dateString.Length, 8)
|
||||
Dim parsedDate As DateTime = DateTime.ParseExact(dateNo, "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture)
|
||||
outputDate = parsedDate.ToString("dd.MM.yyyy")
|
||||
If Not isNewFormat Then
|
||||
If Dateiname.Contains(dateString) Then
|
||||
dateNo = Dateiname.Substring(Dateiname.IndexOf(dateString) + dateString.Length, 8)
|
||||
Dim parsedDate As DateTime = DateTime.ParseExact(dateNo, "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture)
|
||||
outputDate = parsedDate.ToString("dd.MM.yyyy")
|
||||
Else
|
||||
dateNo = Dateiname.Substring(Dateiname.IndexOf("_") + 1, 8)
|
||||
Dim parsedDate As DateTime = DateTime.ParseExact(dateNo, "ddMMyyyy", System.Globalization.CultureInfo.InvariantCulture)
|
||||
outputDate = parsedDate.ToString("dd.MM.yyyy")
|
||||
End If
|
||||
Else
|
||||
dateNo = Dateiname.Substring(Dateiname.IndexOf("_") + 1, 8)
|
||||
Dim parsedDate As DateTime = DateTime.ParseExact(dateNo, "ddMMyyyy", System.Globalization.CultureInfo.InvariantCulture)
|
||||
outputDate = parsedDate.ToString("dd.MM.yyyy")
|
||||
'wenns in der Bezeichnung fehlt (bei New Format), heutiges Datum annehmen!
|
||||
outputDate = Today.ToString("dd.MM.yyyy")
|
||||
|
||||
End If
|
||||
|
||||
|
||||
If outputDate IsNot Nothing AndAlso customerNo <> "" AndAlso invoiceNo <> "" Then
|
||||
|
||||
Select Case Type
|
||||
@@ -604,7 +609,7 @@ Public Class frmNachrichtenVerarbeitung_MDM_divers
|
||||
|
||||
If True Then 'Not System.IO.Directory.Exists(zielpfad & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then System.IO.Directory.CreateDirectory(zielpfad & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
|
||||
If fi.Name.ToString.StartsWith("AP") AndAlso fi.Name.ToLower.Contains("zugferd") Then
|
||||
If (fi.Name.ToString.StartsWith("AP") AndAlso fi.Name.ToLower.Contains("zugferd")) OrElse (fi.Name.ToString.Contains("(") AndAlso fi.Name.ToString.Contains(")") AndAlso fi.Name.ToString.Contains("_RE_")) Then 'Rechnungen per Mail oder manuelle RE!
|
||||
|
||||
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "UTA", Now.Year, Now.ToString("yyyyMMdd"), frmStartOptions.getFileName(d))
|
||||
|
||||
@@ -626,63 +631,93 @@ Public Class frmNachrichtenVerarbeitung_MDM_divers
|
||||
Dim invoiceDate As String = ""
|
||||
Dim Kundenummer As Integer
|
||||
Dim Abrechnungsnummer As Integer
|
||||
Dim Rechnungsland As String = ""
|
||||
Dim doc = New Spire.Pdf.PdfDocument()
|
||||
doc.LoadFromFile(fi.FullName)
|
||||
|
||||
Dim pdfAtt = doc.Attachments(0)
|
||||
If pdfAtt.FileName = "ZUGFeRD-invoice.xml" Then
|
||||
If doc.Attachments.Count > 0 Then
|
||||
|
||||
Dim xmlFile = doc.Attachments(0)
|
||||
Dim pathTempXMLFile = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath(xmlFile.FileName, ".xml", False, False)
|
||||
File.WriteAllBytes(pathTempXMLFile, pdfAtt.Data)
|
||||
Dim pdfAtt = doc.Attachments(0)
|
||||
If pdfAtt.FileName = "ZUGFeRD-invoice.xml" OrElse pdfAtt.FileName = "factur-x.xml" Then
|
||||
|
||||
Dim docxml As New XmlDocument()
|
||||
docxml.Load(New XmlTextReader(pathTempXMLFile))
|
||||
If docxml.HasChildNodes Then
|
||||
Dim xmlFile = doc.Attachments(0)
|
||||
Dim pathTempXMLFile = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath(xmlFile.FileName, ".xml", False, False)
|
||||
File.WriteAllBytes(pathTempXMLFile, pdfAtt.Data)
|
||||
|
||||
If docxml.GetElementsByTagName("rsm:ExchangedDocument").Count > 0 Then
|
||||
Dim count As Integer = 1
|
||||
For Each node As XmlElement In docxml.GetElementsByTagName("rsm:ExchangedDocument")
|
||||
If node.HasChildNodes Then
|
||||
For Each element As XmlElement In node.ChildNodes
|
||||
If element.Name = "ram:ID" AndAlso element.InnerText <> "" Then invoiceNr = element.InnerText 'Rechnungsnummer
|
||||
If element.Name = "ram:IssueDateTime" AndAlso element.InnerText <> "" Then invoiceDate = element.InnerText 'Rechnungsdatum
|
||||
Dim docxml As New XmlDocument()
|
||||
docxml.Load(New XmlTextReader(pathTempXMLFile))
|
||||
If docxml.HasChildNodes Then
|
||||
|
||||
Next
|
||||
If docxml.GetElementsByTagName("rsm:ExchangedDocument").Count > 0 Then
|
||||
Dim count As Integer = 1
|
||||
For Each node As XmlElement In docxml.GetElementsByTagName("rsm:ExchangedDocument")
|
||||
If node.HasChildNodes Then
|
||||
For Each element As XmlElement In node.ChildNodes
|
||||
If element.Name = "ram:ID" AndAlso element.InnerText <> "" Then invoiceNr = element.InnerText 'Rechnungsnummer
|
||||
If element.Name = "ram:IssueDateTime" AndAlso element.InnerText <> "" Then invoiceDate = element.InnerText 'Rechnungsdatum
|
||||
|
||||
count = count + 1
|
||||
Next
|
||||
|
||||
End If
|
||||
Next
|
||||
count = count + 1
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
If docxml.GetElementsByTagName("ram:ApplicableHeaderTradeAgreement").Count > 0 Then
|
||||
Dim count As Integer = 1
|
||||
For Each node As XmlElement In docxml.GetElementsByTagName("ram:ApplicableHeaderTradeAgreement")
|
||||
If node.HasChildNodes Then
|
||||
For Each element As XmlElement In node.ChildNodes
|
||||
|
||||
If element.Name = "ram:BuyerReference" Then
|
||||
Kundenummer = CInt(element.InnerText) 'Kundennummer
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
count = count + 1
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
If docxml.GetElementsByTagName("ram:SpecifiedTradeProduct").Count > 0 Then
|
||||
Dim count As Integer = 1
|
||||
For Each node As XmlElement In docxml.GetElementsByTagName("ram:OriginTradeCountry")
|
||||
If node.HasChildNodes Then
|
||||
For Each element As XmlElement In node.ChildNodes
|
||||
|
||||
If element.Name = "ram:ID" AndAlso element.InnerText <> "" Then
|
||||
Rechnungsland = element.InnerText 'Rechnungsnummer'Kundennummer
|
||||
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
count = count + 1
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If docxml.GetElementsByTagName("ram:ApplicableHeaderTradeAgreement").Count > 0 Then
|
||||
Dim count As Integer = 1
|
||||
For Each node As XmlElement In docxml.GetElementsByTagName("ram:ApplicableHeaderTradeAgreement")
|
||||
If node.HasChildNodes Then
|
||||
For Each element As XmlElement In node.ChildNodes
|
||||
|
||||
If element.Name = "ram:BuyerReference" Then
|
||||
Kundenummer = CInt(element.InnerText) 'Kundennummer
|
||||
Exit For
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
count = count + 1
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
found = True
|
||||
If invoiceNr <> "" AndAlso invoiceDate <> "" AndAlso Kundenummer > 0 Then
|
||||
|
||||
'SQL.doSQL("Update [tblUTAImportNew] SET [daId]='" & DS.da_id & "', daIdgesetztDatum = getdate() where [Rechnungsnummer_pro_Lieferland] = '" & r.Item("Rechnungsnummer_pro_Lieferland") & "' AND cast(Rechnungsdatum as Date) = '" & utaDate & "' AND Kundennummer =" & r.Item("Kundennummer") & " and Abrechnungsnummer =" & r.Item("Abrechnungsnummer") & " and daId is null", "FMZOLL")
|
||||
End If
|
||||
|
||||
found = True
|
||||
If invoiceNr <> "" AndAlso invoiceDate <> "" AndAlso Kundenummer > 0 AndAlso Rechnungsland <> "" Then
|
||||
|
||||
Dim parsedDate As DateTime = DateTime.ParseExact(invoiceDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
|
||||
invoiceDate = parsedDate.ToString("dd.MM.yyyy")
|
||||
|
||||
SQL.doSQL("Update [tblUTAImportNew] SET [daId]='" & DS.da_id & "', daIdgesetztDatum = getdate() where [Rechnungsnummer_pro_Lieferland] = '" & invoiceNr & "' AND cast(Rechnungsdatum as Date) = '" & invoiceDate & "' AND Kundennummer =" & Kundenummer & " and Lieferland_ISO2 ='" & Rechnungsland & "' and daId is null", "FMZOLL")
|
||||
|
||||
|
||||
' If SQL.doSQL("Update [tblUTAImportNew] SET [daId]='" & DS.da_id & "' where [Rechnungsnummer_pro_Lieferland] = '" & invoiceNr & "' AND cast(Rechnungsdatum as Date) = '" & invoiceDate & "' AND Kundennummer =" & Kundenummer & " and Abrechnungsnummer =" & r.Item("Abrechnungsnummer") & " and daId is null ", "FMZOLL") Then
|
||||
@@ -773,14 +808,45 @@ Public Class frmNachrichtenVerarbeitung_MDM_divers
|
||||
|
||||
If fi.Extension.ToLower = ".pdf" Then
|
||||
|
||||
If fi.Name.ToString.StartsWith("COPY_INVOICE_") Then
|
||||
Dim dateiname As String = fi.Name.ToString
|
||||
Dim cutLenght As Integer = 20
|
||||
Dim newFormat As Boolean = False
|
||||
|
||||
createIDSInvoice(fi.Name.ToString.Replace("COPY_INVOICE_", ""), "INVOICE")
|
||||
'im alten Format!
|
||||
'PS = Zusammenfassung
|
||||
'SP = Tankungen pro Karte
|
||||
'OBO = Rechnungen pro Land
|
||||
'VATR = Rechnungen pro Land
|
||||
'COPY_INVOICE = alles zusammen pro Kunde!
|
||||
|
||||
If dateiname.Contains("IV_") AndAlso dateiname.Length > cutLenght Then 'dann ist es das neue Format von IDS!!!!
|
||||
|
||||
newFormat = True
|
||||
|
||||
'im neuen Format!
|
||||
'PS = Zusammenfassung
|
||||
'SPEC = Tankungen pro Karte
|
||||
'OBO = Rechnungen pro Land
|
||||
'VATR = Rechnungen pro Land
|
||||
|
||||
'COPY_INVOICE = gibt es im neuen Format nicht mehr!!!!!!!!!!!! -> sehr schlecht, muss manuell zusammengebaut werden -> per BATCH-JOB
|
||||
'AUFBAU der COPY_INVOICE: PS + SPEC + OBO + VATR
|
||||
|
||||
dateiname = dateiname.Substring(cutLenght, dateiname.Length - cutLenght)
|
||||
|
||||
If dateiname.Contains("_WP") Then dateiname = dateiname.Replace("_WP", "")
|
||||
If dateiname.Contains("-") Then dateiname = dateiname.Replace("-", "")
|
||||
|
||||
End If
|
||||
|
||||
If dateiname.StartsWith("COPY_INVOICE_") Then
|
||||
|
||||
createIDSInvoice(dateiname.Replace("COPY_INVOICE_", ""), "INVOICE",, newFormat)
|
||||
|
||||
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "IDS", Now.Year, Now.ToString("yyyyMMdd"), frmStartOptions.getFileName(d))
|
||||
|
||||
If DS.uploadDataToDATENSERVER(d,,,,,, True) Then
|
||||
If SQL.doSQL("Update [tblIDSInvoicesNew] SET [daId]='" & DS.da_id & "' where [DocumentName] = '" & DS.da_name.ToString.Replace("COPY_INVOICE_", "") & "' ", "FMZOLL") Then
|
||||
If SQL.doSQL("Update [tblIDSInvoicesNew] SET [daId]='" & DS.da_id & "' where [DocumentName] = '" & dateiname.ToString.Replace("COPY_INVOICE_", "") & "' ", "FMZOLL") Then
|
||||
frmStartOptions.moveFile_DateBack(d, zielpfad & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
cntDatenEingelesen += 1
|
||||
End If
|
||||
@@ -791,28 +857,28 @@ Public Class frmNachrichtenVerarbeitung_MDM_divers
|
||||
Catch ex As System.Exception
|
||||
End Try
|
||||
|
||||
ElseIf fi.Name.ToString.StartsWith("OBO_") Then
|
||||
ElseIf dateiname.StartsWith("OBO_") Then
|
||||
|
||||
createIDSInvoice(fi.Name.ToString.Replace("OBO_", ""), "INVOICEBYCOUNTRY")
|
||||
createIDSInvoice(dateiname.Replace("OBO_", ""), "INVOICEBYCOUNTRY",, newFormat)
|
||||
|
||||
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "IDS_COUNTRY", Now.Year, Now.ToString("yyyyMMdd"), frmStartOptions.getFileName(d))
|
||||
|
||||
If DS.uploadDataToDATENSERVER(d,,,,,, True) Then
|
||||
If SQL.doSQL("Update [tblIDSInvoicesNewSplittedByCountry] SET [daId]='" & DS.da_id & "' where [DocumentName] = '" & DS.da_name.ToString.Replace("OBO_", "") & "' ", "FMZOLL") Then
|
||||
If SQL.doSQL("Update [tblIDSInvoicesNewSplittedByCountry] SET [daId]='" & DS.da_id & "' where [DocumentName] = '" & dateiname.ToString.Replace("OBO_", "") & "' ", "FMZOLL") Then
|
||||
frmStartOptions.moveFile_DateBack(d, zielpfad & "Invoice_PDF_Country\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
cntDatenEingelesen += 1
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
ElseIf fi.Name.ToString.StartsWith("VATR_") Then
|
||||
ElseIf dateiname.StartsWith("VATR_") Then
|
||||
|
||||
createIDSInvoice(fi.Name.ToString.Replace("VATR_", ""), "INVOICEBYCOUNTRY")
|
||||
createIDSInvoice(dateiname.Replace("VATR_", ""), "INVOICEBYCOUNTRY",, newFormat)
|
||||
|
||||
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "IDS_COUNTRY", Now.Year, Now.ToString("yyyyMMdd"), frmStartOptions.getFileName(d))
|
||||
|
||||
If DS.uploadDataToDATENSERVER(d,,,,,, True) Then
|
||||
If SQL.doSQL("Update [tblIDSInvoicesNewSplittedByCountry] SET [daId]='" & DS.da_id & "' where [DocumentName] = '" & DS.da_name.ToString.Replace("VATR_", "") & "' ", "FMZOLL") Then
|
||||
If SQL.doSQL("Update [tblIDSInvoicesNewSplittedByCountry] SET [daId]='" & DS.da_id & "' where [DocumentName] = '" & dateiname.ToString.Replace("VATR_", "") & "' ", "FMZOLL") Then
|
||||
frmStartOptions.moveFile_DateBack(d, zielpfad & "Invoice_PDF_Country\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
cntDatenEingelesen += 1
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user