Files
SDL/SDL/USTV/VATRefund_RO.vb

369 lines
14 KiB
VB.net

Imports Chilkat
Public Class VATRefundApplication_RO
Public Property CodF1 As FormInfo
Public Property RefundPeriod As Period
Public Property ApplicationReference As ApplicationReference
Public Property ProrateAdjustment As ProrateAdjustment
Public Property Applicant As Party
Public Property BusinessDescription As BusinessDescription
Public Property Representative As Party
Public Property DetailedBankAccount As BankAccount
Public Property PurchaseInformation As PurchaseInformation
Public Property ImportInformation As ImportInformation
Public Property DocumentCopy As List(Of DocumentCopy)
Public Property NumberOfDocuments As NumberOfDocuments
Public Property ApplicantSignature As Signature
Public Sub New()
DocumentCopy = New List(Of DocumentCopy)()
PurchaseInformation = New PurchaseInformation()
ImportInformation = New ImportInformation()
End Sub
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
UpdateGoodsDescriptionXml(xml, $"{path}|GoodsDescription", inv.GoodsDescription)
' 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)
UpdateEUSupplierXml(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)
UpdateGoodsDescriptionXml(xml, $"{path}|GoodsDescription", imp.GoodsDescription)
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)
xml.UpdateChildContent($"{path}|VATIdentificationNumber", party.VATIdentificationNumber)
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
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
'=========================
Public Class FormInfo
Public Property FormType As String
Public Property FormId As Integer
Public Property UniversalCode As String
End Class
Public Class Period
Public Property StartDate As Integer
Public Property EndDate As Integer
End Class
Public Class ApplicationReference
Public Property Year As Integer
Public Property RefundingCountryCode As String
Public Property Language As String
Public Property Currency As String
Public Property ApplicationType As Integer
Public Property ReferenceNumber As String
Public Property Annual As Integer
Public Property an_r As Integer
Public Property d_rec As Integer
Public Property luna_r As Integer
Public Property cif As Integer
Public Property totalPlata_A As Integer
End Class
Public Class ProrateAdjustment
Public Property Year As String
Public Property FinalProrate As String
End Class
Public Class Party
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 Property CountryCode 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 BankAccount
Public Property Total As Decimal
Public Property Currency As String
Public Property OwnerType As Integer
Public Property OwnerName As String
Public Property IBAN As String
Public Property BIC As String
End Class
Public Class PurchaseInformation
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 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 Party
End Class
Public Class GoodsDescription
Public Property GoodsItem As List(Of GoodsItem)
End Class
Public Class GoodsItem
Public Property Code As Integer
Public Property SubCode As String
Public Property FreeText As String
End Class
Public Class TransactionDescription
Public Property TaxableAmount As String
Public Property VATAmount As String
End Class
Public Class Deduction
Public Property ProRataRate As String
Public Property DeductibleVATAmount As String
End Class
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 Position As String
End Class