From e13dcd095e457464b890925065e81639a5e71dca Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Thu, 20 Nov 2025 13:50:00 +0100 Subject: [PATCH] Plose date, etc. --- MDM_Worker/cPLOSE_Inv_Data.vb | 18 +++ UID/usrctlProcedures.Designer.vb | 48 ++++-- UID/usrctlProcedures.vb | 60 +++++++- initATLASAufschubkonten/frmStartOptions.vb | 162 +++++++++++++++++---- 4 files changed, 248 insertions(+), 40 deletions(-) diff --git a/MDM_Worker/cPLOSE_Inv_Data.vb b/MDM_Worker/cPLOSE_Inv_Data.vb index 8ce6a28..a4297a8 100644 --- a/MDM_Worker/cPLOSE_Inv_Data.vb +++ b/MDM_Worker/cPLOSE_Inv_Data.vb @@ -346,6 +346,24 @@ Public Class cPLOSE_Inv_Data End Function + Public Shared Function setBackToCustomer(SQL As SQL, backToCustomer As Boolean, ab As Date, customerNo As Integer) As Boolean + + + Return SQL.doSQL("update tblPLOSE_Inv_Data set plInv_InvToCustomer = " & IIf(backToCustomer, "1", "NULL") & " where cast(plInv_SupplierRechnungsDatum as Date) >= '" & ab.ToShortDateString & "' AND plInv_PLOSEKundennummer = '" & customerNo & "'", "FMZOLL") + + End Function + + Public Shared Function setBackToCustomerCustomerID(SQL As SQL, backToCustomer As Boolean, customerNo As String) As Boolean + + Return SQL.doSQL("update tblPLOSE_Inv_Data set plInv_InvToCustomer = " & IIf(backToCustomer, "1", "NULL") & " where plInv_InvToCustomer Is null AND plInv_PLOSEKundennummer = '" & customerNo & "'", "FMZOLL") + + End Function + + Public Shared Function setBackToCustomerInvoiceID(SQL As SQL, backToCustomer As Boolean, Optional invoiceID As String = "") As Boolean + + Return SQL.doSQL("update tblPLOSE_Inv_Data set plInv_InvToCustomer = " & IIf(backToCustomer, "1", "0") & " where plInv_InvToCustomer Is null " & IIf(invoiceID <> "", "AND plInv_Id = '" & invoiceID & "'", " ") & "", "FMZOLL") + + End Function Public Shared Function setWahrunginIvoiceFromTransactions(jahr As Integer, Optional message As Boolean = False, Optional kdNr As Integer = -1) As Boolean diff --git a/UID/usrctlProcedures.Designer.vb b/UID/usrctlProcedures.Designer.vb index bbd4e8f..5863c8e 100644 --- a/UID/usrctlProcedures.Designer.vb +++ b/UID/usrctlProcedures.Designer.vb @@ -59,8 +59,6 @@ Partial Class usrctlProcedures Me.Button11 = New System.Windows.Forms.Button() Me.Button10 = New System.Windows.Forms.Button() Me.DataGridView1 = New System.Windows.Forms.DataGridView() - Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn() - Me.Column2 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Button9 = New System.Windows.Forms.Button() Me.Button8 = New System.Windows.Forms.Button() Me.Button7 = New System.Windows.Forms.Button() @@ -157,6 +155,10 @@ Partial Class usrctlProcedures Me.Button99 = New System.Windows.Forms.Button() Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn() + Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn() + Me.Column2 = New System.Windows.Forms.DataGridViewTextBoxColumn() + Me.Button54 = New System.Windows.Forms.Button() + Me.Label23 = New System.Windows.Forms.Label() Me.TabControl1.SuspendLayout() Me.TabPage3.SuspendLayout() Me.TabPage1.SuspendLayout() @@ -539,16 +541,6 @@ Partial Class usrctlProcedures Me.DataGridView1.Size = New System.Drawing.Size(240, 431) Me.DataGridView1.TabIndex = 5 ' - 'Column1 - ' - Me.Column1.HeaderText = "dat" - Me.Column1.Name = "Column1" - ' - 'Column2 - ' - Me.Column2.HeaderText = "anz" - Me.Column2.Name = "Column2" - ' 'Button9 ' Me.Button9.Location = New System.Drawing.Point(131, 131) @@ -793,6 +785,8 @@ Partial Class usrctlProcedures ' 'TabPage6 ' + Me.TabPage6.Controls.Add(Me.Label23) + Me.TabPage6.Controls.Add(Me.Button54) Me.TabPage6.Controls.Add(Me.Label19) Me.TabPage6.Controls.Add(Me.Label18) Me.TabPage6.Controls.Add(Me.Label17) @@ -1449,6 +1443,34 @@ Partial Class usrctlProcedures Me.DataGridViewTextBoxColumn2.HeaderText = "anz" Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2" ' + 'Column1 + ' + Me.Column1.HeaderText = "dat" + Me.Column1.Name = "Column1" + ' + 'Column2 + ' + Me.Column2.HeaderText = "anz" + Me.Column2.Name = "Column2" + ' + 'Button54 + ' + Me.Button54.Location = New System.Drawing.Point(33, 133) + Me.Button54.Name = "Button54" + Me.Button54.Size = New System.Drawing.Size(106, 28) + Me.Button54.TabIndex = 72 + Me.Button54.Text = "ZNB Zinssätze" + Me.Button54.UseVisualStyleBackColor = True + ' + 'Label23 + ' + Me.Label23.AutoSize = True + Me.Label23.Location = New System.Drawing.Point(11, 141) + Me.Label23.Name = "Label23" + Me.Label23.Size = New System.Drawing.Size(16, 13) + Me.Label23.TabIndex = 73 + Me.Label23.Text = "3." + ' 'usrctlProcedures ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -1664,4 +1686,6 @@ Partial Class usrctlProcedures Friend WithEvents Label22 As Label Friend WithEvents dtpbis As DateTimePicker Friend WithEvents Button53 As Button + Friend WithEvents Label23 As Label + Friend WithEvents Button54 As Button End Class diff --git a/UID/usrctlProcedures.vb b/UID/usrctlProcedures.vb index b9ceba3..e69fa44 100644 --- a/UID/usrctlProcedures.vb +++ b/UID/usrctlProcedures.vb @@ -4098,7 +4098,7 @@ Public Class usrctlProcedures Dim kdnr_tmp = "" Try - VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False + VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxMDM_Testsystem.Checked Dim fd As New OpenFileDialog If fd.ShowDialog = DialogResult.OK Then @@ -4181,7 +4181,7 @@ Public Class usrctlProcedures Try - VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True + VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxMDM_Testsystem.Checked Dim fd As New OpenFileDialog If fd.ShowDialog = DialogResult.OK Then @@ -4341,6 +4341,7 @@ OPTION (MAXRECURSION 1000);", "AVISO") ' Case "Vereinigte Arabische Emirate" : ISO2SetCountry = "AE" Case "Vereinigte Staaten" : ISO2SetCountry = "US" Case "Vereinigtes Königreich" : ISO2SetCountry = "GB" + Case "Bosnien und Herzegowina" : ISO2SetCountry = "BA" End Select @@ -4359,6 +4360,61 @@ OPTION (MAXRECURSION 1000);", "AVISO") ' End Sub + Private Sub Button54_Click(sender As Object, e As EventArgs) Handles Button54.Click + + + Dim cnt = 0 + Dim sql As New VERAG_PROG_ALLGEMEIN.SQL + + Try + + VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxMDM_Testsystem.Checked + + Dim fd As New OpenFileDialog + If fd.ShowDialog = DialogResult.OK Then + If fd.FileName.ToLower.EndsWith(".csv") Then + + ' fd.FileName.EndsWith(".csv") + Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(fd.FileName, Encoding.Default) + MyReader.TextFieldType = FileIO.FieldType.Delimited + MyReader.SetDelimiters(";") + Dim currentRow As String() + While Not MyReader.EndOfData + Try + currentRow = MyReader.ReadFields() + + If currentRow.Length > 1 AndAlso isleernothing(currentRow(0)) IsNot Nothing AndAlso IsNumeric(currentRow(0)) Then + + Dim KUNDE_ERW As New cKundenErweitert(currentRow(0)) + + If isleernothing(currentRow(1)) IsNot Nothing AndAlso IsNumeric(currentRow(1)) Then + KUNDE_ERW.kde_zinssatz = CDbl(currentRow(1)) + KUNDE_ERW.SAVE() + End If + + + + End If + + + cnt += 1 + + Catch ex As Exception + MsgBox(ex.Message & ex.StackTrace) + End Try + End While + End Using + End If + End If + + Catch ex As Exception + MessageBox.Show("Datei nicht vorhanden.") + Finally + + End Try + + End Sub + 'Private Sub Button26_Click(sender As Object, e As EventArgs) diff --git a/initATLASAufschubkonten/frmStartOptions.vb b/initATLASAufschubkonten/frmStartOptions.vb index 4ef30c8..fe2dbd4 100644 --- a/initATLASAufschubkonten/frmStartOptions.vb +++ b/initATLASAufschubkonten/frmStartOptions.vb @@ -8,7 +8,9 @@ Imports System.Threading Imports System.Xml Imports com.sun.crypto.provider Imports com.sun.org.apache.bcel.internal.generic +Imports com.sun.org.apache.xpath.internal.operations Imports com.sun.xml.internal.rngom +Imports io.konik.zugferd Imports MDM_Worker Imports Renci.SshNet Imports VERAG_PROG_ALLGEMEIN @@ -6918,7 +6920,11 @@ repeatRequest: Dim sql_query = "" + Dim sql_query_keineMWST = "" + 'alle ab 2025! + + Dim test As String = " AND Adressen.AdressenNr = 401026" Select Case Lieferant Case "IDS" @@ -6926,40 +6932,108 @@ repeatRequest: inner join [VERAG].[dbo].[tbl_IDS_Kunden] on tblIDSInvoicesNewSplittedByCountry.CustomerCode = tbl_IDS_Kunden.CustomerCode inner join Adressen on Adressen.AdressenNr = KdNrVERAG WHERE tblIDSInvoicesNewSplittedByCountry.[CustomerCode] in (SELECT distinct([CustomerCode]) FROM [VERAG].[dbo].[tbl_IDS_Kunden] - WHERE 1 = 1 AND isnull([tbl_IDS_Kunden].KdNrAlt, 0) = 0) AND tblIDSInvoicesNewSplittedByCountry.InvToCustomer is null" + WHERE 1 = 1 AND isnull([tbl_IDS_Kunden].KdNrAlt, 0) = 0) AND tblIDSInvoicesNewSplittedByCountry.InvToCustomer is null and Year(YearMonthDay) > 2024" + + sql_query_keineMWST = "select distinct(tblKundenErweitert.kde_KundenNr) as KundenNr FROM tblIDSInvoicesNewSplittedByCountry + inner join [VERAG].[dbo].[tbl_IDS_Kunden] on tblIDSInvoicesNewSplittedByCountry.CustomerCode = tbl_IDS_Kunden.CustomerCode + inner join tblKundenErweitert on tblKundenErweitert.kde_KundenNr = KdNrVERAG + WHERE tblIDSInvoicesNewSplittedByCountry.[CustomerCode] in (SELECT distinct([CustomerCode]) FROM [VERAG].[dbo].[tbl_IDS_Kunden] + WHERE 1 = 1 AND isnull([tbl_IDS_Kunden].KdNrAlt, 0) = 0) AND tblIDSInvoicesNewSplittedByCountry.InvToCustomer is null and Year(YearMonthDay) > 2024 and kde_keineMWSt = 1" Case "MSE" - sql_query = " select partner_customer_number as KundenNr,invoice_id,LandKz as KundenLandKz, total_vat_amount_euro as MWST, country as RELandKz FROM tblMSEInvoices + sql_query = " select customer_number as KundenNr,invoice_id,LandKz as KundenLandKz, total_vat_amount_euro as MWST, country as RELandKz FROM tblMSEInvoices inner join tblMSECustomers on customer_id = [customer_number] inner join Adressen on Adressen.AdressenNr = partner_customer_number - where tblMSEInvoices.InvToCustomer is null and Year()" + where tblMSEInvoices.InvToCustomer is null and Year(invoice_date) > 2024" + + sql_query_keineMWST = "select distinct(customer_number) as KundenNr FROM tblMSEInvoices + inner join tblMSECustomers on customer_id = [customer_number] + inner join tblKundenErweitert on tblKundenErweitert.kde_KundenNr = partner_customer_number + where tblMSEInvoices.InvToCustomer is null and Year(invoice_date) > 2024 and kde_keineMWSt = 1" Case "PLOSE" - sql_query = " select Adressen.AdressenNr as KundenNr, [plInv_Id] as invoice_id,LandKz as KundenLandKz ,[plInv_MWSTBetrag] as MWST, [plInv_SupplierCountry] as RELandKz FROM tblPLOSE_Inv_Data + + Dim kdNrPlose As String = "" + If txtPLoseKdNr.Text <> "" AndAlso IsNumeric(txtPLoseKdNr.Text) Then + kdNrPlose = " AND plInv_PLOSEKundennummer = " & txtPLoseKdNr.Text + End If + + sql_query = " select plInv_PLOSEKundennummer as KundenNr, [plInv_Id] as invoice_id,LandKz as KundenLandKz ,[plInv_MWSTBetrag] as MWST, [plInv_SupplierCountry] as RELandKz FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer - where plInv_InvToCustomer is null" + where plInv_InvToCustomer is null and YEAR(plInv_SupplierRechnungsDatum) > 2024" & kdNrPlose + + + sql_query_keineMWST = "select distinct(plInv_PLOSEKundennummer) as KundenNr FROM tblPLOSE_Inv_Data + inner join tblKundenErweitert on tblKundenErweitert.kde_KundenNr = plInv_PLOSEKundennummer + where plInv_InvToCustomer is null and YEAR(plInv_SupplierRechnungsDatum) > 2024 and kde_keineMWSt = 1 " Case "UTA" - sql_query = " select Adressen.AdressenNr as KundenNr,[Rechnungsnummer_pro_Lieferland] as invoice_id,LandKz as KundenLandKz, SUM(Gesamtbetrag_Umsatzsteuer_in_Darstellwährung) as MWSt,[Lieferland_ISO2] as RELandKz FROM [VERAG].[dbo].[tblUTAImportNew] - inner join adressen on Kundennummer = UTAKundenNr - where InvToCustomer is null - group by Adressen.AdressenNr,[Rechnungsnummer_pro_Lieferland],LandKz,[Lieferland_ISO2]" + sql_query = " select Adressen.UTAKundenNr as KundenNr,[Rechnungsnummer_pro_Lieferland] as invoice_id,LandKz as KundenLandKz, SUM(Gesamtbetrag_Umsatzsteuer_in_Darstellwährung) as MWSt,[Lieferland_ISO2] as RELandKz FROM [VERAG].[dbo].[tblUTAImportNew] + inner join Adressen on Adressen.UTAKundenNr= [tblUTAImportNew].Kundennummer + inner join tblKundenErweitert on tblKundenErweitert.kde_KundenNr = Adressen.AdressenNr + where InvToCustomer is null and Year(Rechnungsdatum) > 2024 + group by Adressen.UTAKundenNr ,[Rechnungsnummer_pro_Lieferland],LandKz,[Lieferland_ISO2]" + + sql_query_keineMWST = "select distinct(Adressen.UTAKundenNr) as KundenNr FROM [VERAG].[dbo].[tblUTAImportNew] + inner join Adressen on Adressen.UTAKundenNr= [tblUTAImportNew].Kundennummer + inner join tblKundenErweitert on tblKundenErweitert.kde_KundenNr = Adressen.AdressenNr + where InvToCustomer is null and Year(Rechnungsdatum) > 2024 and kde_keineMWSt = 1 + group by Adressen.UTAKundenNr " Case "RMC" - sql_query = " select Adressen.AdressenNr as KundenNr,rmc_id as invoice_id,LandKz as KundenLandKz,[rmc_betragMWST] as MWST,rmc_landKZ as RELandKz + sql_query = " select Adressen.WölflKundenNr as KundenNr,rmc_id as invoice_id,LandKz as KundenLandKz,[rmc_betragMWST] as MWST,rmc_landKZ as RELandKz FROM [VERAG].[dbo].[tblRMCImport] - inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr - where InvToCustomer is null" + inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr + where InvToCustomer is null and Year(rmc_reDatum) > 2024" + + sql_query_keineMWST = "select distinct(Adressen.WölflKundenNr) as KundenNr FROM [VERAG].[dbo].[tblRMCImport] + inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr + inner join tblKundenErweitert on tblKundenErweitert.kde_KundenNr = Adressen.AdressenNr + where InvToCustomer is null and Year(rmc_reDatum) > 2024 and kde_keineMWSt = 1" End Select - - - Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL + + + Dim dt_keineMWST As DataTable = SQL.loadDgvBySql(sql_query_keineMWST, "FMZOLL") + + 'zuerst alle setzen, MWST nicht MDM uns machen! + For Each r In dt_keineMWST.Rows + + If Not IsDBNull(r.Item("KundenNr")) AndAlso IsNumeric(r.Item("KundenNr")) Then + Select Case Lieferant + Case "IDS" 'OK + + Dim IDS As cIDS + IDS.setBackToCustomerCustomerID(SQL, True, r.Item("KundenNr")) + + Case "MSE" 'OK + Dim MSE As cMSEAPI + MSE.setBackToCustomerCustomerID(SQL, True, r.Item("KundenNr")) + + Case "PLOSE" + Dim ploseRE As cPLOSE_Inv_Data + ploseRE.setBackToCustomerCustomerID(SQL, True, r.Item("KundenNr")) + + Case "UTA" + + Dim uta As cUTA + uta.setBackToCustomerCustomerID(SQL, True, r.Item("KundenNr")) + + Case "RMC" + Dim rmc As cRMC + rmc.setBackToCustomerCustomerID(SQL, True, r.Item("KundenNr")) + + End Select + + End If + + Next + Dim dtnichtGesetzteInvToCustomer As DataTable = SQL.loadDgvBySql(sql_query, "FMZOLL") @@ -6968,7 +7042,6 @@ repeatRequest: 'checks! 'ORIGINAL-RECHNUNG setzen: - If Not IsDBNull(r.Item("MWST")) AndAlso IsNumeric(r.Item("MWST")) AndAlso CDbl(r.Item("MWST")) = 0 Then 'wenn die Rechnung die MWST-SUMME 0 aufweist!!! @@ -7026,14 +7099,32 @@ repeatRequest: Next Select Case Lieferant - Case "IDS" : SQL.doSQL("update tblIDSInvoicesNewSplittedByCountry set InvToCustomer = 0 where InvToCustomer is null", "FMZOLL") - Case "MSE" : SQL.doSQL("update tblMSEInvoices set InvToCustomer = 0 where InvToCustomer is null", "FMZOLL") - Case "PLOSE" : SQL.doSQL("update tblPLOSE_Inv_Data set plInv_InvToCustomer = 0 where plInv_InvToCustomer is null", "FMZOLL") - Case "UTA" : SQL.doSQL("update tblUTAImportNew set InvToCustomer = 0 where InvToCustomer is null", "FMZOLL") - Case "RMC" : SQL.doSQL("update tblRMCImport set InvToCustomer = 0 where InvToCustomer is null", "FMZOLL") + Case "IDS" + + Dim IDS As cIDS + IDS.setBackToCustomerInvoiceID(SQL, False) + + Case "MSE" + Dim MSE As cMSEAPI + MSE.setBackToCustomerInvoiceID(SQL, False) + + Case "PLOSE" + Dim ploseRE As cPLOSE_Inv_Data + ploseRE.setBackToCustomerInvoiceID(SQL, False) + + Case "UTA" + + Dim uta As cUTA + uta.setBackToCustomerInvoiceID(SQL, False) + + Case "RMC" + Dim rmc As cRMC + rmc.setBackToCustomerInvoiceID(SQL, False) End Select + + End Sub @@ -7042,11 +7133,30 @@ repeatRequest: Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Select Case Lieferant - Case "IDS" : SQL.doSQL("update tblIDSInvoicesNewSplittedByCountry set InvToCustomer = 1 where invoice_id = '" & InvoiceID & "'", "FMZOLL") - Case "MSE" : SQL.doSQL("update tblMSEInvoices set InvToCustomer = 1 where invoice_id = '" & InvoiceID & "'", "FMZOLL") - Case "PLOSE" : SQL.doSQL("update tblPLOSE_Inv_Data set plInv_InvToCustomer = 1 where plInv_Id = '" & InvoiceID & "'", "FMZOLL") - Case "UTA" : SQL.doSQL("update tblUTAImportNew set InvToCustomer = 1 where [Rechnungsnummer_pro_Lieferland] = '" & InvoiceID & "'", "FMZOLL") - Case "RMC" : SQL.doSQL("update tblRMCImport set InvToCustomer = 1 where rmc_id = '" & InvoiceID & "'", "FMZOLL") + Case "IDS" + + Dim IDS As cIDS + IDS.setBackToCustomerInvoiceID(SQL, True, InvoiceID) + + + Case "MSE" + Dim MSE As cMSEAPI + MSE.setBackToCustomerInvoiceID(SQL, True, InvoiceID) + + + Case "PLOSE" + Dim ploseRE As cPLOSE_Inv_Data + ploseRE.setBackToCustomerInvoiceID(SQL, True, InvoiceID) + + Case "UTA" + + Dim uta As cUTA + uta.setBackToCustomerInvoiceID(SQL, True, InvoiceID) + + Case "RMC" + Dim rmc As cRMC + rmc.setBackToCustomerInvoiceID(SQL, True, InvoiceID) + End Select