CBAM, USTVA, etc.

This commit is contained in:
2026-02-10 09:14:53 +01:00
parent 18f73c3c6f
commit 345b0eff40
3 changed files with 160 additions and 60 deletions

View File

@@ -94,11 +94,9 @@ Public Class VATRefundApplication
xml.UpdateChildContent($"{path}|IssuingDate", inv.IssuingDate) xml.UpdateChildContent($"{path}|IssuingDate", inv.IssuingDate)
' GoodsDescription ' GoodsDescription
If inv.GoodsDescription IsNot Nothing AndAlso inv.GoodsDescription.GoodsItem IsNot Nothing Then
xml.UpdateChildContentInt($"{path}|GoodsDescription|GoodsItem|Code", inv.GoodsDescription.GoodsItem.Code) UpdateGoodsDescriptionXml(xml, $"{path}|GoodsDescription", inv.GoodsDescription)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|SubCode", inv.GoodsDescription.GoodsItem.SubCode)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|FreeText", inv.GoodsDescription.GoodsItem.FreeText)
End If
' TransactionDescription ' TransactionDescription
If inv.TransactionDescription IsNot Nothing Then If inv.TransactionDescription IsNot Nothing Then
@@ -114,7 +112,8 @@ Public Class VATRefundApplication
' EUSupplier ' EUSupplier
If inv.EUSupplier IsNot Nothing Then If inv.EUSupplier IsNot Nothing Then
UpdatePartyXml(xml, $"{path}|EUSupplier", inv.EUSupplier) ' UpdatePartyXml(xml, $"{path}|EUSupplier", inv.EUSupplier)
UpdateEUSupplierXml(xml, $"{path}|EUSupplier", inv.EUSupplier)
End If End If
Next Next
@@ -127,11 +126,7 @@ Public Class VATRefundApplication
xml.UpdateChildContent($"{path}|IssuingDate", imp.IssuingDate) xml.UpdateChildContent($"{path}|IssuingDate", imp.IssuingDate)
' xml.UpdateChildContent($"{path}|ReferenceInformation", imp.ReferenceInformation) ' xml.UpdateChildContent($"{path}|ReferenceInformation", imp.ReferenceInformation)
If imp.GoodsDescription IsNot Nothing AndAlso imp.GoodsDescription.GoodsItem IsNot Nothing Then UpdateGoodsDescriptionXml(xml, $"{path}|GoodsDescription", imp.GoodsDescription)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|Code", imp.GoodsDescription.GoodsItem.Code)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|SubCode", imp.GoodsDescription.GoodsItem.SubCode)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|FreeText", imp.GoodsDescription.GoodsItem.FreeText)
End If
If imp.TransactionDescription IsNot Nothing Then If imp.TransactionDescription IsNot Nothing Then
xml.UpdateChildContent($"{path}|TransactionDescription|TaxableAmount", imp.TransactionDescription.TaxableAmount) xml.UpdateChildContent($"{path}|TransactionDescription|TaxableAmount", imp.TransactionDescription.TaxableAmount)
@@ -177,9 +172,6 @@ Public Class VATRefundApplication
'========================= '=========================
Private Sub UpdatePartyXml(xml As Xml, path As String, party As Party) Private Sub UpdatePartyXml(xml As Xml, path As String, party As Party)
xml.UpdateChildContent($"{path}|NameFree", party.NameFree) xml.UpdateChildContent($"{path}|NameFree", party.NameFree)
'If party.VATIdentificationNumber.HasValue Then
' xml.UpdateChildContentInt($"{path}|VATIdentificationNumber", party.VATIdentificationNumber.Value)
'End If
xml.UpdateChildContent($"{path}|VATIdentificationNumber", party.VATIdentificationNumber) xml.UpdateChildContent($"{path}|VATIdentificationNumber", party.VATIdentificationNumber)
xml.UpdateChildContent($"{path}|AddressFree", party.AddressFree) xml.UpdateChildContent($"{path}|AddressFree", party.AddressFree)
xml.UpdateChildContent($"{path}|PostCode", party.PostCode) xml.UpdateChildContent($"{path}|PostCode", party.PostCode)
@@ -189,8 +181,76 @@ Public Class VATRefundApplication
xml.UpdateChildContent($"{path}|RepresentativeID", party.RepresentativeID) xml.UpdateChildContent($"{path}|RepresentativeID", party.RepresentativeID)
xml.UpdateChildContent($"{path}|identificationType", party.IdentificationType) xml.UpdateChildContent($"{path}|identificationType", party.IdentificationType)
End Sub End Sub
Private Sub UpdateEUSupplierXml(xml As Xml, path As String, party As Party)
xml.UpdateChildContent($"{path}|NameFree", party.NameFree)
xml.UpdateChildContent($"{path}|AddressFree", party.AddressFree)
xml.UpdateChildContent($"{path}|PostCode", party.PostCode)
xml.UpdateChildContent($"{path}|Phone", party.Phone)
xml.UpdateChildContent($"{path}|EmailAddress", party.EmailAddress)
xml.UpdateChildContent($"{path}|CountryCode", party.CountryCode)
xml.UpdateChildContent($"{path}|RepresentativeID", party.RepresentativeID)
xml.UpdateChildContent($"{path}|identificationType", party.IdentificationType)
' 👇 VAT ONLY HERE
If Not String.IsNullOrWhiteSpace(party.VATIdentificationNumber) Then
xml.UpdateChildContent(
$"{path}|EUTraderID|VATIdentificationNumber",
party.VATIdentificationNumber)
End If
End Sub
Private Sub UpdateGoodsDescriptionXml(
xml As Chilkat.Xml,
parentPath As String,
goodsDesc As GoodsDescription)
If goodsDesc Is Nothing OrElse goodsDesc.GoodsItem Is Nothing Then Exit Sub
xml.UpdateChildContent(parentPath, "")
For i As Integer = 0 To goodsDesc.GoodsItem.Count - 1
Dim item = goodsDesc.GoodsItem(i)
Dim basePath = $"{parentPath}|GoodsItem[{i}]"
xml.UpdateChildContentInt($"{basePath}|Code", item.Code)
xml.UpdateChildContent($"{basePath}|SubCode", item.SubCode)
xml.UpdateChildContent($"{basePath}|FreeText", item.FreeText)
Next
End Sub
Private Function EnsureNode(xml As Chilkat.Xml, path As String) As Chilkat.Xml
Dim parts() As String = path.Split("|"c)
Dim current As Chilkat.Xml = xml
For Each part As String In parts
Dim node As Chilkat.Xml = current.FirstChild
Dim found As Boolean = False
While Not node Is Nothing
If node.Tag = part Then
current = node
found = True
Exit While
End If
node = node.NextSibling
End While
' If node not found, create it
If Not found Then
current = current.NewChild(part, "")
End If
Next
Return current
End Function
End Class End Class
'========================= '=========================
' UNTERKLASSEN ' UNTERKLASSEN
'========================= '=========================
@@ -268,7 +328,7 @@ Public Class Invoice
End Class End Class
Public Class GoodsDescription Public Class GoodsDescription
Public Property GoodsItem As GoodsItem Public Property GoodsItem As List(Of GoodsItem)
End Class End Class
Public Class GoodsItem Public Class GoodsItem

View File

@@ -1357,12 +1357,12 @@ Public Class frmMDM_USTVAntrag
If USTV_POS.UStVPo_Nettobetrag Is Nothing Then If USTV_POS.UStVPo_Nettobetrag Is Nothing Then
If Not IsDBNull(r.Item("Gesamtbetrag_Netto_in_Lieferlandwährung")) AndAlso r.Item("Gesamtbetrag_Netto_in_Lieferlandwährung") <> "" Then If Not IsDBNull(r.Item("Gesamtbetrag_Netto_in_Lieferlandwährung")) AndAlso IsNumeric(r.Item("Gesamtbetrag_Netto_in_Lieferlandwährung")) Then
USTV_POS.UStVPo_Nettobetrag = CDbl(r.Item("Gesamtbetrag_Netto_in_Lieferlandwährung")) USTV_POS.UStVPo_Nettobetrag = CDbl(r.Item("Gesamtbetrag_Netto_in_Lieferlandwährung"))
USTVA_Nettobetragchanged = True USTVA_Nettobetragchanged = True
End If End If
If Not IsDBNull(r.Item("Gesamtbetrag_Netto_in_Darstellwährung")) AndAlso r.Item("Gesamtbetrag_Netto_in_Darstellwährung") <> "" Then If Not IsDBNull(r.Item("Gesamtbetrag_Netto_in_Darstellwährung")) AndAlso IsNumeric(r.Item("Gesamtbetrag_Netto_in_Darstellwährung")) Then
USTV_POS.UStVPo_NettobetragEUR = CDbl(r.Item("Gesamtbetrag_Netto_in_Darstellwährung")) USTV_POS.UStVPo_NettobetragEUR = CDbl(r.Item("Gesamtbetrag_Netto_in_Darstellwährung"))
USTVA_Nettobetragchanged = True USTVA_Nettobetragchanged = True
End If End If
@@ -1555,9 +1555,9 @@ Public Class frmMDM_USTVAntrag
ElseIf USTVA_Nettobetragchanged Then ElseIf USTVA_Nettobetragchanged Then
updateNettobetrag(USTV_POS.UStVPo_ReNr, USTV_POS.UStVPo_ReDat, USTV_POS.UStVPo_SchnittstellenNr, USTV_POS) updateNettobetrag(USTV_POS.UStVPo_ReNr, USTV_POS.UStVPo_ReDat, USTV_POS.UStVPo_SchnittstellenNr, USTV_POS)
End If End If
Next Next
@@ -4175,11 +4175,13 @@ Public Class frmMDM_USTVAntrag
For Each row As DataGridViewRow In dgvUSTVPositionen.SelectedRows.Cast(Of DataGridViewRow)().OrderBy(Function(dgvr) dgvr.Index) For Each row As DataGridViewRow In dgvUSTVPositionen.SelectedRows.Cast(Of DataGridViewRow)().OrderBy(Function(dgvr) dgvr.Index)
Dim UIDNrLeistender = "" Dim UIDNrLeistender = ""
Dim LeistenderName As String = ""
Dim maut As Boolean = False Dim maut As Boolean = False
Dim diesel As Boolean = False Dim diesel As Boolean = False
Dim parkplatz As Boolean = False Dim parkplatz As Boolean = False
Dim zubeh As Boolean = False Dim zubeh As Boolean = False
Dim uebernachtung As Boolean = False
If Not IsDBNull(row.Cells("UstV_Leistender_UstNr").Value) AndAlso row.Cells("UstV_Leistender_UstNr").Value IsNot Nothing AndAlso row.Cells("UstV_Leistender_UstNr").Value <> "" IsNot Nothing Then If Not IsDBNull(row.Cells("UstV_Leistender_UstNr").Value) AndAlso row.Cells("UstV_Leistender_UstNr").Value IsNot Nothing AndAlso row.Cells("UstV_Leistender_UstNr").Value <> "" IsNot Nothing Then
@@ -4187,32 +4189,65 @@ Public Class frmMDM_USTVAntrag
UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "") UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "")
End If End If
LeistenderName = row.Cells("UStVPo_Leistender").Value
LeistenderName.ToString.Replace(Antrag_LandKz, "")
Dim Nettobetrag As Double = 0
If Not IsDBNull(row.Cells("UStVPo_Nettobetrag").Value) AndAlso IsNumeric(row.Cells("UStVPo_Nettobetrag").Value) Then Nettobetrag = CDbl(row.Cells("UStVPo_Nettobetrag").Value)
If Not IsDBNull(row.Cells("UStVPo_Leistungsbezeichnung").Value) AndAlso row.Cells("UStVPo_Leistungsbezeichnung").Value IsNot Nothing Then If Not IsDBNull(row.Cells("UStVPo_Leistungsbezeichnung").Value) AndAlso row.Cells("UStVPo_Leistungsbezeichnung").Value IsNot Nothing Then
Dim Bez As String = row.Cells("UStVPo_Leistungsbezeichnung").Value Dim Bez As String = row.Cells("UStVPo_Leistungsbezeichnung").Value
Bez = Bez.ToLower Bez = Bez.ToLower
If Bez.Contains("maut") Then maut = True If Bez.Contains("maut") Or Bez.Contains("toll") Then maut = True
If Bez.Contains("diesel") Then diesel = True If Bez.Contains("diesel") Or Bez.Contains("fuel") Then diesel = True
If Bez.Contains("parkplatz") Then parkplatz = True If Bez.Contains("parkplatz") Then parkplatz = True
If Bez.Contains("zubeh") Then zubeh = True If Bez.Contains("zubeh") Then zubeh = True
If Bez.Contains("übern") Then uebernachtung = True
End If End If
Dim Nettobetrag As Double = 0 Dim goods As New GoodsDescription With {.GoodsItem = New List(Of GoodsItem)}
If Not IsDBNull(row.Cells("UStVPo_Nettobetrag").Value) AndAlso IsNumeric(row.Cells("UStVPo_Nettobetrag").Value) Then Nettobetrag = CDbl(row.Cells("UStVPo_Nettobetrag").Value)
'diesel Code 1 SubCode 1.1.2
'maut Code 4 SubCode 4.1
'Zubehör Code 3 SubCode 3.1.5
'parkplatz Code 3 SubCode 3.1.4
'Übernachtung Code 6 SubCode 6.5
If diesel Then
goods.GoodsItem.Add(New GoodsItem With {.Code = 1, .SubCode = "1.1.2", .FreeText = ""})
End If
If maut Then
goods.GoodsItem.Add(New GoodsItem With {.Code = 4, .SubCode = "4.1", .FreeText = ""})
End If
If zubeh Then
goods.GoodsItem.Add(New GoodsItem With {.Code = 3, .SubCode = "3.1.5", .FreeText = ""})
End If
If parkplatz Then
goods.GoodsItem.Add(New GoodsItem With {.Code = 3, .SubCode = "3.1.4", .FreeText = ""})
End If
If uebernachtung Then
goods.GoodsItem.Add(New GoodsItem With {.Code = 6, .SubCode = "6.5", .FreeText = ""})
End If
app.PurchaseInformation.Invoices.Add(New Invoice With { app.PurchaseInformation.Invoices.Add(New Invoice With {
.SequenceNumber = counter, .SequenceNumber = counter,
.SimplifiedInvoice = 0, .SimplifiedInvoice = 0,
.ReferenceNumber = row.Cells("UStVPo_ReNr").Value, ' "25/000616354/987", .ReferenceNumber = row.Cells("UStVPo_ReNr").Value, ' "25/000616354/987",
.IssuingDate = CDate(row.Cells("UStVPo_ReDat").Value).ToString("yyyy-MM-dd"),'"2025-11-30", .IssuingDate = CDate(row.Cells("UStVPo_ReDat").Value).ToString("yyyy-MM-dd"),'"2025-11-30",
.GoodsDescription = New GoodsDescription With {.GoodsItem = New GoodsItem}, .GoodsDescription = goods,
.TransactionDescription = New TransactionDescription With {.TaxableAmount = Nettobetrag.ToString.Replace(",", "."), .VATAmount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", ".")}, .TransactionDescription = New TransactionDescription With {.TaxableAmount = Nettobetrag.ToString.Replace(",", "."), .VATAmount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", ".")},
.Deduction = New Deduction With {.ProRataRate = "", .DeductibleVATAmount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", ".")}, .Deduction = New Deduction With {.ProRataRate = "", .DeductibleVATAmount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", ".")},
.EUSupplier = New Party With { .EUSupplier = New Party With {
.NameFree = row.Cells("UStVPo_Leistender").Value,'"DKV EURO SERVICE GMBH + CO KG", .NameFree = LeistenderName,'"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", .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, .VATIdentificationNumber = UIDNrLeistender,
.CountryCode = Antrag_LandKz .CountryCode = Antrag_LandKz
@@ -4232,6 +4267,8 @@ Public Class frmMDM_USTVAntrag
' .Deduction = New Deduction With {.DeductibleVATAmount = "0.00", .ProRataRate = ""} ' .Deduction = New Deduction With {.DeductibleVATAmount = "0.00", .ProRataRate = ""}
'}) '})
counter = +1
Next Next
@@ -4263,9 +4300,9 @@ Public Class frmMDM_USTVAntrag
Next Next
End If End If
If list.Count = 0 Then Me.Cursor = Cursors.Default : Exit Sub If list.Count > 0 Then
If list.Count > 1 Then If list.Count > 1 Then
Dim pathPDF = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("RG_" & Now.ToString("ddMMyyyyHHmmss") & ".pdf", ".pdf", False, False) Dim pathPDF = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("RG_" & Now.ToString("ddMMyyyyHHmmss") & ".pdf", ".pdf", False, False)
If FormularManagerNEU.MergePdfFiles(list, pathPDF) Then If FormularManagerNEU.MergePdfFiles(list, pathPDF) Then
pdfPathfinished = pathPDF pdfPathfinished = pathPDF
@@ -4282,51 +4319,53 @@ Public Class frmMDM_USTVAntrag
Dim fileZipped As Boolean = True Dim fileZipped As Boolean = True
If pdfPathfinished <> "" Then If pdfPathfinished <> "" Then
' Falls ZIP schon existiert → löschen ' Falls ZIP schon existiert → löschen
If File.Exists(fileNamePDFAttZIP) Then If File.Exists(fileNamePDFAttZIP) Then
File.Delete(fileNamePDFAttZIP) File.Delete(fileNamePDFAttZIP)
End If End If
Dim zipFile As New Chilkat.Zip() Dim zipFile As New Chilkat.Zip()
Dim success = zipFile.NewZip(fileNamePDFAttZIP) Dim success = zipFile.NewZip(fileNamePDFAttZIP)
If (success = False) Then If (success = False) Then
Debug.WriteLine(zipFile.LastErrorText) Debug.WriteLine(zipFile.LastErrorText)
Exit Sub Exit Sub
End If End If
Dim saveExtraPath As Boolean = False Dim saveExtraPath As Boolean = False
success = zipFile.AppendFiles(pdfPathfinished, saveExtraPath) success = zipFile.AppendFiles(pdfPathfinished, saveExtraPath)
If (success = False) Then If (success = False) Then
fileZipped = False fileZipped = False
End If End If
success = zipFile.WriteZipAndClose() success = zipFile.WriteZipAndClose()
If (success = False) Then If (success = False) Then
fileZipped = False fileZipped = False
End If 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
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
End If End If
' ========================= ' =========================
' 5⃣ XML erzeugen ' 5⃣ XML erzeugen
' ========================= ' =========================
Dim xml As Chilkat.Xml = app.ToXml() Dim xml As Chilkat.Xml = app.ToXml()
Dim xmlString As String = xml.GetXml() Dim xmlString As String = xml.GetXml()
Console.WriteLine(xmlString) Console.WriteLine(xmlString)
System.IO.File.WriteAllText(filePath, xmlString) System.IO.File.WriteAllText(filePath, xmlString)

View File

@@ -820,6 +820,7 @@ Public Class usrCntlCBAM
,max(Warentarifnummer) Tarifnummer ,max(Warentarifnummer) Tarifnummer
,max(Eigenmasse) Eigenmasse ,max(Eigenmasse) Eigenmasse
,max([VersendungsLand]) VersendungsLand ,max([VersendungsLand]) VersendungsLand
,max(Ursprungsland_ISO2) as 'Ursprungsland'
,'DE' Bestimmungsland ,'DE' Bestimmungsland
,max([DV1Rechnungsbetrag])Rechnungspreis ,max([DV1Rechnungsbetrag])Rechnungspreis
,max([Rechnungswährung]) Rechnungswaehrung ,max([Rechnungswährung]) Rechnungswaehrung