Skip to main content

Invoice Model

This document describes the Invoice model, as defined in the Go codebase. The Invoice model represents invoice data, including its unique identifier, status, type, price details, and relevant timestamps. It is primarily used for sending invoice information via webhooks.

Structure

type Invoice struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
InvoiceNumber string `json:"invoice_number"`
InvoiceType InvoiceType `json:"invoice_type"`
Status InvoiceStatus `json:"status"`
TotalPrice Price `json:"total_price"`
From *time.Time `json:"from"`
TillIncl *time.Time `json:"till_incl"`
UserID uuid.UUID `json:"user_id"`
InvoiceCreditID *uuid.UUID `json:"invoice_credit_id"`
}

Field Descriptions

FieldTypeDescription
IDuuid.UUIDUnique identifier of the invoice.
CreatedAttime.TimeDate and time when the invoice was created.
UpdatedAttime.TimeDate and time when the invoice was last updated.
DeletedAt*time.TimeDate and time when the invoice was deleted (optional).
InvoiceNumberstringThe number of the invoice.
InvoiceTypeInvoiceTypeThe type of the invoice (see InvoiceType).
StatusInvoiceStatusThe status of the invoice (see InvoiceStatus).
TotalPricePriceThe total price of the invoice, including VAT breakdown (see Price).
From*time.TimeThe starting date of the invoice period.
TillIncl*time.TimeThe ending date of the invoice period (inclusive).
UserIDuuid.UUIDThe ID of the user associated with the invoice.
InvoiceCreditID*uuid.UUIDThe ID of the credit invoice, if applicable (optional).

Price Structure

The Price struct represents the price breakdown of the invoice.

type Price struct {
Excl decimal.Decimal `json:"total_excl"`
Incl decimal.Decimal `json:"total_incl"`
VAT decimal.Decimal `json:"vat"`
}
FieldTypeDescription
Excldecimal.DecimalTotal price excluding VAT.
Incldecimal.DecimalTotal price including VAT.
VATdecimal.DecimalVAT amount.

InvoiceStatus Enum

The InvoiceStatus enum indicates the current state of the invoice.

ValueDescription
InvoiceStatusUndefinedUndefined status (should be considered as an error).
InvoiceStatusCreatedInvoice has been created.
InvoiceStatusDraftInvoice is still in draft.
InvoiceStatusExpiredInvoice has expired. Deprecated
InvoiceStatusPaidInvoice has been paid by the customer.
InvoiceStatusCreditedInvoice has been credited (cancelled by a credit invoice).
InvoiceStatusToBundleNo longer supported. Deprecated
InvoiceStatusBundledNo longer supported. Deprecated
InvoiceStatusInvalidInvoice in a bundle is invalidated. Deprecated
InvoiceStatusBundledPaidNo longer supported. Deprecated
InvoiceStatusPaymentExpectedTransaction created, payment not yet received.
InvoiceStatusSettledInvoice has been settled with another invoice.
InvoiceStatusPayoutInvoice is ready for payout/excasso.
InvoiceStatusPartiallyPaidPartial payment received for the invoice.

Status String Representation

When serialized to JSON, the status is represented as a string, e.g., "Paid", "Draft", etc.


InvoiceType Enum

The InvoiceType enum indicates the type of invoice.

ValueDescription
InvoiceTypeUndefinedUndefined type (should be considered as an error).
InvoiceTypeUpfrontUpfront invoice.
InvoiceTypeOneOffOne-off invoice.
InvoiceTypeYearYearly invoice.
InvoiceTypeEndEnd invoice.
InvoiceTypeSmartMeterSmart meter invoice.
InvoiceTypeMonthlyMonthly invoice.
InvoiceTypeCreditCredit invoice.
InvoiceTypeCollectionCollection invoice.
InvoiceTypeMonthlySettleMonthly settlement invoice.

Type String Representation

When serialized to JSON, the type is represented as a string, e.g., "Upfront", "Monthly", etc.


Example JSON

{
"id": "b6e5c8f3-7d4b-4b5a-9e6a-2b8e7c0f3e4c",
"created_at": "2025-05-20T12:00:00Z",
"updated_at": "2025-05-20T12:30:00Z",
"deleted_at": null,
"invoice_number": "INV-2025-0001",
"invoice_type": "Monthly",
"status": "Paid",
"total_price": {
"total_excl": "100.00",
"total_incl": "121.00",
"vat": "21.00"
},
"from": "2025-05-01T00:00:00Z",
"till_incl": "2025-05-31T23:59:59Z",
"user_id": "a1b2c3d4-e5f6-7a8b-9c0d-1e2f3a4b5c6d",
"invoice_credit_id": null
}

Notes

  • Deprecated Statuses: Some statuses and types are marked as deprecated and should not be used in new implementations.
  • Optional Fields: DeletedAt, From, TillIncl, and InvoiceCreditID can be null in JSON.
  • Enumerations: Both InvoiceStatus and InvoiceType are serialized as human-readable strings.

See Also