divl. Änderungne
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Net
|
||||
Imports System.Net.Http
|
||||
Imports System.Reflection
|
||||
Imports System.Text
|
||||
@@ -47,6 +48,47 @@ Public Class cFiskaltrustClient
|
||||
|
||||
End Function
|
||||
|
||||
'----- TEST
|
||||
Public Async Function SignReceiptAsync_test(posSystemId As String) As Task(Of 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 payload = BuildPayloadReceipt(100, CDec(0.0), LIST, "Cash", posSystemId)
|
||||
Dim endpoint = GetEndpoint("payment")
|
||||
|
||||
Dim requestContent As StringContent
|
||||
|
||||
If _country = "AT" Then
|
||||
' Plaintext
|
||||
'Dim text As String = If(payload?.ToString(), "")
|
||||
Dim json As String = JsonConvert.SerializeObject(payload)
|
||||
'requestContent = New StringContent(json, Encoding.UTF8, "text/plain")
|
||||
requestContent = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
Else
|
||||
' JSON Objekt
|
||||
|
||||
Dim json As String = JsonConvert.SerializeObject(payload)
|
||||
requestContent = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
End If
|
||||
|
||||
|
||||
Return Await SendAsync(endpoint, payload, requestContent)
|
||||
|
||||
End Function
|
||||
|
||||
Public Async Function Echo(KassenName As String) As Task(Of String)
|
||||
|
||||
Dim payload = KassenName & " - VERBINDUNG OK"
|
||||
@@ -192,7 +234,7 @@ Public Class cFiskaltrustClient
|
||||
endpoint &= "?type=" & type
|
||||
End If
|
||||
|
||||
Dim requestContent As StringContent
|
||||
Dim requestContent As StringContent = Nothing
|
||||
|
||||
If _country = "AT" Then
|
||||
' Plaintext
|
||||
@@ -206,48 +248,7 @@ Public Class cFiskaltrustClient
|
||||
requestContent = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
End If
|
||||
|
||||
Return Await SendAsync(endpoint, payload, requestContent)
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Async Function SignReceiptAsync_test(posSystemId As String) As Task(Of 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 payload = BuildPayloadReceipt(100, 0, LIST, "Cash", posSystemId)
|
||||
Dim endpoint = GetEndpoint("payment")
|
||||
|
||||
Dim requestContent As StringContent
|
||||
|
||||
If _country = "AT" Then
|
||||
' Plaintext
|
||||
'Dim text As String = If(payload?.ToString(), "")
|
||||
Dim json As String = JsonConvert.SerializeObject(payload)
|
||||
'requestContent = New StringContent(json, Encoding.UTF8, "text/plain")
|
||||
requestContent = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
Else
|
||||
' JSON Objekt
|
||||
|
||||
Dim json As String = JsonConvert.SerializeObject(payload)
|
||||
requestContent = New StringContent(json, Encoding.UTF8, "application/json")
|
||||
End If
|
||||
|
||||
|
||||
Return Await SendAsync(endpoint, payload, requestContent)
|
||||
Return Await SendAsync(endpoint, payload, requestContent, True)
|
||||
|
||||
End Function
|
||||
|
||||
@@ -311,7 +312,7 @@ Public Class cFiskaltrustClient
|
||||
End Function
|
||||
|
||||
|
||||
Private Async Function SendAsync(endpoint As String, payload As Object, requestContent As StringContent) As Task(Of String)
|
||||
Private Async Function SendAsync(endpoint As String, payload As Object, requestContent As StringContent, Optional ignorerequestContent As Boolean = False) As Task(Of String)
|
||||
|
||||
Dim url = _baseUrl & endpoint
|
||||
|
||||
@@ -321,6 +322,8 @@ Public Class cFiskaltrustClient
|
||||
Dim lastException As Exception = Nothing
|
||||
Dim shouldRetry As Boolean = False
|
||||
|
||||
ServicePointManager.Expect100Continue = False
|
||||
|
||||
For attempt As Integer = 1 To retries
|
||||
|
||||
shouldRetry = False
|
||||
@@ -332,13 +335,19 @@ Public Class cFiskaltrustClient
|
||||
request.Headers.Add("cashboxid", _cashboxId)
|
||||
request.Headers.Add("accesstoken", _accessToken)
|
||||
|
||||
If requestContent IsNot Nothing Then
|
||||
If Not ignorerequestContent AndAlso requestContent IsNot Nothing Then
|
||||
request.Content = requestContent
|
||||
End If
|
||||
|
||||
|
||||
Dim cts As New CancellationTokenSource(TimeSpan.FromSeconds(30))
|
||||
Dim response = Await _httpClient.SendAsync(request, cts.Token)
|
||||
Debug.WriteLine("Before SendAsync")
|
||||
|
||||
Dim response = Await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cts.Token)
|
||||
|
||||
Debug.WriteLine("Headers received")
|
||||
|
||||
Debug.WriteLine("After SendAsync")
|
||||
Dim result = Await response.Content.ReadAsStringAsync()
|
||||
|
||||
Log($"[{DateTime.Now}] Response ({CInt(response.StatusCode)}): {result}")
|
||||
@@ -366,7 +375,9 @@ Public Class cFiskaltrustClient
|
||||
|
||||
lastException = ex
|
||||
|
||||
Log($"[{DateTime.Now}] Attempt {attempt} failed: {ex.Message}")
|
||||
Debug.WriteLine(ex.GetType().FullName)
|
||||
Debug.WriteLine(ex.ToString())
|
||||
Throw
|
||||
|
||||
End Try
|
||||
|
||||
@@ -379,6 +390,7 @@ Public Class cFiskaltrustClient
|
||||
|
||||
If lastException IsNot Nothing Then
|
||||
Throw lastException
|
||||
MsgBox(lastException)
|
||||
End If
|
||||
|
||||
Throw New Exception("Unexpected error")
|
||||
@@ -603,11 +615,11 @@ Public Class cFiskaltrustClient
|
||||
.ftSignatureFormat = SignObj.StringOf("ftSignatureFormat")
|
||||
.ftSignatureType = SignObj.StringOf("ftSignatureType")
|
||||
saved = .SAVE()
|
||||
If IsNumeric(.ftSignatureType) AndAlso CInt(.ftSignatureType) = 3 Then
|
||||
QR_CodeString = .ftData
|
||||
End If
|
||||
If IsNumeric(.ftSignatureType) AndAlso CInt(.ftSignatureType) = IIf(VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True, 0, 3) Then
|
||||
QR_CodeString = .ftData
|
||||
End If
|
||||
|
||||
End With
|
||||
End With
|
||||
|
||||
Next
|
||||
|
||||
@@ -791,26 +803,6 @@ Public Class cFiskaltrustSignatures
|
||||
|
||||
|
||||
|
||||
'Public Function getUpdateCmd() As String
|
||||
' Try
|
||||
' Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
' Dim str As String = ""
|
||||
' For Each i In list
|
||||
' If Not i.isPrimaryParam Then
|
||||
' str &= "[" & i.Text & "] = @" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
|
||||
' End If
|
||||
' Next
|
||||
' str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||
' Return (" UPDATE [tblTABLE] SET " & str & " WHERE _BASE_id=@_BASE_id ")
|
||||
|
||||
' Catch ex As Exception
|
||||
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
' End Try
|
||||
' Return ""
|
||||
'End Function
|
||||
|
||||
|
||||
Public Function getInsertCmd() As String
|
||||
Try
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
@@ -908,28 +900,6 @@ Public Class cFiskaltrustSignaturPositions
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
'Public Function getUpdateCmd() As String
|
||||
' Try
|
||||
' Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
' Dim str As String = ""
|
||||
' For Each i In list
|
||||
' If Not i.isPrimaryParam Then
|
||||
' str &= "[" & i.Text & "] = @" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
|
||||
' End If
|
||||
' Next
|
||||
' str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||
' Return (" UPDATE [tblTABLE] SET " & str & " WHERE _BASE_id=@_BASE_id ")
|
||||
|
||||
' Catch ex As Exception
|
||||
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
' End Try
|
||||
' Return ""
|
||||
'End Function
|
||||
|
||||
|
||||
Public Function getInsertCmd() As String
|
||||
Try
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
@@ -116,8 +116,6 @@ Public Class cRKSV
|
||||
|
||||
Dim steuersatz As Double = SQL.getValueTxtBySql("SELECT isnull(tblSteuersätze.Steuersatz,0) FROM tblSteuersätze WHERE tblSteuersätze.Nr='" & steuerSchluessel & "' ", "FMZOLL")
|
||||
|
||||
|
||||
|
||||
Dim BetragSatzNormal = IIf(steuersatz = 0.2, summeBRUTTO, 0.0) 'summe
|
||||
Dim BetragSatzErm1 = IIf(steuersatz = 0.1, summeBRUTTO, 0.0)
|
||||
Dim BetragSatzErm2 = IIf(steuersatz = 0.13, summeBRUTTO, 0.0)
|
||||
@@ -129,8 +127,12 @@ Public Class cRKSV
|
||||
|
||||
|
||||
Dim result = Await client.SignReceiptAsync(summeBRUTTO, steuersatz, POS, "Cash", kasse.rksv_id)
|
||||
If result <> "" Then
|
||||
Return client.saveRKSV_FT(result, QR_CodeString)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return client.saveRKSV_FT(result, QR_CodeString)
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user