eet

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GOBL ➡️ Czech EET 2.0

Go library to convert GOBL payments into Czech EET 2.0 sale messages and send them to the Financial Administration: the cz-eet-v1 addon, a converter from payments to the EET data message, a WS-Security signer, a client for the service, and a reader for its responses.

Released under the Apache 2.0 LICENSE, Copyright 2026 Invopop S.L..

Lint Test Go Go Report Card codecov GoDoc Latest Tag Ask DeepWiki

EET 2.0 in short

From 1 January 2027, payments taken in person in the Czech Republic (cash, card at the counter, vouchers and similar) are sent to the Financial Administration as signed data messages, Trzba, and it answers each with a confirmation code, the POK. The law sets which payments and taxpayers this covers, and exempts some. EET calls each of these payments a sale (tržba), so here "sale" is the message and "payment" the GOBL document. The message has no lines, taxes or customer: only the merchant's tax ID, the recording unit and device the payment was taken on, its sequence number and time, and the amount received in CZK. Each merchant signs with their own certificate from the CA EET. The interface description, schema and samples are on eet.gov.cz.

The addon

Import the addon to register it, then declare cz-eet-v1 on a payment receipt, one for every payment taken in person:

import _ "github.com/invopop/gobl.cz.eet/addon"
$schema: "https://gobl.org/draft-0/bill/payment"
$addons:
  - "cz-eet-v1"
series: "PRG"
code: "000135"
issue_date: "2027-01-09"
issue_time: "16:45:36"
ext:
  cz-eet-unit: "303"
  cz-eet-device: "POS-1"

supplier:
  name: "Kavárna u Mostu s.r.o."
  tax_id:
    country: "CZ"
    code: "25596641"

lines:
  - amount: "205.00"

methods:
  - key: "cash"

That is all a payment needs. GOBL fills in the rest when it calculates the payment: the receipt type, the regime and the currency from the supplier's tax ID, the amount of a single method, and the total.

Key Kind EET item
cz-eet-unit Extension in the payment's ext id_jednotky, the recording unit number from DIS+
cz-eet-device Extension in the payment's ext id_pokl, the end device within the unit
prepaid Payment method key qualifier, as in other+prepaid cerp_zuct, the part drawn from prepaid credit
cz-eet-prepaid-load Extension in a line's ext, value true or false urceno_cerp_zuct, the part loaded onto prepaid credit
ordering.issuer Party in the payment eic_popl and eic_poverujiciho, for a sale recorded under a delegation
cz-eet-multiple-taxpayers Extension in the payment's ext, value true or false povereni_vice_popl, for a sale that is income of several taxpayers
eet-pok Stamp pok, the confirmation code

The sale total is the payment's total, which GOBL makes negative for lines marked refund: a refund is a receipt with refund lines, and an exchange is one receipt with a refund line for the item taken back and another line for the new one, so the sale is the difference paid. The Financial Administration also accepts an exchange sent as two messages, the refund and the new sale, which suits a till that can't net them. An exchange at the same price nets to 0.00, which EET accepts; for a sale that nets to zero, the Financial Administration recommends two messages instead (item description, returnable packaging, example 3).

The rules ask for what the message needs and a payment may lack: the receipt type, a Czech supplier tax ID, an issue time, the unit and device extensions, CZK or an exchange rate to CZK, a series and code that fit porad_cis, and a total, and parts drawn from or loaded onto prepaid credit, within ±99,999,999.99 CZK. The two yes-or-no extensions take true or false, each in its own place: cz-eet-prepaid-load on a line and cz-eet-multiple-taxpayers on the payment. A method dated on another day than the payment is refused, as each payment is recorded on its own. A total that is not the sum of the lines is refused too, as on a payment that was never calculated or was changed afterwards. Full examples are in examples.

The issue date and time are the moment the money was received, in Czech local time (Europe/Prague), which EET records with seconds. An issue time taken from a server clock in another zone records the sale at the wrong hour without any error.

The addon has no rules for invoices, and NewSale only takes a payment: EET records each payment, not each invoice. One payment document is one payment taken in person. An advance payment and the final payment of an invoice are two payments, each with its own receipt, and money received another way, such as a bank transfer, gets no receipt with the addon.

Usage

Go Package

You must have first created a GOBL envelope containing a payment receipt with the cz-eet-v1 addon, calculated, for each payment taken in person. The module doesn't write to the envelope: keep the POK it returns as the envelope's eet-pok stamp, which the addon defines, on a signed envelope, as GOBL only accepts stamps on one.

import (
	"context"
	"errors"

	eet "github.com/invopop/gobl.cz.eet"
	_ "github.com/invopop/gobl.cz.eet/addon"
	"github.com/invopop/xmldsig"
)

// The merchant's certificate, the .p12 file the CA EET issues.
cert, err := xmldsig.LoadCertificate("./CA_EET.p12", password)
if err != nil {
	return err
}

client, err := eet.New(
	eet.WithCertificate(cert),
	eet.InProduction(), // the Playground by default
)
if err != nil {
	return err
}

var res *eet.Response
sale, err := client.NewSale(env) // validates the payment in the envelope
if err == nil {
	res, err = client.Send(ctx, sale)
}
switch {
case err == nil && res.Confirmation != nil:
	// recorded: keep res.Confirmation.POK as the envelope's eet-pok stamp
case err == nil:
	// verification mode: the message passed the checks, nothing recorded
case errors.Is(err, eet.ErrUntrusted), errors.Is(err, eet.ErrEnvironment):
	// a validly signed confirmation whose certificate isn't the environment's
	// signer or couldn't be checked (a clock set wrong, say), or one from the
	// other environment: no valid POK, so send again with eet.WithResend(),
	// and have someone check the certificate, the clock or where it was sent
case errors.Is(err, eet.ErrConnection), errors.Is(err, eet.ErrServer):
	// no answer, one we can't read, or one that says to try later: send
	// again later with client.NewSale(env, eet.WithResend())
case errors.Is(err, eet.ErrDuplicate):
	// the envelope has a POK for this environment: nothing to send
case errors.Is(err, eet.ErrValidation):
	// the payment, the certificate or the request needs fixing before it
	// can go: the error's code and message say what failed
}

Send signs the sale, posts it over HTTP/1.1 and TLS 1.2 or higher, verifying the server's certificate, and reads the reply with ParseResponse. An error code in the reply (Chyba) comes back as an error with the code: ErrServer for the codes to send again later (8, and every negative code: -1 is a temporary error and -999 to -2 are reserved next to it, interface description, 3.5.4), ErrValidation for the rest. A SOAP fault is ErrServer for a Server fault code, or a more specific one such as Server.Busy, and ErrValidation for any other. A SOAP envelope is read as the reply whatever the HTTP status; any other body with a status other than 2xx, such as an error page, is ErrServer, 4xx included: the service reports what is wrong with a message with an error code or a fault, so such a page comes from the infrastructure in front of it, and the sale is sent again. A network error, the time limit passing, or a reply that can't be read or answers another message is ErrConnection.

Response.TransactionID is the X-Global-Transaction-Id the service tags the exchange with, for tracing it with the Financial Administration (interface description, 5.4); errors about a reply carry it too, when the service sent one. The client waits 10 seconds for a reply by default; WithTimeout changes that, but not below the 2 seconds the EET Act sets (MinTimeout). The client speaks HTTP/1.1 over TLS 1.2 or higher, follows no redirects, and takes a proxy from the environment (HTTPS_PROXY). With DEBUG=true in the environment, the client logs each request with its body, and the status and headers of each reply; the reply's body isn't logged, as the client reads it itself. An app that posts the request itself gets it from client.Sign(sale) and reads the reply with eet.ParseResponse(data, sale, client.Environment()).

NewSale expects a payment that has been calculated. It validates the payment itself and refuses it with the faults when a rule doesn't pass, so a payment whose total isn't the sum of its lines, or that EET would take with the wrong number, never builds a message.

NewSale fills cerp_zuct from the methods whose key has prepaid, such as other+prepaid, leaving it out when they add up to zero, and urceno_cerp_zuct from the lines marked cz-eet-prepaid-load: "true", refund lines subtracted, left out when they add up to zero. A load and a purchase paid together (item 14, example 1) are one payment with a line for each: a wallet topped up with 1,000 CZK and a drink for 50 CZK are sent as celk_trzba="1050.00" and urceno_cerp_zuct="1000.00". A line or payment without the extension counts as "false".

A sale recorded under a delegation to record sales (pověření, § 10 of the EET Act; item description, chapter 3, situations 4 and 5) has the taxpayer whose income it is as the supplier and whoever records it as the ordering issuer (ordering.issuer, the third party who issues the document):

  • With an issuer, the issuer records it for the supplier. eic_popl is the issuer's tax ID and eic_poverujiciho the supplier's.
  • Marked cz-eet-multiple-taxpayers: "true", the sale is income of several taxpayers, and povereni_vice_popl is sent. With an issuer, eic_popl is the issuer's tax ID and eic_poverujiciho the supplier's, as the Financial Administration recommends; without one, the supplier records it and eic_popl is theirs.

Whoever records the sale sends it from their own recording unit (cz-eet-unit) and signs it with their own certificate, whose tax ID should be the one in eic_popl, or the service adds warning 1. The payee, who receives the money, isn't part of the message.

NewSale makes a new message, with its own UUID, on every call, and Sign sets its send time and signs it once, so build one per attempt; WithCurrentTime fixes the send time in tests. A UUID is never used twice: it is the only thing that ties a reply to its message. Data.SaleKey() identifies the sale across attempts. WithVerification() asks the service to check a message without recording it.

A payment is only sent again when no POK came back for it (item description, chapter 3), so NewSale refuses an envelope that already has the eet-pok stamp with ErrDuplicate, except in verification mode, which records nothing. A Playground POK, ending in -ff, isn't valid under the EET Act (interface description, 3.4.2.3), so it only blocks in the Playground. An empty eet-pok stamp, or more than one, is refused with ErrValidation.

Every attempt after the first is built with WithResend(), also when the first got no answer or an answer that ParseResponse refused. A sale that could not be recorded is sent again without delay once the cause has passed, at the latest 48 hours after the sale, and it still has to be recorded if that limit is missed (§ 19 of the EET Act; item description, chapter 6).

Sending again is always safe: a message with the same sale data as one already received counts as the same sale (interface description, chapter 4, on eic_popl, id_jednotky, id_pokl, porad_cis, dat_trzby and celk_trzba), and a sale is sent again whenever no POK came back (item description, chapter 3). ErrUntrusted and ErrEnvironment say the reply came back with a valid signature but can't be trusted: its certificate isn't the environment's signer, the client couldn't check it (a clock set wrong makes the certificate look expired or not yet valid), or it comes from the other environment. A missing or broken signature is ErrConnection. No valid POK came back, so the sale is sent again with WithResend(); these errors stay apart from ErrConnection so that the app can also have someone look at the certificate, the clock or the environment, as they repeat until the cause is fixed.

The client's environment, production or the Playground, gives both the URL to send to and the checks on the reply, so the two can't be mixed; ParseResponse takes it as an Environment. Both come from the operations documents ("Přístupové a provozní informace" v1.2, for production and the Playground): the URL from chapter 2.1, the signer from chapter 3.3.

ParseResponse only accepts a confirmation signed by the environment's certificate, as the interface description sets out (section 5.3), for the very message it is given, checked by chain, validity, subject and policy as ca sets out from chapter 3.3 of the operations documents (production, Playground). The service may change the certificate at any time while keeping those attributes (developer seminar slides, page 44), so they are what is checked, not its key.

The certificate is loaded with xmldsig, as in the other GOBL modules, but signing and verification use helium, as xmldsig only has the XAdES profiles and EET asks for WS-Security with a BinarySecurityToken. The module adds the WS-Security envelope and the interface description's checks on the signature's shape (5.2).

The client and the response checks rely on Go's HTTP, certificate and XML code, so the module asks for Go 1.26.11, the first release that fixes what govulncheck finds reachable from them. Build the app with the latest Go 1.26 patch release.

Limitations

  • The response signer's certificate is not checked against I.CA's revocation lists.
  • The recorded replies the tests read come from the Playground only: the production signer's identity comes from the operations document (chapter 3.3), and no production reply has been read yet.
  • One sale per message, as EET takes them; retries, the 48-hour limit and keeping track of which sales are confirmed are left to the app.

Development

go test ./...
go test . -update      # rewrite the golden files in examples/out

The signer is tested against the three official signed sample requests in test/samples, whose bodies it digests identically, and the response reader against Playground replies in test/responses. In the tests, signatures are also checked by a second, independent judge built on goxmldsig.

Documentation

Overview

Package eet records GOBL payments with the Czech EET 2.0 service and returns the POK of each; the GOBL addon, with the eet-pok stamp to keep it in, lives in the addon subpackage.

The package embeds the time zone database (time/tzdata, about 450 KB) so that Europe/Prague always loads, as falling back to UTC would record every sale an hour or two off.

Index

Constants

View Source
const (
	MinTimeout     = 2 * time.Second
	DefaultTimeout = 10 * time.Second
)

MinTimeout is the shortest wait for a reply the EET Act allows (§ 19; item description, chapter 6), and DefaultTimeout the one used when none is set.

View Source
const MaxRequestSize = 12000

MaxRequestSize is the largest signed request the service accepts, the smaller reading of the "12 kB" of error 7 (interface description, 3.5.4).

View Source
const SOAPAction = "http://fs.gov.cz/eet/OdeslaniTrzby"

SOAPAction is the action of the service's one operation, OdeslaniTrzby, which SOAP 1.1 sends in quotes in the SOAPAction header.

Variables

View Source
var (
	// ErrConnection is used when the service could not be reached or gave a
	// response we're unable to understand, including one that answers
	// another message.
	ErrConnection = newError("connection")
	// ErrValidation implies there is something wrong with the contents of
	// the request that needs to be fixed before sending it again.
	ErrValidation = newError("validation")
	// ErrServer indicates the service had a problem handling the request,
	// which may succeed if sent again later.
	ErrServer = newError("server")
	// ErrDuplicate is used when the envelope has a POK that records the sale
	// in the client's environment (any in the Playground, a production one
	// in production), as a sale is only sent again when none came back
	// (item description, chapter 3).
	ErrDuplicate = newError("duplicate")
	// ErrUntrusted says the confirmation's signature is valid but its
	// certificate isn't the environment's signer, or couldn't be checked (a
	// clock set wrong, say), while a missing or broken signature is
	// ErrConnection: send the sale again with WithResend, and have someone
	// check the certificate and the clock.
	ErrUntrusted = newError("untrusted")
	// ErrEnvironment says a confirmation comes from the other environment:
	// send the sale again with WithResend, and have someone check where it
	// was sent.
	ErrEnvironment = newError("environment")
)

Errors returned by this package, matched with errors.Is on their key.

View Source
var (
	// ErrOnlyPayments is returned for an envelope whose document isn't a
	// payment.
	ErrOnlyPayments = ErrValidation.WithMessage("only payments are supported")
)

Standard error responses.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client builds sale messages from GOBL payments and sends them to one environment of the EET service.

func New

func New(opts ...Option) (*Client, error)

New creates a client for the Playground, or production with InProduction, which without a certificate builds sales but doesn't send them.

func (*Client) CurrentTime

func (c *Client) CurrentTime() time.Time

CurrentTime returns the send time for the sale messages.

func (*Client) Environment

func (c *Client) Environment() Environment

Environment returns the environment the client sends to.

func (*Client) NewSale

func (c *Client) NewSale(env *gobl.Envelope, opts ...GenerateOption) (*Sale, error)

NewSale builds the message for the calculated payment in the envelope, one for every attempt, refusing it with the rules' faults, or with ErrDuplicate for an envelope whose POK records the sale in the client's environment (any in the Playground, a production one in production) unless WithVerification is given.

func (*Client) Send

func (c *Client) Send(ctx context.Context, sale *Sale) (*Response, error)

Send signs and posts the sale, which can't have been signed before, and reads the reply as ParseResponse does; a context deadline under MinTimeout cuts the wait short, and errors about a reply carry its transaction ID, when the service sent one.

func (*Client) Sign

func (c *Client) Sign(sale *Sale) ([]byte, error)

Sign returns the SOAP request carrying the sale, signed with the client's certificate as the interface description asks (5.2), with the send time (dat_odesl, 3.3.3.2) set now; a sale is used once (3.3.3.1), so Sign followed by Send fails, and an app that posts the request itself uses Sign and ParseResponse while any other uses only Send.

type Confirmation

type Confirmation struct {
	// POK (pok) is the confirmation code, unique to each confirmed message.
	POK string `xml:"pok,attr"`
	// Test (test) is true outside production.
	Test bool `xml:"test,attr"`
}

Confirmation (Potvrzeni) that the sale was recorded.

func (*Confirmation) UnmarshalXML

func (c *Confirmation) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML reads a Potvrzeni element, refusing one without a POK.

type Data

type Data struct {
	// TaxID (eic_popl) of whoever records the sale, which should be the CN of
	// the signing certificate, or the service adds warning 1.
	TaxID string `xml:"eic_popl,attr"`
	// DelegatingTaxID (eic_poverujiciho) of the merchant that delegated the
	// recording, when there is one.
	DelegatingTaxID string `xml:"eic_poverujiciho,attr,omitempty"`
	// DelegatedByMany (povereni_vice_popl) when several merchants delegated
	// the recording.
	DelegatedByMany bool `xml:"povereni_vice_popl,attr,omitempty"`
	// UnitID (id_jednotky) of the recording unit, as registered in DIS+.
	UnitID string `xml:"id_jednotky,attr"`
	// DeviceID (id_pokl) of the end device within the unit.
	DeviceID string `xml:"id_pokl,attr"`
	// Number (porad_cis) of the sale in the device's sequence.
	Number string `xml:"porad_cis,attr"`
	// SoldAt (dat_trzby) is the local time of the sale.
	SoldAt string `xml:"dat_trzby,attr"`
	// Total (celk_trzba) amount paid, in CZK.
	Total string `xml:"celk_trzba,attr"`
	// PrepaidLoaded (urceno_cerp_zuct) is the part of the total meant to be
	// drawn down or settled later.
	PrepaidLoaded string `xml:"urceno_cerp_zuct,attr,omitempty"`
	// PrepaidDrawn (cerp_zuct) is the part paid by drawing down an earlier
	// prepayment.
	PrepaidDrawn string `xml:"cerp_zuct,attr,omitempty"`
}

Data (Data) describes the sale itself.

func (*Data) SaleKey

func (d *Data) SaleKey() string

SaleKey joins with '|' the six values by which the service counts messages as the same sale (interface description, chapter 4).

type Environment

type Environment string

Environment is one of the EET service's two environments, production or the Playground, and gives both the URL to send a sale to and the signer its confirmations must have.

const (
	EnvironmentProduction Environment = "production"
	EnvironmentPlayground Environment = "playground"
)

The service's environments.

func (Environment) URL

func (e Environment) URL() string

URL is where the environment receives sales ("Přístupové a provozní informace" v1.2, chapter 2.1), or empty for an unknown environment.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is an error of this package: a key that says how to handle it, with a code and message when there are any.

func (*Error) Code

func (e *Error) Code() string

Code returns the code provided by the service: the EET error code of a Chyba, the faultcode of a SOAP fault, or the HTTP status.

func (*Error) Error

func (e *Error) Error() string

Error produces a human readable error message.

func (*Error) Is

func (e *Error) Is(target error) bool

Is matches an Error with the same key, and the same code and message where the target has them.

func (*Error) Key

func (e *Error) Key() string

Key returns the key for the error.

func (*Error) Message

func (e *Error) Message() string

Message returns the human message for the error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the error that caused this one, if any.

func (*Error) WithCode

func (e *Error) WithCode(code string) *Error

WithCode duplicates and adds the code to the error.

func (*Error) WithMessage

func (e *Error) WithMessage(msg string) *Error

WithMessage duplicates and adds the message to the error.

type ErrorCode

type ErrorCode int

ErrorCode (kod) of a response. Match on the code, not on the text, which differs between versions of the spec.

const (
	// ErrorCodeTemporary is a temporary technical error: send again later.
	ErrorCodeTemporary ErrorCode = -1
	// ErrorCodeVerified says, in verification mode, that the message passed
	// every check.
	ErrorCodeVerified ErrorCode = 0
	// ErrorCodeEncoding says the XML encoding is not valid.
	ErrorCodeEncoding ErrorCode = 2
	// ErrorCodeSchema says the message fails the XML schema.
	ErrorCodeSchema ErrorCode = 3
	// ErrorCodeSignature says the signature is invalid, or the certificate is
	// not trusted, not valid or revoked.
	ErrorCodeSignature ErrorCode = 4
	// ErrorCodeTaxID says the merchant's tax ID (eic_popl) has a wrong
	// structure.
	ErrorCodeTaxID ErrorCode = 6
	// ErrorCodeTooLarge says the message is over 12 kB.
	ErrorCodeTooLarge ErrorCode = 7
	// ErrorCodeProcessing is a technical or data error in processing: send
	// again later.
	ErrorCodeProcessing ErrorCode = 8
)

Error codes of the interface description, chapter 3.5. Code 1 does not exist and 5 was used before version 4 only.

func (ErrorCode) Retryable

func (c ErrorCode) Retryable() bool

Retryable reports whether the sale can be sent again later as it is: code 8, and every negative code, as -1 is a temporary error and -999 to -2 are reserved next to it (interface description, 3.5.4).

type GenerateOption

type GenerateOption func(*generateOptions)

GenerateOption adjusts the message built for a sale.

func WithResend

func WithResend() GenerateOption

WithResend marks the message as a resend (prvni_zaslani false), for every attempt after the first.

func WithVerification

func WithVerification() GenerateOption

WithVerification asks the service to check the message without recording the sale (overeni): the response carries error code 0 and no POK.

type Header struct {
	// UUID (uuid_zpravy) of the message, new for every attempt, resends
	// included.
	UUID string `xml:"uuid_zpravy,attr"`
	// SentAt (dat_odesl) is when the message was sent.
	SentAt string `xml:"dat_odesl,attr"`
	// FirstAttempt (prvni_zaslani) is false on a resend.
	FirstAttempt bool `xml:"prvni_zaslani,attr"`
	// Verification (overeni) asks the service to check the message without
	// recording it.
	Verification *bool `xml:"overeni,attr,omitempty"`
}

Header (Hlavicka) identifies one attempt to send a sale.

type Option

type Option func(*Client)

Option is used to configure the client.

func InPlayground

func InPlayground() Option

InPlayground sends to the Playground, the EET service's public test environment.

func InProduction

func InProduction() Option

InProduction sends to the production environment, where sales are recorded.

func WithCertificate

func WithCertificate(cert *xmldsig.Certificate) Option

WithCertificate sets the merchant's CA EET certificate, whose tax ID is its CN, to sign the sales with.

func WithCurrentTime

func WithCurrentTime(curTime time.Time) Option

WithCurrentTime fixes the send time of the sale messages.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets how long to wait for a reply, at least MinTimeout.

type Response

type Response struct {
	Header       *ResponseHeader `xml:"http://fs.gov.cz/eet/schema/v4 Hlavicka"`
	Confirmation *Confirmation   `xml:"http://fs.gov.cz/eet/schema/v4 Potvrzeni"`
	Error        *ResponseError  `xml:"http://fs.gov.cz/eet/schema/v4 Chyba"`
	Warnings     []*Warning      `xml:"http://fs.gov.cz/eet/schema/v4 Varovani"`

	// TransactionID is the X-Global-Transaction-Id the service tagged the
	// exchange with (interface description, 5.4), which only Send sees.
	TransactionID string `xml:"-"`
}

Response (Odpoved) is the service's answer to a sale message: a confirmation with the POK when the sale is recorded, or an error, and up to ten warnings either way.

func ParseResponse

func ParseResponse(data []byte, sale *Sale, env Environment) (*Response, error)

ParseResponse reads the service's reply to the sale, accepting a confirmation only when the environment's certificate signs it for that very message, and returns an error code other than 0 as an error alongside the reply.

type ResponseError

type ResponseError struct {
	Code    ErrorCode `xml:"kod,attr"`
	Test    bool      `xml:"test,attr"`
	Message string    `xml:",chardata"`
}

ResponseError (Chyba) explains why a sale was not recorded. In verification mode, code 0 says the message passed every check.

func (*ResponseError) Err

func (e *ResponseError) Err() error

Err maps the error by its code: nil for code 0, a verification that passed, ErrServer when the code says to send again later, ErrValidation otherwise.

func (*ResponseError) UnmarshalXML

func (e *ResponseError) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML reads a Chyba element, refusing one without a numeric code: a missing code would otherwise read as 0, the verification success.

type ResponseHeader

type ResponseHeader struct {
	// UUID (uuid_zpravy) of the message answered.
	UUID string `xml:"uuid_zpravy,attr"`
	// ReceivedAt (dat_prij) is when the sale was recorded.
	ReceivedAt string `xml:"dat_prij,attr"`
	// RejectedAt (dat_odmit) is when the message was rejected.
	RejectedAt string `xml:"dat_odmit,attr"`
}

ResponseHeader (Hlavicka) of a response.

func (*ResponseHeader) UnmarshalXML

func (h *ResponseHeader) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML reads a Hlavicka element, refusing attributes in another namespace.

type Sale

type Sale struct {
	XMLName xml.Name `xml:"v4:Trzba"`
	Header  *Header  `xml:"v4:Hlavicka"`
	Data    *Data    `xml:"v4:Data"`
	// contains filtered or unexported fields
}

Sale is the data message of a sale (Trzba), with its values in the text form the schema takes and optional attributes left empty when they don't apply, as the service refuses empty ones.

type Warning

type Warning struct {
	Code    WarningCode `xml:"kod_varov,attr"`
	Message string      `xml:",chardata"`
}

Warning (Varovani) about a sale that was recorded all the same.

func (*Warning) UnmarshalXML

func (w *Warning) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML reads a Varovani element, refusing attributes in another namespace.

type WarningCode

type WarningCode int

WarningCode (kod_varov) of a response.

const (
	// WarningCodeTaxIDMismatch says the merchant's tax ID differs from the
	// CN of the signing certificate.
	WarningCodeTaxIDMismatch WarningCode = 1
	// WarningCodeDelegatingTaxID says the delegating merchant's tax ID has a
	// wrong structure.
	WarningCodeDelegatingTaxID WarningCode = 2
	// WarningCodeSaleTimeAhead says the sale time is more than 2 hours after
	// the message was received.
	WarningCodeSaleTimeAhead WarningCode = 4
	// WarningCodeSaleTimeOld says the sale time is more than 2 years before
	// the message was received, or before the environment's first day.
	WarningCodeSaleTimeOld WarningCode = 5
	// WarningCodeUnitID says the unit ID doesn't have the form DIS+ gives
	// units.
	WarningCodeUnitID WarningCode = 6
	// WarningCodeSelfDelegation says the delegating merchant is the merchant
	// itself.
	WarningCodeSelfDelegation WarningCode = 7
)

Warning codes of the interface description, chapter 3.4.

Directories

Path Synopsis
Package addon provides the cz-eet-v1 GOBL addon for Czech EET 2.0 sales recording: the extensions that say where a sale happened, whether it is income of several taxpayers and which lines load prepaid credit, the payment means key for credit drawn, the stamp for the confirmation code, and the rules a payment must meet before it can be sent.
Package addon provides the cz-eet-v1 GOBL addon for Czech EET 2.0 sales recording: the extensions that say where a sale happened, whether it is income of several taxpayers and which lines load prepaid credit, the payment means key for credit drawn, the stamp for the confirmation code, and the rules a payment must meet before it can be sent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址