diff --git a/SDL/Classes/cFiskaltrustClient.vb b/SDL/Classes/cFiskaltrustClient.vb index 384b82ba..a1aacac8 100644 --- a/SDL/Classes/cFiskaltrustClient.vb +++ b/SDL/Classes/cFiskaltrustClient.vb @@ -542,6 +542,17 @@ Public Class cFiskaltrustClient Throw New Exception("Unsupported country") End Select + ElseIf type = "storno" Then + + Select Case _country + Case "DE" + Return "/json/v1/Sign" + Case "AT" + Return "/json/Sign" + Case Else + Throw New Exception("Unsupported country") + End Select + End If diff --git a/SDL/Classes/cFiskaltrustClient_chilkat.vb b/SDL/Classes/cFiskaltrustClient_chilkat.vb index ed52b292..b1ba50ff 100644 --- a/SDL/Classes/cFiskaltrustClient_chilkat.vb +++ b/SDL/Classes/cFiskaltrustClient_chilkat.vb @@ -2,8 +2,67 @@ Imports System.Data.SqlClient Imports System.Reflection Imports Chilkat +Imports GrapeCity.DataVisualization.Chart Imports Newtonsoft.Json +Public Class FtReceiptCases + + ' Normaler Verkauf + Public Const PosReceipt As Long = &H4445000000000001L + + ' Test-/Nullbeleg + Public Const ZeroReceipt As Long = &H4445000000000002L + + Public Const InitialOperation As Long = &H4445000000000003L + Public Const OutOfOperation As Long = &H4445000000000004L + + ' Tagesabschluss (Z-Bericht) + Public Const MonthlyClosing As Long = &H4445000000000005L + Public Const YearlyClosing As Long = &H4445000000000006L + Public Const DailyClosing As Long = &H4445000000000007L + + ' Flags + Public Const ImplicitTransaction As Long = &H100000000L + Public Const ReversalReceipt As Long = &H40000L + Public Const TrainingReceipt As Long = &H20000L + +End Class + +Public Class FtChargeItemCase + + Public Const RevenueNormal As Long = &H4445000000000001L ' 19 % + Public Const RevenueReduced As Long = &H4445000000000002L ' 7 % + Public Const RevenueTaxFree As Long = &H4445000000000005L ' 0 % + +End Class + +Public Class FtJournalType + + Public Const VersionInformation As Integer = 0 + Public Const ActionJournal As Integer = 1 + Public Const ReceiptJournal As Integer = 2 + Public Const QueueItemJournal As Integer = 3 + +End Class + +Public Class FtPayItemCases + + ' Barzahlung + Public Const Cash As Long = &H4445000000000001L + + ' EC-/Girokarte + Public Const DebitCard As Long = &H4445000000000004L + + ' Kreditkarte + Public Const CreditCard As Long = &H4445000000000005L + + ' Online-Zahlung (PayPal, Klarna, etc.) + Public Const OnlinePayment As Long = &H4445000000000006L + + ' Gutschein + Public Const Voucher As Long = &H444500000000000DL + +End Class Public Class cFiskaltrustClient_chilkat @@ -21,9 +80,10 @@ Public Class cFiskaltrustClient_chilkat Public Function SignReceipt(amount As Decimal, vat As Decimal, POS As List(Of EABelegPositionen), kindOfPayment As String, posSystemId As String) As String - Dim payload As JsonObject = BuildPayloadReceipt(amount, vat, POS, kindOfPayment, posSystemId) + Dim payload As JsonObject = BuildPayloadReceipt(amount, vat, POS, kindOfPayment, posSystemId, "Verkauf", "") Return SendChilkat(GetEndpoint("payment"), payload.Emit()) + End Function Public Function SignReceipt_test(posSystemId As String) As String @@ -48,18 +108,55 @@ Public Class cFiskaltrustClient_chilkat Dim POS = LIST Dim kindOfPayment = "Cash" - Dim payload As JsonObject = BuildPayloadReceipt(amount, vat, POS, kindOfPayment, posSystemId) + Dim payload As JsonObject = BuildPayloadReceipt(amount, vat, POS, kindOfPayment, posSystemId, "Verkauf", "") Return SendChilkat(GetEndpoint("payment"), payload.Emit()) End Function + + + Public Function ChancelReceipt(reference As String, amount As Decimal, vat As Decimal, POS As List(Of EABelegPositionen), kindOfPayment As String, posSystemId As String) As String + + Dim payload As JsonObject = BuildPayloadReceipt(amount, vat, POS, kindOfPayment, posSystemId, "Storno", reference) + + Return SendChilkat(GetEndpoint("storno"), payload.Emit()) + End Function + + Public Function ChancelReceipt_test(reference As String, posSystemId As String) As String + + Dim LIST = New List(Of EABelegPositionen) + Dim p = New EABelegPositionen + p.Mandant = "VERA" + p.Niederlassung = "SUB" + p.Benutzer = 74 + p.BelegDat = Now + p.BelegNr = 1 + p.PreislistenNr = 1 + p.PreislistenPos = 1 + p.LeistungsNr = 300 + p.LeistungsBez = "TEST" + p.Preis = 10 + p.Anzahl = 1 + LIST.Add(p) + + Dim amount = 100 + Dim vat = 0 + Dim POS = LIST + Dim kindOfPayment = "Cash" + + Dim payload As JsonObject = BuildPayloadReceipt(amount, vat, POS, kindOfPayment, posSystemId, "Storno", reference) + + Return SendChilkat(GetEndpoint("storno"), payload.Emit()) + End Function + + Public Function SignNullReceipt(posSystemId As String) As String Return SendChilkat(GetEndpoint("payment"), BuildPayloadNullReceipt(posSystemId, _country).Emit()) End Function - Public Function SignClosingReceipt(receiptType As String, posSystemId As String) As String + Public Function SignClosingReceipt(receiptType As String, posSystemId As String, kind As String) As String - Return SendChilkat(GetEndpoint("payment"), BuildPayloadClosingReceipt(receiptType, posSystemId).Emit()) + Return SendChilkat(GetEndpoint("payment"), BuildPayloadClosingReceipt(receiptType, posSystemId, kind).Emit()) End Function Public Function Echo(kassenName As String) As String @@ -71,13 +168,13 @@ Public Class cFiskaltrustClient_chilkat End Function - Public Function Journal(Optional typ As String = "") As String + Public Function Journal(ftJournalType As Integer) As String Dim endpoint = GetEndpoint("journal") - If typ <> "" Then endpoint &= "?type=" & typ + endpoint &= "?type=" & ftJournalType - Return SendChilkat(endpoint, "", True) + Return SendChilkat(endpoint, "") End Function Private Function SendChilkat(endpoint As String, payload As String, Optional isGet As Boolean = False) As String @@ -144,42 +241,87 @@ Public Class cFiskaltrustClient_chilkat End Function - Private Function BuildPayloadReceipt(amount As Decimal, vat As Decimal, POS As List(Of EABelegPositionen), kindOfPayment As String, posSystemId As String) As JsonObject + Private Function BuildPayloadReceipt(amount As Decimal, vat As Decimal, POS As List(Of EABelegPositionen), kindOfPayment As String, posSystemId As String, _receiptCase As String, _reference As String) As JsonObject Dim json As New JsonObject() json.UpdateString("ftCashBoxID", _cashboxId) json.UpdateString("ftPosSystemId", getVersion(posSystemId)) json.UpdateString("cbTerminalID", posSystemId) - json.UpdateString("cbReceiptReference", Guid.NewGuid().ToString()) + + If _reference <> "" Then + json.UpdateString("cbReceiptReference", _reference) + Else + json.UpdateString("cbReceiptReference", Guid.NewGuid().ToString()) + End If + json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o")) - json.UpdateString("ftReceiptCase", 4919338172267102209) - Dim chargeItems = json.AppendArray("cbChargeItems") + Dim receipCase As Long + Select Case _receiptCase - For Each p In POS + Case "Storno" + receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ReversalReceipt Or FtReceiptCases.ImplicitTransaction 'Storno - If chargeItems.AddObjectAt(-1) Then - Dim item As Chilkat.JsonObject = chargeItems.ObjectAt(chargeItems.Size - 1) - item.UpdateInt("Quantity", p.Anzahl) - item.UpdateNumber("Amount", p.Preis.ToString().Replace(",", ".")) - item.UpdateNumber("VATRate", vat.ToString().Replace(",", ".")) - item.UpdateString("Description", p.LeistungsBez) - item.UpdateString("ftChargeItemCase", 4919338167972134929) - End If + Case Else + receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ImplicitTransaction 'Verkauf + + End Select - Next + json.UpdateString("ftReceiptCase", receipCase) - Dim payItems = json.AppendArray("cbPayItems") - payItems.AddObjectAt(-1) - Dim pay As Chilkat.JsonObject = payItems.ObjectAt(payItems.Size - 1) - pay.UpdateInt("Quantity", 1) - pay.UpdateNumber("Amount", amount.ToString().Replace(",", ".")) - pay.UpdateString("Description", kindOfPayment) - pay.UpdateString("ftPayItemCase", 4919338167972134913) - Return json + Dim chargeItems = json.AppendArray("cbChargeItems") + + For Each p In POS + + If chargeItems.AddObjectAt(-1) Then + Dim item As Chilkat.JsonObject = chargeItems.ObjectAt(chargeItems.Size - 1) + item.UpdateInt("Quantity", p.Anzahl) + item.UpdateNumber("Amount", p.Preis.ToString().Replace(",", ".")) + item.UpdateNumber("VATRate", vat.ToString().Replace(",", ".")) + item.UpdateString("Description", p.LeistungsBez) + + Dim ChargeItemCase As Long + Select Case vat + + Case 19D + ChargeItemCase = FtChargeItemCase.RevenueNormal + + Case 7D + ChargeItemCase = FtChargeItemCase.RevenueReduced + + Case 0D + ChargeItemCase = FtChargeItemCase.RevenueTaxFree + + Case Else + Throw New Exception("Unbekannter Steuersatz") + End Select + + + item.UpdateString("ftChargeItemCase", ChargeItemCase) + End If + + + Next + + Dim payItems = json.AppendArray("cbPayItems") + payItems.AddObjectAt(-1) + Dim pay As Chilkat.JsonObject = payItems.ObjectAt(payItems.Size - 1) + pay.UpdateInt("Quantity", 1) + pay.UpdateNumber("Amount", amount.ToString().Replace(",", ".")) + pay.UpdateString("Description", kindOfPayment) + + Select Case kindOfPayment + Case "Cash" + pay.UpdateString("ftPayItemCase", FtPayItemCases.Cash) + Case "Card" + pay.UpdateString("ftPayItemCase", FtPayItemCases.DebitCard) + End Select + + + Return json End Function @@ -191,17 +333,86 @@ Public Class cFiskaltrustClient_chilkat json.UpdateString("ftPosSystemId", getVersion(posSystemId)) json.UpdateString("cbTerminalID", posSystemId) json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o")) + json.UpdateString("ftReceiptCase", (FtReceiptCases.ZeroReceipt Or FtReceiptCases.ImplicitTransaction).ToString()) + json.UpdateString("cbReceiptReference", "ZeroReceiptAfterFailure") + + Dim chargeItems = json.AppendArray("cbChargeItems") + Dim payItems = json.AppendArray("cbPayItems") Return json End Function - Private Function BuildPayloadClosingReceipt(receiptType As String, posSystemId As String) As JsonObject + Private Function BuildPayloadInitialOperationReceipt(posSystemId As String, country As String) As JsonObject Dim json As New JsonObject() json.UpdateString("ftCashBoxID", _cashboxId) json.UpdateString("ftPosSystemId", getVersion(posSystemId)) json.UpdateString("cbTerminalID", posSystemId) + json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o")) + json.UpdateString("ftReceiptCase", (FtReceiptCases.InitialOperation).ToString()) + json.UpdateString("cbReceiptReference", "INIT") + + json.UpdateString("cbUser", "Admin") + json.UpdateString("ftReceiptCaseData", "") + + + + Dim chargeItems = json.AppendArray("cbChargeItems") + Dim payItems = json.AppendArray("cbPayItems") + + Return json + End Function + + Private Function BuildPayloadOutOfOperationReceipt(posSystemId As String, country As String) As JsonObject + + Dim json As New JsonObject() + + json.UpdateString("ftCashBoxID", _cashboxId) + json.UpdateString("ftPosSystemId", getVersion(posSystemId)) + json.UpdateString("cbTerminalID", posSystemId) + json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o")) + json.UpdateString("ftReceiptCase", (FtReceiptCases.OutOfOperation).ToString()) + json.UpdateString("cbReceiptReference", "OutOfOperation") + + json.UpdateString("cbUser", "Admin") + json.UpdateString("ftReceiptCaseData", "") + + Dim chargeItems = json.AppendArray("cbChargeItems") + Dim payItems = json.AppendArray("cbPayItems") + + Return json + End Function + + Private Function BuildPayloadClosingReceipt(receiptType As String, posSystemId As String, kind As String) As JsonObject + + Dim json As New JsonObject() + + json.UpdateString("ftCashBoxID", _cashboxId) + json.UpdateString("ftPosSystemId", getVersion(posSystemId)) + json.UpdateString("cbTerminalID", posSystemId) + json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o")) + Dim chargeItems = json.AppendArray("cbChargeItems") + Dim payItems = json.AppendArray("cbPayItems") + + + + Select Case kind + Case "yearly" + + json.UpdateString("cbReceiptReference", "yearly-closing-" & DateTime.UtcNow.ToString("o")) + json.UpdateString("ftReceiptCase", (FtReceiptCases.YearlyClosing Or FtReceiptCases.ImplicitTransaction).ToString()) + + Case "monthly" + + json.UpdateString("cbReceiptReference", "monthly-closing-" & DateTime.UtcNow.ToString("o")) + json.UpdateString("ftReceiptCase", (FtReceiptCases.MonthlyClosing Or FtReceiptCases.ImplicitTransaction).ToString()) + + Case Else 'daily + json.UpdateString("cbReceiptReference", "daily-closing-" & DateTime.UtcNow.ToString("o")) + json.UpdateString("ftReceiptCase", (FtReceiptCases.DailyClosing Or FtReceiptCases.ImplicitTransaction).ToString()) + + End Select Return json End Function @@ -231,6 +442,14 @@ Public Class cFiskaltrustClient_chilkat Case "AT" : Return "/json/Journal" End Select + Case "storno" + + Select Case _country + Case "DE" : Return "/json/v1/Sign" + Case "AT" : Return "/json/Sign" + End Select + + End Select Throw New Exception("Unsupported country") @@ -398,5 +617,19 @@ Public Class cFiskaltrustClient_chilkat Console.WriteLine(message) End Sub + Public Function PrettyPrintJson(jsonText As String) As String + + Dim json As New Chilkat.JsonObject() + + If Not json.Load(jsonText) Then + Return jsonText + End If + + json.EmitCompact = False + + Return json.Emit() + + End Function + End Class diff --git a/SDL/Fakturierung/cAutomailversand.vb b/SDL/Fakturierung/cAutomailversand.vb index d6df9cf0..4e88c395 100644 --- a/SDL/Fakturierung/cAutomailversand.vb +++ b/SDL/Fakturierung/cAutomailversand.vb @@ -934,9 +934,6 @@ Public Class cAutomailversand Private Function mergeSinglePDFDocuments(path As String, Filiale As Integer, Firma As Integer, isSR As Boolean) - - - Dim zusammenfassen As Boolean = False 'True @@ -962,9 +959,8 @@ Public Class cAutomailversand If Not isSR Then Return True Else - - 'mit Marlene sprechen! - If Not (path.ToString.ToLower.Contains("flyercbam") OrElse Not (path.ToString.ToLower.Contains("sammelrechnung"))) Then + 'laut Marlene nichts zusammenfassen (außer CBAM)! Mail am 19.06.2026 + If Not (path.ToString.ToLower.Contains("flyercbam")) Then Return True End If End If diff --git a/SDL/My Project/AssemblyInfo.vb b/SDL/My Project/AssemblyInfo.vb index d690090a..e7fa788b 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/My Project/Resources.Designer.vb b/SDL/My Project/Resources.Designer.vb index 22f5e90c..33ece2bb 100644 --- a/SDL/My Project/Resources.Designer.vb +++ b/SDL/My Project/Resources.Designer.vb @@ -2591,6 +2591,16 @@ Namespace My.Resources End Get End Property + ''' + ''' Sucht eine lokalisierte Ressource vom Typ System.Byte[]. + ''' + Friend ReadOnly Property Ustveu_Rechnungsanlagen_DE() As Byte() + Get + Dim obj As Object = ResourceManager.GetObject("Ustveu_Rechnungsanlagen_DE", resourceCulture) + Return CType(obj,Byte()) + End Get + End Property + ''' ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. ''' diff --git a/SDL/My Project/Resources.resx b/SDL/My Project/Resources.resx index 8808797a..1e835a90 100644 --- a/SDL/My Project/Resources.resx +++ b/SDL/My Project/Resources.resx @@ -991,4 +991,7 @@ ..\Resources\auto_mailversand_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Ustveu-Rechnungsanlagen-DE.xls;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/SDL/Resources/Ustveu-Rechnungsanlagen-DE.xls b/SDL/Resources/Ustveu-Rechnungsanlagen-DE.xls new file mode 100644 index 00000000..2c6dc12d Binary files /dev/null and b/SDL/Resources/Ustveu-Rechnungsanlagen-DE.xls differ diff --git a/SDL/SDL.vbproj b/SDL/SDL.vbproj index 44032f34..cfc0d814 100644 --- a/SDL/SDL.vbproj +++ b/SDL/SDL.vbproj @@ -1412,7 +1412,8 @@ Component - + + usrCntlUSTV.vb @@ -5063,6 +5064,7 @@ + Always diff --git a/SDL/USTV/VATRefund_HR.vb b/SDL/USTV/VATRefund_HR.vb new file mode 100644 index 00000000..69ea80e0 --- /dev/null +++ b/SDL/USTV/VATRefund_HR.vb @@ -0,0 +1,286 @@ + + +Public Class GlobalVATRefundApplication_HR + + Public Property Applicant As Applicant_ + Public Property Representative As Representative_ + Public Property RefundPeriod As RefundPeriod_ + Public Property BankAccount As BankAccount_ + Public Property RefundRequest As RefundRequest_ + + Public Function ToXml() As Chilkat.Xml + + Dim xml As New Chilkat.Xml + + xml.Tag = "p:GlobalVATRefundApplication" + + xml.AddAttribute("xmlns:p", "http://VATRefund/") + xml.AddAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") + xml.AddAttribute("xsi:type", "p:GlobalVATRefundApplication") + + ' Applicant + xml.UpdateChildContent("applicant|nameType", Applicant.NameType) + xml.UpdateChildContent("applicant|nameFree", Applicant.NameFree) + xml.UpdateChildContent("applicant|addressFree", Applicant.AddressFree) + xml.UpdateChildContent("applicant|telephone", Applicant.Telephone) + + xml.UpdateChildContent("applicant|country|countryISOCode", + Applicant.CountryISOCode) + + xml.UpdateChildContent("applicant|country|memberStatePreferences|countryMSCode", + Applicant.CountryISOCode) + + xml.UpdateChildContent("applicant|identification|VATId", + Applicant.VATId) + + xml.UpdateChildContent("applicant|identification|identificationCountry|countryISOCode", + Applicant.CountryISOCode) + + xml.UpdateChildContent("applicant|identification|identificationCountry|memberStatePreferences|countryMSCode", + Applicant.CountryISOCode) + + xml.UpdateChildContent("applicant|email", + Applicant.Email) + + ' Representative + xml.UpdateChildContent("representative|nameFree", + Representative.Name) + + xml.UpdateChildContent("representative|addressFree", + Representative.Address) + + xml.UpdateChildContent("representative|telephone", + Representative.Telephone) + + xml.UpdateChildContent("representative|country|countryISOCode", + Representative.CountryISOCode) + + xml.UpdateChildContent("representative|identification|identificationType", + Representative.IdentificationType) + + xml.UpdateChildContent("representative|identification|identificationNumber", + Representative.IdentificationNumber) + + xml.UpdateChildContent("representative|identification|identificationCountry|countryISOCode", + Representative.CountryISOCode) + + xml.UpdateChildContent("representative|email", + Representative.Email) + + ' RefundPeriod + xml.UpdateChildContent("refundPeriod|fromDate", + RefundPeriod.FromDate) + + xml.UpdateChildContent("refundPeriod|toDate", + RefundPeriod.ToDate) + + ' businessDescription + xml.UpdateChildContent("businessDescription", "") + + ' Bank + xml.UpdateChildContent("defaultBankAccount|IBAN", + BankAccount.IBAN) + + xml.UpdateChildContent("defaultBankAccount|BIC", + BankAccount.BIC) + + xml.UpdateChildContent("defaultBankAccount|ownerName", + BankAccount.OwnerName) + + xml.UpdateChildContent("defaultBankAccount|details|ownerType", + BankAccount.OwnerType) + + xml.UpdateChildContent("defaultBankAccount|details|currency|currencyISO", + BankAccount.CurrencyISO) + + xml.UpdateChildContent("version", + DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ")) + + ' RefundRequest + xml.UpdateChildContent("refundRequest|refundMemberState|countryISOCode", RefundRequest.RefundMemberState) + + For i As Integer = 0 To RefundRequest.PurchaseInformation.Count - 1 + + Dim p = RefundRequest.PurchaseInformation(i) + + Dim path = $"refundRequest|purchaseInformation[{i}]" + + xml.UpdateChildContent(path & "|sequence", p.Sequence.ToString) + + xml.UpdateChildContent(path & "|simplifiedInvoice", p.SimplifiedInvoice.ToString.ToLower) + + xml.UpdateChildContent(path & "|referenceNumber", p.ReferenceNumber) + + xml.UpdateChildContent(path & "|issuingDate", p.IssuingDate) + + xml.UpdateChildContent(path & "|transactionDescription|taxableAmount|amount", + p.TransactionDescription.TaxableAmount.Amount.ToString(Globalization.CultureInfo.InvariantCulture)) + + xml.UpdateChildContent(path & "|transactionDescription|taxableAmount|currency|currencyISO", + p.TransactionDescription.TaxableAmount.CurrencyISO) + + xml.UpdateChildContent(path & "|transactionDescription|VATAmount|amount", + p.TransactionDescription.VATAmount.Amount.ToString(Globalization.CultureInfo.InvariantCulture)) + + xml.UpdateChildContent(path & "|transactionDescription|VATAmount|currency|currencyISO", + p.TransactionDescription.VATAmount.CurrencyISO) + + xml.UpdateChildContent(path & "|deduction|deductibleAmount|amount", + p.Deduction.DeductibleAmount.Amount.ToString(Globalization.CultureInfo.InvariantCulture)) + + xml.UpdateChildContent(path & "|deduction|deductibleAmount|currency|currencyISO", + p.Deduction.DeductibleAmount.CurrencyISO) + + xml.UpdateChildContent(path & "|goodsDescription|code", + p.GoodsDescription.Code) + + xml.UpdateChildContent(path & "|EUSupplier|nameFree", + p.EUSupplier.NameFree) + + xml.UpdateChildContent(path & "|EUSupplier|addressFree", + p.EUSupplier.AddressFree) + + xml.UpdateChildContent(path & "|EUSupplier|country|countryISOCode", + p.EUSupplier.CountryISOCode) + + xml.UpdateChildContent(path & "|EUSupplier|identification|VATId", + p.EUSupplier.VATId) + + xml.UpdateChildContent(path & "|EUSupplier|identification|identificationCountry|countryISOCode", + p.EUSupplier.CountryISOCode) + + xml.UpdateChildContent(path & "|state", "N") + + Next + + Dim idx As Integer = 1 + + For Each d In RefundRequest.DocumentCopy + + Dim path = $"refundRequest|documentCopy[{idx}]" + + xml.UpdateChildContent(path & "|fileType", d.FileType) + xml.UpdateChildContent(path & "|filename", d.FileName) + xml.UpdateChildContent(path & "|description", d.Description) + xml.UpdateChildContent(path & "|file", d.Base64Content) + + idx += 1 + + Next + + + xml.UpdateChildContent("refundRequest|state", "N") + + xml.UpdateChildContent("submittedLocale", "de") + + Return xml + + End Function + + + +End Class + +Public Class Applicant_ + Public Property NameType As String + Public Property NameFree As String + Public Property AddressFree As String + Public Property Telephone As String + Public Property CountryISOCode As String + Public Property VATId As String + Public Property Email As String +End Class + +Public Class Representative_ + Public Property Name As String + Public Property Address As String + Public Property Telephone As String + Public Property CountryISOCode As String + Public Property IdentificationType As String + Public Property IdentificationNumber As String + Public Property Email As String +End Class + +Public Class RefundPeriod_ + Public Property FromDate As String + Public Property ToDate As String +End Class + +Public Class BankAccount_ + Public Property IBAN As String + Public Property BIC As String + Public Property OwnerName As String + Public Property OwnerType As String + Public Property CurrencyISO As String +End Class + +Public Class Purchase_ + + Public Property Sequence As Integer + Public Property SimplifiedInvoice As Boolean + Public Property ReferenceNumber As String + Public Property IssuingDate As String + Public Property TransactionDescription As TransactionDescription_ + Public Property Deduction As Deduction_ + Public Property GoodsDescription As GoodsDescription_ + Public Property EUSupplier As EUSupplier_ + Public Property State As String = "N" + +End Class + +Public Class DocumentCopy_ + + Public Property FileType As String + Public Property FileName As String + Public Property Description As String + Public Property Base64Content As String + +End Class + +Public Class RefundRequest_ + + Public Property RefundMemberState As String + Public Property PurchaseInformation As New List(Of Purchase_) + Public Property DocumentCopy As New List(Of DocumentCopy_) + Public Property State As String = "N" + +End Class + +Public Class TransactionDescription_ + + Public Property TaxableAmount As MoneyAmount_ + Public Property VATAmount As MoneyAmount_ + +End Class + +Public Class Deduction_ + + Public Property DeductibleAmount As MoneyAmount_ + +End Class + +Public Class MoneyAmount_ + + Public Property Amount As Decimal + Public Property CurrencyISO As String = "EUR" + +End Class + +Public Class GoodsDescription_ + + Public Property Code As String + +End Class + +Public Class EUSupplier_ + + Public Property NameFree As String + Public Property AddressFree As String + Public Property CountryISOCode As String + Public Property VATId As String + +End Class + + + + diff --git a/SDL/USTV/VATRefund.vb b/SDL/USTV/VATRefund_RO.vb similarity index 98% rename from SDL/USTV/VATRefund.vb rename to SDL/USTV/VATRefund_RO.vb index 86c6b66e..1c9909e8 100644 --- a/SDL/USTV/VATRefund.vb +++ b/SDL/USTV/VATRefund_RO.vb @@ -1,9 +1,6 @@ Imports Chilkat -'========================= -' HAUFENKLASSEN -'========================= -Public Class VATRefundApplication +Public Class VATRefundApplication_RO Public Property CodF1 As FormInfo Public Property RefundPeriod As Period Public Property ApplicationReference As ApplicationReference @@ -24,9 +21,6 @@ Public Class VATRefundApplication ImportInformation = New ImportInformation() End Sub - '========================= - ' Methode um das XML zu erzeugen - '========================= Public Function ToXml() As Xml Dim xml As New Xml xml.Tag = "VATRefundApplication" diff --git a/SDL/USTV/frmMDM_USTVAntrag.vb b/SDL/USTV/frmMDM_USTVAntrag.vb index 8cd6e33b..317b9efb 100644 --- a/SDL/USTV/frmMDM_USTVAntrag.vb +++ b/SDL/USTV/frmMDM_USTVAntrag.vb @@ -1,7 +1,9 @@ -Imports System.IO +Imports System.Globalization +Imports System.IO Imports System.Reflection Imports System.Windows.Documents Imports itextsharp.text.pdf +Imports java.util.function Imports Microsoft.Office.Interop Imports VERAG_PROG_ALLGEMEIN @@ -4152,324 +4154,16 @@ Public Class frmMDM_USTVAntrag End If 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 - Me.Cursor = Cursors.Default - Exit Sub - End If + 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" - Dim fullFilePath As String = saveDialog.FileName - Dim directoryPath As String = Path.GetDirectoryName(fullFilePath) - - If Not Directory.Exists(directoryPath) Then - Directory.CreateDirectory(directoryPath) - End If - - - Select Case Antrag_LandKz - Case "AT", "DE", "CZ", "BE", "SI" - BANK_OWNER = FIRMA.Firma_Bez - BANK_IBAN = FIRMA.Firma_IBAN1 - BANK_BIC = FIRMA.Firma_BIC1 - - If BANK_BIC.ToString.Contains("BIC:") Then - BANK_BIC = BANK_BIC.ToString.Replace("BIC:", "") - BANK_BIC = BANK_BIC.Trim() - BANK_BIC = BANK_BIC.ToString.Replace(" ", "") - End If - - If BANK_IBAN.ToString.Contains("IBAN:") Then - BANK_IBAN = BANK_IBAN.ToString.Replace("IBAN:", "") - BANK_IBAN = BANK_IBAN.Trim() - BANK_IBAN = BANK_IBAN.ToString.Replace(" ", "") - End If - - Case Else - 'Bank aus Kunden! - Dim dtBank As New DataTable - dtBank = SQL.loadDgvBySql("SELECT isnull(bnk_name,'') as bnk_name ,bnk_anschrift,ISNULL(bnk_iban,'') as bnk_iban,ISNULL(bnk_bic,'') as bnk_bic FROM [tblBankverbindungen] WHERE isnull(bnk_hauptkonto,0) = 0 and isnull(bnk_archiv,0) = 0 and bnk_KundenNr = " & KUNDE.KundenNr, "FMZOLL") - - If dtBank.Rows.Count > 0 Then - BANK_OWNER = ADR.Name_1 - BANK_IBAN = dtBank.Rows(0).Item("bnk_iban") - BANK_BIC = dtBank.Rows(0).Item("bnk_bic") - End If - 'wenn nicht hinterlegt, dann leer lassen! - + Select Case ADR.LandKz + Case "RO", "R" : fileName = fileName & ".xml" : createXMLforRO(ADR, KUNDE, KUNDE_ERW, FIRMA, BANK_OWNER, BANK_IBAN, BANK_BIC, fileName, filePath) + Case "DE", "D" : fileName = fileName & ".csv" : createCSVforDE(ADR, KUNDE, KUNDE_ERW, FIRMA, BANK_OWNER, BANK_IBAN, BANK_BIC, fileName, filePath) 'ALTERNATIVE: ELMA5-Massendatenschnittstelle allerdings um einiges aufwendiger! + Case "HR" : fileName = fileName & ".xml" : createXMLforHR(ADR, KUNDE, KUNDE_ERW, FIRMA, BANK_OWNER, BANK_IBAN, BANK_BIC, fileName, filePath) End Select - 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 = IIf(CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month = 1 And CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month = 12, 1, 0), - .an_r = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Year, - .d_rec = 0, - .luna_r = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month, - .cif = IIf(Not IsDBNull(ADR.UstIdNr) AndAlso ADR.UstIdNr IsNot Nothing, ADR.UstIdNr, 0), - .totalPlata_A = 0 - }, - .ProrateAdjustment = New ProrateAdjustment With {.Year = "", .FinalProrate = ""}, - .Applicant = New Party With { - .NameFree = ADR.Name_1, - .VATIdentificationNumber = IIf(Not IsDBNull(ADR.UstIdNr) AndAlso ADR.UstIdNr IsNot Nothing, ADR.UstIdNr, 0), - .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 = txtSummeEUR._value.ToString.Replace(",", "."), - .Currency = USTV_ANTRAG.UStVAn_Währungscode, - .OwnerType = 1, - .OwnerName = BANK_OWNER, - .IBAN = BANK_IBAN, - .BIC = BANK_BIC - }, - .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 = "" - 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 - UIDNrLeistender = row.Cells("UstV_Leistender_UstNr").Value - UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "") - End If - - LeistenderName = row.Cells("UStVPo_Leistender").Value - LeistenderName = 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 row.Cells("UStVPo_SchnittstellenNr").Value = 10 Then - 'UTA überspringen - ElseIf row.Cells("UStVPo_SchnittstellenNr").Value = 9 Then - maut = True 'MSE immer MAUT - Else - 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 - - End If - - - - Dim goods As New GoodsDescription With {.GoodsItem = New List(Of GoodsItem)} - - 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 - - Select Case Antrag_LandKz - Case "DE", "CZ", "LU" - For Each good In goods.GoodsItem - good.SubCode = "" 'SUbcodes leeren - Next - End Select - - - 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 = goods, - .TransactionDescription = New TransactionDescription With {.TaxableAmount = Nothing, .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 = 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 - } - }) - - '[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 = ""} - '}) - - counter = +1 - - Next - - - - ' ========================= - ' 4️⃣ Dokumente hinzufügen - ' ========================= - - - 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 - - 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 - - - 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 @@ -4481,6 +4175,743 @@ Public Class frmMDM_USTVAntrag End Sub + Private Function createXMLforRO(ADR As cAdressen, KUNDE As cKunde, KUNDE_ERW As cKundenErweitert, FIRMA As cFirmen, BANK_OWNER As String, BANK_IBAN As String, BANK_BIC As String, filename As String, filePath As String) + 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 + Me.Cursor = Cursors.Default + Return False + 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 + + + Select Case Antrag_LandKz + Case "AT", "DE", "CZ", "BE", "SI" + BANK_OWNER = FIRMA.Firma_Bez + BANK_IBAN = FIRMA.Firma_IBAN1 + BANK_BIC = FIRMA.Firma_BIC1 + + If BANK_BIC.ToString.Contains("BIC:") Then + BANK_BIC = BANK_BIC.ToString.Replace("BIC:", "") + BANK_BIC = BANK_BIC.Trim() + BANK_BIC = BANK_BIC.ToString.Replace(" ", "") + End If + + If BANK_IBAN.ToString.Contains("IBAN:") Then + BANK_IBAN = BANK_IBAN.ToString.Replace("IBAN:", "") + BANK_IBAN = BANK_IBAN.Trim() + BANK_IBAN = BANK_IBAN.ToString.Replace(" ", "") + End If + + Case Else + 'Bank aus Kunden! + Dim dtBank As New DataTable + dtBank = SQL.loadDgvBySql("SELECT isnull(bnk_name,'') as bnk_name ,bnk_anschrift,ISNULL(bnk_iban,'') as bnk_iban,ISNULL(bnk_bic,'') as bnk_bic FROM [tblBankverbindungen] WHERE isnull(bnk_hauptkonto,0) = 0 and isnull(bnk_archiv,0) = 0 and bnk_KundenNr = " & KUNDE.KundenNr, "FMZOLL") + + If dtBank.Rows.Count > 0 Then + BANK_OWNER = ADR.Name_1 + BANK_IBAN = dtBank.Rows(0).Item("bnk_iban") + BANK_BIC = dtBank.Rows(0).Item("bnk_bic") + End If + 'wenn nicht hinterlegt, dann leer lassen! + + End Select + + + Dim app As New VATRefundApplication_RO() 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 = IIf(CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month = 1 And CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month = 12, 1, 0), + .an_r = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Year, + .d_rec = 0, + .luna_r = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month, + .cif = IIf(Not IsDBNull(ADR.UstIdNr) AndAlso ADR.UstIdNr IsNot Nothing, ADR.UstIdNr, 0), + .totalPlata_A = 0 + }, + .ProrateAdjustment = New ProrateAdjustment With {.Year = "", .FinalProrate = ""}, + .Applicant = New Party With { + .NameFree = ADR.Name_1, + .VATIdentificationNumber = IIf(Not IsDBNull(ADR.UstIdNr) AndAlso ADR.UstIdNr IsNot Nothing, ADR.UstIdNr, 0), + .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 = txtSummeEUR._value.ToString.Replace(",", "."), + .Currency = USTV_ANTRAG.UStVAn_Währungscode, + .OwnerType = 1, + .OwnerName = BANK_OWNER, + .IBAN = BANK_IBAN, + .BIC = BANK_BIC + }, + .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 = "" + 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 + UIDNrLeistender = row.Cells("UstV_Leistender_UstNr").Value + UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "") + End If + + LeistenderName = row.Cells("UStVPo_Leistender").Value + LeistenderName = 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 row.Cells("UStVPo_SchnittstellenNr").Value = 10 Then + 'UTA überspringen + ElseIf row.Cells("UStVPo_SchnittstellenNr").Value = 9 Then + maut = True 'MSE immer MAUT + Else + 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 + + End If + + + + Dim goods As New GoodsDescription With {.GoodsItem = New List(Of GoodsItem)} + + 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 + + Select Case Antrag_LandKz + Case "DE", "CZ", "LU" + For Each good In goods.GoodsItem + good.SubCode = "" 'SUbcodes leeren + Next + End Select + + + 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 = goods, + .TransactionDescription = New TransactionDescription With {.TaxableAmount = Nothing, .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 = 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 + } + }) + + '[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 = ""} + '}) + + counter = +1 + + Next + + + + ' ========================= + ' 4️⃣ Dokumente hinzufügen + ' ========================= + + + 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 : Return False + 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 + + 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) + Return False + 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 + + + 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) + + End Function + + + Private Function createXMLforHR(ADR As cAdressen, KUNDE As cKunde, KUNDE_ERW As cKundenErweitert, FIRMA As cFirmen, BANK_OWNER As String, BANK_IBAN As String, BANK_BIC As String, filename As String, filePath As String) + 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 + Me.Cursor = Cursors.Default + Return False + 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 + + + Select Case Antrag_LandKz + Case "AT", "DE", "CZ", "BE", "SI" + BANK_OWNER = FIRMA.Firma_Bez + BANK_IBAN = FIRMA.Firma_IBAN1 + BANK_BIC = FIRMA.Firma_BIC1 + + If BANK_BIC.ToString.Contains("BIC:") Then + BANK_BIC = BANK_BIC.ToString.Replace("BIC:", "") + BANK_BIC = BANK_BIC.Trim() + BANK_BIC = BANK_BIC.ToString.Replace(" ", "") + End If + + If BANK_IBAN.ToString.Contains("IBAN:") Then + BANK_IBAN = BANK_IBAN.ToString.Replace("IBAN:", "") + BANK_IBAN = BANK_IBAN.Trim() + BANK_IBAN = BANK_IBAN.ToString.Replace(" ", "") + End If + + Case Else + 'Bank aus Kunden! + Dim dtBank As New DataTable + dtBank = SQL.loadDgvBySql("SELECT isnull(bnk_name,'') as bnk_name ,bnk_anschrift,ISNULL(bnk_iban,'') as bnk_iban,ISNULL(bnk_bic,'') as bnk_bic FROM [tblBankverbindungen] WHERE isnull(bnk_hauptkonto,0) = 0 and isnull(bnk_archiv,0) = 0 and bnk_KundenNr = " & KUNDE.KundenNr, "FMZOLL") + + If dtBank.Rows.Count > 0 Then + BANK_OWNER = ADR.Name_1 + BANK_IBAN = dtBank.Rows(0).Item("bnk_iban") + BANK_BIC = dtBank.Rows(0).Item("bnk_bic") + End If + 'wenn nicht hinterlegt, dann leer lassen! + + End Select + + Dim app As New GlobalVATRefundApplication_HR() With { + .RefundPeriod = New RefundPeriod_ With {.FromDate = CDate(USTV_ANTRAG.UStVAn_ReDatVon).Month, .ToDate = CDate(USTV_ANTRAG.UStVAn_ReDatBis).Month}, + .Applicant = New Applicant_ With { + .NameFree = ADR.Name_1, + .VATId = IIf(Not IsDBNull(ADR.UstIdNr) AndAlso ADR.UstIdNr IsNot Nothing, ADR.UstIdNr, 0), + .AddressFree = ADR.Straße.ToString & vbCrLf & ADR.LandKz.ToString & " - " & ADR.PLZ.ToString & " -" & ADR.Ort.ToString, '"RO - 550270 - MUN. SIBIU", + .CountryISOCode = ADR.LandKz, .Telephone = "", .Email = "juricevic@verag.ag" + }, + .Representative = New Representative_ With { + .Name = "VERAG 360 GMBH", + .IdentificationNumber = "ATU76165837", + .Address = "SUBEN NR. 100, AT-4975 SUBEN", + .Telephone = "00437711277719", + .Email = "juricevic@verag.ag", + .CountryISOCode = "AT", + .IdentificationType = "TIN" + }, + .BankAccount = New BankAccount_ With { + .CurrencyISO = USTV_ANTRAG.UStVAn_Währungscode, + .OwnerType = 1, + .OwnerName = BANK_OWNER, + .IBAN = BANK_IBAN, + .BIC = BANK_BIC + } + } + + + + + + Dim counter As Integer = 1 + + 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 : Return False + End Select + + + + 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 + UIDNrLeistender = row.Cells("UstV_Leistender_UstNr").Value + UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "") + End If + + LeistenderName = row.Cells("UStVPo_Leistender").Value + LeistenderName = 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 row.Cells("UStVPo_SchnittstellenNr").Value = 10 Then + 'UTA überspringen + ElseIf row.Cells("UStVPo_SchnittstellenNr").Value = 9 Then + maut = True 'MSE immer MAUT + Else + + Dim code As String = "" + 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 + + End If + + Dim p As New Purchase_ + p.Sequence = counter + p.SimplifiedInvoice = False + p.ReferenceNumber = row.Cells("UStVPo_ReNr").Value + p.IssuingDate = CDate(row.Cells("UStVPo_ReDat").Value).ToString("yyyy-MM-dd") + + p.TransactionDescription = New TransactionDescription_ With { + .TaxableAmount = New MoneyAmount_ With { + .Amount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", "."), + .CurrencyISO = "EUR" + }, + .VATAmount = New MoneyAmount_ With { + .Amount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", "."), + .CurrencyISO = "EUR" + } + } + + p.Deduction = New Deduction_ With { + .DeductibleAmount = New MoneyAmount_ With { + .Amount = row.Cells("UStVPo_USteuerbetrag").Value.ToString.Replace(",", "."), + .CurrencyISO = "EUR" + } + } + + + + + If diesel Then + p.GoodsDescription = New GoodsDescription_ With {.Code = "1.1.2"} + End If + + If maut Then + p.GoodsDescription = New GoodsDescription_ With {.Code = "4.1"} + End If + + If zubeh Then + p.GoodsDescription = New GoodsDescription_ With {.Code = "3.1.5"} + End If + + If parkplatz Then + p.GoodsDescription = New GoodsDescription_ With {.Code = "3.1.4"} + End If + + If uebernachtung Then + p.GoodsDescription = New GoodsDescription_ With {.Code = "6.5"} + End If + + + p.EUSupplier = New EUSupplier_ With { + .NameFree = LeistenderName, + .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, + .CountryISOCode = Antrag_LandKz, + .VATId = UIDNrLeistender + } + + app.RefundRequest = New RefundRequest_ With { + .RefundMemberState = Antrag_LandKz, + .State = "N" + } + + + app.RefundRequest.PurchaseInformation.Add(p) + + + + 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 + Dim dc As New DocumentCopy_ + + Dim pdfName As New FileInfo(pdf) + dc.FileType = pdfName.Extension.ToString.Replace(".", "") + dc.Description = "Invoice" + dc.FileName = pdfName.Name + + Dim bd As New Chilkat.BinData + If bd.LoadFile(pdf) Then + dc.Base64Content = bd.GetEncoded("base64") + End If + + app.RefundRequest.DocumentCopy.Add(dc) + + End If + + + + + counter = +1 + + Next + + ' ========================= + ' 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) + + End Function + + + Private Function createCSVforDE(ADR As cAdressen, KUNDE As cKunde, KUNDE_ERW As cKundenErweitert, FIRMA As cFirmen, BANK_OWNER As String, BANK_IBAN As String, BANK_BIC As String, filename As String, filePath As String) + + Try + + + Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SDL\tmp\" + If Not My.Computer.FileSystem.DirectoryExists(sPath) Then + My.Computer.FileSystem.CreateDirectory(sPath) + End If + + + Dim exclApp As Object 'as Application + Dim Datei As Object 'as WorkBook + Dim Blatt As Object 'Microsoft.Office.Interop.Excel.Worksheet 'As Object 'as Worksheet + exclApp = CreateObject("Excel.Application") + + With exclApp + .Visible = False + + Try + filePath = sPath & filename + + If File.Exists(filePath) Then + File.Delete(filePath) + End If + + My.Computer.FileSystem.WriteAllBytes(filePath, My.Resources.Ustveu_Rechnungsanlagen_DE, False) + + Catch ex As System.Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + Me.Cursor = Cursors.Default + Return False + + End Try + + Datei = .Workbooks.Open(filePath) 'Anpassen + Blatt = Datei.Worksheets(1) 'Anpassen + + + Dim counter As Integer = 1 + + 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 + UIDNrLeistender = row.Cells("UstV_Leistender_UstNr").Value + UIDNrLeistender = UIDNrLeistender.ToString.Replace(Antrag_LandKz, "") + End If + + LeistenderName = row.Cells("UStVPo_Leistender").Value + LeistenderName = 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) + + Dim Steuerbetrag As Double = 0 + If Not IsDBNull(row.Cells("UStVPo_USteuerbetragEUR").Value) AndAlso IsNumeric(row.Cells("UStVPo_USteuerbetragEUR").Value) Then Steuerbetrag = CDbl(row.Cells("UStVPo_USteuerbetragEUR").Value) + + Dim land = row.Cells("UstV_Leistender_Land").Value + Dim iso2Land = "" + + If land.Length = 2 Then + iso2Land = land + ElseIf land.Length = 3 Then + iso2Land = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2LandFromISO3Land(land) + ElseIf land.Length = 1 Then + iso2Land = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2LandFromISO1Land(land) + End If + + + + + Blatt.Range("A" & counter + 1).Value = counter + Blatt.Range("B" & counter + 1).Value = CDate(row.Cells("UStVPo_ReDat").Value).ToString("dd.MM.yyyy") + Blatt.Range("C" & counter + 1).Value = row.Cells("UStVPo_ReNr").Value + Blatt.Range("D" & counter + 1).Value = Nettobetrag.ToString("0.00", CultureInfo.InvariantCulture) + Blatt.Range("E" & counter + 1).Value = Steuerbetrag.ToString("0.00", CultureInfo.InvariantCulture) + Blatt.Range("F" & counter + 1).Value = Steuerbetrag.ToString("0.00", CultureInfo.InvariantCulture) + Blatt.Range("H" & counter + 1).Value = "false" + Blatt.Range("I" & counter + 1).Value = LeistenderName + Blatt.Range("J" & counter + 1).Value = row.Cells("UstV_Leistender_Strasse").Value + Blatt.Range("M" & counter + 1).Value = row.Cells("UstV_Leistender_PLZ").Value + Blatt.Range("N" & counter + 1).Value = row.Cells("UstV_Leistender_Stadt").Value + Blatt.Range("O" & counter + 1).Value = iso2Land + Blatt.Range("P" & counter + 1).Value = UIDNrLeistender + + Datei.Save + + Blatt = Datei.Worksheets(2) + + 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 row.Cells("UStVPo_SchnittstellenNr").Value = 10 Then + 'UTA überspringen + ElseIf row.Cells("UStVPo_SchnittstellenNr").Value = 9 Then + maut = True 'MSE immer MAUT + Else + 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 + + Blatt.Range("A" & counter + 1).Value = counter + + If diesel Then + Blatt.Range("B" & counter + 1).Value = "1.1.2" + End If + + If maut Then + Blatt.Range("B" & counter + 1).Value = "4.1" + End If + + If zubeh Then + Blatt.Range("B" & counter + 1).Value = "3.1.3" + End If + + If parkplatz Then + Blatt.Range("B" & counter + 1).Value = "3.1.4" + End If + + If uebernachtung Then + Blatt.Range("B" & counter + 1).Value = "6.1" + End If + + + + End If + + + Datei.Save + + + Blatt = Datei.Worksheets(1) + + + counter += 1 + + Next + + Datei.Save + + .Visible = True + + + End With + + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + + Me.Cursor = Cursors.Default + + + End Function + Private Function PDFInvoicesPath(ByRef posId As String) As String diff --git a/SDL/kassenbuch/frmBelegNeu.vb b/SDL/kassenbuch/frmBelegNeu.vb index 9b8e1989..5894d4b7 100644 --- a/SDL/kassenbuch/frmBelegNeu.vb +++ b/SDL/kassenbuch/frmBelegNeu.vb @@ -1941,8 +1941,26 @@ Public Class frmBelegNeu cm_FT.Items.Add(ids) End If - If Not cm_FT.Items.ContainsKey("journal") Then - Dim ids = New ToolStripMenuItem() With {.Text = "Journal", .Name = "journal", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} + If Not cm_FT.Items.ContainsKey("version") Then + Dim ids = New ToolStripMenuItem() With {.Text = "Journal - Version", .Name = "version", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} + AddHandler ids.Click, AddressOf mnuItemAuftrauege_Clicked + cm_FT.Items.Add(ids) + End If + + If Not cm_FT.Items.ContainsKey("signatures") Then + Dim ids = New ToolStripMenuItem() With {.Text = "Journal - Signaturen", .Name = "signatures", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} + AddHandler ids.Click, AddressOf mnuItemAuftrauege_Clicked + cm_FT.Items.Add(ids) + End If + + If Not cm_FT.Items.ContainsKey("action") Then + Dim ids = New ToolStripMenuItem() With {.Text = "Journal - Action", .Name = "action", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} + AddHandler ids.Click, AddressOf mnuItemAuftrauege_Clicked + cm_FT.Items.Add(ids) + End If + + If Not cm_FT.Items.ContainsKey("queueitem") Then + Dim ids = New ToolStripMenuItem() With {.Text = "Journal - Queue", .Name = "queueitem", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} AddHandler ids.Click, AddressOf mnuItemAuftrauege_Clicked cm_FT.Items.Add(ids) End If @@ -1961,7 +1979,7 @@ Public Class frmBelegNeu KASSE.LOAD(cboKassen._value) - Dim client As New cFiskaltrustClient(KASSE.rksv_FT_RestServiceURL, KASSE.rksv_FT_CashboxID, KASSE.rksv_FT_AccessToken, KASSE.rksv_FT_Country) + 'Dim client As New cFiskaltrustClient(KASSE.rksv_FT_RestServiceURL, KASSE.rksv_FT_CashboxID, KASSE.rksv_FT_AccessToken, KASSE.rksv_FT_Country) Dim client_chilkat As New cFiskaltrustClient_chilkat(KASSE.rksv_FT_RestServiceURL, KASSE.rksv_FT_CashboxID, KASSE.rksv_FT_AccessToken, KASSE.rksv_FT_Country) If item.Name = "null" Then @@ -1970,20 +1988,36 @@ Public Class frmBelegNeu Dim result As String = client_chilkat.SignNullReceipt(KASSE.rksv_id) - MsgBox(result) + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If ElseIf item.Name = "test" Then 'beide 'Dim result As String = Await client.Echo(KASSE.rksv_bez & " " & KASSE.rksv_FT_Country & " - ") Dim result As String = client_chilkat.Echo(KASSE.rksv_bez & " " & KASSE.rksv_FT_Country & " - ") - MsgBox(result) + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If ElseIf item.Name = "storno" Then 'beide - Dim result As String = Await client.CancelReceiptAsync_test("-1", 100, "Cash", KASSE.rksv_id) - MsgBox(result) + 'Dim result As String = Await client.CancelReceiptAsync_test("-1", 100, "Cash", KASSE.rksv_id) + Dim result As String = client_chilkat.ChancelReceipt_test("-1", KASSE.rksv_id) + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If ElseIf item.Name = "bar" Then 'beide @@ -1994,26 +2028,41 @@ Public Class frmBelegNeu If vbYes = MsgBox(result & vbNewLine & vbNewLine & "Testdaten in DB speichern?", vbYesNoCancel) Then Dim QR_CodeString As String = "" - client.saveRKSV_FT(result, QR_CodeString) + client_chilkat.saveRKSV_FT(result, QR_CodeString) End If Else Return False End If - MsgBox(result) + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If ElseIf item.Name = "monthly" Then 'beide 'Dim result As String = Await client.SignClosinglReceiptAsync(item.Name, KASSE.rksv_id) - Dim result As String = client_chilkat.SignClosingReceipt(item.Name, KASSE.rksv_id) - MsgBox(result) + Dim result As String = client_chilkat.SignClosingReceipt(item.Name, KASSE.rksv_id, item.Name) + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If ElseIf item.Name = "daily" Then 'Nur DE If KASSE.rksv_FT_Country = "DE" Then 'Dim result As String = Await client.SignClosinglReceiptAsync(item.Name, KASSE.rksv_id) - Dim result As String = client_chilkat.SignClosingReceipt(item.Name, KASSE.rksv_id) - MsgBox(result) + Dim result As String = client_chilkat.SignClosingReceipt(item.Name, KASSE.rksv_id, item.Name) + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If Else MsgBox("nicht für AT-Kassen möglich!") End If @@ -2022,14 +2071,30 @@ Public Class frmBelegNeu ElseIf item.Name = "yearly" Then ' Dim result As String = Await client.SignClosinglReceiptAsync(item.Name, KASSE.rksv_id) - Dim result As String = client_chilkat.SignClosingReceipt(item.Name, KASSE.rksv_id) - MsgBox(result) + Dim result As String = client_chilkat.SignClosingReceipt(item.Name, KASSE.rksv_id, item.Name) + If result <> "" Then - ElseIf item.Name = "journal" Then + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If + + ElseIf (item.Name = "version" Or item.Name = "action" Or item.Name = "signatures" Or item.Name = "queueitem") Then 'Dim result As String = Await client.Journal(2) - Dim result As String = client_chilkat.Journal(2) - MsgBox(result) + + Dim result As String = "" + Select Case item.Name + Case "version" : result = client_chilkat.Journal(FtJournalType.VersionInformation) + Case "action" : result = client_chilkat.Journal(FtJournalType.ActionJournal) + Case "signatures" : result = client_chilkat.Journal(FtJournalType.ReceiptJournal) + Case "queueitem" : result = client_chilkat.Journal(FtJournalType.QueueItemJournal) + End Select + + If result <> "" Then + + MsgBox(client_chilkat.PrettyPrintJson(result)) + + End If diff --git a/VERAG_PROG_ALLGEMEIN/My Project/Settings.Designer.vb b/VERAG_PROG_ALLGEMEIN/My Project/Settings.Designer.vb index e6caa8af..e9ddc492 100644 --- a/VERAG_PROG_ALLGEMEIN/My Project/Settings.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/My Project/Settings.Designer.vb @@ -195,9 +195,9 @@ Namespace My _ + Global.System.Configuration.DefaultSettingValueAttribute("Data Source=192.168.0.90\DEVSQL;Initial Catalog=AVISO;Integrated Security=false;U"& _ + "ser ID=AppUser;Password=yp/THDd?xM+pZ$;Pooling=true;Min Pool Size=20;Max Pool Si"& _ + "ze=250")> _ Public ReadOnly Property AVISOConnectionStringTEST() As String Get Return CType(Me("AVISOConnectionStringTEST"),String) diff --git a/VERAG_PROG_ALLGEMEIN/My Project/Settings.settings b/VERAG_PROG_ALLGEMEIN/My Project/Settings.settings index 570b9dd8..26c5f16b 100644 --- a/VERAG_PROG_ALLGEMEIN/My Project/Settings.settings +++ b/VERAG_PROG_ALLGEMEIN/My Project/Settings.settings @@ -65,9 +65,9 @@ <?xml version="1.0" encoding="utf-16"?> <SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <ConnectionString>Data Source=192.168.0.90\DEVSQL;Initial Catalog=AVISO_new;Integrated Security=false;User ID=AppUser;Password=yp/THDd?xM+pZ$;Pooling=true;Min Pool Size=20;Max Pool Size=250</ConnectionString> + <ConnectionString>Data Source=192.168.0.90\DEVSQL;Initial Catalog=AVISO;Integrated Security=false;User ID=AppUser;Password=yp/THDd?xM+pZ$;Pooling=true;Min Pool Size=20;Max Pool Size=250</ConnectionString> </SerializableConnectionString> - Data Source=192.168.0.90\DEVSQL;Initial Catalog=AVISO_new;Integrated Security=false;User ID=AppUser;Password=yp/THDd?xM+pZ$;Pooling=true;Min Pool Size=20;Max Pool Size=250 + Data Source=192.168.0.90\DEVSQL;Initial Catalog=AVISO;Integrated Security=false;User ID=AppUser;Password=yp/THDd?xM+pZ$;Pooling=true;Min Pool Size=20;Max Pool Size=250 <?xml version="1.0" encoding="utf-16"?>