Mailversand, FIskaltrust, ustva, etc.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user