diff --git a/SDL/My Project/AssemblyInfo.vb b/SDL/My Project/AssemblyInfo.vb index 14eeb4e0..da1f2415 100644 --- a/SDL/My Project/AssemblyInfo.vb +++ b/SDL/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/SDL/USTV/VATRefund.vb b/SDL/USTV/VATRefund.vb index 237c9ae8..b56c3e9c 100644 --- a/SDL/USTV/VATRefund.vb +++ b/SDL/USTV/VATRefund.vb @@ -177,9 +177,10 @@ Public Class VATRefundApplication '========================= Private Sub UpdatePartyXml(xml As Xml, path As String, party As Party) xml.UpdateChildContent($"{path}|NameFree", party.NameFree) - If party.VATIdentificationNumber.HasValue Then - xml.UpdateChildContentInt($"{path}|VATIdentificationNumber", party.VATIdentificationNumber.Value) - End If + 'If party.VATIdentificationNumber.HasValue Then + ' xml.UpdateChildContentInt($"{path}|VATIdentificationNumber", party.VATIdentificationNumber.Value) + 'End If + xml.UpdateChildContent($"{path}|VATIdentificationNumber", party.VATIdentificationNumber) xml.UpdateChildContent($"{path}|AddressFree", party.AddressFree) xml.UpdateChildContent($"{path}|PostCode", party.PostCode) xml.UpdateChildContent($"{path}|Phone", party.Phone) @@ -226,7 +227,7 @@ End Class Public Class Party Public Property NameFree As String - Public Property VATIdentificationNumber As Integer? + Public Property VATIdentificationNumber As String Public Property AddressFree As String Public Property PostCode As String Public Property Phone As String diff --git a/SDL/USTV/frmMDM_USTVAntrag.vb b/SDL/USTV/frmMDM_USTVAntrag.vb index 233ee031..58f55d9a 100644 --- a/SDL/USTV/frmMDM_USTVAntrag.vb +++ b/SDL/USTV/frmMDM_USTVAntrag.vb @@ -1,6 +1,8 @@ Imports System.IO +Imports System.IO.Compression Imports System.Reflection Imports System.Windows.Documents +Imports com.sun.net.httpserver.Authenticator Imports itextsharp.text.pdf Imports Microsoft.Office.Interop Imports VERAG_PROG_ALLGEMEIN @@ -840,21 +842,21 @@ Public Class frmMDM_USTVAntrag If USTV_ANTRAG.UStVAn_Währungscode <> "EUR" AndAlso ANTRAG.plose_WaehrungAbbuchung = "EUR" Then - UST_org = Math.round(kurs.EXCHANGE_EURTOCUR(UST_EUR, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + UST_org = Math.Round(kurs.EXCHANGE_EURTOCUR(UST_EUR, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) ElseIf USTV_ANTRAG.UStVAn_Währungscode = "EUR" AndAlso ANTRAG.plose_WaehrungAbbuchung <> "EUR" Then - UST_EUR = Math.round(kurs.EXCHANGE_CURTOEUR(UST_org, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + UST_EUR = Math.Round(kurs.EXCHANGE_CURTOEUR(UST_org, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) ElseIf USTV_ANTRAG.UStVAn_Währungscode <> "EUR" AndAlso ANTRAG.plose_WaehrungAbbuchung <> "EUR" Then - UST_EUR = Math.round(kurs.EXCHANGE_CURTOEUR(UST_org, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + UST_EUR = Math.Round(kurs.EXCHANGE_CURTOEUR(UST_org, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) End If If (UST_org <> 0 AndAlso UST_org <> UST_EUR) Then - umrechKurs = Math.floor((UST_org / UST_EUR * 100 + 0.5)) / 100 + umrechKurs = Math.Floor((UST_org / UST_EUR * 100 + 0.5)) / 100 End If @@ -982,7 +984,7 @@ Public Class frmMDM_USTVAntrag Dim umrechKurs As Double = 1 Dim UST_EUR = CDbl(r.Item("SteuerbetragLokal")) - UST_EUR = Math.round(UST_EUR, 2) + UST_EUR = Math.Round(UST_EUR, 2) USTV_POS.UStVPo_USteuerbetragEUR = UST_EUR USTV_POS.UStVPo_Umrechnungskurs = umrechKurs @@ -1100,12 +1102,12 @@ Public Class frmMDM_USTVAntrag 'umrechKurs = frmdw / eur - umrechKurs = Math.floor((UST_org / UST_EUR * 100 + 0.5)) / 100 + umrechKurs = Math.Floor((UST_org / UST_EUR * 100 + 0.5)) / 100 End If If CDbl(r.Item("rmc_betragMWST")) <> 0 Then - USTV_POS.UStVPo_USteuerbetragEUR = Math.round((r.Item("rmc_betragMWST") / umrechKurs), 2) + USTV_POS.UStVPo_USteuerbetragEUR = Math.Round((r.Item("rmc_betragMWST") / umrechKurs), 2) USTV_POS.UStVPo_Umrechnungskurs = umrechKurs USTV_POS.UStVPo_USteuerbetrag = r.Item("rmc_betragMWST") End If @@ -1178,7 +1180,7 @@ Public Class frmMDM_USTVAntrag 'umrechKurs = UST_org / UST_EUR - umrechKurs = Math.floor((UST_org / UST_EUR * 100 + 0.5)) / 100 + umrechKurs = Math.Floor((UST_org / UST_EUR * 100 + 0.5)) / 100 End If @@ -1260,7 +1262,7 @@ Public Class frmMDM_USTVAntrag If (UST_org <> 0 AndAlso UST_org <> UST_EUR) Then - umrechKurs = Math.floor((UST_org / UST_EUR * 100 + 0.5)) / 100 + umrechKurs = Math.Floor((UST_org / UST_EUR * 100 + 0.5)) / 100 End If @@ -1376,11 +1378,11 @@ Public Class frmMDM_USTVAntrag If USTV_ANTRAG.UStVAn_Währungscode <> "EUR" Then Dim kurs As New cEZB_Waehrungskurse(USTV_ANTRAG.UStVAn_Währungscode) - UST_org = Math.round(kurs.EXCHANGE_EURTOCUR(UST_EUR, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + UST_org = Math.Round(kurs.EXCHANGE_EURTOCUR(UST_EUR, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) End If If (UST_org <> 0 AndAlso UST_org <> UST_EUR) Then - umrechKurs = Math.floor((UST_org / UST_EUR * 100 + 0.5)) / 100 + umrechKurs = Math.Floor((UST_org / UST_EUR * 100 + 0.5)) / 100 End If @@ -1543,8 +1545,8 @@ Public Class frmMDM_USTVAntrag Else USTV_POS.UStVPo_USteuerbetrag = r.Cells("total_VAT_amount").Value - USTV_POS.UStVPo_USteuerbetragEUR = Math.round(kurs.EXCHANGE_CURTOEUR(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, CDate(USTV_POS.UStVPo_ReDat)), 2) - USTV_POS.UStVPo_Umrechnungskurs = Math.floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 + USTV_POS.UStVPo_USteuerbetragEUR = Math.Round(kurs.EXCHANGE_CURTOEUR(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, CDate(USTV_POS.UStVPo_ReDat)), 2) + USTV_POS.UStVPo_Umrechnungskurs = Math.Floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 End If Else '2. Antragswährung <> Belegswährung (EUR zu FREMD und FREMD zu EUR) @@ -1552,10 +1554,10 @@ Public Class frmMDM_USTVAntrag Dim kurs As New cEZB_Waehrungskurse(r.Cells("total_VAT_currency").Value) If r.Cells("total_VAT_currency").Value <> "EUR" Then USTV_POS.UStVPo_USteuerbetrag = r.Cells("total_VAT_amount").Value - USTV_POS.UStVPo_USteuerbetragEUR = Math.round(kurs.EXCHANGE_CURTOEUR(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, CDate(USTV_POS.UStVPo_ReDat)), 2) - USTV_POS.UStVPo_Umrechnungskurs = Math.floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 + USTV_POS.UStVPo_USteuerbetragEUR = Math.Round(kurs.EXCHANGE_CURTOEUR(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, CDate(USTV_POS.UStVPo_ReDat)), 2) + USTV_POS.UStVPo_Umrechnungskurs = Math.Floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 ElseIf r.Cells("total_VAT_currency").Value = "EUR" Then - USTV_POS.UStVPo_USteuerbetrag = Math.round(kurs.EXCHANGE_EURTOCUR(r.Cells("total_VAT_amount").Value, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + USTV_POS.UStVPo_USteuerbetrag = Math.Round(kurs.EXCHANGE_EURTOCUR(r.Cells("total_VAT_amount").Value, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) USTV_POS.UStVPo_USteuerbetragEUR = USTV_POS.UStVPo_USteuerbetrag USTV_POS.UStVPo_Umrechnungskurs = 1 End If @@ -1564,13 +1566,13 @@ Public Class frmMDM_USTVAntrag If r.Cells("total_VAT_currency").Value = "EUR" Then USTV_POS.UStVPo_USteuerbetragEUR = r.Cells("total_VAT_amount").Value Dim kurs As New cEZB_Waehrungskurse(USTV_ANTRAG.UStVAn_Währungscode) - USTV_POS.UStVPo_USteuerbetrag = Math.round(kurs.EXCHANGE_EURTOCUR(r.Cells("total_VAT_amount").Value, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) - USTV_POS.UStVPo_Umrechnungskurs = Math.floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 + USTV_POS.UStVPo_USteuerbetrag = Math.Round(kurs.EXCHANGE_EURTOCUR(r.Cells("total_VAT_amount").Value, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + USTV_POS.UStVPo_Umrechnungskurs = Math.Floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 Else USTV_POS.UStVPo_USteuerbetrag = VERAG_PROG_ALLGEMEIN.cProgramFunctions.fktEuro(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, USTV_ANTRAG.UStVAn_Währungscode) Dim kurs As New cEZB_Waehrungskurse(USTV_ANTRAG.UStVAn_Währungscode) - USTV_POS.UStVPo_USteuerbetragEUR = Math.round(kurs.EXCHANGE_CURTOEUR(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, CDate(USTV_POS.UStVPo_ReDat)), 2) - USTV_POS.UStVPo_Umrechnungskurs = Math.floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 + USTV_POS.UStVPo_USteuerbetragEUR = Math.Round(kurs.EXCHANGE_CURTOEUR(r.Cells("total_VAT_amount").Value, r.Cells("total_VAT_currency").Value, CDate(USTV_POS.UStVPo_ReDat)), 2) + USTV_POS.UStVPo_Umrechnungskurs = Math.Floor((CDbl(USTV_POS.UStVPo_USteuerbetrag) / CDbl(USTV_POS.UStVPo_USteuerbetragEUR) * 100 + 0.5)) / 100 End If @@ -1632,10 +1634,10 @@ Public Class frmMDM_USTVAntrag averageUmrechnungskurs = averageUmrechnungskurs / dgvUSTVPositionen.Rows.Count End If - Dim abw As Double = Math.abs(Math.round(GesamtUSteuer / averageUmrechnungskurs, 2) - Math.round(GesamtUSteuerEUR, 2)) + Dim abw As Double = Math.Abs(Math.Round(GesamtUSteuer / averageUmrechnungskurs, 2) - Math.Round(GesamtUSteuerEUR, 2)) If abw >= 250 Then - MsgBox("Bitte Umrechnungskurs in den Antragspositionen kontrollieren!" & vbNewLine & "Der Steuerbetrag weicht um " & Math.round(abw, 2) & "€ vom FW-Steuerbetrag ab! ") + MsgBox("Bitte Umrechnungskurs in den Antragspositionen kontrollieren!" & vbNewLine & "Der Steuerbetrag weicht um " & Math.Round(abw, 2) & "€ vom FW-Steuerbetrag ab! ") End If End If @@ -4004,13 +4006,13 @@ Public Class frmMDM_USTVAntrag .an_r = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Year, .d_rec = 0, .luna_r = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month, - .cif = ADR.Steuernummer.ToString.Replace("RO", ""), + .cif = ADR.UstIdNr, .totalPlata_A = 0 }, .ProrateAdjustment = New ProrateAdjustment With {.Year = "", .FinalProrate = ""}, .Applicant = New Party With { .NameFree = ADR.Name_1, - .VATIdentificationNumber = ADR.Steuernummer.ToString.Replace("RO", ""), + .VATIdentificationNumber = ADR.UstIdNr, .AddressFree = ADR.Straße.ToString & vbCrLf & ADR.LandKz.ToString & " - " & ADR.PLZ.ToString & " -" & ADR.Ort.ToString, '"RO - 550270 - MUN. SIBIU", .PostCode = "", .Phone = "", .EmailAddress = "juricevic@verag.ag" }, @@ -4028,34 +4030,43 @@ Public Class frmMDM_USTVAntrag .IdentificationType = "TIN" }, .DetailedBankAccount = New BankAccount With { - .Total = 5947.99D, + .Total = txtSummeEUR._value.ToString.Replace(",", "."), .Currency = "EUR", .OwnerType = 1, .OwnerName = "VERAG 360 GMBH", .IBAN = "AT053445500004210225", .BIC = "RZOOAT2L455" }, - .NumberOfDocuments = New NumberOfDocuments With {.AtachatedFiles = 0, .PurchaseOrders = 16, .ImportOrders = 0}, - .ApplicantSignature = New Signature With {.NameFree = "", .Position = ""} + .NumberOfDocuments = New NumberOfDocuments With {.AtachatedFiles = 0, .PurchaseOrders = dgvUSTVPositionen.SelectedRows.Count, .ImportOrders = 0}, + .ApplicantSignature = New Signature With {.NameFree = "LUXBAUER BRIGITTE", .Position = "IMPUTERNICIT"} } Dim counter As Integer = 1 + For Each row As DataGridViewRow In dgvUSTVPositionen.SelectedRows.Cast(Of DataGridViewRow)().OrderBy(Function(dgvr) dgvr.Index) + Dim UIDNrLeistender = "" + + If row.Cells("UstV_Leistender_UstNr").Value IsNot Nothing AndAlso row.Cells("UstV_Leistender_UstNr").Value <> "" IsNot Nothing Then + UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "") + End If + + + app.PurchaseInformation.Invoices.Add(New Invoice With { .SequenceNumber = counter, .SimplifiedInvoice = 0, .ReferenceNumber = row.Cells("UStVPo_ReNr").Value, ' "25/000616354/987", .IssuingDate = row.Cells("UStVPo_ReDat").Value,'"2025-11-30", .GoodsDescription = New GoodsDescription With {.GoodsItem = New GoodsItem With {.Code = 1, .SubCode = "1.1.2", .FreeText = ""}}, - .TransactionDescription = New TransactionDescription With {.TaxableAmount = "00.00", .VATAmount = row.Cells("UStVPo_USteuerbetrag").Value}, - .Deduction = New Deduction With {.ProRataRate = "", .DeductibleVATAmount = row.Cells("UStVPo_USteuerbetrag").Value}, + .TransactionDescription = New TransactionDescription With {.TaxableAmount = "00.00", .VATAmount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", ".")}, + .Deduction = New Deduction With {.ProRataRate = "", .DeductibleVATAmount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", ".")}, .EUSupplier = New Party With { .NameFree = row.Cells("UStVPo_Leistender").Value,'"DKV EURO SERVICE GMBH + CO KG", - .AddressFree = row.Cells("UstV_Leistender_Strasse").Value & " " & row.Cells("UstV_Leistender_Land").Value & " " & row.Cells("UstV_Leistender_PLZ").Value & " " & row.Cells("UstV_Leistender_Stadt").Value,'"BALCKE DÜRR ALLEE 3 DE 40882 RATINGEN", - .CountryCode = Antrag_LandKz, - .VATIdentificationNumber = Nothing + .AddressFree = row.Cells("UstV_Leistender_Strasse").Value & " " & row.Cells("UstV_Leistender_Land").Value & " " & row.Cells("UstV_Leistender_PLZ").Value & " " & row.Cells("UstV_Leistender_Stadt").Value,'"BALCKE DÜRR ALLEE 3 DE 40882 RATINGEN", + .VATIdentificationNumber = UIDNrLeistender, + .CountryCode = Antrag_LandKz } }) @@ -4076,29 +4087,101 @@ Public Class frmMDM_USTVAntrag - ' ========================= ' 4️⃣ Dokumente hinzufügen ' ========================= - 'app.DocumentCopy.Add(New DocumentCopy With { - '.Bifa_atasament = 1, - '.Document = New DocumentFile With { - ' .FileName = "RG_AT_10_12_2025.zip", - ' .FileType = "application/zip", - ' .FileDescription = "INVOICES/POA" - '} - '}) - ' ========================= - ' 5️⃣ XML erzeugen - ' ========================= - Dim xml As Chilkat.Xml = app.ToXml() + + Dim list As New List(Of String) + Dim pdfPathfinished As String = "" + + If dgvUSTVPositionen.SelectedRows.Count > 0 Then + Dim nummerierung As Boolean = False + + Select Case MsgBox("Soll eine Nummerierung auf den PDF Dokumenten angegeben werden?", vbYesNoCancel) + Case vbYes : nummerierung = True + Case vbNo : nummerierung = False + Case Else : Exit Sub + End Select + + For Each row As DataGridViewRow In dgvUSTVPositionen.SelectedRows.Cast(Of DataGridViewRow)().OrderBy(Function(dgvr) dgvr.Index) + + Dim pdf As String = "" + pdf = func.getPDF(row.Cells("UStVPo_SchnittstellenNr").Value, row.Cells("UStVPo_ReNr").Value, row.Cells("UStVPo_ReDat").Value, row.Cells("UStVPo_daId").Value, IIf(nummerierung, row.Cells("UStVPo_ID").Value, -1), True, Antrag_LandKz, USTV_ANTRAG, New cFakturierung, False) + + If pdf <> "" Then list.Add(pdf) + + Next + End If + + If list.Count = 0 Then Me.Cursor = Cursors.Default : Exit Sub + + If list.Count > 1 Then + Dim pathPDF = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("RG_" & Now.ToString("ddMMyyyyHHmmss") & ".pdf", ".pdf", False, False) + If FormularManagerNEU.MergePdfFiles(list, pathPDF) Then + pdfPathfinished = pathPDF + End If + Else + + pdfPathfinished = list(0) + + End If + + Dim fileNamePDFAttZIP As String = "RG_" & Antrag_LandKz & "_" & CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month & "_" & CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month & "_" & CDate(USTV_ANTRAG.UStVAn_ReDatBis).Year & ".zip" + + fileNamePDFAttZIP = directoryPath & "\" & fileNamePDFAttZIP + + + Dim fileZipped As Boolean = True + If pdfPathfinished <> "" Then + + ' Falls ZIP schon existiert → löschen + If File.Exists(fileNamePDFAttZIP) Then + File.Delete(fileNamePDFAttZIP) + End If + + Dim zipFile As New Chilkat.Zip() + + + Dim success = zipFile.NewZip(fileNamePDFAttZIP) + If (success = False) Then + Debug.WriteLine(zipFile.LastErrorText) + Exit Sub + End If + Dim saveExtraPath As Boolean = False + success = zipFile.AppendFiles(pdfPathfinished, saveExtraPath) + If (success = False) Then + fileZipped = False + End If + + + success = zipFile.WriteZipAndClose() + If (success = False) Then + fileZipped = False + End If + + If fileZipped Then + app.DocumentCopy.Add(New DocumentCopy With { + .Bifa_atasament = 1, + .Document = New DocumentFile With { + .FileName = fileNamePDFAttZIP, + .FileType = "application/zip", + .FileDescription = "INVOICES/POA" + } + }) + End If + + + End If + + ' ========================= + ' 5️⃣ XML erzeugen + ' ========================= + Dim xml As Chilkat.Xml = app.ToXml() Dim xmlString As String = xml.GetXml() Console.WriteLine(xmlString) System.IO.File.WriteAllText(filePath, xmlString) - - Me.Cursor = Cursors.Default