This commit is contained in:
2025-01-10 15:23:56 +01:00
parent f7099586dd
commit d5a89899d3
4 changed files with 257 additions and 349 deletions

View File

@@ -1897,6 +1897,8 @@ Public Class cFakturierung
Dim BelegartenKz = If(Gesamt_RG_Betrag < 0, "AG", "AR")
If ROW("RechnungsNr") Is DBNull.Value Then Return ""
Dim RechnungsNr = If(ROW("RechnungsNr") IsNot DBNull.Value, addYeartoRgNr(FIRMA.Firma_ID, ROW("Buchungsjahr")) & ROW("RechnungsNr"), "Vorschau")
Dim RechnungsDatum = If(ROW("RechnungsDatum") IsNot DBNull.Value, ROW("RechnungsDatum"), "Vorschau")
Dim zahlungszieldatum As Date = CDate(RechnungsDatum).AddDays(ZZTage)

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.4.5")>
<Assembly: AssemblyFileVersion("1.3.4.5")>
<Assembly: AssemblyVersion("1.3.4.6")>
<Assembly: AssemblyFileVersion("1.3.4.6")>

View File

@@ -2,8 +2,10 @@
Imports System.IO
Imports Challenge
Imports com.sun.org.glassfish.external.probe.provider.annotations
Imports GrapeCity.ActiveReports.Export.Pdf.Section.Signing
Imports itextsharp.text.pdf
Imports MDM_Worker
Imports sun.swing
Imports TAlex.WPF.Helpers
Imports VERAG_PROG_ALLGEMEIN
Imports VERAG_PROG_ALLGEMEIN.TESTJSON
@@ -1272,18 +1274,20 @@ Public Class frmMDMDatenverarbetiung
Dim SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch = Nothing
Dim verarbOK = IIf(test, False, True)
Dim RECHNUNG As cRechnungsausgang = Nothing
If Not gen_SPEDBUCH_ByKdNr(uta("Customer Nr"), SPEDBUCH, "UTA",,,, datPloseAnhang.Value) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(uta("Customer Nr"), SPEDBUCH, "UTA") Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(uta("Customer Nr"), SPEDBUCH, "UTA",,,, RECHNUNG) Then verarbOK = False
genUTAAttachmentByKdNr(uta("Customer Nr"), uta("Customer ID"), dir, datPloseAnhang.Value)
Dim pathFile = genUTAAttachmentByKdNr(uta("Customer Nr"), uta("Customer ID"), dir, datPloseAnhang.Value)
If Not AddAttachementToRE(pathFile, uta("Customer Nr"), RECHNUNG, "UTA") Then verarbOK = False
If verarbOK Then
'UPDATE Fakturiert
SQL.doSQL("UPDATE [tblUTAImportNew] set chargedDatetime=GETDATE() where chargedDatetime is null and [Rechnungsdatum] = '" & DateTimePicker2.Text & "' and Kundennummer = " & uta("Customer ID"), "FMZOLL")
End If
If True Then 'cnt Mod 10 = 0 Then
txtPloseAnh_Einarbeitung.Text = cnt & " / " & dt_Main.Rows.Count
Dim proz As Double = (cnt / dt_Main.Rows.Count) * 100
@@ -1306,20 +1310,16 @@ Public Class frmMDMDatenverarbetiung
Next
End If
If Not Directory.Exists(dirAnhang) Then Directory.CreateDirectory(dirAnhang)
For Each f In Directory.GetFiles(dir)
File.Copy(f, dirAnhang & (New FileInfo(f)).Name)
Next
pbPloseAnh_Proz.Value = 100
txtPloseAnh_Einarbeitung.Text = dt_Main.Rows.Count & " / " & dt_Main.Rows.Count
lblPloseAnh_Proz.Text = "100.00 %"
Return True
End If
Return False
End Function
Function genRGAtt_MSE(mseParam As cMSEAPI) As Boolean
Dim top = ""
'top = " TOP 20 "
@@ -1409,11 +1409,24 @@ Public Class frmMDMDatenverarbetiung
Dim SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch = Nothing
Dim verarbOK = IIf(test, False, True)
Dim RECHNUNG As cRechnungsausgang = Nothing
If Not gen_SPEDBUCH_ByKdNr(MSE("Customer Nr"), SPEDBUCH, "MSE",,,, datPloseAnhang.Value) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(MSE("Customer Nr"), SPEDBUCH, "MSE") Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(MSE("Customer Nr"), SPEDBUCH, "MSE",,,, RECHNUNG) Then verarbOK = False
Dim pathfilePDF = genMSEAttachmentByKdNr(MSE("Customer Nr"), MSE("Customer ID"), dir, datPloseAnhang.Value)
If Not AddAttachementToRE(pathfilePDF, MSE("Customer Nr"), RECHNUNG, "MSE") Then verarbOK = False
If Directory.Exists(dir) Then
For Each f In Directory.GetFiles(dir)
If f.Contains(MSE("Customer Nr") & "_Maut_MSE.csv") Then
Dim pathFileCSV As String = New FileInfo(f).FullName
If Not AddAttachementToRE(pathFileCSV, MSE("Customer Nr"), RECHNUNG, "MSE") Then verarbOK = False
End If
Next
End If
genMSEAttachmentByKdNr(MSE("Customer Nr"), MSE("Customer ID"), dir, datPloseAnhang.Value)
If verarbOK Then
'Update Fakturiert
@@ -1491,7 +1504,7 @@ Public Class frmMDMDatenverarbetiung
LEFT JOIN
tblIDSInvoicesNew
on tblIDSInvoicesNew.CustomerCode = tblIDSTransactionsNew.CustomerCode and tblIDSInvoicesNew.Invoicenumber = Paymentsummarynumber
WHERE cast(tblIDSTransactionsNew.YearMonthDay as Date) = '" & DateTimePicker2.Text & "' AND tblIDSTransactionsNew.[UStVAn_ID] is null and isnull(charged,0) = 0 " & sqlWhere & "
WHERE cast(tblIDSTransactionsNew.YearMonthDay as Date) = '" & DateTimePicker2.Text & "' AND tblIDSTransactionsNew.[UStVAn_ID] is null and isnull(charged,0) <> 0 " & sqlWhere & "
order by tblIDSTransactionsNew.KdNrVERAG"
Dim dt_Main As DataTable = SQL.loadDgvBySql_Param(SQLStr, "FMZOLL", 1200)
@@ -1522,18 +1535,20 @@ Public Class frmMDMDatenverarbetiung
Directory.CreateDirectory(dir)
End If
For Each IDS In dt_Main.Rows
Dim SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch = Nothing
Dim verarbOK = IIf(test, False, True)
Dim RECHNUNG As cRechnungsausgang = Nothing
If Not gen_SPEDBUCH_ByKdNr(IDS("KdNrVERAG"), SPEDBUCH, art,,,, datPloseAnhang.Value) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(IDS("KdNrVERAG"), SPEDBUCH, art) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(IDS("KdNrVERAG"), SPEDBUCH, art,,,, RECHNUNG) Then verarbOK = False
If IDS("Rechnungsdruck") = 2 Then
If genIDSAttachmentByKdNr(IDS("KdNrVERAG"), IDS("CustomerCode"), dir, datPloseAnhang.Value, art) = "" Then verarbOK = False
Dim pathfile = genIDSAttachmentByKdNr(IDS("KdNrVERAG"), IDS("CustomerCode"), dir, datPloseAnhang.Value, art)
If Not AddAttachementToRE(pathfile, IDS("KdNrVERAG"), RECHNUNG, "IDS") Then verarbOK = False
End If
If IDS("InvoiceID") > 0 Then
@@ -1552,13 +1567,16 @@ Public Class frmMDMDatenverarbetiung
pdfReader.Close()
Dim PdfTmp = fm.fillPDFVorhandenesLokalesPDF_Path(DS.GET_TOP1_PATH, listTowrite, , , , ,)
If Not AddAttachementToRE(PdfTmp, IDS("KdNrVERAG"), RECHNUNG, "IDS") Then verarbOK = False
File.Copy(PdfTmp, dir & "\" & IDS("KdNrVERAG") & "_" & (DS.da_name), True)
Else
File.Copy(DS.GET_TOP1_PATH, dir & "\" & IDS("KdNrVERAG") & "_" & (DS.da_name), True)
File.Copy(DS.GET_TOP1_PATH, dir & "\" & IDS("KdNrVERAG") & "_" & (DS.da_name), True)
End If
End If
End If
If verarbOK Then
@@ -1718,8 +1736,29 @@ End If
For Each R_ASFINAG In distinctDT_distKunden.Rows
Dim SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch = Nothing
Dim verarbOK = IIf(test, False, True)
Dim RECHNUNG As cRechnungsausgang = Nothing
If Not gen_SPEDBUCH_ByKdNr(R_ASFINAG("KundenNr"), SPEDBUCH, "ASFINAG",,,, abrechnungsdatum) Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(R_ASFINAG("KundenNr"), SPEDBUCH, "ASFINAG") Then verarbOK = False
If Not gen_RECHNUNG_BySPEDBUCH(R_ASFINAG("KundenNr"), SPEDBUCH, "ASFINAG",,,, RECHNUNG) Then verarbOK = False
If Directory.Exists(dir) Then
For Each f In Directory.GetFiles(dir)
If f.Contains(R_ASFINAG("KundenNr") & "_Maut_AT.csv") Then
Dim pathFileCSV As String = New FileInfo(f).FullName
If Not AddAttachementToRE(pathFileCSV, R_ASFINAG("KundenNr"), RECHNUNG, "ASFINAG") Then verarbOK = False
End If
Next
End If
If Directory.Exists(dir) Then
For Each f In Directory.GetFiles(dir)
If f.Contains(R_ASFINAG("KundenNr") & "_Maut_AT.pdf") Then
Dim pathFilePDF As String = New FileInfo(f).FullName
If Not AddAttachementToRE(pathFilePDF, R_ASFINAG("KundenNr"), RECHNUNG, "ASFINAG") Then verarbOK = False
End If
Next
End If
If verarbOK Then
@@ -3327,7 +3366,7 @@ End If
'End Function
Function gen_RECHNUNG_BySPEDBUCH(KdNr As String, SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, Lieferant As String, Optional PLOSEKundenNr As String = "", Optional von As Date = Nothing, Optional bis As Date = Nothing)
Function gen_RECHNUNG_BySPEDBUCH(KdNr As String, SPEDBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch, Lieferant As String, Optional PLOSEKundenNr As String = "", Optional von As Date = Nothing, Optional bis As Date = Nothing, Optional RE As cRechnungsausgang = Nothing)
Try
If KdNr = "" Then Return False
@@ -3621,7 +3660,20 @@ End If
Call usrCntlFaktAbrechnung.przPP(RG) ' Porto/Papiere errechnen
Call usrCntlFaktAbrechnung.przBS415(RG) ' Bankspesen errechnen
Return IIf(test, True, RG.SAVE)
RE = RG
If test Then
Return True
Else
If RG.SAVE Then
RE = RG
Return True
Else
Return False
End If
End If
Catch ex As System.Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
@@ -4604,11 +4656,6 @@ RabattBerechnen:
End Select
If trans.TransactionVolume <> 0 Then
trans.RabattbetragProLiter = trans.Rabattbetrag / trans.TransactionVolume
trans.RabattbetragProLiterOrig = trans.RabattbetragProLiter
@@ -4631,182 +4678,6 @@ RabattBerechnen:
initDgv_IDS()
MsgBox(i & " Rechenwerte wurden gesetzt!")
' Public Function fktDieselIDSImportiereCSV()
'1380 If Not IsNull(![KdNrVERAG]) Then
' ' Kunde ohne Rabatt
'1390 strSQL = "SELECT *" & _
' " FROM tbl_IDS_Kunden_ohne_Rabatt" & _
' " WHERE (((tbl_IDS_Kunden_ohne_Rabatt.CustomerCode)=" & ![KdNrVERAG] & "));"
'1400 Set rstIDSRechenwert = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
'1410 If Not rstIDSRechenwert.EOF Then
'1420 GoTo Rabatt_errechnen
'1430 End If
'1440 rstIDSRechenwert.Close
' ' Rechenwert für Land/Station/Kunde/Produkt ermitteln
'1450 strSQL = "SELECT Rechenwert, Kz, KategorieNr" & _
' " FROM tbl_IDS_Rechenwerte" & _
' " WHERE (((OutletCountryCode)=" & ![Outlet Country Code] & ")" & _
' " AND ((OutletCode)=" & ![Outlet Code] & ")" & _
' " AND ((CustomerCode)=" & ![KdNrVERAG] & ")" & _
' " AND ((ProductTypeCode)=" & ![Product Type Code] & "))" & _
' " ORDER BY Zeitstempel DESC;"
'1460 Set rstIDSRechenwert = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
'1470 If Not rstIDSRechenwert.EOF Then
'1480 GoTo Rechenwert_eintragen
'1490 End If
'1500 rstIDSRechenwert.Close
' ' Rechenwert für Land/Kunde/Produkt ermittteln
'1510 strSQL = "SELECT Rechenwert, Kz, KategorieNr" & _
' " FROM tbl_IDS_Rechenwerte" & _
' " WHERE (((OutletCountryCode)=" & ![Outlet Country Code] & ")" & _
' " AND ((OutletCode) Is Null)" & _
' " AND ((CustomerCode)=" & ![KdNrVERAG] & ")" & _
' " AND ((ProductTypeCode)=" & ![Product Type Code] & "))" & _
' " ORDER BY Zeitstempel DESC;"
'1520 Set rstIDSRechenwert = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
'1530 If Not rstIDSRechenwert.EOF Then
'1540 GoTo Rechenwert_eintragen
'1550 End If
'1560 rstIDSRechenwert.Close
'1570 End If
' ' Rechenwert für Land/Station/Produkt ermitteln
'1580 strSQL = "SELECT Rechenwert, Kz, KategorieNr" & _
' " FROM tbl_IDS_Rechenwerte" & _
' " WHERE (((OutletCountryCode)=" & ![Outlet Country Code] & ")" & _
' " AND ((OutletCode)=" & ![Outlet Code] & ")" & _
' " AND ((CustomerCode) Is Null)" & _
' " AND ((ProductTypeCode)=" & ![Product Type Code] & "))" & _
' " ORDER BY Zeitstempel DESC;"
'1590 Set rstIDSRechenwert = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
'1600 If Not rstIDSRechenwert.EOF Then
'1610 GoTo Rechenwert_eintragen
'1620 End If
'1630 rstIDSRechenwert.Close
' ' Rechenwert für Land/Produkt ermitteln
'1640 strSQL = "SELECT Rechenwert, Kz, KategorieNr" & _
' " FROM tbl_IDS_Rechenwerte" & _
' " WHERE (((OutletCountryCode)=" & ![Outlet Country Code] & ")" & _
' " AND ((OutletCode) Is Null)" & _
' " AND ((CustomerCode) Is Null)" & _
' " AND ((ProductTypeCode)=" & ![Product Type Code] & "))" & _
' " ORDER BY Zeitstempel DESC;"
'1650 Set rstIDSRechenwert = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
'1660 If Not rstIDSRechenwert.EOF Then
'1670 GoTo Rechenwert_eintragen
'1680 End If
'1690 rstIDSRechenwert.Close
'1700 GoTo Rabatt_errechnen
'Rechenwert_eintragen:
'1710 !Rechenwert = rstIDSRechenwert!Rechenwert
'1720 !Kz = rstIDSRechenwert!Kz
'1730 If Not IsNull(rstIDSRechenwert!KategorieNr) Then
'1740 Set qry = dbs.QueryDefs("qry_IDS_KategorieNr_ProductTypeCode_Rechenwert")
'1750 qry.Parameters("[prmKategorieNr]") = rstIDSRechenwert!KategorieNr
'1760 qry.Parameters("[prmProductTypeCode]") = ![Product Type Code]
'1770 Set rst = qry.OpenRecordset(dbOpenSnapshot)
'1780 If Not rst.EOF Then
'1790 !Rechenwert = !Rechenwert + rst!Rechenwert
'1800 If !Rechenwert < 0 Then
'1810 !Rechenwert = 0
'1820 End If
'1830 End If
'1840 rst.Close
'1850 qry.Close
'1860 End If
'1870 rstIDSRechenwert.Close
'Rabatt_errechnen:
'1880 Select Case !Kz
' Case "P" 'Rechenwert ist Preis pro Liter
'1890 !Rabattbetrag = ![Total Net Amount] - Int(!Rechenwert * ![Transaction Volume] * 100 + 0.5) / 100
'1900 Case "R" 'Rechenwert ist Rabatt pro Liter
'1910 !Rabattbetrag = Int(!Rechenwert * ![Transaction Volume] * 100 + 0.5) / 100
'1920 End Select
'1930 If ![Transaction Volume] <> 0 Then
'1940 !RabattbetragProLiter = !Rabattbetrag / ![Transaction Volume]
'1950 End If
' ' Zeitstempel und Sachbearbeiter in tblDiesel eintragen
'1960 !Zeitstempel = Now
'1970 !Sachbearbeiter = CurrentUser()
'1980 .Update
' ' Daten in das Archiv schreiben.
'1990 Set qryIDSDieselArchiv = dbs.QueryDefs("qryDieselArchivPKey")
'2000 qryIDSDieselArchiv.Parameters("[prmYearMonthDay]") = ![Year Month Day]
'2010 qryIDSDieselArchiv.Parameters("[prmPaymentSummaryNumber]") = ![Payment summary number]
'2020 qryIDSDieselArchiv.Parameters("[prmCustomerCode]") = ![Customer Code]
'2030 qryIDSDieselArchiv.Parameters("[prmOutletCountryCode]") = ![Outlet Country Code]
'2040 qryIDSDieselArchiv.Parameters("[prmOutletCode]") = ![Outlet Code]
'2050 qryIDSDieselArchiv.Parameters("[prmProductTypeCode]") = ![Product Type Code]
'2060 Set rstIDSDieselArchiv = qryIDSDieselArchiv.OpenRecordset(dbOpenDynaset)
'2070 If rstIDSDieselArchiv.EOF Then
'2080 rstIDSDieselArchiv.AddNew
'2090 lngDatensätzeAngefügt = lngDatensätzeAngefügt + 1
'2100 Call SysCmd(acSysCmdSetStatus, "IDS-Diesel-Archiv Neuzugang: " & ![Year Month Day] & "-" & ![Payment summary number] & "-" & ![Customer Code] & "-" & ![Outlet Country Code] & "-" & ![Outlet Code] & "-" & ![Product Type Code])
'2110 Else
'2120 rstIDSDieselArchiv.Edit
'2130 lngDatensätzeAktualisiert = lngDatensätzeAktualisiert + 1
'2140 Call SysCmd(acSysCmdSetStatus, "IDS-Diesel-Archiv Änderung: " & ![Year Month Day] & "-" & ![Payment summary number] & "-" & ![Customer Code] & "-" & ![Outlet Country Code] & "-" & ![Outlet Code] & "-" & ![Product Type Code])
'2150 End If
'2160 For Each fld In .Fields
'2170 rstIDSDieselArchiv(fld.Name) = fld.Value
'2180 Next
'2190 rstIDSDieselArchiv.Update
'2200 rstIDSDieselArchiv.Close
'2210 qryIDSDieselArchiv.Close
'2220 DoEvents
'2230 .MoveNext
'2240 Loop
'2250 wrk.CommitTrans
'2260 On Error GoTo Fehler
'2270 .Close
'2280 End With
'2290 Call SysCmd(acSysCmdClearStatus)
'2300 DoCmd.Hourglass False
'2310 strPrompt = "Es wurden " & lngDatensätzeAngefügt & " Datensätze in das Archiv übernommen."
'2320 If lngDatensätzeAktualisiert > 0 Then
'2330 strPrompt = strPrompt & vbNewLine & lngDatensätzeAktualisiert & " Archivsätze wurden aktualisiert."
'2340 End If
'2350 strTitle = "Diesel-Datenarchiv"
'2360 MsgBox strPrompt, , strTitle
' ' intAntwort = MsgBox("Das Einlesen ist beendet. Soll die Datei gelöscht werden?", vbYesNo + vbQuestion + vbDefaultButton2, Trim(dlg.SelectedItems(1)))
' ' If intAntwort = vbYes Then Kill (Trim(dlg.SelectedItems(1)))
'2370 Else
'2380 MsgBox "Es wurde keine Datei ausgewählt.", vbInformation, "Daten einlesen."
'2390 End If
'Ende:
'2400 DoCmd.Hourglass False
'2410 Exit Function
'Rollback:
'2420 wrk.Rollback
'Fehler:
'2430 Call SysCmd(acSysCmdClearStatus)
'2440 DoCmd.Hourglass False
'2450 DoCmd.Beep
'2460 MsgBox "Error: " & Err.Number & ". " & Err.Description, , "fktDieselIDSImportiereCSV"
'2470 Resume Ende
' End Function
End Function
@@ -4958,4 +4829,35 @@ RabattBerechnen:
End If
End Sub
Private Function AddAttachementToRE(pathFile As String, kdNr As Integer, RECHNUNG As cRechnungsausgang, Lieferant As String) As Boolean
If Not IO.File.Exists(pathFile) Then Return False
Dim fi As New System.IO.FileInfo(pathFile)
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_ABRECHNUNG", Lieferant, datPloseAnhang.Value.ToString("ddMMyyyy"), "", fi.Name,)
If Not DS.uploadDataToDATENSERVER(pathFile, fi.Name, fi.Extension,,,, True) Then
MsgBox("Fehler beim Speichern: Datenserver! KDNR:" & kdNr)
Return False
End If
If CInt(DS.da_id) <= 0 Then
MsgBox("Keine DocId!")
Return False
End If
Dim da_id = DS.da_id
Dim destPath = DS.GET_TOP1_PATH
If RECHNUNG IsNot Nothing Then
RECHNUNG.ANHAENGE.Clear()
Dim ANH As New VERAG_PROG_ALLGEMEIN.cRechnungsausgangAnhaenge
ANH.dsId = CInt(DS.da_id)
ANH.Bezeichnung = DS.da_name
RECHNUNG.ANHAENGE.Add(ANH)
Return RECHNUNG.SAVE_ANHAENGE(RECHNUNG.RK_ID)
Else
Return False
End If
End Function
End Class

View File

@@ -2277,10 +2277,14 @@ Public Class DATENVERVER_OPTIONS
Dim docPdf As Spire.Pdf.PdfDocument = New Spire.Pdf.PdfDocument()
docPdf.LoadFromFile(File)
If attPath <> "" Then
Dim attachment As PdfAttachment = New PdfAttachment(attPath)
docPdf.Attachments.Add(attachment)
docPdf.SaveToFile(File)
End If
Return File