Fiskaltrust, etc.

This commit is contained in:
2026-08-25 11:51:30 +02:00
parent 28149cdbff
commit b4b483d9d2
4 changed files with 189 additions and 46 deletions

View File

@@ -1,12 +1,4 @@
 Imports Chilkat
Imports System.Data.SqlClient
Imports System.IO
Imports System.Reflection
Imports Chilkat
Imports Gma.QrCodeNet.Encoding
Imports GrapeCity.DataVisualization.Chart
Imports itextsharp.text.pdf.qrcode
Imports Newtonsoft.Json
Imports QRCoder Imports QRCoder
Public Class FtReceiptCases Public Class FtReceiptCases
@@ -104,7 +96,7 @@ Public Class cFiskaltrustClient_chilkat
p.LeistungsNr = 300 p.LeistungsNr = 300
p.LeistungsBez = "TEST" p.LeistungsBez = "TEST"
p.Preis = 10 p.Preis = 10
p.Anzahl = 1 p.Anzahl = 10
LIST.Add(p) LIST.Add(p)
Dim amount = 100 Dim amount = 100
@@ -181,28 +173,87 @@ Public Class cFiskaltrustClient_chilkat
Return SendChilkat(endpoint, "") Return SendChilkat(endpoint, "")
End Function End Function
'Private Function old_SendChilkat(endpoint As String, payload As String, Optional isGet As Boolean = False) As String
' Dim retries As Integer = 3
' Dim lastEx As Exception = Nothing
' VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
' Dim rest As New Chilkat.Rest
' Dim failureDesc As String
' rest.VerboseLogging = True
' For i As Integer = 1 To retries
' Try
' Dim uri As New Uri(_baseUrl)
' If Not rest.Connect(uri.Host, uri.Port, uri.Scheme = "https", True) Then
' Throw New Exception(rest.LastErrorText)
' failureDesc = rest.LastErrorText
' Return failureDesc
' End If
' rest.AddHeader("cashboxid", _cashboxId)
' rest.AddHeader("accesstoken", _accessToken)
' Dim response As String
' If isGet Then
' response = rest.FullRequestNoBody("GET", uri.AbsoluteUri & endpoint)
' Else
' If _country = "AT" Then
' rest.AddHeader("Content-Type", "text/plain")
' response = rest.FullRequestString("POST", uri.AbsoluteUri & endpoint, payload)
' Else
' rest.AddHeader("Content-Type", "application/json")
' response = rest.FullRequestString("POST", uri.AbsoluteUri & endpoint, payload)
' End If
' End If
' If rest.ResponseStatusCode >= 200 AndAlso rest.ResponseStatusCode < 300 Then
' Return response
' Else
' failureDesc = rest.LastErrorText
' End If
' Throw New Exception("HTTP " & rest.ResponseStatusCode & ": " & response)
' Catch ex As Exception
' lastEx = ex
' Threading.Thread.Sleep(500)
' End Try
' Next
' Throw lastEx
'End Function
Private Function SendChilkat(endpoint As String, payload As String, Optional isGet As Boolean = False) As String Private Function SendChilkat(endpoint As String, payload As String, Optional isGet As Boolean = False) As String
Dim retries As Integer = 3 Dim retries As Integer = 3
Dim lastEx As Exception = Nothing Dim lastEx As Exception = Nothing
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
Dim rest As New Chilkat.Rest
Dim failureDesc As String
rest.VerboseLogging = True
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
Dim rest As New Chilkat.Rest
rest.VerboseLogging = True
For i As Integer = 1 To retries For i As Integer = 1 To retries
Try Try
Dim uri As New Uri(_baseUrl) Dim uri As New Uri(_baseUrl)
If Not rest.Connect(uri.Host, uri.Port, uri.Scheme = "https", True) Then If Not rest.Connect(uri.Host, uri.Port, uri.Scheme = "https", True) Then
Throw New Exception(rest.LastErrorText) Throw New Exception(rest.LastErrorText)
failureDesc = rest.LastErrorText
Return failureDesc
End If End If
rest.AddHeader("cashboxid", _cashboxId) rest.AddHeader("cashboxid", _cashboxId)
@@ -211,32 +262,79 @@ Public Class cFiskaltrustClient_chilkat
Dim response As String Dim response As String
If isGet Then If isGet Then
response = rest.FullRequestNoBody("GET", uri.AbsoluteUri & endpoint)
Else
response = rest.FullRequestNoBody(
"GET",
uri.AbsoluteUri & endpoint
)
Else
If _country = "AT" Then If _country = "AT" Then
rest.AddHeader("Content-Type", "text/plain") rest.AddHeader("Content-Type", "text/plain")
response = rest.FullRequestString("POST", uri.AbsoluteUri & endpoint, payload)
Else Else
rest.AddHeader("Content-Type", "application/json") rest.AddHeader("Content-Type", "application/json")
response = rest.FullRequestString("POST", uri.AbsoluteUri & endpoint, payload)
End If End If
response = rest.FullRequestString(
"POST",
uri.AbsoluteUri & endpoint,
payload
)
End If End If
If rest.ResponseStatusCode >= 200 AndAlso rest.ResponseStatusCode < 300 Then Dim statusCode As Integer = rest.ResponseStatusCode
' SUCCESS
If statusCode >= 200 AndAlso statusCode < 300 Then
Return response Return response
Else
failureDesc = rest.LastErrorText
End If End If
Throw New Exception("HTTP " & rest.ResponseStatusCode & ": " & response) ' 4xx = client/request error -> DO NOT RETRY
If statusCode >= 400 AndAlso statusCode < 500 Then
Throw New Exception(
"HTTP " & statusCode & ": " & response
)
End If
' 5xx = server error -> retry
If statusCode >= 500 AndAlso statusCode < 600 Then
lastEx = New Exception(
"HTTP " & statusCode & ": " & response
)
If i < retries Then
Threading.Thread.Sleep(500)
Continue For
End If
Throw lastEx
End If
' Unexpected status code
Throw New Exception(
"HTTP " & statusCode & ": " & response
)
Catch ex As Exception Catch ex As Exception
lastEx = ex lastEx = ex
Threading.Thread.Sleep(500)
' If this was an HTTP 4xx, don't retry.
If rest.ResponseStatusCode >= 400 AndAlso
rest.ResponseStatusCode < 500 Then
Throw
End If
' Connection/transport error -> retry
If i < retries Then
Threading.Thread.Sleep(500)
End If
End Try End Try
Next Next
@@ -261,19 +359,32 @@ Public Class cFiskaltrustClient_chilkat
json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o")) json.UpdateString("cbReceiptMoment", DateTime.UtcNow.ToString("o"))
Dim receipCase As Long
Select Case _receiptCase
Case "Storno" Dim receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ReversalReceipt Or FtReceiptCases.ImplicitTransaction
receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ReversalReceipt Or FtReceiptCases.ImplicitTransaction 'Storno
Case Else If _receiptCase = "Storno" Then
receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ImplicitTransaction 'Verkauf
End Select ' New reference for the Storno receipt
json.UpdateString("cbReceiptReference", Guid.NewGuid().ToString())
' Reference to the original receipt from the database
json.UpdateString("cbPreviousReceiptReference", _reference)
' Storno = POS receipt + reversal + implicit transaction
receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ReversalReceipt Or FtReceiptCases.ImplicitTransaction
Else
' New reference for a normal receipt
json.UpdateString("cbReceiptReference", Guid.NewGuid().ToString())
' Normal sale
receipCase = FtReceiptCases.PosReceipt Or FtReceiptCases.ImplicitTransaction
End If
json.UpdateString("ftReceiptCase", receipCase.ToString())
json.UpdateString("ftReceiptCase", receipCase)
Dim chargeItems = json.AppendArray("cbChargeItems") Dim chargeItems = json.AppendArray("cbChargeItems")
@@ -466,8 +577,12 @@ Public Class cFiskaltrustClient_chilkat
Public Function saveRKSV_FT(ByRef result_zahlung As String, ByRef QR_CodeString As String, ByRef beleg_temp As EABeleg, ByRef isStorno As Boolean) As Boolean Public Function saveRKSV_FT(ByRef result_zahlung As String, ByRef QR_CodeString As String, ByRef beleg_temp As EABeleg, ByRef isStorno As Boolean) As Boolean
If result_zahlung <> "" Then If String.IsNullOrWhiteSpace(result_zahlung) Then
Dim json As New Chilkat.JsonObject Return False
End If
Dim json As New Chilkat.JsonObject
Dim success As Boolean = json.Load(result_zahlung) Dim success As Boolean = json.Load(result_zahlung)
If (success <> True) Then If (success <> True) Then
Debug.WriteLine(json.LastErrorText) Debug.WriteLine(json.LastErrorText)
@@ -572,10 +687,6 @@ Public Class cFiskaltrustClient_chilkat
Return saved Return saved
End If
End Function End Function
@@ -625,7 +736,7 @@ Public Class cFiskaltrustClient_chilkat
R("ftQueueId") = .StringOf("ftQueueId") R("ftQueueId") = .StringOf("ftQueueId")
R("ftQueueItemId") = .StringOf("ftQueueItemId") R("ftQueueItemId") = .StringOf("ftQueueItemId")
R("ftReceiptHash") = .StringOf("ftReceiptHash") R("ftReceiptHash") = .StringOf("ftReceiptHash")
R("TimeStamp") = tmstmp.GetAsTimestamp(getAsLocal) R("TimeStamp") = .StringOf("ftReceiptMoment")
End With End With

View File

@@ -1965,6 +1965,12 @@ Public Class frmBelegNeu
cm_FT.Items.Add(ids) cm_FT.Items.Add(ids)
End If End If
If Not cm_FT.Items.ContainsKey("exportJournal") Then
Dim ids = New ToolStripMenuItem() With {.Text = "Journal - EXPORT", .Name = "exportJournal", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)}
AddHandler ids.Click, AddressOf mnuItemAuftrauege_Clicked
cm_FT.Items.Add(ids)
End If
cm_FT.Show(Cursor.Position) cm_FT.Show(Cursor.Position)
End Sub End Sub
@@ -2078,7 +2084,7 @@ Public Class frmBelegNeu
End If End If
ElseIf (item.Name = "version" Or item.Name = "action" Or item.Name = "signatures" Or item.Name = "queueitem") Then ElseIf (item.Name = "version" Or item.Name = "action" Or item.Name = "signatures" Or item.Name = "queueitem" Or item.Name = "exportJournal") Then
'Dim result As String = Await client.Journal(2) 'Dim result As String = Await client.Journal(2)
@@ -2088,12 +2094,17 @@ Public Class frmBelegNeu
Case "action" : result = client_chilkat.Journal(FtJournalType.ActionJournal) Case "action" : result = client_chilkat.Journal(FtJournalType.ActionJournal)
Case "signatures" : result = client_chilkat.Journal(FtJournalType.ReceiptJournal) Case "signatures" : result = client_chilkat.Journal(FtJournalType.ReceiptJournal)
Case "queueitem" : result = client_chilkat.Journal(FtJournalType.QueueItemJournal) Case "queueitem" : result = client_chilkat.Journal(FtJournalType.QueueItemJournal)
Case "exportJournal" : result = client_chilkat.Journal(FtJournalType.ReceiptJournal)
End Select End Select
If result <> "" Then If result <> "" Then
MsgBox(client_chilkat.PrettyPrintJson(result)) MsgBox(client_chilkat.PrettyPrintJson(result))
If item.Name = "exportJournal" Then
client_chilkat.exportJournal(result)
End If
End If End If

View File

@@ -225,7 +225,18 @@ Public Class frmFremdbeleg
Dim answer = "" Dim answer = ""
If KASSE.rksv_aktiv Then If KASSE.rksv_aktiv Then
If Not cRKSV.insertRKSV(KASSE, KASSE.rksv_CompanyGUID, KASSE.rksv_Umsatzzaehler, BELEG.BelegDat, BELEG.Steuerschlüssel, RKSV_Beleg_Id, summeBRUTTO, QR_CodeString, LastJWS, TESTBUCHUNG, answer) Then 'Digitale Signierung und Erfassung in die RKSV-Datenbank mittels ITG-Service
Dim verarbeitet As Boolean = False
If KASSE.rksv_FT_RestServiceURL <> "" Then
Dim result = cRKSV.insertRKSVFiskaltrustAsync(KASSE, BELEG, RKSV_Beleg_Id, summeBRUTTO, TESTBUCHUNG, QR_CodeString, LastJWS)
'result.Wait()
verarbeitet = result
Else
verarbeitet = cRKSV.insertRKSV(KASSE, KASSE.rksv_CompanyGUID, KASSE.rksv_Umsatzzaehler, BELEG.BelegDat, BELEG.Steuerschlüssel, RKSV_Beleg_Id, summeBRUTTO, QR_CodeString, LastJWS, TESTBUCHUNG, answer) 'Digitale Signierung und Erfassung in die RKSV-Datenbank mittels ITG-Service
End If
If Not verarbeitet Then 'Digitale Signierung und Erfassung in die RKSV-Datenbank mittels ITG-Service
If Not TESTBUCHUNG Then If Not TESTBUCHUNG Then
KASSE.DECREASE_BELEG_UMSATZ(oldBelegZaehler, BELEG.rksv_umsatz * -1) KASSE.DECREASE_BELEG_UMSATZ(oldBelegZaehler, BELEG.rksv_umsatz * -1)
cRKSV.DELETE(BELEG, KASSE.rksv_firma) cRKSV.DELETE(BELEG, KASSE.rksv_firma)

View File

@@ -365,7 +365,17 @@ Public Class frmNacherfassungLeihgeld
If KASSE.rksv_aktiv Then ' WENN für die Kasse die RKSV gilt If KASSE.rksv_aktiv Then ' WENN für die Kasse die RKSV gilt
Dim answer = "" Dim answer = ""
If Not cRKSV.insertRKSV(KASSE, KASSE.rksv_CompanyGUID, KASSE.rksv_Umsatzzaehler, BELEG.BelegDat, BELEG.Steuerschlüssel, RKSV_Beleg_Id, summeBRUTTO, QR_CodeString, LastJWS, TESTBUCHUNG, answer) Then 'Digitale Signierung und Erfassung in die RKSV-Datenbank mittels ITG-Service
Dim verarbeitet As Boolean = False
If KASSE.rksv_FT_RestServiceURL <> "" Then
Dim result = cRKSV.insertRKSVFiskaltrustAsync(KASSE, BELEG, RKSV_Beleg_Id, summeBRUTTO, TESTBUCHUNG, QR_CodeString, LastJWS)
'result.Wait()
verarbeitet = result
Else
verarbeitet = cRKSV.insertRKSV(KASSE, KASSE.rksv_CompanyGUID, KASSE.rksv_Umsatzzaehler, BELEG.BelegDat, BELEG.Steuerschlüssel, RKSV_Beleg_Id, summeBRUTTO, QR_CodeString, LastJWS, TESTBUCHUNG, answer) 'Digitale Signierung und Erfassung in die RKSV-Datenbank mittels ITG-Service
End If
If Not verarbeitet Then 'Digitale Signierung und Erfassung in die RKSV-Datenbank mittels ITG-Service
If Not TESTBUCHUNG Then If Not TESTBUCHUNG Then
KASSE.DECREASE_BELEG_UMSATZ(oldBelegZaehler, summeBRUTTO * -1) KASSE.DECREASE_BELEG_UMSATZ(oldBelegZaehler, summeBRUTTO * -1)
cRKSV.DELETE(BELEG, KASSE.rksv_firma) cRKSV.DELETE(BELEG, KASSE.rksv_firma)