This commit is contained in:
2026-02-06 15:03:29 +01:00
parent 9f1092fc19
commit 2e4278603a
5 changed files with 384 additions and 325 deletions

View File

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

View File

@@ -1336,7 +1336,6 @@
<Compile Include="USTV\ustCntlUSTV_AntragPosition.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="USTV\VATRefundMapper.vb" />
<Compile Include="Web References\eu.europa.ec1\Reference.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>

View File

@@ -1,122 +1,207 @@
Imports System.Xml.Serialization
Imports java.util.function
Imports javax.print.attribute.standard
Imports Chilkat
<XmlRoot("VATRefundApplication")>
'=========================
' HAUFENKLASSEN
'=========================
Public Class VATRefundApplication
<XmlElement("codF1")>
Public Property CodF1 As CodF1
<XmlElement("RefundPeriod")>
Public Property RefundPeriod As RefundPeriod
<XmlElement("ApplicationReference")>
Public Property CodF1 As FormInfo
Public Property RefundPeriod As Period
Public Property ApplicationReference As ApplicationReference
<XmlElement("ProrateAdjustment")>
Public Property ProrateAdjustment As ProrateAdjustment
<XmlElement("Applicant")>
Public Property Applicant As Applicant
<XmlElement("BusinessDescription")>
Public Property Applicant As Party
Public Property BusinessDescription As BusinessDescription
<XmlElement("Representative")>
Public Property Representative As Representative
<XmlElement("DetailedBankAccount")>
Public Property DetailedBankAccount As DetailedBankAccount
<XmlElement("PurchaseInformation")>
Public Property Representative As Party
Public Property DetailedBankAccount As BankAccount
Public Property PurchaseInformation As PurchaseInformation
<XmlElement("ImportInformation")>
Public Property ImportInformation As ImportInformation
<XmlElement("DocumentCopy1")>
Public Property DocumentCopy1 As DocumentCopy1
<XmlElement("NumberOfDocuments")>
Public Property DocumentCopy As List(Of DocumentCopy)
Public Property NumberOfDocuments As NumberOfDocuments
Public Property ApplicantSignature As Signature
<XmlElement("ApplicantSignature")>
Public Property ApplicantSignature As ApplicantSignature
Public Sub New()
DocumentCopy = New List(Of DocumentCopy)()
PurchaseInformation = New PurchaseInformation()
ImportInformation = New ImportInformation()
End Sub
'=========================
' Methode um das XML zu erzeugen
'=========================
Public Function ToXml() As Xml
Dim xml As New Xml
xml.Tag = "VATRefundApplication"
xml.AddAttribute("xmlns:xfa", "http://www.xfa.org/schema/xfa-data/1.0/")
' FormInfo
xml.UpdateChildContent("codF1|formType", CodF1.FormType)
xml.UpdateChildContentInt("codF1|formId", CodF1.FormId)
xml.UpdateChildContent("codF1|universalCode", CodF1.UniversalCode)
' RefundPeriod
xml.UpdateChildContentInt("RefundPeriod|StartDate", RefundPeriod.StartDate)
xml.UpdateChildContentInt("RefundPeriod|EndDate", RefundPeriod.EndDate)
' ApplicationReference
With ApplicationReference
xml.UpdateChildContentInt("ApplicationReference|Year", .Year)
xml.UpdateChildContent("ApplicationReference|RefundingCountryCode", .RefundingCountryCode)
xml.UpdateChildContent("ApplicationReference|Language", .Language)
xml.UpdateChildContent("ApplicationReference|Currency", .Currency)
xml.UpdateChildContentInt("ApplicationReference|ApplicationType", .ApplicationType)
xml.UpdateChildContent("ApplicationReference|ReferenceNumber", .ReferenceNumber)
xml.UpdateChildContentInt("ApplicationReference|Annual", .Annual)
xml.UpdateChildContentInt("ApplicationReference|an_r", .an_r)
xml.UpdateChildContentInt("ApplicationReference|d_rec", .d_rec)
xml.UpdateChildContentInt("ApplicationReference|luna_r", .luna_r)
xml.UpdateChildContentInt("ApplicationReference|cif", .cif)
xml.UpdateChildContentInt("ApplicationReference|totalPlata_A", .totalPlata_A)
End With
' ProrateAdjustment
xml.UpdateChildContent("ProrateAdjustment|Year", ProrateAdjustment.Year)
xml.UpdateChildContent("ProrateAdjustment|FinalProrate", ProrateAdjustment.FinalProrate)
' Applicant
UpdatePartyXml(xml, "Applicant", Applicant)
' BusinessDescription
With BusinessDescription
xml.UpdateChildContentInt("BusinessDescription|d_caen", .d_caen)
xml.UpdateChildContent("BusinessDescription|CAEN", .CAEN)
xml.UpdateChildContentInt("BusinessDescription|BusinessActivity", .BusinessActivity)
End With
' Representative
UpdatePartyXml(xml, "Representative", Representative)
' DetailedBankAccount
With DetailedBankAccount
xml.UpdateChildContent("DetailedBankAccount|Total", .Total)
xml.UpdateChildContent("DetailedBankAccount|Currency", .Currency)
xml.UpdateChildContentInt("DetailedBankAccount|OwnerType", .OwnerType)
xml.UpdateChildContent("DetailedBankAccount|OwnerName", .OwnerName)
xml.UpdateChildContent("DetailedBankAccount|IBAN", .IBAN)
xml.UpdateChildContent("DetailedBankAccount|BIC", .BIC)
End With
' PurchaseInformation
For i As Integer = 0 To PurchaseInformation.Invoices.Count - 1
Dim inv = PurchaseInformation.Invoices(i)
Dim path = $"PurchaseInformation|Invoice[{i}]"
xml.UpdateChildContentInt($"{path}|SequenceNumber", inv.SequenceNumber)
xml.UpdateChildContentInt($"{path}|simplifiedInvoice", inv.SimplifiedInvoice)
xml.UpdateChildContent($"{path}|ReferenceNumber", inv.ReferenceNumber)
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
' TransactionDescription
If inv.TransactionDescription IsNot Nothing Then
xml.UpdateChildContent($"{path}|TransactionDescription|TaxableAmount", inv.TransactionDescription.TaxableAmount)
xml.UpdateChildContent($"{path}|TransactionDescription|VATAmount", inv.TransactionDescription.VATAmount)
End If
' Deduction
If inv.Deduction IsNot Nothing Then
xml.UpdateChildContent($"{path}|Deduction|ProRataRate", inv.Deduction.ProRataRate)
xml.UpdateChildContent($"{path}|Deduction|DeductibleVATAmount", inv.Deduction.DeductibleVATAmount)
End If
' EUSupplier
If inv.EUSupplier IsNot Nothing Then
UpdatePartyXml(xml, $"{path}|EUSupplier", inv.EUSupplier)
End If
Next
' ImportInformation
For i As Integer = 0 To ImportInformation._Imports.Count - 1
Dim imp = ImportInformation._Imports(i)
Dim path = $"ImportInformation|Import[{i}]"
xml.UpdateChildContentInt($"{path}|SequenceNumber", imp.SequenceNumber)
xml.UpdateChildContent($"{path}|ReferenceNumber", imp.ReferenceNumber)
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
If imp.TransactionDescription IsNot Nothing Then
xml.UpdateChildContent($"{path}|TransactionDescription|TaxableAmount", imp.TransactionDescription.TaxableAmount)
xml.UpdateChildContent($"{path}|TransactionDescription|VATAmount", imp.TransactionDescription.VATAmount)
End If
If imp.Deduction IsNot Nothing Then
xml.UpdateChildContent($"{path}|Deduction|ProRataRate", imp.Deduction.ProRataRate)
xml.UpdateChildContent($"{path}|Deduction|DeductibleVATAmount", imp.Deduction.DeductibleVATAmount)
End If
If imp.EUSupplier IsNot Nothing Then
UpdatePartyXml(xml, $"{path}|Supplier", imp.EUSupplier)
End If
Next
' DocumentCopy
For i As Integer = 0 To DocumentCopy.Count - 1
Dim doc = DocumentCopy(i)
Dim path = $"DocumentCopy{i + 1}"
xml.UpdateChildContentInt($"{path}|Bifa_atasament", doc.Bifa_atasament)
xml.UpdateChildContent($"{path}|Document|FileName", doc.Document.FileName)
xml.UpdateChildContent($"{path}|Document|FileType", doc.Document.FileType)
xml.UpdateChildContent($"{path}|Document|FileDescription", doc.Document.FileDescription)
Next
' NumberOfDocuments
With NumberOfDocuments
xml.UpdateChildContentInt("NumberOfDocuments|AtachatedFiles", .AtachatedFiles)
xml.UpdateChildContentInt("NumberOfDocuments|PurchaseOrders", .PurchaseOrders)
xml.UpdateChildContentInt("NumberOfDocuments|ImportOrders", .ImportOrders)
End With
' ApplicantSignature
xml.UpdateChildContent("ApplicantSignature|NameFree", ApplicantSignature.NameFree)
xml.UpdateChildContent("ApplicantSignature|Position", ApplicantSignature.Position)
Return xml
End Function
'=========================
' Hilfsmethode: Party in XML
'=========================
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}|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)
End Sub
End Class
Public Class BusinessDescription
Public Property d_caen As String
Public Property CAEN As String
Public Property BusinessActivity As String
'=========================
' UNTERKLASSEN
'=========================
Public Class FormInfo
Public Property FormType As String
Public Property FormId As Integer
Public Property UniversalCode As String
End Class
Public Class ImportInformation
<XmlElement("Import")>
Public Property ListOfImports As List(Of Import)
End Class
Public Class DocumentCopy1
Public Property Bifa_atasament As Integer
<XmlElement("Document")>
Public Property Document As Document
End Class
Public Class ApplicantSignature
Public Property NameFree As String
Public Property Position As String
End Class
Public Class Document
Public Property FileName As String
Public Property FileType As String
Public Property FileDescription As String
Friend Class Drawing
End Class
End Class
Public Class Import
Public Property SequenceNumber As Integer
Public Property ReferenceNumber As String
Public Property IssuingDate As String
Public Property ReferenceInformation As String
Public Property GoodsDescription As GoodsDescription
Public Property TransactionDescription As TransactionDescription
Public Property Deduction As Deduction
Public Property Supplier As Supplier
End Class
Public Class Supplier
Public Property NameFree As String
Public Property AddressFree As String
Public Property CountryCode As String
Public Property Phone As String
End Class
Public Class ProrateAdjustment
Public Property Year As String
Public Property FinalProrate As String
End Class
Public Class CodF1
Public Property formType As String
Public Property formId As String
Public Property universalCode As String
End Class
Public Class RefundPeriod
Public Property StartDate As String
Public Property EndDate As String
Public Class Period
Public Property StartDate As Integer
Public Property EndDate As Integer
End Class
Public Class ApplicationReference
@@ -130,32 +215,34 @@ Public Class ApplicationReference
Public Property an_r As Integer
Public Property d_rec As Integer
Public Property luna_r As Integer
Public Property cif As String
Public Property totalPlata_A As Decimal
Public Property cif As Integer
Public Property totalPlata_A As Integer
End Class
Public Class Applicant
Public Property NameFree As String
Public Property VATIdentificationNumber As String
Public Property AddressFree As String
Public Property PostCode As String
Public Property Phone As String
Public Property EmailAddress As String
Public Class ProrateAdjustment
Public Property Year As String
Public Property FinalProrate As String
End Class
Public Class Representative
Public Class Party
Public Property NameFree As String
Public Property RepresentativeID As String
Public Property VATIdentificationNumber As Integer?
Public Property AddressFree As String
Public Property PostCode As String
Public Property Phone As String
Public Property EmailAddress As String
Public Property CountryCode As String
Public Property identificationType As String
Public Property RepresentativeID As String
Public Property IdentificationType As String
End Class
Public Class BusinessDescription
Public Property d_caen As Integer
Public Property CAEN As String
Public Property BusinessActivity As Integer
End Class
Public Class DetailedBankAccount
Public Class BankAccount
Public Property Total As Decimal
Public Property Currency As String
Public Property OwnerType As Integer
@@ -165,54 +252,62 @@ Public Class DetailedBankAccount
End Class
Public Class PurchaseInformation
<XmlElement("Invoice")>
Public Property Invoices As List(Of Invoice)
Public Property Invoices As List(Of Invoice) = New List(Of Invoice)
End Class
Public Class Invoice
Public Property SequenceNumber As Integer
Public Property simplifiedInvoice As Integer
Public Property SimplifiedInvoice As Integer
Public Property ReferenceNumber As String
Public Property IssuingDate As String
Public Property GoodsDescription As GoodsDescription
Public Property TransactionDescription As TransactionDescription
Public Property Deduction As Deduction
Public Property EUSupplier As EUSupplier
Public Property EUSupplier As Party
End Class
Public Class GoodsDescription
Public Property GoodsItem As GoodsItem
End Class
Public Class GoodsItem
Public Property Code As String
Public Property Code As Integer
Public Property SubCode As String
Public Property FreeText As String
End Class
Public Class TransactionDescription
Public Property TaxableAmount As Decimal
Public Property VATAmount As Decimal
Public Property TaxableAmount As String
Public Property VATAmount As String
End Class
Public Class Deduction
Public Property ProRataRate As String
Public Property DeductibleVATAmount As Decimal
Public Property DeductibleVATAmount As String
End Class
Public Class EUSupplier
Public Class ImportInformation
Public Property _Imports As List(Of Invoice) = New List(Of Invoice)
End Class
Public Class DocumentCopy
Public Property Bifa_atasament As Integer
Public Property Document As DocumentFile
End Class
Public Class DocumentFile
Public Property FileName As String
Public Property FileType As String
Public Property FileDescription As String
End Class
Public Class NumberOfDocuments
Public Property AtachatedFiles As Integer
Public Property PurchaseOrders As Integer
Public Property ImportOrders As Integer
End Class
Public Class Signature
Public Property NameFree As String
Public Property AddressFree As String
Public Property CountryCode As String
Public Property Phone As String
Public Property EUTraderID As EUTraderID
Public Property Position As String
End Class
Public Class EUTraderID
Public Property VATIdentificationNumber As String
End Class

View File

@@ -1,143 +0,0 @@
Imports javax.print.attribute.standard
Imports VERAG_PROG_ALLGEMEIN
Public Class VATRefundMapper
Public Shared Function BuildApplication(year As Integer, startMonth As Integer, endMonth As Integer, invoices As DataTable, company As cFirmen, ANTRAG As cUSTVAntrag) As VATRefundApplication
Dim app As New VATRefundApplication()
' ================= HEADER =================
app.CodF1 = New CodF1 With {
.formType = "D318",
.formId = "318",
.universalCode = "D318_A1.0.0"
}
app.RefundPeriod = New RefundPeriod With {
.StartDate = startMonth.ToString("00"),
.EndDate = endMonth.ToString("00")
}
' ================= APPLICATION REF =================
app.ApplicationReference = New ApplicationReference With {
.Year = year,
.RefundingCountryCode = ANTRAG.UStVAn_LandKz,
.Language = "DE",
.Currency = ANTRAG.UStVAn_Währungscode,
.ApplicationType = 1,
.Annual = 0,
.an_r = year,
.d_rec = 0,
.luna_r = endMonth,
.cif = "",
.totalPlata_A = invoices.AsEnumerable().
Sum(Function(r) CDec(r!VatAmount))
}
' ================= PRORATE =================
app.ProrateAdjustment = New ProrateAdjustment()
' ================= APPLICANT =================
app.Applicant = New Applicant With {
.NameFree = company.Firma_Bez,
.VATIdentificationNumber = company.Firma_UID,
.AddressFree = company.Firma_Straße + " " + company.Firma_PLZ + " " + company.Firma_Ort,
.EmailAddress = company.Firma_E_Mail
}
' ================= BUSINESS =================
app.BusinessDescription = New BusinessDescription With {
.d_caen = "2",
.CAEN = "4941--Transp.rutiere de marfuri",
.BusinessActivity = "4941"
}
' ================= BANK =================
app.DetailedBankAccount = New DetailedBankAccount With {
.Total = invoices.AsEnumerable().
Sum(Function(r) CDec(r!VatAmount)),
.Currency = "EUR",
.OwnerType = 1,
.OwnerName = company.Firma_Bankverbindung1,
.IBAN = company.Firma_IBAN1,
.BIC = company.Firma_BIC1
}
' ================= PURCHASES =================
app.PurchaseInformation = BuildPurchaseInformation(invoices)
' ================= IMPORTS (leer) =================
app.ImportInformation = New ImportInformation With {
.ListOfImports = New List(Of Import)()
}
' ================= ATTACHMENTS =================
'app.DocumentCopy1 = New DocumentCopy1 With {
' .Bifa_atasament = 1,
' .Document = New Document With {
' .FileName = "INVOICES.zip",
' .FileType = "application/zip",
' .FileDescription = "INVOICES"
' }
'}
'app.NumberOfDocuments = New NumberOfDocuments With {
' .AtachatedFiles = 0,
' .PurchaseOrders = invoices.Rows.Count,
' .ImportOrders = 0
'}
app.ApplicantSignature = New ApplicantSignature()
Return app
End Function
Private Shared Function BuildPurchaseInformation(
invoices As DataTable
) As PurchaseInformation
Dim result As New PurchaseInformation With {
.Invoices = New List(Of Invoice)()
}
Dim seq As Integer = 1
For Each r As DataRow In invoices.Rows
Dim inv As New Invoice With {
.SequenceNumber = seq,
.simplifiedInvoice = 0,
.ReferenceNumber = r!InvoiceNo.ToString(),
.IssuingDate = CDate(r!InvoiceDate).ToString("yyyy-MM-dd"),
.GoodsDescription = New GoodsDescription With {
.GoodsItem = New GoodsItem With {
.Code = r!GoodsCode.ToString(),
.SubCode = r!GoodsSubCode.ToString()
}
},
.TransactionDescription = New TransactionDescription With {
.TaxableAmount = CDec(r!NetAmount),
.VATAmount = CDec(r!VatAmount)
},
.Deduction = New Deduction With {
.DeductibleVATAmount = CDec(r!VatAmount)
},
.EUSupplier = New EUSupplier With {
.NameFree = r!SupplierName.ToString(),
.AddressFree = r!SupplierAddress.ToString(),
.CountryCode = "AT",
.EUTraderID = New EUTraderID With {
.VATIdentificationNumber = r!SupplierVatId.ToString()
}
}
}
result.Invoices.Add(inv)
seq += 1
Next
Return result
End Function
End Class

View File

@@ -1,10 +1,6 @@
Imports System.IO
Imports System.Reflection
Imports System.Text
Imports System.Windows.Documents
Imports System.Xml.Serialization
Imports com.sun.crypto.provider
Imports GrapeCity.SpreadBuilder
Imports itextsharp.text.pdf
Imports Microsoft.Office.Interop
Imports VERAG_PROG_ALLGEMEIN
@@ -844,21 +840,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
@@ -986,7 +982,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
@@ -1104,12 +1100,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
@@ -1182,7 +1178,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
@@ -1264,7 +1260,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
@@ -1380,11 +1376,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
@@ -1547,8 +1543,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)
@@ -1556,10 +1552,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
@@ -1568,13 +1564,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
@@ -1636,10 +1632,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
@@ -3963,38 +3959,150 @@ Public Class frmMDM_USTVAntrag
Dim FIRMA As New cFirmen(VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA_ID)
Dim ADR As New cAdressen(USTV_ANTRAG.UStVAn_KuNr)
Dim KUNDE As New cKunde(USTV_ANTRAG.UStVAn_KuNr)
Dim KUNDE_ERW As New cKundenErweitert(USTV_ANTRAG.UStVAn_KuNr)
Dim filePath As String = ""
Dim fileName As String = USTV_ANTRAG.UStVAn_KuNr & "_" & Antrag_LandKz & "_" & CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month & "_" & CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month & "_" & CDate(USTV_ANTRAG.UStVAn_ReDatBis).Year & "_VATRefund.xml"
Dim saveDialog As New SaveFileDialog() With {
.Title = "XML-Datei speichern",
.Filter = "XML-Dateien (*.xml)|*.xml|Alle Dateien (*.*)|*.*",
.DefaultExt = "xml",
.AddExtension = True,
.FileName = fileName,
.OverwritePrompt = True
}
If saveDialog.ShowDialog() = DialogResult.OK Then
filePath = saveDialog.FileName
Else
Exit Sub
End If
Dim fullFilePath As String = saveDialog.FileName
Dim directoryPath As String = Path.GetDirectoryName(fullFilePath)
If Not Directory.Exists(directoryPath) Then
Directory.CreateDirectory(directoryPath)
End If
Dim app As New VATRefundApplication() With {
.CodF1 = New FormInfo With {.FormType = "D318", .FormId = 318, .UniversalCode = "D318_A1.0.0"},
.RefundPeriod = New Period With {.StartDate = CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month, .EndDate = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month},
.ApplicationReference = New ApplicationReference With {
.Year = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Year,
.RefundingCountryCode = Antrag_LandKz,
.Language = "DE",
.Currency = USTV_ANTRAG.UStVAn_Währungscode,
.ApplicationType = 1,
.ReferenceNumber = "",
.Annual = 0,
.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", ""),
.totalPlata_A = 0
},
.ProrateAdjustment = New ProrateAdjustment With {.Year = "", .FinalProrate = ""},
.Applicant = New Party With {
.NameFree = ADR.Name_1,
.VATIdentificationNumber = ADR.Steuernummer.ToString.Replace("RO", ""),
.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"
},
.BusinessDescription = New BusinessDescription With {
.d_caen = 2, .CAEN = "4941--Transp.rutiere de marfuri", .BusinessActivity = 4941
},
.Representative = New Party With {
.NameFree = "VERAG 360 GMBH",
.RepresentativeID = "ATU76165837",
.AddressFree = "SUBEN NR. 100, AT-4975 SUBEN",
.PostCode = "4975",
.Phone = "00437711277719",
.EmailAddress = "juricevic@verag.ag",
.CountryCode = "AT",
.IdentificationType = "TIN"
},
.DetailedBankAccount = New BankAccount With {
.Total = 5947.99D,
.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 = ""}
}
Dim counter As Integer = 1
For Each row As DataGridViewRow In dgvUSTVPositionen.SelectedRows.Cast(Of DataGridViewRow)().OrderBy(Function(dgvr) dgvr.Index)
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},
.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
}
})
'[UStVAn_ID] , [UStVPo_ID], [UStVPo_ReDat], [UStVPo_ReNr], [UStVPo_Leistungsbezeichnung], [UStVPo_Leistender], leist.[UstV_Leistender_Strasse] + ' ' + leist.[UstV_Leistender_StrasseNr] as [UstV_Leistender_Strasse],leist.[UstV_Leistender_PLZ],leist.[UstV_Leistender_Stadt],leist.[UstV_Leistender_Land],leist.[UstV_Leistender_UstNr],[UStVPo_USteuerbetrag],[UStVPo_Schnittstelle],[UStVPo_SchnittstellenNr],[UStVPo_Umrechnungskurs],[UStVPo_USteuerbetragEUR],[UStVPo_Sachbearbeiter], [UStVPo_daId], [UStVPo_daId_loeschbar] ,[UStVPo_VZ],[UStVPo_VZ_RKID]
' =========================
' 3⃣ ImportInformation hinzufügen (wenn vorhanden - OPTIONAL)
' =========================
' app.ImportInformation._Imports.Add(New Invoice With {
' .SequenceNumber = 17,
' .ReferenceNumber = "",
' .IssuingDate = "",
' .GoodsDescription = New GoodsDescription With {.GoodsItem = New GoodsItem With {.FreeText = "", .Code = 0, .SubCode = ""}},
' .Deduction = New Deduction With {.DeductibleVATAmount = "0.00", .ProRataRate = ""}
'})
Next
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\MDM\tmp\"
' sicherstellen, dass das Verzeichnis existiert
If Not Directory.Exists(sPath) Then
Directory.CreateDirectory(sPath)
End If
Dim fn As String = Path.Combine(sPath, "D318.xml")
Dim app = VATRefundMapper.BuildApplication(CDate(USTV_ANTRAG.UStVAn_ReDatVon).Year, CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month, CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month, dtInvoices, FIRMA, USTV_ANTRAG)
Dim ser As New XmlSerializer(GetType(VATRefundApplication))
Using sw As New StreamWriter("VATRefund.xml", False, Encoding.UTF8)
ser.Serialize(sw, app)
End Using
' =========================
' 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 xmlString As String = xml.GetXml()
Console.WriteLine(xmlString)
System.IO.File.WriteAllText(filePath, xmlString)
Me.Cursor = Cursors.Default
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
Me.Cursor = Cursors.Default