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)
' GoodsDescription
If inv.GoodsDescription IsNot Nothing AndAlso inv.GoodsDescription.GoodsItem IsNot Nothing Then
xml.UpdateChildContentInt($"{path}|GoodsDescription|GoodsItem|Code", inv.GoodsDescription.GoodsItem.Code)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|SubCode", inv.GoodsDescription.GoodsItem.SubCode)
xml.UpdateChildContent($"{path}|GoodsDescription|GoodsItem|FreeText", inv.GoodsDescription.GoodsItem.FreeText)
End If
UpdateGoodsDescriptionXml(xml, $"{path}|GoodsDescription", inv.GoodsDescription)
' TransactionDescription
If inv.TransactionDescription IsNot Nothing Then
@@ -114,7 +112,8 @@ Public Class VATRefundApplication
' EUSupplier
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
Next
@@ -127,11 +126,7 @@ Public Class VATRefundApplication
xml.UpdateChildContent($"{path}|IssuingDate", imp.IssuingDate)
' xml.UpdateChildContent($"{path}|ReferenceInformation", imp.ReferenceInformation)
If imp.GoodsDescription IsNot Nothing AndAlso imp.GoodsDescription.GoodsItem IsNot Nothing Then
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
UpdateGoodsDescriptionXml(xml, $"{path}|GoodsDescription", imp.GoodsDescription)
If imp.TransactionDescription IsNot Nothing Then
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)
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}|AddressFree", party.AddressFree)
xml.UpdateChildContent($"{path}|PostCode", party.PostCode)
@@ -189,8 +181,76 @@ Public Class VATRefundApplication
xml.UpdateChildContent($"{path}|RepresentativeID", party.RepresentativeID)
xml.UpdateChildContent($"{path}|identificationType", party.IdentificationType)
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
'=========================
' UNTERKLASSEN
'=========================
@@ -268,7 +328,7 @@ Public Class Invoice
End Class
Public Class GoodsDescription
Public Property GoodsItem As GoodsItem
Public Property GoodsItem As List(Of GoodsItem)
End Class
Public Class GoodsItem

View File

@@ -1357,12 +1357,12 @@ Public Class frmMDM_USTVAntrag
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"))
USTVA_Nettobetragchanged = True
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"))
USTVA_Nettobetragchanged = True
End If
@@ -4175,11 +4175,13 @@ Public Class frmMDM_USTVAntrag
For Each row As DataGridViewRow In dgvUSTVPositionen.SelectedRows.Cast(Of DataGridViewRow)().OrderBy(Function(dgvr) dgvr.Index)
Dim UIDNrLeistender = ""
Dim LeistenderName As String = ""
Dim maut As Boolean = False
Dim diesel As Boolean = False
Dim parkplatz 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
@@ -4187,32 +4189,65 @@ Public Class frmMDM_USTVAntrag
UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "")
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
Dim Bez As String = row.Cells("UStVPo_Leistungsbezeichnung").Value
Bez = Bez.ToLower
If Bez.Contains("maut") Then maut = True
If Bez.Contains("diesel") Then diesel = True
If Bez.Contains("maut") Or Bez.Contains("toll") Then maut = True
If Bez.Contains("diesel") Or Bez.Contains("fuel") Then diesel = True
If Bez.Contains("parkplatz") Then parkplatz = True
If Bez.Contains("zubeh") Then zubeh = True
If Bez.Contains("übern") Then uebernachtung = True
End If
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)
Dim goods As New GoodsDescription With {.GoodsItem = New List(Of GoodsItem)}
'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 {
.SequenceNumber = counter,
.SimplifiedInvoice = 0,
.ReferenceNumber = row.Cells("UStVPo_ReNr").Value, ' "25/000616354/987",
.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(",", ".")},
.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",
.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",
.VATIdentificationNumber = UIDNrLeistender,
.CountryCode = Antrag_LandKz
@@ -4232,6 +4267,8 @@ Public Class frmMDM_USTVAntrag
' .Deduction = New Deduction With {.DeductibleVATAmount = "0.00", .ProRataRate = ""}
'})
counter = +1
Next
@@ -4263,7 +4300,7 @@ Public Class frmMDM_USTVAntrag
Next
End If
If list.Count = 0 Then Me.Cursor = Cursors.Default : Exit Sub
If list.Count > 0 Then
If list.Count > 1 Then
Dim pathPDF = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("RG_" & Now.ToString("ddMMyyyyHHmmss") & ".pdf", ".pdf", False, False)
@@ -4320,6 +4357,8 @@ Public Class frmMDM_USTVAntrag
'})
End If
End If
End If

View File

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