fakturaxl

package module
v0.0.0-...-55ee874 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package fakturaxl provides a Go client for the Faktura XL Polish accounting software API.

Index

Constants

View Source
const (
	// DefaultBaseURL is the default API base URL.
	DefaultBaseURL = "https://program.fakturaxl.pl/api"
	// DefaultTimeout is the default HTTP client timeout.
	DefaultTimeout = 30 * time.Second
	// Version is the client library version.
	Version = "devel"
)
View Source
const (
	// Success codes for different operations.
	ResponseCodeDocumentCreated = 1  // Document successfully created
	ResponseCodeDocumentRead    = 5  // Document successfully read
	ResponseCodeDocumentDeleted = 20 // Document successfully deleted
	ResponseCodeDocumentSaved   = 33 // Document successfully saved
	ResponseCodeEmailSent       = 23 // Document sent via email
	ResponseCodeTagsAdded       = 61 // Tags successfully added
	ResponseCodeTagsDeleted     = 62 // Tags successfully deleted
	ResponseCodeKSeFSent        = 49 // Document sent to KSeF

	// Error codes.
	ResponseCodeInvalidRequest = 2
	ResponseCodeInvalidToken   = 3
	ResponseCodeNotFound       = 4
	// Note: Code 5 is used as success code for document read (ResponseCodeDocumentRead)
	ResponseCodeLimitExceeded    = 6
	ResponseCodeDuplicateNumber  = 7
	ResponseCodeBuyerNameEmpty   = 9
	ResponseCodeInvalidNIP       = 10
	ResponseCodeInvalidCountry   = 11
	ResponseCodeProductNameEmpty = 12
	ResponseCodeInvalidDate      = 13
	ResponseCodeInvalidStatus    = 14
	ResponseCodeInvalidCurrency  = 15
	ResponseCodeInvalidLanguage  = 17
	ResponseCodeInvalidPayment   = 18
	ResponseCodeLimitReached     = 19
	ResponseCodePeriodClosed     = 21
	ResponseCodeNoEmail          = 22
	ResponseCodeDateRangeExceeds = 28
	ResponseCodeFirstNameEmpty   = 38
	ResponseCodeLastNameEmpty    = 39
	ResponseCodeKSeFError        = 50
	ResponseCodeAPIBlocked       = 70
)

API response codes as defined by Faktura XL. Different operations have different success codes.

Variables

View Source
var (
	ErrInvalidToken  = &APIError{Code: ResponseCodeInvalidToken, Message: "invalid API token"}
	ErrNotFound      = &APIError{Code: ResponseCodeNotFound, Message: "document not found"}
	ErrLimitExceeded = &APIError{Code: ResponseCodeLimitExceeded, Message: "rate limit exceeded"}
	ErrAPIBlocked    = &APIError{Code: ResponseCodeAPIBlocked, Message: "API key blocked"}
)

Common API errors.

Functions

func IsInvalidToken

func IsInvalidToken(err error) bool

IsInvalidToken checks if an error is an "invalid token" error.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a "not found" error.

func IsPackageLimitReached

func IsPackageLimitReached(err error) bool

IsPackageLimitReached checks if an error is a "package limit reached" error. This occurs when the account's subscription plan limit has been exceeded.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited checks if an error is a "rate limit exceeded" error.

Types

type APIError

type APIError struct {
	Code    int
	Message string
}

APIError represents an error returned by the Faktura XL API.

func IsAPIError

func IsAPIError(err error) (*APIError, bool)

IsAPIError checks if an error is an APIError and returns it.

func NewAPIError

func NewAPIError(code int, message string) *APIError

NewAPIError creates a new APIError from a response code and message.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

type Amount

type Amount int64

Amount represents a monetary amount in the smallest currency unit (grosze/cents). For example, 9990 represents 99.90 PLN. This avoids floating-point precision issues common in financial calculations.

func AmountFromFloat

func AmountFromFloat(f float64) Amount

AmountFromFloat creates an Amount from a float64, rounding to 2 decimal places. Use with caution due to floating-point representation issues. Prefer Grosze for precise values.

func Cents

func Cents(c int64) Amount

Cents is an alias for Grosze for familiarity with other currencies.

func Grosze

func Grosze(g int64) Amount

Grosze creates an Amount from grosze (1/100 of PLN). For example, Grosze(9990) represents 99.90 PLN.

func ParseAmount

func ParseAmount(s string) (Amount, error)

ParseAmount parses a string in "X.XX" format into an Amount. Returns an error if the format is invalid.

func (Amount) Int64

func (a Amount) Int64() int64

Int64 returns the amount as an int64 in the smallest currency unit.

func (Amount) IsZero

func (a Amount) IsZero() bool

IsZero returns true if the amount is zero.

func (Amount) MarshalXML

func (a Amount) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (Amount) String

func (a Amount) String() string

String returns the string representation in "X.XX" format.

func (*Amount) UnmarshalXML

func (a *Amount) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

type Buyer

type Buyer struct {
	Type        ClientType `xml:"firma_lub_osoba_prywatna,omitempty"`
	Name        string     `xml:"nazwa,omitempty"`
	FirstName   string     `xml:"imie,omitempty"`
	LastName    string     `xml:"nazwisko,omitempty"`
	NIP         string     `xml:"nip,omitempty"`
	Street      string     `xml:"ulica_i_numer,omitempty"`
	PostalCode  string     `xml:"kod_pocztowy,omitempty"`
	City        string     `xml:"miejscowosc,omitempty"`
	Country     string     `xml:"kraj,omitempty"`
	Email       string     `xml:"email,omitempty"`
	Phone       string     `xml:"telefon,omitempty"`
	BankAccount string     `xml:"nr_konta_bankowego,omitempty"`
}

Buyer represents buyer/client information in a document.

type Client

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

Client is a Faktura XL API client.

func New

func New(apiToken string, opts ...Option) *Client

New creates a new Faktura XL API client.

func (*Client) AddTags

func (c *Client) AddTags(ctx context.Context, documentID DocumentID, tags []string) error

AddTags adds tags to a document.

func (*Client) CreateDocument

func (c *Client) CreateDocument(ctx context.Context, doc Document) (*DocumentResponse, error)

CreateDocument creates a new document (invoice, proforma, etc.).

func (*Client) DeleteDocument

func (c *Client) DeleteDocument(ctx context.Context, documentID DocumentID) error

DeleteDocument deletes a document by its ID.

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, documentID DocumentID) (*DocumentResponse, error)

GetDocument retrieves a document by its ID.

func (*Client) GetInventory

func (c *Client) GetInventory(ctx context.Context, filter InventoryRequest) (*InventoryResponse, error)

GetInventory retrieves inventory quantities for products.

func (*Client) GetKSeFNumber

func (c *Client) GetKSeFNumber(ctx context.Context, documentID DocumentID) (*KSeFResponse, error)

GetKSeFNumber retrieves the KSeF number for a submitted document.

func (*Client) GetPDF

func (c *Client) GetPDF(ctx context.Context, documentID DocumentID) ([]byte, error)

GetPDF retrieves a document as a PDF (base64 encoded).

func (*Client) GetPDFURL

func (c *Client) GetPDFURL(documentCode DocumentCode, mode PDFMode) string

GetPDFURL returns a URL for viewing/downloading a PDF directly. The documentCode is the kod_dokumentu from the document response. Mode can be PDFModeView (view in browser) or PDFModeDownload (download as attachment).

func (*Client) GetProductInventory

func (c *Client) GetProductInventory(ctx context.Context, productID string) (*InventoryResponse, error)

GetProductInventory retrieves inventory for a specific product.

func (*Client) GetWarehouseInventory

func (c *Client) GetWarehouseInventory(ctx context.Context, warehouseID string) (*InventoryResponse, error)

GetWarehouseInventory retrieves inventory for a specific warehouse.

func (*Client) ListClients

func (c *Client) ListClients(ctx context.Context, filter ListClientsRequest) (*ListClientsResponse, error)

ListClients retrieves a list of clients with optional filtering.

func (*Client) ListDepartments

func (c *Client) ListDepartments(ctx context.Context) (*ListDepartmentsResponse, error)

ListDepartments retrieves a list of company departments.

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context, filter ListDocumentsRequest) (*ListDocumentsResponse, error)

ListDocuments retrieves a list of documents with optional filtering.

func (*Client) ListProducts

func (c *Client) ListProducts(ctx context.Context, filter ListProductsRequest) (*ListProductsResponse, error)

ListProducts retrieves a list of products with optional filtering.

func (*Client) ListWarehouses

func (c *Client) ListWarehouses(ctx context.Context) (*ListWarehousesResponse, error)

ListWarehouses retrieves a list of warehouses.

func (*Client) RemoveTags

func (c *Client) RemoveTags(ctx context.Context, documentID DocumentID, tags []string) error

RemoveTags removes tags from a document.

func (*Client) SendInvoiceByEmail

func (c *Client) SendInvoiceByEmail(ctx context.Context, req SendEmailRequest) error

SendInvoiceByEmail sends an invoice to the specified email address.

func (*Client) SubmitToKSeF

func (c *Client) SubmitToKSeF(ctx context.Context, documentID DocumentID) error

SubmitToKSeF submits a document to the Polish e-invoice system (KSeF).

func (*Client) UpdateDocument

func (c *Client) UpdateDocument(ctx context.Context, req UpdateDocumentRequest) error

UpdateDocument updates an existing document (e.g., payment status).

type ClientSummary

type ClientSummary struct {
	ID         string `xml:"id"`
	Name       string `xml:"nazwa"`
	NIP        string `xml:"nip"`
	Street     string `xml:"ulica"`
	PostalCode string `xml:"kod_pocztowy"`
	City       string `xml:"miejscowosc"`
	Country    string `xml:"kraj"`
	Email      string `xml:"email"`
	Phone      string `xml:"telefon"`
}

ClientSummary represents a client in a list response.

type ClientType

type ClientType int

ClientType represents whether the client is a company or individual.

const (
	ClientTypeCompany    ClientType = 0
	ClientTypeIndividual ClientType = 1
)

Client type constants.

type Department

type Department struct {
	ID   string `xml:"id"`
	Name string `xml:"nazwa"`
}

Department represents a department/division.

type Document

type Document struct {
	DocumentType     DocumentType  `xml:"typ_faktury"`
	InvoiceNumber    string        `xml:"numer_faktury,omitempty"`
	IssueDate        string        `xml:"data_wystawienia"`
	SaleDate         string        `xml:"data_sprzedazy,omitempty"`
	PaymentDeadline  string        `xml:"termin_platnosci_data,omitempty"`
	Currency         string        `xml:"waluta,omitempty"`
	PaymentMethod    PaymentMethod `xml:"rodzaj_platnosci,omitempty"`
	Language         Language      `xml:"jezyk,omitempty"`
	Seller           *Seller       `xml:"sprzedawca,omitempty"`
	Buyer            *Buyer        `xml:"nabywca,omitempty"`
	LineItems        []LineItem    `xml:"faktura_pozycje,omitempty"`
	Notes            string        `xml:"uwagi,omitempty"`
	InternalNotes    string        `xml:"notatki,omitempty"`
	PaidAmount       Amount        `xml:"zaplacono,omitempty"`
	PaymentStatus    PaymentStatus `xml:"status_platnosci,omitempty"`
	DepartmentID     string        `xml:"dzial_id,omitempty"`
	WarehouseID      string        `xml:"magazyn_id,omitempty"`
	ExchangeRate     Amount        `xml:"kurs_waluty,omitempty"`
	ExchangeRateDate string        `xml:"data_kursu,omitempty"`
	SplitPayment     string        `xml:"split_payment,omitempty"`
	ReverseCharge    string        `xml:"odwrotne_obciazenie,omitempty"`
	CorrectedInvoice string        `xml:"korygowana_faktura,omitempty"`
	CorrectionReason string        `xml:"powod_korekty,omitempty"`
}

Document represents a full document structure for creation.

type DocumentCode

type DocumentCode string

DocumentCode is a unique code for a document, used primarily for PDF URLs. This is different from DocumentID and should not be confused with it.

type DocumentID

type DocumentID string

DocumentID is a unique identifier for a document in the Faktura XL system. Use this for most API operations (get, update, delete, etc.).

type DocumentResponse

type DocumentResponse struct {
	XMLName         xml.Name     `xml:"dokument"`
	Code            int          `xml:"kod"`
	Message         string       `xml:"komunikat,omitempty"`
	DocumentID      DocumentID   `xml:"dokument_id,omitempty"`
	DocumentNumber  string       `xml:"dokument_nr,omitempty"`
	DocumentCode    DocumentCode `xml:"unikatowy_kod,omitempty"`
	GrossTotal      Amount       `xml:"brutto,omitempty"`
	NetTotal        Amount       `xml:"netto,omitempty"`
	VATTotal        Amount       `xml:"vat,omitempty"`
	Currency        string       `xml:"waluta,omitempty"`
	IssueDate       string       `xml:"data_wystawienia,omitempty"`
	SaleDate        string       `xml:"data_sprzedazy,omitempty"`
	PaymentDeadline string       `xml:"termin_platnosci,omitempty"`
	PaymentMethod   string       `xml:"forma_platnosci,omitempty"`
	PaymentStatus   string       `xml:"status_platnosci,omitempty"`
	Seller          *Seller      `xml:"sprzedawca,omitempty"`
	Buyer           *Buyer       `xml:"nabywca,omitempty"`
}

DocumentResponse represents the API response after creating/reading a document.

type DocumentSummary

type DocumentSummary struct {
	ID            string `xml:"id"`
	Number        string `xml:"numer"`
	DocumentCode  string `xml:"kod_dokumentu"`
	Type          string `xml:"typ"`
	IssueDate     string `xml:"data_wystawienia"`
	SaleDate      string `xml:"data_sprzedazy"`
	GrossTotal    Amount `xml:"brutto"`
	NetTotal      Amount `xml:"netto"`
	Currency      string `xml:"waluta"`
	PaymentStatus string `xml:"status_platnosci"`
	BuyerName     string `xml:"nabywca_nazwa"`
	BuyerNIP      string `xml:"nabywca_nip"`
}

DocumentSummary represents a document in a list response.

type DocumentType

type DocumentType int

DocumentType represents the type of document (typ_faktury).

const (
	DocumentTypeVATInvoice        DocumentType = 0  // Faktura VAT
	DocumentTypeProforma          DocumentType = 1  // Faktura Proforma
	DocumentTypeCorrectionInvoice DocumentType = 4  // Faktura Korygująca
	DocumentTypeReceipt           DocumentType = 6  // Paragon
	DocumentTypeFinalInvoice      DocumentType = 3  // Faktura Końcowa
	DocumentTypeAdvanceInvoice    DocumentType = 11 // Faktura Zaliczkowa
	DocumentTypeMarginInvoice     DocumentType = 7  // Faktura Marża
	DocumentTypeExportInvoice     DocumentType = 12 // Faktura Eksportowa
	DocumentTypeInternalInvoice   DocumentType = 16 // Faktura Wewnętrzna
	DocumentTypeReceiptInvoice    DocumentType = 14 // Faktura do paragonu
)

Document type constants.

type GTUSymbol

type GTUSymbol string

GTUSymbol represents GTU (tax group) symbols for items.

const (
	GTUNone GTUSymbol = ""
	GTU01   GTUSymbol = "GTU_01" // Alcoholic beverages
	GTU02   GTUSymbol = "GTU_02" // Fuels
	GTU03   GTUSymbol = "GTU_03" // Heating oils
	GTU04   GTUSymbol = "GTU_04" // Tobacco products
	GTU05   GTUSymbol = "GTU_05" // Waste
	GTU06   GTUSymbol = "GTU_06" // Electronic devices
	GTU07   GTUSymbol = "GTU_07" // Vehicles and parts
	GTU08   GTUSymbol = "GTU_08" // Precious metals
	GTU09   GTUSymbol = "GTU_09" // Medicines
	GTU10   GTUSymbol = "GTU_10" // Buildings
	GTU11   GTUSymbol = "GTU_11" // Greenhouse gas emissions
	GTU12   GTUSymbol = "GTU_12" // Intangible services
	GTU13   GTUSymbol = "GTU_13" // Transport services
)

GTU symbol constants.

type GenericResponse

type GenericResponse struct {
	XMLName xml.Name `xml:"dokument"`
	Code    int      `xml:"kod"`
	Message string   `xml:"komunikat,omitempty"`
}

GenericResponse represents a generic API response.

type InventoryItem

type InventoryItem struct {
	ProductID   string   `xml:"produkt_id"`
	ProductName string   `xml:"nazwa"`
	ProductCode string   `xml:"kod"`
	Quantity    Quantity `xml:"ilosc"`
	Unit        string   `xml:"jm"`
	WarehouseID string   `xml:"magazyn_id"`
}

InventoryItem represents an item in inventory.

type InventoryRequest

type InventoryRequest struct {
	WarehouseID string `xml:"magazyn_id,omitempty"`
	ProductID   string `xml:"produkt_id,omitempty"`
}

InventoryRequest represents a request to get inventory quantities.

type InventoryResponse

type InventoryResponse struct {
	XMLName xml.Name        `xml:"dokumenty"`
	Code    int             `xml:"kod"`
	Message string          `xml:"komunikat,omitempty"`
	Items   []InventoryItem `xml:"produkt"`
}

InventoryResponse represents the API response for inventory queries.

type KSeFResponse

type KSeFResponse struct {
	XMLName    xml.Name `xml:"dokument"`
	Code       int      `xml:"kod"`
	Message    string   `xml:"komunikat,omitempty"`
	KSeFNumber string   `xml:"numer_ksef,omitempty"`
	KSeFStatus string   `xml:"status_ksef,omitempty"`
}

KSeFResponse represents the API response for KSeF operations.

type Language

type Language int

Language represents the document language.

const (
	LanguagePolish  Language = 0
	LanguageEnglish Language = 1
	LanguageGerman  Language = 2
	LanguageFrench  Language = 3
)

Language constants.

type LineItem

type LineItem struct {
	Name        string    `xml:"nazwa"`
	Quantity    Quantity  `xml:"ilosc"`
	Unit        string    `xml:"jm,omitempty"`
	VAT         VATRate   `xml:"vat"`
	GrossValue  Amount    `xml:"wartosc_brutto,omitempty"`
	NetValue    Amount    `xml:"wartosc_netto,omitempty"`
	ProductCode string    `xml:"kod_produktu,omitempty"`
	ProductID   string    `xml:"produkt_id,omitempty"`
	GTUSymbol   GTUSymbol `xml:"symbol_gtu,omitempty"`
	PKWiU       string    `xml:"pkwiu,omitempty"`
	Description string    `xml:"opis,omitempty"`
	Discount    Amount    `xml:"rabat,omitempty"`
}

LineItem represents a single item/line in a document.

type ListClientsRequest

type ListClientsRequest struct {
	Page   int    `xml:"strona,omitempty"`
	Limit  int    `xml:"limit,omitempty"`
	Search string `xml:"szukaj,omitempty"`
}

ListClientsRequest represents a request to list clients.

type ListClientsResponse

type ListClientsResponse struct {
	XMLName xml.Name        `xml:"dokumenty"`
	Code    int             `xml:"kod"`
	Message string          `xml:"komunikat,omitempty"`
	Clients []ClientSummary `xml:"klient"`
	Total   int             `xml:"razem,omitempty"`
	Page    int             `xml:"strona,omitempty"`
	Pages   int             `xml:"stron,omitempty"`
}

ListClientsResponse represents the API response for client listing.

type ListDepartmentsResponse

type ListDepartmentsResponse struct {
	XMLName     xml.Name     `xml:"dokument"`
	Code        int          `xml:"kod"`
	Message     string       `xml:"komunikat,omitempty"`
	Departments []Department `xml:"dzialy>dzial"`
}

ListDepartmentsResponse represents the API response for department listing.

type ListDocumentsRequest

type ListDocumentsRequest struct {
	DateFrom     string `xml:"data_od,omitempty"`
	DateTo       string `xml:"data_do,omitempty"`
	UpdatedFrom  string `xml:"aktualizacja_od,omitempty"`
	UpdatedTo    string `xml:"aktualizacja_do,omitempty"`
	Page         int    `xml:"strona,omitempty"`
	Limit        int    `xml:"limit,omitempty"`
	DocumentType string `xml:"typ,omitempty"`
}

ListDocumentsRequest represents a request to list documents.

type ListDocumentsResponse

type ListDocumentsResponse struct {
	XMLName   xml.Name          `xml:"dokumenty"`
	Code      int               `xml:"kod"`
	Message   string            `xml:"komunikat,omitempty"`
	Documents []DocumentSummary `xml:"dokument"`
	Total     int               `xml:"razem,omitempty"`
	Page      int               `xml:"strona,omitempty"`
	Pages     int               `xml:"stron,omitempty"`
}

ListDocumentsResponse represents the API response for document listing.

type ListProductsRequest

type ListProductsRequest struct {
	Page   int    `xml:"strona,omitempty"`
	Limit  int    `xml:"limit,omitempty"`
	Search string `xml:"szukaj,omitempty"`
}

ListProductsRequest represents a request to list products.

type ListProductsResponse

type ListProductsResponse struct {
	XMLName  xml.Name  `xml:"dokumenty"`
	Code     int       `xml:"kod"`
	Message  string    `xml:"komunikat,omitempty"`
	Products []Product `xml:"produkt"`
	Total    int       `xml:"razem,omitempty"`
	Page     int       `xml:"strona,omitempty"`
	Pages    int       `xml:"stron,omitempty"`
}

ListProductsResponse represents the API response for product listing.

type ListWarehousesResponse

type ListWarehousesResponse struct {
	XMLName    xml.Name    `xml:"dokumenty"`
	Code       int         `xml:"kod"`
	Message    string      `xml:"komunikat,omitempty"`
	Warehouses []Warehouse `xml:"magazyn"`
}

ListWarehousesResponse represents the API response for warehouse listing.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets a custom base URL for the API.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom HTTP client.

type PDFMode

type PDFMode string

PDFMode represents the PDF download mode.

const (
	PDFModeView     PDFMode = "1" // View in browser
	PDFModeDownload PDFMode = "2" // Download attachment
)

PDF mode constants.

type PDFResponse

type PDFResponse struct {
	XMLName xml.Name `xml:"dokument"`
	Code    int      `xml:"kod"`
	Message string   `xml:"komunikat,omitempty"`
	PDF     string   `xml:"pdf,omitempty"` // Base64 encoded PDF
}

PDFResponse represents the API response for PDF download.

type PaymentMethod

type PaymentMethod string

PaymentMethod represents the payment method (rodzaj_platnosci).

const (
	PaymentMethodTransfer     PaymentMethod = "Przelew"
	PaymentMethodCash         PaymentMethod = "Gotówka"
	PaymentMethodCard         PaymentMethod = "Karta płatnicza"
	PaymentMethodBLIK         PaymentMethod = "BLIK"
	PaymentMethodPrzelewy24   PaymentMethod = "Przelewy24"
	PaymentMethodPayU         PaymentMethod = "PayU"
	PaymentMethodPayPal       PaymentMethod = "PayPal"
	PaymentMethodCompensation PaymentMethod = "Kompensata"
)

Payment method constants.

type PaymentStatus

type PaymentStatus int

PaymentStatus represents the payment status of a document.

const (
	PaymentStatusUnpaid  PaymentStatus = 0
	PaymentStatusPartial PaymentStatus = 1
	PaymentStatusPaid    PaymentStatus = 2
)

Payment status constants.

type Product

type Product struct {
	ID          string  `xml:"id"`
	Name        string  `xml:"nazwa"`
	Code        string  `xml:"kod"`
	Unit        string  `xml:"jm"`
	VAT         VATRate `xml:"vat"`
	NetPrice    Amount  `xml:"cena_netto"`
	GrossPrice  Amount  `xml:"cena_brutto"`
	Description string  `xml:"opis"`
	PKWiU       string  `xml:"pkwiu"`
}

Product represents a product in a list response.

type Quantity

type Quantity int64

Quantity represents a quantity value in thousandths (millis). For example, 1500 represents 1.500 units. The API uses 3 decimal places for quantities.

func Millis

func Millis(m int64) Quantity

Millis creates a Quantity from thousandths. For example, Millis(1500) represents 1.500 units.

func ParseQuantity

func ParseQuantity(s string) (Quantity, error)

ParseQuantity parses a string in "X.XXX" format into a Quantity.

func QuantityFromFloat

func QuantityFromFloat(f float64) Quantity

QuantityFromFloat creates a Quantity from a float64.

func QuantityFromInt

func QuantityFromInt(n int) Quantity

QuantityFromInt creates a Quantity from a whole number. For example, QuantityFromInt(5) represents 5.000 units.

func (Quantity) Int64

func (q Quantity) Int64() int64

Int64 returns the quantity as an int64 in thousandths.

func (Quantity) MarshalXML

func (q Quantity) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (Quantity) String

func (q Quantity) String() string

String returns the string representation in "X.XXX" format.

func (*Quantity) UnmarshalXML

func (q *Quantity) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

type Seller

type Seller struct {
	Name        string `xml:"nazwa,omitempty"`
	NIP         string `xml:"nip,omitempty"`
	Street      string `xml:"ulica_i_numer,omitempty"`
	PostalCode  string `xml:"kod_pocztowy,omitempty"`
	City        string `xml:"miejscowosc,omitempty"`
	Country     string `xml:"kraj,omitempty"`
	Email       string `xml:"email,omitempty"`
	Phone       string `xml:"telefon,omitempty"`
	Fax         string `xml:"fax,omitempty"`
	Website     string `xml:"www,omitempty"`
	BankAccount string `xml:"nr_konta_bankowego,omitempty"`
}

Seller represents seller information in a document.

type SendEmailRequest

type SendEmailRequest struct {
	DocumentID DocumentID `xml:"dokument_id"`
	Email      string     `xml:"email"`
	Subject    string     `xml:"temat,omitempty"`
	Message    string     `xml:"tresc,omitempty"`
	SendCopy   string     `xml:"kopia,omitempty"` // "1" to send copy to sender
}

SendEmailRequest represents a request to send invoice via email.

type SendEmailResponse

type SendEmailResponse struct {
	XMLName xml.Name `xml:"dokument"`
	Code    int      `xml:"kod"`
	Message string   `xml:"komunikat,omitempty"`
}

SendEmailResponse represents the API response for email sending.

type TagResponse

type TagResponse struct {
	XMLName xml.Name `xml:"dokument"`
	Code    int      `xml:"kod"`
	Message string   `xml:"komunikat,omitempty"`
}

TagResponse represents the API response for tag operations.

type UpdateDocumentRequest

type UpdateDocumentRequest struct {
	DocumentID    DocumentID    `xml:"dokument_id"`
	PaymentStatus PaymentStatus `xml:"status_platnosci,omitempty"`
	PaidAmount    Amount        `xml:"zaplacono,omitempty"`
	Notes         string        `xml:"uwagi,omitempty"`
}

UpdateDocumentRequest represents a document update request.

type VATRate

type VATRate string

VATRate represents common VAT rates.

const (
	VATRate23 VATRate = "23"
	VATRate8  VATRate = "8"
	VATRate5  VATRate = "5"
	VATRate0  VATRate = "0"
	VATRateZW VATRate = "zw" // Exempt
	VATRateNP VATRate = "np" // Not applicable
	VATRateOO VATRate = "oo" // Reverse charge
)

VAT rate constants.

type Warehouse

type Warehouse struct {
	ID   string `xml:"id"`
	Name string `xml:"nazwa"`
}

Warehouse represents a warehouse.

Jump to

Keyboard shortcuts

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