Documentation ¶
Overview ¶
Package ticketbai provides a client for generating and sending TicketBAI documents to the different regional services in the Basque Country.
Index ¶
- Constants
- Variables
- type CancelDocument
- type Client
- func (c *Client) Cancel(ctx context.Context, d *CancelDocument) error
- func (c *Client) CurrentTime() time.Time
- func (c *Client) Fetch(ctx context.Context, zone l10n.Code, nif string, name string, year int, ...) ([]*doc.TicketBAI, error)
- func (c *Client) NewCancelDocument(env *gobl.Envelope) (*CancelDocument, error)
- func (c *Client) NewDocument(env *gobl.Envelope) (*Document, error)
- func (c *Client) Post(ctx context.Context, d *Document) error
- type ClientError
- type Document
- func (d *Document) Bytes() ([]byte, error)
- func (d *Document) BytesIndent() ([]byte, error)
- func (d *Document) Fingerprint(prev *PreviousInvoice) error
- func (d *Document) Head() *doc.CabeceraFactura
- func (d *Document) SetIssueTimestamp(ts time.Time)
- func (d *Document) Sign() error
- func (d *Document) SignatureValue() string
- type Option
- func InProduction() Option
- func InTesting() Option
- func WithCertificate(cert *xmldsig.Certificate) Option
- func WithCurrentTime(curTime time.Time) Option
- func WithCustomerIssuer() Option
- func WithGateway(code l10n.Code, conn gateways.Connection) Option
- func WithSupplierIssuer() Option
- func WithThirdPartyIssuer() Option
- func WithZone(zone l10n.Code) Option
- type PreviousInvoice
- type Software
- type TestConnection
- func (tc *TestConnection) Cancel(_ context.Context, _ *bill.Invoice, _ *doc.AnulaTicketBAI) error
- func (tc *TestConnection) Fetch(_ context.Context, _ string, _ string, _ int, _ int, _ *doc.CabeceraFactura) ([]*doc.TicketBAI, error)
- func (tc *TestConnection) Post(_ context.Context, _ *bill.Invoice, _ *doc.TicketBAI) error
Constants ¶
const ( ZoneBI l10n.Code = doc.ZoneBI ZoneSS l10n.Code = doc.ZoneSS ZoneVI l10n.Code = doc.ZoneVI )
Expose zone codes for external use.
Variables ¶
var ( ErrNotSpanish = newClientError("only spanish invoices are supported") ErrAlreadyProcessed = newClientError("already processed") ErrOnlyInvoices = newClientError("only invoices are supported") ErrInvalidZone = newClientError("invalid zone") )
Standard error responses.
Functions ¶
This section is empty.
Types ¶
type CancelDocument ¶ added in v0.15.0
type CancelDocument struct {
// contains filtered or unexported fields
}
CancelDocument is a wrapper around the internal AnulaTicketBAI document.
func (*CancelDocument) Fingerprint ¶ added in v0.15.0
func (d *CancelDocument) Fingerprint() error
Fingerprint generates a finger print for the TicketBAI document using the data provided from the previous invoice data.
func (*CancelDocument) Sign ¶ added in v0.15.0
func (d *CancelDocument) Sign() error
Sign is used to generate the XML DSig components of the final XML document.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the main interface to the TicketBAI package.
func New ¶
New creates a new TicketBAI client with shared software and configuration options for creating and sending new documents.
func (*Client) Cancel ¶ added in v0.15.0
func (c *Client) Cancel(ctx context.Context, d *CancelDocument) error
Cancel will send the cancel document in the TicketBAI gateway.
func (*Client) CurrentTime ¶
CurrentTime returns the current time to use when generating the TicketBAI document.
func (*Client) Fetch ¶ added in v0.15.0
func (c *Client) Fetch(ctx context.Context, zone l10n.Code, nif string, name string, year int, page int) ([]*doc.TicketBAI, error)
Fetch will retrieve the issued documents from the TicketBAI gateway.
func (*Client) NewCancelDocument ¶ added in v0.15.0
func (c *Client) NewCancelDocument(env *gobl.Envelope) (*CancelDocument, error)
NewCancelDocument creates a new AnulaTicketBAI document from the provided GOBL Envelope.
func (*Client) NewDocument ¶
NewDocument creates a new TicketBAI document from the provided GOBL Envelope. The envelope must contain a valid Invoice.
type ClientError ¶ added in v0.16.0
type ClientError struct {
// contains filtered or unexported fields
}
ClientError is a simple wrapper around client-side errors (that should not be retried) as opposed to server-side errors (that should be retried).
func (*ClientError) Error ¶ added in v0.16.0
func (e *ClientError) Error() string
Error implements the error interface for ClientError.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is a wrapper around the internal TicketBAI document.
func (*Document) BytesIndent ¶
BytesIndent generates the indented byte output of the TicketBAI Document.
func (*Document) Fingerprint ¶ added in v0.15.0
func (d *Document) Fingerprint(prev *PreviousInvoice) error
Fingerprint generates a finger print for the TicketBAI document using the data provided from the previous invoice data. If there was no previous invoice, the parameter should be nil.
func (*Document) Head ¶
func (d *Document) Head() *doc.CabeceraFactura
Head returns the CabeceraFactura from the TicketBAI document.
func (*Document) SetIssueTimestamp ¶ added in v0.16.0
SetIssueTimestamp updates the issue date and time of the TicketBAI document.
func (*Document) Sign ¶ added in v0.15.0
Sign is used to generate the XML DSig components of the final XML document. This method will also update the GOBL Envelope with the QR codes that are generated.
func (*Document) SignatureValue ¶
SignatureValue provides quick access to the XML signatures final value.
type Option ¶
type Option func(*Client)
Option is used to configure the client.
func InProduction ¶
func InProduction() Option
InProduction defines the connection to use the production environment.
func InTesting ¶
func InTesting() Option
InTesting defines the connection to use the testing environment.
func WithCertificate ¶
func WithCertificate(cert *xmldsig.Certificate) Option
WithCertificate defines the signing certificate to use when producing the TicketBAI document.
func WithCurrentTime ¶
WithCurrentTime defines the current time to use when generating the TicketBAI document. Useful for testing.
func WithCustomerIssuer ¶ added in v0.9.0
func WithCustomerIssuer() Option
WithCustomerIssuer set the issuer type to customer. To be used when the invoice's supplier, using their own certificate, is issuing the document.
func WithGateway ¶
func WithGateway(code l10n.Code, conn gateways.Connection) Option
WithGateway defines a new gateway connection to use for a specific zone. This option can be used multiple times to define multiple gateways. Useful for testing.
func WithSupplierIssuer ¶ added in v0.9.0
func WithSupplierIssuer() Option
WithSupplierIssuer set the issuer type to supplier. To be used when the invoice's supplier, using their own certificate, is issuing the document.
func WithThirdPartyIssuer ¶ added in v0.9.0
func WithThirdPartyIssuer() Option
WithThirdPartyIssuer set the issuer type to third party. To be used when the an authorised third party, using their own certificate, is issuing the document on behalf of the invoice's supplier.
type PreviousInvoice ¶
PreviousInvoice stores the fields from the previously generated invoice document that are linked to in the new document.
type Software ¶
Software defines the details about the software that is using this library to generate TicketBAI documents. These details are included in the final document.
type TestConnection ¶ added in v0.16.0
type TestConnection struct {
// contains filtered or unexported fields
}
TestConnection is a mock gateway connection for testing purposes
func (*TestConnection) Cancel ¶ added in v0.16.0
func (tc *TestConnection) Cancel(_ context.Context, _ *bill.Invoice, _ *doc.AnulaTicketBAI) error
Cancel mocks the Cancel method of the Connection interface
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gobl.ticketbai
Package main provides the command line interface to the TicketBAI package.
|
Package main provides the command line interface to the TicketBAI package. |
internal
|
|
doc
Package doc contains the TicketBAI document structures and methods to generate it.
|
Package doc contains the TicketBAI document structures and methods to generate it. |
gateways
Package gateways contains the different interfaces to send the TicketBAI documents to.
|
Package gateways contains the different interfaces to send the TicketBAI documents to. |
gateways/ebizkaia
Package ebizkaia provides a gatewy for generating and sending documents to the Bizkaia region.
|
Package ebizkaia provides a gatewy for generating and sending documents to the Bizkaia region. |
Package test provides common functions for testing.
|
Package test provides common functions for testing. |