bill

package
v0.401.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 21 Imported by: 27

Documentation

Overview

Package bill provides models for dealing with Billing and specifically invoicing.

Index

Constants

View Source
const (
	ShortSchemaOrder    = "bill/order"
	ShortSchemaDelivery = "bill/delivery"
	ShortSchemaInvoice  = "bill/invoice"
	ShortSchemaPayment  = "bill/payment"
	ShortSchemaStatus   = "bill/status"
)

Constants used to help identify document schemas

View Source
const (
	ChargeKeyStampDuty cbc.Key = "stamp-duty"
	ChargeKeyOutlay    cbc.Key = "outlay"
	ChargeKeyTax       cbc.Key = "tax"
	ChargeKeyCustoms   cbc.Key = "customs"
	ChargeKeyDelivery  cbc.Key = "delivery"
	ChargeKeyPacking   cbc.Key = "packing"
	ChargeKeyHandling  cbc.Key = "handling"
	ChargeKeyInsurance cbc.Key = "insurance"
	ChargeKeyStorage   cbc.Key = "storage"
	ChargeKeyAdmin     cbc.Key = "admin" // administration
	ChargeKeyCleaning  cbc.Key = "cleaning"
)

Charge keys for identifying the type of charge being applied. These are based on a subset of the UN/CEFACT UNTDID 7161 codes, and are intentionally kept lean.

View Source
const (
	DeliveryTypeAdvice  cbc.Key = "advice"
	DeliveryTypeNote    cbc.Key = "note"
	DeliveryTypeWaybill cbc.Key = "waybill"
	DeliveryTypeReceipt cbc.Key = "receipt"
)

Delivery document types.

View Source
const (
	DiscountKeyEarlyCompletion  cbc.Key = "early-completion"
	DiscountKeyMilitary         cbc.Key = "military"
	DiscountKeyWorkAccident     cbc.Key = "work-accident"
	DiscountKeySpecialAgreement cbc.Key = "special-agreement"
	DiscountKeyProductionError  cbc.Key = "production-error"
	DiscountKeyNewOutlet        cbc.Key = "new-outlet"
	DiscountKeySample           cbc.Key = "sample"
	DiscountKeyEndOfRange       cbc.Key = "end-of-range"
	DiscountKeyIncoterm         cbc.Key = "incoterm"
	DiscountKeyPOSThreshold     cbc.Key = "pos-threshold"
	DiscountKeySpecialRebate    cbc.Key = "special-rebate"
	DiscountKeyTemporary        cbc.Key = "temporary"
	DiscountKeyStandard         cbc.Key = "standard"
	DiscountKeyYarlyTurnover    cbc.Key = "yearly-turnover"
)

Discount keys for identifying the type of discount being applied. These are based on the UN/CEFACT UNTDID 5189 code list subset defined in the EN16931 code lists and are mean as suggestions.

View Source
const (
	InvoiceTypeStandard   cbc.Key = "standard"
	InvoiceTypeProforma   cbc.Key = "proforma"
	InvoiceTypeCorrective cbc.Key = "corrective"
	InvoiceTypeCreditNote cbc.Key = "credit-note"
	InvoiceTypeDebitNote  cbc.Key = "debit-note"
	InvoiceTypeOther      cbc.Key = "other"
)

Predefined list of the invoice type codes officially supported.

View Source
const (
	OrderTypePurchase cbc.Key = "purchase"
	OrderTypeSale     cbc.Key = "sale"
	OrderTypeQuote    cbc.Key = "quote"
)

Predefined list of the order types supported.

View Source
const (
	PaymentTypeRequest cbc.Key = "request"
	PaymentTypeReceipt cbc.Key = "receipt"
	PaymentTypeAdvice  cbc.Key = "advice"
)

Predefined list of the payment types supported.

View Source
const (
	StatusTypeResponse cbc.Key = "response"
	StatusTypeUpdate   cbc.Key = "update"
	StatusTypeSystem   cbc.Key = "system"
)

Status type representing the context in which the status was generated.

View Source
const (
	StatusEventIssued       cbc.Key = "issued"
	StatusEventAcknowledged cbc.Key = "acknowledged"
	StatusEventProcessing   cbc.Key = "processing"
	StatusEventQuerying     cbc.Key = "querying"
	StatusEventRejected     cbc.Key = "rejected"
	StatusEventAccepted     cbc.Key = "accepted"
	StatusEventPaid         cbc.Key = "paid"
	StatusEventError        cbc.Key = "error"
)

Status event keys representing the specific status being reported.

View Source
const (
	ReasonKeyNone            cbc.Key = "none"
	ReasonKeyReferences      cbc.Key = "references"
	ReasonKeyLegal           cbc.Key = "legal"
	ReasonKeyUnknownReceiver cbc.Key = "unknown-receiver"
	ReasonKeyQuality         cbc.Key = "quality"
	ReasonKeyDelivery        cbc.Key = "delivery"
	ReasonKeyPrices          cbc.Key = "prices"
	ReasonKeyQuantity        cbc.Key = "quantity"
	ReasonKeyItems           cbc.Key = "items"
	ReasonKeyPaymentTerms    cbc.Key = "payment-terms"
	ReasonKeyNotRecognized   cbc.Key = "not-recognized"
	ReasonKeyFinanceTerms    cbc.Key = "finance-terms"
	ReasonKeyPartial         cbc.Key = "partial"
	ReasonKeyOther           cbc.Key = "other"
)

Reason keys as used to represent the reason for a specific status line key.

View Source
const (
	ActionKeyNone          cbc.Key = "none"
	ActionKeyProvide       cbc.Key = "provide"
	ActionKeyReissue       cbc.Key = "reissue"
	ActionKeyCreditFull    cbc.Key = "credit-full"
	ActionKeyCreditPartial cbc.Key = "credit-partial"
	ActionKeyCreditAmount  cbc.Key = "credit-amount"
	ActionKeyOther         cbc.Key = "other"
)

Action keys are used to suggest to the recipient what they should do with the next document.

View Source
const (
	// UNTDID1001Key is the key used to identify the UNTDID 1001 code
	// associated with an invoice type.
	UNTDID1001Key cbc.Key = "untdid1001"
)

Variables

View Source
var ActionKeys = []*cbc.Definition{
	{
		Key: ActionKeyNone,
		Name: i18n.String{
			i18n.EN: "No action required",
		},
		Desc: i18n.String{
			i18n.EN: "No action required.",
		},
	},
	{
		Key: ActionKeyProvide,
		Name: i18n.String{
			i18n.EN: "Provide information",
		},
		Desc: i18n.String{
			i18n.EN: "Missing information requested without re-issuing invoice.",
		},
	},
	{
		Key: ActionKeyReissue,
		Name: i18n.String{
			i18n.EN: "Issue new invoice",
		},
		Desc: i18n.String{
			i18n.EN: "Request to re-issue a corrected invoice.",
		},
	},
	{
		Key: ActionKeyCreditFull,
		Name: i18n.String{
			i18n.EN: "Credit fully",
		},
		Desc: i18n.String{
			i18n.EN: "Request to fully cancel the referenced invoice with a credit note.",
		},
	},
	{
		Key: ActionKeyCreditPartial,
		Name: i18n.String{
			i18n.EN: "Credit partially",
		},
		Desc: i18n.String{
			i18n.EN: "Request to issue partial credit note for corrections only.",
		},
	},
	{
		Key: ActionKeyCreditAmount,
		Name: i18n.String{
			i18n.EN: "Credit the amount",
		},
		Desc: i18n.String{
			i18n.EN: "Request to repay the amount paid on the invoice.",
		},
	},
	{
		Key: ActionKeyOther,
		Name: i18n.String{
			i18n.EN: "Other",
		},
		Desc: i18n.String{
			i18n.EN: "Requested action is not defined by code.",
		},
	},
}

ActionKeys describes the different actions that can be suggested to the recipient.

View Source
var Corrective schema.Option = func(o interface{}) {
	opts := o.(*CorrectionOptions)
	opts.Type = InvoiceTypeCorrective
}

Corrective is used for creating corrective or rectified invoices that completely replace a previous document.

View Source
var Credit schema.Option = func(o interface{}) {
	opts := o.(*CorrectionOptions)
	opts.Type = InvoiceTypeCreditNote
}

Credit indicates that the corrective operation requires a credit note or equivalent.

View Source
var Debit schema.Option = func(o interface{}) {
	opts := o.(*CorrectionOptions)
	opts.Type = InvoiceTypeDebitNote
}

Debit indicates that the corrective operation is to append new items to the previous invoice, usually as a debit note.

View Source
var DeliveryTypes = []*cbc.Definition{
	{
		Key: DeliveryTypeAdvice,
		Name: i18n.String{
			i18n.EN: "Delivery Advice",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A delivery or despatch advice document send by the supplier to indicate how
				an order is to be delivered.
			`),
		},
	},
	{
		Key: DeliveryTypeNote,
		Name: i18n.String{
			i18n.EN: "Delivery Note",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A delivery note is a document accompanying a shipment of goods that lists the
				items included in the shipment.
			`),
		},
	},
	{
		Key: DeliveryTypeWaybill,
		Name: i18n.String{
			i18n.EN: "Waybill",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A waybill is a document issued by a carrier giving details and instructions
				relating to the shipment of a consignment of goods.
			`),
		},
	},
	{
		Key: DeliveryTypeReceipt,
		Name: i18n.String{
			i18n.EN: "Delivery Receipt",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A delivery receipt is a document that is signed by the person who receives
				goods to confirm that they have been received.
			`),
		},
	},
}

DeliveryTypes provides the list of supported delivery documents in GOBL.

View Source
var InvoiceTypes = []*cbc.Definition{
	{
		Key: InvoiceTypeStandard,
		Name: i18n.String{
			i18n.EN: "Standard",
		},
		Desc: i18n.String{
			i18n.EN: "A regular commercial invoice document between a supplier and customer.",
		},
		Map: cbc.CodeMap{
			UNTDID1001Key: "380",
		},
	},
	{
		Key: InvoiceTypeProforma,
		Name: i18n.String{
			i18n.EN: "Proforma",
		},
		Desc: i18n.String{
			i18n.EN: "For a clients validation before sending a final invoice.",
		},
		Map: cbc.CodeMap{
			UNTDID1001Key: "325",
		},
	},
	{
		Key: InvoiceTypeCorrective,
		Name: i18n.String{
			i18n.EN: "Corrective",
		},
		Desc: i18n.String{
			i18n.EN: "Corrected invoice that completely *replaces* the preceding document.",
		},
		Map: cbc.CodeMap{
			UNTDID1001Key: "384",
		},
	},
	{
		Key: InvoiceTypeCreditNote,
		Name: i18n.String{
			i18n.EN: "Credit Note",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				Reflects a refund either partial or complete of the preceding document. A 
				credit note effectively *extends* the previous document.
			`),
		},
		Map: cbc.CodeMap{
			UNTDID1001Key: "381",
		},
	},
	{
		Key: InvoiceTypeDebitNote,
		Name: i18n.String{
			i18n.EN: "Debit Note",
		},
		Desc: i18n.String{
			i18n.EN: "An additional set of charges to be added to the preceding document.",
		},
		Map: cbc.CodeMap{
			UNTDID1001Key: "383",
		},
	},
	{
		Key: InvoiceTypeOther,
		Name: i18n.String{
			i18n.EN: "Other",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				Any other type of invoice that does not fit into the standard categories and implies
				that any scenarios defined in tax regimes or addons will not be applied.

				This is useful for being able to create invoices with custom types in extensions,
				but is not recommend for general use.
			`),
		},
	},
}

InvoiceTypes describes each of the InvoiceTypes supported.

View Source
var OrderTypes = []*cbc.Definition{
	{
		Key: OrderTypePurchase,
		Name: i18n.String{
			i18n.EN: "Purchase Order",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A purchase order is a document that a buyer sends to a seller to request goods or services.
			`),
		},
	},
	{
		Key: OrderTypeSale,
		Name: i18n.String{
			i18n.EN: "Sales Order",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A sales order is a document that a seller sends to a buyer to confirm the sale of goods or services.
			`),
		},
	},
	{
		Key: OrderTypeQuote,
		Name: i18n.String{
			i18n.EN: "Quote",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A quote is a document that a seller sends to a buyer to provide a price for goods or services.
			`),
		},
	},
}

OrderTypes defines the list of order types supported.

View Source
var PaymentTypes = []*cbc.Definition{
	{
		Key: PaymentTypeRequest,
		Name: i18n.String{
			i18n.EN: "Request",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A payment request sent from the supplier to a customer indicating that they are
				requesting a transfer of funds from the customer directly or a payer.
				This is used to request payment for specific documents and invoices.
			`),
		},
	},
	{
		Key: PaymentTypeAdvice,
		Name: i18n.String{
			i18n.EN: "Advice",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A remittance advice sent from the customer to the supplier reflecting that payment for
				the referenced documents has been made.
			`),
		},
	},
	{
		Key: PaymentTypeReceipt,
		Name: i18n.String{
			i18n.EN: "Receipt",
		},
		Desc: i18n.String{
			i18n.EN: here.Doc(`
				A payment receipt sent from the supplier to a customer indicating that they have
				received a transfer of funds from the customer directly or a payer.
				This is the default payment type and may be required by some tax
				regimes in order to communicate the payment of specific documents and invoices.
			`),
		},
	},
}

PaymentTypes defines the list of potential payment types.

View Source
var ReasonKeys = []*cbc.Definition{
	{
		Key: ReasonKeyNone,
		Name: i18n.String{
			i18n.EN: "No Issue",
		},
		Desc: i18n.String{
			i18n.EN: "Receiver of the documents sends the message just to update the status and there are no problems with document processing.",
		},
	},
	{
		Key: ReasonKeyReferences,
		Name: i18n.String{
			i18n.EN: "References Incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Received document did not contain references as required by the receiver for correctly routing the document for approval or processing.",
		},
	},
	{
		Key: ReasonKeyLegal,
		Name: i18n.String{
			i18n.EN: "Legal information incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Information in the received document is not according to legal requirements.",
		},
	},
	{
		Key: ReasonKeyUnknownReceiver,
		Name: i18n.String{
			i18n.EN: "Receiver unknown",
		},
		Desc: i18n.String{
			i18n.EN: "The party to which the document is addressed is not known.",
		},
	},
	{
		Key: ReasonKeyQuality,
		Name: i18n.String{
			i18n.EN: "Item quality issue",
		},
		Desc: i18n.String{
			i18n.EN: "Unacceptable or incorrect quality.",
		},
	},
	{
		Key: ReasonKeyDelivery,
		Name: i18n.String{
			i18n.EN: "Delivery issues",
		},
		Desc: i18n.String{
			i18n.EN: "Delivery proposed or provided is not acceptable.",
		},
	},
	{
		Key: ReasonKeyPrices,
		Name: i18n.String{
			i18n.EN: "Prices incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Prices not according to previous expectation.",
		},
	},
	{
		Key: ReasonKeyQuantity,
		Name: i18n.String{
			i18n.EN: "Quantity incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Quantity not according to previous expectation.",
		},
	},
	{
		Key: ReasonKeyItems,
		Name: i18n.String{
			i18n.EN: "Items incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Items not according to previous expectation.",
		},
	},
	{
		Key: ReasonKeyPaymentTerms,
		Name: i18n.String{
			i18n.EN: "Payment terms incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Payment terms not according to previous expectation.",
		},
	},
	{
		Key: ReasonKeyNotRecognized,
		Name: i18n.String{
			i18n.EN: "Not recognized",
		},
		Desc: i18n.String{
			i18n.EN: "Commercial transaction not recognized.",
		},
	},
	{
		Key: ReasonKeyFinanceTerms,
		Name: i18n.String{
			i18n.EN: "Finance incorrect",
		},
		Desc: i18n.String{
			i18n.EN: "Finance terms not according to previous expectation.",
		},
	},
	{
		Key: ReasonKeyPartial,
		Name: i18n.String{
			i18n.EN: "Partially paid",
		},
		Desc: i18n.String{
			i18n.EN: "Payment is partially but not fully paid.",
		},
	},
	{
		Key: ReasonKeyOther,
		Name: i18n.String{
			i18n.EN: "Other",
		},
		Desc: i18n.String{
			i18n.EN: "Reason for status is not defined by code.",
		},
	},
}

ReasonKeys describes the different reasons for a status event.

View Source
var StatusEvents = []*cbc.Definition{
	{
		Key: StatusEventIssued,
		Name: i18n.String{
			i18n.EN: "Issued",
		},
		Desc: i18n.String{
			i18n.EN: "Document has been submitted pending review by the recipient.",
		},
	},
	{
		Key: StatusEventAcknowledged,
		Name: i18n.String{
			i18n.EN: "Acknowledged",
		},
		Desc: i18n.String{
			i18n.EN: "Received a readable invoice message that can be understood and submitted for processing by the Buyer.",
		},
	},
	{
		Key: StatusEventProcessing,
		Name: i18n.String{
			i18n.EN: "In Process",
		},
		Desc: i18n.String{
			i18n.EN: "Indicates that the referenced message or transaction is being processed.",
		},
	},
	{
		Key: StatusEventQuerying,
		Name: i18n.String{
			i18n.EN: "Under Query",
		},
		Desc: i18n.String{
			i18n.EN: "Buyer will not proceed to accept the Invoice without receiving additional information from the Seller.",
		},
	},
	{
		Key: StatusEventRejected,
		Name: i18n.String{
			i18n.EN: "Rejected",
		},
		Desc: i18n.String{
			i18n.EN: "Buyer will not process the referenced Invoice any further. Buyer is rejecting this invoice but not necessarily the commercial transaction. Although it can be used also for rejection for commercial reasons (invoice not corresponding to delivery).",
		},
	},
	{
		Key: StatusEventAccepted,
		Name: i18n.String{
			i18n.EN: "Accepted / Approved",
		},
		Desc: i18n.String{
			i18n.EN: "Buyer has given a final approval of the invoice and the next step is payment.",
		},
	},
	{
		Key: StatusEventPaid,
		Name: i18n.String{
			i18n.EN: "Paid",
		},
		Desc: i18n.String{
			i18n.EN: "Buyer has initiated payment, or the supplier has acknowledged receipt of payment.",
		},
	},
	{
		Key: StatusEventError,
		Name: i18n.String{
			i18n.EN: "Error",
		},
		Desc: i18n.String{
			i18n.EN: "There is a technical issue with the document that has caused it to be rejected.",
		},
	},
}

StatusEvents describes the different status events that can be reported.

View Source
var StatusTypes = []*cbc.Definition{
	{
		Key: StatusTypeResponse,
		Name: i18n.String{
			i18n.EN: "Response",
		},
		Desc: i18n.String{
			i18n.EN: "A response to a document that has been submitted, often used in a two way communication between a customer and supplier.",
		},
	},
	{
		Key: StatusTypeUpdate,
		Name: i18n.String{
			i18n.EN: "Update",
		},
		Desc: i18n.String{
			i18n.EN: "Issued by the supplier (or issuer) that may be shared with the customer, but more likely with a fifth-corner, like a government agency.",
		},
	},
	{
		Key: StatusTypeSystem,
		Name: i18n.String{
			i18n.EN: "System",
		},
		Desc: i18n.String{
			i18n.EN: "A system event that is not directly related to a specific document, but needs to be recorded for compliance purposes.",
		},
	},
}

StatusTypes describes the different types of status messages that can be issued.

Functions

func DefaultInvoiceTags added in v0.220.0

func DefaultInvoiceTags() *tax.TagSet

DefaultInvoiceTags is a convenience function to get the default invoice tags.

func InvoiceScenarios added in v0.219.0

func InvoiceScenarios() *tax.ScenarioSet

InvoiceScenarios provides a standard set of scenarios to either be extended or overridden by a regime or addon.

func InvoiceTypeIn added in v0.400.0

func InvoiceTypeIn(types ...cbc.Key) rules.Test

InvoiceTypeIn returns true if the invoice's type property is in one of the specified list.

func RequireLineTaxCategory added in v0.115.0

func RequireLineTaxCategory(key cbc.Code) rules.Test

RequireLineTaxCategory provides a rules.Test that ensures the line has the required tax category.

func WithCopyTax added in v0.211.0

func WithCopyTax() schema.Option

WithCopyTax will ensure the tax is copied from the previous document to the corrective document preceding row.

func WithData added in v0.51.0

func WithData(data json.RawMessage) schema.Option

WithData expects a raw JSON object that will be marshalled into a CorrectionOptions instance and used as the base for the correction.

func WithExtension added in v0.67.0

func WithExtension(key cbc.Key, code cbc.Code) schema.Option

WithExtension adds a specific extension combination to the invoice's preceding data, can be called multiple times.

func WithIssueDate added in v0.51.0

func WithIssueDate(date cal.Date) schema.Option

WithIssueDate can be used to override the issue date of the corrective invoice produced.

func WithOptions added in v0.51.0

func WithOptions(opts *CorrectionOptions) schema.Option

WithOptions takes an already completed CorrectionOptions instance and uses this as a base instead of passing individual options. This is useful for passing options from an API, developers should use the regular option methods.

func WithReason added in v0.40.0

func WithReason(reason string) schema.Option

WithReason allows a reason to be provided for the corrective operation.

func WithSeries added in v0.77.0

func WithSeries(value cbc.Code) schema.Option

WithSeries assigns a new series to the corrective document.

func WithStamps added in v0.40.0

func WithStamps(stamps []*head.Stamp) schema.Option

WithStamps provides a configuration option with stamp information usually included in the envelope header for a previously generated and processed invoice document.

Types

type Action added in v0.401.0

type Action struct {
	// Key helps determine what to do next.
	Key cbc.Key `json:"key" jsonschema:"title=Key"`

	// Description includes human readable details about what steps should be
	// take next.
	Description string `json:"description,omitempty" jsonschema:"title=Description"`

	// Extensions for local or format focussed data
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
}

Action provides a suggestion about what to do next with the document.

func (Action) JSONSchemaExtend added in v0.401.0

func (Action) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Action) Normalize added in v0.401.0

func (a *Action) Normalize(normalizers tax.Normalizers)

Normalize runs any registered normalizers on the action.

type Charge added in v0.13.0

type Charge struct {
	uuid.Identify
	// Line number inside the list of charges (calculated).
	Index int `json:"i" jsonschema:"title=Index" jsonschema_extras:"calculated=true"`
	// Key for grouping or identifying charges for tax purposes. A suggested list of
	// keys is provided, but these may be extended by the issuer.
	Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
	// Code to used to refer to the this charge by the issuer
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Text description as to why the charge was applied
	Reason string `json:"reason,omitempty" jsonschema:"title=Reason"`
	// Base represents the value used as a base for percent calculations instead
	// of the invoice's sum of lines.
	Base *num.Amount `json:"base,omitempty" jsonschema:"title=Base"`
	// Percentage to apply to the sum of all lines
	Percent *num.Percentage `json:"percent,omitempty" jsonschema:"title=Percent"`
	// Amount to apply (calculated if percent present)
	Amount num.Amount `json:"amount" jsonschema:"title=Amount" jsonschema_extras:"calculated=true"`
	// List of taxes to apply to the charge
	Taxes tax.Set `json:"taxes,omitempty" jsonschema:"title=Taxes"`
	// Extension codes that apply to the charge
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
	// Additional semi-structured information.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

Charge represents a surchange applied to the complete document independent from the individual lines.

func (*Charge) GetTaxes added in v0.20.0

func (m *Charge) GetTaxes() tax.Set

GetTaxes responds with the array of tax rates applied to this line.

func (*Charge) GetTotal added in v0.13.0

func (m *Charge) GetTotal() num.Amount

GetTotal provides the final total for this line, excluding any tax calculations.

func (Charge) JSONSchemaExtend added in v0.204.0

func (Charge) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend adds the charge key definitions to the schema.

func (*Charge) Normalize added in v0.200.0

func (m *Charge) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the line and embedded objects using the provided list of normalizers.

type Condition added in v0.401.0

type Condition struct {
	// Code is generated by the system that raised the condition.
	Code cbc.Code `json:"code" jsonschema:"title=Code"`

	// Paths contains an array of JSON paths that maps the GOBL specific error
	// to a field inside the envelope that the condition is applied to.
	Paths []string `json:"paths,omitempty" jsonschema:"title=Paths"`

	// Message contains human readable details about the specific condition.
	Message string `json:"message,omitempty" jsonschema:"title=Message"`
}

Condition provides a more formal structure for describing with a specific code what has been unacceptable about the source document, including potentially references to the fields causing issues.

func (*Condition) Normalize added in v0.401.0

func (c *Condition) Normalize(normalizers tax.Normalizers)

Normalize normalizes the condition's code and runs any registered normalizers.

type CorrectionOptions added in v0.51.0

type CorrectionOptions struct {
	head.CorrectionOptions

	// The type of corrective invoice to produce.
	Type cbc.Key `json:"type" jsonschema:"title=Type"`
	// When the new corrective invoice's issue date should be set to.
	IssueDate *cal.Date `json:"issue_date,omitempty" jsonschema:"title=Issue Date"`
	// Series to assign to the new corrective invoice.
	Series cbc.Code `json:"series,omitempty" jsonschema:"title=Series"`
	// Stamps of the previous document to include in the preceding data.
	Stamps []*head.Stamp `json:"stamps,omitempty" jsonschema:"title=Stamps"`
	// Human readable reason for the corrective operation.
	Reason string `json:"reason,omitempty" jsonschema:"title=Reason"`
	// Extensions for region specific requirements that may be added in the preceding
	// or at the document level, according to the local rules.
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
	// CopyTax when true will copy the tax totals from the previous document to the
	// preceding document data.
	CopyTax bool `json:"copy_tax,omitempty" jsonschema:"title=Copy Tax Totals"`
	// contains filtered or unexported fields
}

CorrectionOptions defines a structure used to pass configuration options to correct a previous invoice. This is made available to make it easier to pass options between external services.

type Delivery

type Delivery struct {
	tax.Regime
	tax.Addons
	tax.Tags
	uuid.Identify

	// Type of delivery document.
	Type cbc.Key `json:"type" jsonschema:"title=Type" jsonschema_extras:"enum=advice,note,waybill,receipt"`
	// Series is used to identify groups of deliveries by date, business area, project,
	// type, customer, a combination of any, or other company specific data.
	// If the output format does not support the series as a separate field, it will be
	// prepended to the code for presentation with a dash (`-`) for separation.
	Series cbc.Code `json:"series,omitempty" jsonschema:"title=Series"`
	// Code is a sequential identifier that uniquely identifies the delivery. The code can
	// be left empty initially, but is **required** to **sign** the document.
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// When the delivery document is to be issued.
	IssueDate cal.Date `json:"issue_date" jsonschema:"title=Issue Date" jsonschema_extras:"calculated=true"`
	// IssueTime is an optional field that may be useful to indicate the time of day when
	// the delivery was issued. Some regions and formats may require this field to be set.
	// An empty string will be automatically updated to reflect the current time, otherwise
	// the field can be left with a nil value.
	IssueTime *cal.Time `json:"issue_time,omitempty" jsonschema:"title=Issue Time" jsonschema_extras:"calculated=true"`
	// When the taxes of this delivery become accountable, if none set, the issue date is used.
	ValueDate *cal.Date `json:"value_date,omitempty" jsonschema:"title=Value Date"`
	// Currency for all delivery totals.
	Currency currency.Code `json:"currency,omitempty" jsonschema:"title=Currency" jsonschema_extras:"calculated=true"`
	// Exchange rates to be used when converting the invoices monetary values into other currencies.
	ExchangeRates []*currency.ExchangeRate `json:"exchange_rates,omitempty" jsonschema:"title=Exchange Rates"`

	// Ordering details for the delivery, including links to other documents.
	Ordering *Ordering `json:"ordering,omitempty" jsonschema:"title=Ordering"`
	// Key information regarding previous delivery documents that this one will either
	// extend or replace.
	Preceding []*org.DocumentRef `json:"preceding,omitempty" jsonschema:"title=Preceding Details"`

	// Tracking is used to define specific codes or IDs that may be used to
	// identify and track delivery.
	Tracking *Tracking `json:"tracking,omitempty" jsonschema:"title=Tracking"`
	// DespatchDate is the date when the goods are expected to be despatched.
	DespatchDate *cal.Date `json:"despatch_date,omitempty" jsonschema:"title=Despatch Date"`
	// ReceiveDate is the date when the goods are expected to be received.
	ReceiveDate *cal.Date `json:"receive_date,omitempty" jsonschema:"title=Receive Date"`

	// Special tax configuration for calculating totals.
	Tax *Tax `json:"tax,omitempty" jsonschema:"title=Tax"`

	// The entity supplying the goods or services and usually responsible for paying taxes.
	Supplier *org.Party `json:"supplier" jsonschema:"title=Supplier"`
	// Legal entity receiving the goods or services, may be nil in certain circumstances such as simplified invoices.
	Customer *org.Party `json:"customer,omitempty" jsonschema:"title=Customer"`
	// The party who will despatch the goods defined in the invoice.
	Despatcher *org.Party `json:"despatcher,omitempty" jsonschema:"title=Despatcher"`
	// The party who will receive delivery of the goods defined in the invoice.
	Receiver *org.Party `json:"receiver,omitempty" jsonschema:"title=Receiver"`
	// The courier responsible for delivering the goods.
	Courier *org.Party `json:"courier,omitempty" jsonschema:"title=Courier"`

	// List of lines representing each of the items to be ordered.
	Lines []*Line `json:"lines,omitempty" jsonschema:"title=Lines"`
	// Discounts or allowances applied to order totals
	Discounts []*Discount `json:"discounts,omitempty" jsonschema:"title=Discounts"`
	// Charges or surcharges applied to order totals
	Charges []*Charge `json:"charges,omitempty" jsonschema:"title=Charges"`

	// Summary of all the order totals, including taxes (calculated).
	Totals *Totals `json:"totals,omitempty" jsonschema:"title=Totals" jsonschema_extras:"calculated=true"`

	// Unstructured information that is relevant to the delivery, such as correction or additional
	// legal details.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Additional complementary objects that add relevant information to the delivery.
	Complements []*schema.Object `json:"complements,omitempty" jsonschema:"title=Complements"`

	// Additional semi-structured data that doesn't fit into the body of the delivery.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`

	// Attachments provide additional information or supporting documents that are not included
	// in the main document. It is important that attachments are not used for alternative
	// versions of the PDF, for that, see "links" inside the envelope headers.
	Attachments []*org.Attachment `json:"attachments,omitempty" jsonschema:"title=Attachments"`
}

Delivery document used to describe the delivery of goods or potentially also services.

func (*Delivery) Calculate added in v0.211.0

func (dlv *Delivery) Calculate() error

Calculate performs all the normalizations and calculations required for the delivery totals and taxes. If the original delivery only includes partial calculations, this will figure out what's missing.

func (*Delivery) CanSign added in v0.400.0

func (dlv *Delivery) CanSign() bool

CanSign returns a boolean indicating whether the delivery is ready to be signed or not.

func (*Delivery) ConvertInto added in v0.211.0

func (dlv *Delivery) ConvertInto(cur currency.Code) (*Delivery, error)

ConvertInto will use the defined exchange rates in the delivery to convert all the prices into the given currency.

The intent of this method is help convert the delivery amounts when the destination is unable or unwilling to handle the current currency. This is typically the case with tax related reports or declarations.

The method will return a new delivery with all the amounts converted into the given currency or an error if the conversion is not possible.

Conversion is done by first exchanging the lowest common amounts to the destination currency, then recalculating the totals.

func (Delivery) JSONSchemaExtend added in v0.211.0

func (dlv Delivery) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Delivery) Normalize added in v0.211.0

func (dlv *Delivery) Normalize(normalizers tax.Normalizers)

Normalize is run as part of the Calculate method to ensure that the delivery is in a consistent state before calculations are performed. This will leverage any add-ons alongside the tax regime.

func (*Delivery) Replicate added in v0.304.0

func (dlv *Delivery) Replicate() error

Replicate modifies the delivery's fields to ensure that it can be used as part of a replication process. A replicated delivery is one that contains the same base details like supplier, customer, lines, etc., but with updated identifiers and dates.

type DeliveryDetails added in v0.211.0

type DeliveryDetails struct {
	// The party who will receive delivery of the goods defined in the invoice and is not responsible for taxes.
	Receiver *org.Party `json:"receiver,omitempty" jsonschema:"title=Receiver"`
	// Identities is used to define specific codes or IDs that may be used to
	// identify the delivery.
	Identities []*org.Identity `json:"identities,omitempty" jsonschema:"title=Identities"`
	// When the goods should be expected.
	Date *cal.Date `json:"date,omitempty" jsonschema:"title=Date"`
	// Period of time in which to expect delivery if a specific date is not available.
	Period *cal.Period `json:"period,omitempty" jsonschema:"title=Period"`
	// Additional custom data.
	Meta *cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

DeliveryDetails covers the details of the destination for the products described in the invoice body.

type Discount added in v0.13.0

type Discount struct {
	uuid.Identify
	// Line number inside the list of discounts (calculated)
	Index int `json:"i" jsonschema:"title=Index" jsonschema_extras:"calculated=true"`
	// Key for identifying the type of discount being applied.
	Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
	// Code to used to refer to the this discount by the issuer
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Text description as to why the discount was applied
	Reason string `json:"reason,omitempty" jsonschema:"title=Reason"`
	// Base represents the value used as a base for percent calculations instead
	// of the invoice's sum of lines.
	Base *num.Amount `json:"base,omitempty" jsonschema:"title=Base"`
	// Percentage to apply to the base or invoice's sum.
	Percent *num.Percentage `json:"percent,omitempty" jsonschema:"title=Percent"`
	// Amount to apply (calculated if percent present).
	Amount num.Amount `json:"amount" jsonschema:"title=Amount" jsonschema_extras:"calculated=true"`
	// List of taxes to apply to the discount
	Taxes tax.Set `json:"taxes,omitempty" jsonschema:"title=Taxes"`
	// Extension codes that apply to the discount
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
	// Additional semi-structured information.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

Discount represents an allowance applied to the complete document independent from the individual lines. These have more in common with Invoice Lines than anything else, as each discount must have the correct taxes defined.

func (*Discount) GetTaxes added in v0.20.0

func (m *Discount) GetTaxes() tax.Set

GetTaxes responds with the array of tax rates applied to this line.

func (*Discount) GetTotal added in v0.13.0

func (m *Discount) GetTotal() num.Amount

GetTotal provides the final total for this line, excluding any tax calculations. We return a negative value so that discounts will be applied correctly.

func (Discount) JSONSchemaExtend added in v0.204.0

func (Discount) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend adds the discount key definitions to the schema.

func (*Discount) Normalize added in v0.200.0

func (m *Discount) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the line and embedded objects using the provided list of normalizers.

type Invoice

type Invoice struct {
	tax.Regime
	tax.Addons
	tax.Tags
	uuid.Identify

	// Type of invoice document. May be restricted by local tax regime requirements.
	Type cbc.Key `json:"type" jsonschema:"title=Type" jsonschema_extras:"calculated=true"`
	// Series is used to identify groups of invoices by date, business area, project,
	// type of document, customer type, a combination of any or other company specific data.
	// If the output format does not support the series as a separate field, it will be
	// prepended to the code for presentation with a dash (`-`) for separation.
	Series cbc.Code `json:"series,omitempty" jsonschema:"title=Series"`
	// Code is a sequential identifier that uniquely identifies the invoice. The code can
	// be left empty initially, but is **required** to **sign** the invoice.
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Issue date for when the invoice was created and issued. Todays date is used if
	// none is set. There are often legal restrictions on how far back or in the future an
	// invoice can be issued.
	IssueDate cal.Date `json:"issue_date" jsonschema:"title=Issue Date" jsonschema_extras:"calculated=true"`
	// IssueTime is an optional field that may be useful to indicate the time of day when
	// the invoice was issued. Some regions and formats may require this field to be set.
	// An empty string will be automatically updated to reflect the current time, otherwise
	// the field can be left with a nil value.
	IssueTime *cal.Time `json:"issue_time,omitempty" jsonschema:"title=Issue Time" jsonschema_extras:"calculated=true"`
	// Date when the operation defined by the invoice became effective.
	OperationDate *cal.Date `json:"op_date,omitempty" jsonschema:"title=Operation Date"`
	// When the taxes of this invoice become accountable, if none set, the issue date is used.
	ValueDate *cal.Date `json:"value_date,omitempty" jsonschema:"title=Value Date"`
	// Currency for all invoice amounts and totals, unless explicitly stated otherwise.
	Currency currency.Code `json:"currency" jsonschema:"title=Currency" jsonschema_extras:"calculated=true"`
	// Exchange rates to be used when converting the invoices monetary values into other currencies.
	ExchangeRates []*currency.ExchangeRate `json:"exchange_rates,omitempty" jsonschema:"title=Exchange Rates"`

	// Document references for previous invoices that this document replaces or extends.
	Preceding []*org.DocumentRef `json:"preceding,omitempty" jsonschema:"title=Preceding Details"`

	// Special billing tax configuration options.
	Tax *Tax `json:"tax,omitempty" jsonschema:"title=Tax"`

	// The entity supplying the goods or services and usually responsible for paying taxes.
	Supplier *org.Party `json:"supplier" jsonschema:"title=Supplier"`
	// Legal entity receiving the goods or services, may be nil in certain circumstances
	// such as simplified invoices.
	Customer *org.Party `json:"customer,omitempty" jsonschema:"title=Customer"`

	// List of invoice lines representing each of the items sold to the customer.
	Lines []*Line `json:"lines,omitempty" jsonschema:"title=Lines"`
	// Discounts or allowances applied to the complete invoice
	Discounts []*Discount `json:"discounts,omitempty" jsonschema:"title=Discounts"`
	// Charges or surcharges applied to the complete invoice
	Charges []*Charge `json:"charges,omitempty" jsonschema:"title=Charges"`

	// Ordering details including document references and buyer or seller parties.
	Ordering *Ordering `json:"ordering,omitempty" jsonschema:"title=Ordering Details"`
	// Information on when, how, and to whom the invoice should be paid.
	Payment *PaymentDetails `json:"payment,omitempty" jsonschema:"title=Payment Details"`
	// Specific details on delivery of the goods referenced in the invoice.
	Delivery *DeliveryDetails `json:"delivery,omitempty" jsonschema:"title=Delivery Details"`

	// Summary of all the invoice totals, including taxes (calculated).
	Totals *Totals `json:"totals" jsonschema:"title=Totals" jsonschema_extras:"calculated=true"`

	// Unstructured information that is relevant to the invoice, such as correction or additional
	// legal details.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Additional complementary objects that add relevant information to the invoice.
	Complements []*schema.Object `json:"complements,omitempty" jsonschema:"title=Complements"`

	// Additional semi-structured data that doesn't fit into the body of the invoice.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`

	// Attachments provide additional information or supporting documents that are not included
	// in the main document. It is important that attachments are not used for alternative
	// versions of the PDF, for that, see "links" inside the envelope headers.
	Attachments []*org.Attachment `json:"attachments,omitempty" jsonschema:"title=Attachments"`
}

Invoice represents a payment claim for goods or services supplied under conditions agreed between the supplier and the customer. In most cases the resulting document describes the actual financial commitment of goods or services ordered from the supplier.

func (*Invoice) Calculate

func (inv *Invoice) Calculate() error

Calculate performs all the normalizations and calculations required for the invoice totals and taxes. If the original invoice only includes partial calculations, this will figure out what's missing.

func (*Invoice) CanSign added in v0.400.0

func (inv *Invoice) CanSign() bool

CanSign returns a boolean indicating whether the invoice is ready to be signed or not.

func (*Invoice) ConvertInto added in v0.82.0

func (inv *Invoice) ConvertInto(cur currency.Code) (*Invoice, error)

ConvertInto will use the defined exchange rates in the invoice to convert all the prices into the given currency.

The intent of this method is help convert the invoice amounts when the destination is unable or unwilling to handle the current currency. This is typically the case with tax related reports or declarations.

The method will return a new invoice with all the amounts converted into the given currency or an error if the conversion is not possible.

Conversion is done by first exchanging the lowest common amounts to the destination currency, then recalculating the totals.

func (*Invoice) Correct added in v0.40.0

func (inv *Invoice) Correct(opts ...schema.Option) error

Correct moves key fields of the current invoice to the preceding structure and performs any regime specific actions defined by the regime's configuration. If the existing document doesn't have a code, we'll raise an error, for most use cases this will prevent looping over the same invoice.

func (*Invoice) CorrectionOptionsSchema added in v0.58.1

func (inv *Invoice) CorrectionOptionsSchema() (interface{}, error)

CorrectionOptionsSchema provides a dynamic JSON schema of the options that can be used on the invoice in order to correct it. Data is extracted from the tax regime associated with the supplier.

func (*Invoice) Empty added in v0.40.0

func (inv *Invoice) Empty()

Empty is a convenience method that will empty all the lines and related rows.

func (*Invoice) GetExtensions added in v0.200.0

func (inv *Invoice) GetExtensions() []tax.Extensions

GetExtensions goes through the invoice and grabs all the extensions that are in use and expected to be used as part of a scenario.

func (*Invoice) GetTaxCategories added in v0.309.0

func (inv *Invoice) GetTaxCategories() []cbc.Code

GetTaxCategories returns a list of unique tax category codes used across all invoice lines, charges, and discounts.

func (*Invoice) GetType added in v0.200.0

func (inv *Invoice) GetType() cbc.Key

GetType provides the invoice type as part of the tax.ScenarioDocument interface.

func (*Invoice) Invert added in v0.40.0

func (inv *Invoice) Invert() error

Invert effectively reverses the invoice by inverting the sign of all quantity or amount values. Caution should be taken when using this method as advances will also be inverted, while payment terms will remain the same, which could be confusing if no further modifications are made. After inverting the invoice is recalculated and any differences will raise an error.

func (Invoice) JSONSchemaExtend added in v0.38.0

func (inv Invoice) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Invoice) Normalize added in v0.200.0

func (inv *Invoice) Normalize(normalizers tax.Normalizers)

Normalize is run as part of the Calculate method to ensure that the invoice is in a consistent state before calculations are performed. This will leverage any add-ons alongside the tax regime.

func (*Invoice) RemoveIncludedTaxes added in v0.25.2

func (inv *Invoice) RemoveIncludedTaxes() error

RemoveIncludedTaxes is a special function that will go through all prices which may include the tax included in the invoice, and remove them.

This method will call "Calculate" on the invoice automatically after removing the taxes.

If after removing taxes the totals don't match, a rounding error will be added to the invoice totals. In most scenarios this shouldn't be more than a cent or two.

This method will replace the invoice contents in place, or return an error.

func (*Invoice) Replicate added in v0.75.0

func (inv *Invoice) Replicate() error

Replicate modifies the invoice's fields to ensure that it can be used as part of a replication process. A replicated invoice is one that contains the same base details like supplier, customer, lines, etc., but with updated identifiers and dates.

func (*Invoice) ScenarioSummary deprecated added in v0.38.0

func (inv *Invoice) ScenarioSummary() *tax.ScenarioSummary

ScenarioSummary determines a summary of the tax scenario for the invoice based on the document type and tax tags.

Deprecated: tax regimes should be updated to automatically apply all the required extensions and meta-data to the invoice itself. This method will still be needed until all regimes have transitioned to the new approach.

func (*Invoice) UNTDID1001 added in v0.38.0

func (inv *Invoice) UNTDID1001() cbc.Code

UNTDID1001 provides the official code number assigned with the Invoice type.

func (*Invoice) UnmarshalJSON added in v0.200.0

func (inv *Invoice) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface and provides any data migrations that might be required.

type Line

type Line struct {
	uuid.Identify
	// Line number inside the parent (calculated)
	Index int `json:"i" jsonschema:"title=Index" jsonschema_extras:"calculated=true"`
	// Number of items
	Quantity num.Amount `json:"quantity" jsonschema:"title=Quantity"`
	// Single identifier provided by the supplier for an object on which the
	// line item is based and is not considered a universal identity. Examples
	// include a subscription number, telephone number, meter point, etc.
	// Utilize the label property to provide a description of the identifier.
	Identifier *org.Identity `json:"identifier,omitempty" jsonschema:"title=Identifier"`
	// A period of time relevant to when the service or item is delivered.
	Period *cal.Period `json:"period,omitempty" jsonschema:"title=Period"`
	// Order reference for a specific line within a purchase order provided by the buyer.
	Order cbc.Code `json:"order,omitempty" jsonschema:"title=Order Reference"`
	// Buyer accounting reference cost code to associate with the line.
	Cost cbc.Code `json:"cost,omitempty" jsonschema:"title=Cost Reference"`
	// Details about the item, service or good, that is being sold
	Item *org.Item `json:"item" jsonschema:"title=Item"`
	// Breakdown of the line item for more detailed information. The sum of all lines
	// will be used for the item price.
	Breakdown []*SubLine `json:"breakdown,omitempty" jsonschema:"title=Breakdown"`
	// Result of quantity multiplied by the item's price (calculated)
	Sum *num.Amount `json:"sum,omitempty" jsonschema:"title=Sum" jsonschema_extras:"calculated=true"`
	// Discounts applied to this line
	Discounts []*LineDiscount `json:"discounts,omitempty" jsonschema:"title=Discounts"`
	// Charges applied to this line
	Charges []*LineCharge `json:"charges,omitempty" jsonschema:"title=Charges"`
	// Map of taxes to be applied and used in the invoice totals
	Taxes tax.Set `json:"taxes,omitempty" jsonschema:"title=Taxes"`
	// Total line amount after applying discounts to the sum (calculated).
	Total *num.Amount `json:"total,omitempty" jsonschema:"title=Total"  jsonschema_extras:"calculated=true"`

	// List of substituted lines. Useful for deliveries or corrective documents in order
	// to indicate to the recipient which of the requested lines are being replaced.
	// This is for purely informative purposes, and will not be used for calculations.
	Substituted []*SubLine `json:"substituted,omitempty" jsonschema:"title=Substituted"`

	// Seller of the item if different from the supplier or ordering seller. This can be
	// useful for marketplace or drop-ship scenarios in locations that require the
	// original seller to be indicated.
	Seller *org.Party `json:"seller,omitempty" jsonschema:"title=Seller"`

	// Set of specific notes for this line that may be required for
	// clarification.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Extension codes that apply to the line
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
}

Line is a single row in an invoice.

func (*Line) GetTaxes added in v0.20.0

func (l *Line) GetTaxes() tax.Set

GetTaxes responds with the array of tax rates applied to this line. This implements the tax.TaxableLine interface.

func (*Line) GetTotal

func (l *Line) GetTotal() num.Amount

GetTotal provides the final total for this line, excluding any tax calculations. This implements the tax.TaxableLine interface.

func (*Line) Normalize added in v0.200.0

func (l *Line) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the line and embedded objects using the provided list of normalizers.

type LineCharge added in v0.13.0

type LineCharge struct {
	// Key for grouping or identifying charges for tax purposes. A suggested list of
	// keys is provided, but these are for reference only and may be extended by
	// the issuer.
	Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
	// Reference or ID for this charge defined by the issuer
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Text description as to why the charge was applied
	Reason string `json:"reason,omitempty" jsonschema:"title=Reason"`
	// Base for percent calculations instead of the line's sum
	Base *num.Amount `json:"base,omitempty" jsonschema:"title=Base"`
	// Percentage of base or parent line's sum
	Percent *num.Percentage `json:"percent,omitempty" jsonschema:"title=Percent"`
	// Quantity of units to apply the charge to when using the rate instead of
	// the line's quantity.
	Quantity *num.Amount `json:"quantity,omitempty" jsonschema:"title=Quantity"`
	// Unit to associate with the quantity when using the rate.
	Unit org.Unit `json:"unit,omitempty" jsonschema:"title=Unit"`
	// Rate defines a price per unit to use instead of the percentage.
	Rate *num.Amount `json:"rate,omitempty" jsonschema:"title=Rate"`
	// Fixed or resulting charge amount to apply (calculated if percent present).
	Amount num.Amount `json:"amount" jsonschema:"title=Amount" jsonschema_extras:"calculated=true"`
	// Extension codes that apply to the charge
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
}

LineCharge represents an amount added to the line, and will be applied before taxes.

func CleanLineCharges added in v0.204.1

func CleanLineCharges(lines []*LineCharge) []*LineCharge

CleanLineCharges removes any empty charges from the list.

func (*LineCharge) IsEmpty added in v0.204.1

func (lc *LineCharge) IsEmpty() bool

IsEmpty returns true if the charge is empty.

func (LineCharge) JSONSchemaExtend added in v0.204.0

func (LineCharge) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend adds the charge key definitions to the schema.

func (*LineCharge) Normalize added in v0.204.0

func (lc *LineCharge) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the charge and embedded objects using the provided list of normalizers.

type LineDiscount added in v0.13.0

type LineDiscount struct {
	// Key for identifying the type of discount being applied.
	Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
	// Code or reference for this discount defined by the issuer
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Text description as to why the discount was applied
	Reason string `json:"reason,omitempty" jsonschema:"title=Reason"`
	// Base for percent calculations instead of the line's sum.
	Base *num.Amount `json:"base,omitempty" jsonschema:"title=Base"`
	// Percentage to apply to the base or line sum to calculate the discount amount
	Percent *num.Percentage `json:"percent,omitempty" jsonschema:"title=Percent"`
	// Fixed discount amount to apply (calculated if percent present)
	Amount num.Amount `json:"amount" jsonschema:"title=Amount" jsonschema_extras:"calculated=true"`
	// Extension codes that apply to the discount
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
}

LineDiscount represents an amount deducted from the line, and will be applied before taxes.

func CleanLineDiscounts added in v0.204.1

func CleanLineDiscounts(lines []*LineDiscount) []*LineDiscount

CleanLineDiscounts removes any empty discounts from the list.

func (*LineDiscount) IsEmpty added in v0.204.1

func (ld *LineDiscount) IsEmpty() bool

IsEmpty returns true if the discount is empty.

func (LineDiscount) JSONSchemaExtend added in v0.204.0

func (LineDiscount) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend adds the discount key definitions to the schema.

func (*LineDiscount) Normalize added in v0.204.0

func (ld *LineDiscount) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the discount and embedded objects using the provided list of normalizers.

type Order added in v0.211.0

type Order struct {
	tax.Regime
	tax.Addons
	tax.Tags
	uuid.Identify

	// Type of the order.
	Type cbc.Key `json:"type,omitempty" jsonschema:"title=Type"`
	// Series is used to identify groups of orders by date, business area, project,
	// type, customer, a combination of any, or other company specific data.
	// If the output format does not support the series as a separate field, it will be
	// prepended to the code for presentation with a dash (`-`) for separation.
	Series cbc.Code `json:"series,omitempty" jsonschema:"title=Series"`
	// Code is a sequential identifier that uniquely identifies the order. The code can
	// be left empty initially, but is **required** to **sign** the document.
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// When the invoice was created.
	IssueDate cal.Date `json:"issue_date" jsonschema:"title=Issue Date" jsonschema_extras:"calculated=true"`
	// IssueTime is an optional field that may be useful to indicate the time of day when
	// the order was issued. Some regions and formats may require this field to be set.
	// An empty string will be automatically updated to reflect the current time, otherwise
	// the field can be left with a nil value.
	IssueTime *cal.Time `json:"issue_time,omitempty" jsonschema:"title=Issue Time" jsonschema_extras:"calculated=true"`
	// Date when the operation defined by the invoice became effective.
	OperationDate *cal.Date `json:"op_date,omitempty" jsonschema:"title=Operation Date"`
	// When the taxes of this invoice become accountable, if none set, the issue date is used.
	ValueDate *cal.Date `json:"value_date,omitempty" jsonschema:"title=Value Date"`
	// Currency for all invoice totals.
	Currency currency.Code `json:"currency" jsonschema:"title=Currency" jsonschema_extras:"calculated=true"`
	// Exchange rates to be used when converting the invoices monetary values into other currencies.
	ExchangeRates []*currency.ExchangeRate `json:"exchange_rates,omitempty" jsonschema:"title=Exchange Rates"`

	// The identification of contracts.
	Contracts []*org.DocumentRef `json:"contracts,omitempty" jsonschema:"title=Contracts"`
	// Key information regarding previous order documents.
	Preceding []*org.DocumentRef `json:"preceding,omitempty" jsonschema:"title=Preceding Details"`

	// Additional codes, IDs, SKUs, or other regional or custom identifiers that may be used to identify the order.
	Identities []*org.Identity `json:"identities,omitempty" jsonschema:"title=Identities"`
	// Period of time in which the order is valid.
	Period *cal.Period `json:"period,omitempty" jsonschema:"title=Period"`

	// Special tax configuration for billing.
	Tax *Tax `json:"tax,omitempty" jsonschema:"title=Tax"`

	// The entity supplying the goods or services and usually responsible for paying taxes.
	Supplier *org.Party `json:"supplier" jsonschema:"title=Supplier"`
	// Legal entity receiving the goods or services, may be nil in certain circumstances such as simplified invoices.
	Customer *org.Party `json:"customer,omitempty" jsonschema:"title=Customer"`
	// Party who is responsible for issuing payment, if not the same as the customer.
	Buyer *org.Party `json:"buyer,omitempty" jsonschema:"title=Buyer"`
	// Seller is the party liable to pay taxes on the transaction if not the same as the supplier.
	Seller *org.Party `json:"seller,omitempty" jsonschema:"title=Seller"`

	// List of lines representing each of the items to be ordered.
	Lines []*Line `json:"lines,omitempty" jsonschema:"title=Lines"`
	// Discounts or allowances applied to order totals
	Discounts []*Discount `json:"discounts,omitempty" jsonschema:"title=Discounts"`
	// Charges or surcharges applied to order totals
	Charges []*Charge `json:"charges,omitempty" jsonschema:"title=Charges"`

	// Information on when, how, and to whom a final invoice would be paid.
	Payment *PaymentDetails `json:"payment,omitempty" jsonschema:"title=Payment Details"`
	// Specific details on delivery of the goods to copy to the final invoice.
	Delivery *DeliveryDetails `json:"delivery,omitempty" jsonschema:"title=Delivery Details"`

	// Summary of all the order totals, including taxes (calculated).
	Totals *Totals `json:"totals,omitempty" jsonschema:"title=Totals" jsonschema_extras:"calculated=true"`

	// Unstructured information that is relevant to the order, such as correction or additional
	// legal details.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Additional complementary objects that add relevant information to the order.
	Complements []*schema.Object `json:"complements,omitempty" jsonschema:"title=Complements"`

	// Additional semi-structured data that doesn't fit into the body of the order.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`

	// Attachments provide additional information or supporting documents that are not included
	// in the main document. It is important that attachments are not used for alternative
	// versions of the PDF, for that, see "links" inside the envelope headers.
	Attachments []*org.Attachment `json:"attachments,omitempty" jsonschema:"title=Attachments"`
}

Order documents are used for the initial part of a order-to-invoice process where the buyer requests goods or services from the seller.

func (*Order) Calculate added in v0.211.0

func (ord *Order) Calculate() error

Calculate performs all the normalizations and calculations required for the order totals and taxes. If the original order only includes partial calculations, this will figure out what's missing.

func (*Order) CanSign added in v0.400.0

func (ord *Order) CanSign() bool

CanSign returns a boolean indicating whether the order is ready to be signed or not.

func (*Order) ConvertInto added in v0.211.0

func (ord *Order) ConvertInto(cur currency.Code) (*Order, error)

ConvertInto will use the defined exchange rates in the order to convert all the prices into the given currency.

The intent of this method is help convert the order amounts when the destination is unable or unwilling to handle the current currency. This is typically the case with tax related reports or declarations.

The method will return a new order with all the amounts converted into the given currency or an error if the conversion is not possible.

Conversion is done by first exchanging the lowest common amounts to the destination currency, then recalculating the totals.

func (Order) JSONSchemaExtend added in v0.211.0

func (ord Order) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Order) Normalize added in v0.211.0

func (ord *Order) Normalize(normalizers tax.Normalizers)

Normalize is run as part of the Calculate method to ensure that the order is in a consistent state before calculations are performed. This will leverage any add-ons alongside the tax regime.

func (*Order) Replicate added in v0.304.0

func (ord *Order) Replicate() error

Replicate modifies the order's fields to ensure that it can be used as part of a replication process. A replicated order is one that contains the same base details like supplier, customer, lines, etc., but with updated identifiers and dates.

type Ordering

type Ordering struct {
	// Identifier assigned by the customer or buyer for internal routing purposes.
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Any additional Codes, IDs, SKUs, or other regional or custom
	// identifiers that may be used to identify the order.
	Identities []*org.Identity `json:"identities,omitempty" jsonschema:"title=Identities"`
	// Buyer accounting reference cost code associated with the document.
	Cost cbc.Code `json:"cost,omitempty" jsonschema:"title=Cost,example=1287:65464"`
	// Period of time that the document refers to often used in addition to the details
	// provided in the individual line items.
	Period *cal.Period `json:"period,omitempty" jsonschema:"title=Period"`
	// Party who is responsible for issuing payment, if not the same as the customer.
	Buyer *org.Party `json:"buyer,omitempty" jsonschema:"title=Buyer"`
	// Seller is the party liable to pay taxes on the transaction if not the same as the supplier.
	Seller *org.Party `json:"seller,omitempty" jsonschema:"title=Seller"`
	// Issuer represents a third party responsible for issuing the document, but is not
	// responsible for tax. Some tax regimes and formats require this field.
	Issuer *org.Party `json:"issuer,omitempty" jsonschema:"title=Issuer"`
	// Projects this document refers to.
	Projects []*org.DocumentRef `json:"projects,omitempty" jsonschema:"title=Projects"`
	// The identification of contracts.
	Contracts []*org.DocumentRef `json:"contracts,omitempty" jsonschema:"title=Contracts"`
	// Purchase orders issued by the customer or buyer.
	Purchases []*org.DocumentRef `json:"purchases,omitempty" jsonschema:"title=Purchase Orders"`
	// Sales orders issued by the supplier or seller.
	Sales []*org.DocumentRef `json:"sales,omitempty" jsonschema:"title=Sales Orders"`
	// Receiving Advice.
	Receiving []*org.DocumentRef `json:"receiving,omitempty" jsonschema:"title=Receiving Advice"`
	// Despatch advice.
	Despatch []*org.DocumentRef `json:"despatch,omitempty" jsonschema:"title=Despatch Advice"`
	// Tender advice, the identification of the call for tender or lot the document relates to.
	Tender []*org.DocumentRef `json:"tender,omitempty" jsonschema:"title=Tender Advice"`
}

Ordering provides additional information about the ordering process including references to other documents and alternative parties involved in the order-to-delivery process.

func (*Ordering) Normalize added in v0.200.0

func (o *Ordering) Normalize(normalizers tax.Normalizers)

Normalize attempts to clean and normalize the Ordering data.

type Payment

type Payment struct {
	tax.Regime
	tax.Addons
	tax.Tags
	uuid.Identify

	// Type of payment document being issued.
	Type cbc.Key `json:"type" jsonschema:"title=Type" jsonschema_extras:"calculated=true"`
	// Details on how the payment was made based on the original instructions.
	Method *pay.Instructions `json:"method,omitempty" jsonschema:"title=Method"`
	// Series is used to identify groups of payments by date, business area, project,
	// type, customer, a combination of any, or other company specific data.
	// If the output format does not support the series as a separate field, it will be
	// prepended to the code for presentation with a dash (`-`) for separation.
	Series cbc.Code `json:"series,omitempty" jsonschema:"title=Series"`
	// Code is a sequential identifier that uniquely identifies the payment. The code can
	// be left empty initially, but is **required** to **sign** the document.
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// When the payment was issued.
	IssueDate cal.Date `json:"issue_date" jsonschema:"title=Issue Date" jsonschema_extras:"calculated=true"`
	// IssueTime is an optional field that may be useful to indicate the time of day when
	// the payment was issued.
	IssueTime *cal.Time `json:"issue_time,omitempty" jsonschema:"title=Issue Time" jsonschema_extras:"calculated=true"`
	// When the taxes of this payment become accountable, if none set, the issue date is assumed.
	ValueDate *cal.Date `json:"value_date,omitempty" jsonschema:"title=Value Date"`
	// Currency for all payment totals.
	Currency currency.Code `json:"currency" jsonschema:"title=Currency" jsonschema_extras:"calculated=true"`
	// Exchange rates to be used when converting the payment's monetary values into other currencies.
	ExchangeRates []*currency.ExchangeRate `json:"exchange_rates,omitempty" jsonschema:"title=Exchange Rates"`
	// Extensions for additional codes that may be required.
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`

	// Key information regarding previous versions of this document.
	Preceding []*org.DocumentRef `json:"preceding,omitempty" jsonschema:"title=Preceding Details"`

	// The taxable entity who is responsible for supplying goods or services.
	Supplier *org.Party `json:"supplier" jsonschema:"title=Supplier"`
	// Legal entity that receives the goods or services.
	Customer *org.Party `json:"customer,omitempty" jsonschema:"title=Customer"`
	// Legal entity that receives the payment if not the supplier.
	Payee *org.Party `json:"payee,omitempty" jsonschema:"title=Payee"`

	// List of documents that are being paid for.
	Lines []*PaymentLine `json:"lines" jsonschema:"title=Lines"`

	// Ordering allows for additional information about the ordering process including references
	// to other documents and alternative parties involved in the order-to-delivery process.
	Ordering *Ordering `json:"ordering,omitempty" jsonschema:"title=Ordering"`

	// Total amount to be paid in this payment, either positive or negative according to the
	// line types and totals. Calculated automatically.
	Total num.Amount `json:"total" jsonschema:"title=Total,calculated=true"`

	// Unstructured information that is relevant to the payment, such as correction or additional
	// legal details.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Additional complementary objects that add relevant information to the payment.
	Complements []*schema.Object `json:"complements,omitempty" jsonschema:"title=Complements"`

	// Additional semi-structured data that doesn't fit into the body of the invoice.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

A Payment is used to link an invoice or invoices with a payment transaction.

func (*Payment) Calculate added in v0.211.0

func (pmt *Payment) Calculate() error

Calculate performs all the normalizations and calculations required for the invoice totals and taxes. If the original invoice only includes partial calculations, this will figure out what's missing.

func (*Payment) CanSign added in v0.400.0

func (pmt *Payment) CanSign() bool

CanSign returns a boolean indicating whether the payment is ready to be signed or not.

func (Payment) JSONSchemaExtend added in v0.211.0

func (pmt Payment) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Payment) Normalize added in v0.200.0

func (pmt *Payment) Normalize(normalizers tax.Normalizers)

Normalize is run as part of the Calculate method to ensure that the invoice is in a consistent state before calculations are performed. This will leverage any add-ons alongside the tax regime.

func (*Payment) Replicate added in v0.304.0

func (pmt *Payment) Replicate() error

Replicate modifies the payment's fields to ensure that it can be used as part of a replication process. A replicated payment is one that contains the same base details like supplier, customer, lines, etc., but with updated identifiers and dates.

type PaymentDetails added in v0.211.0

type PaymentDetails struct {
	// The party responsible for receiving payment of the invoice, if not the supplier.
	Payee *org.Party `json:"payee,omitempty" jsonschema:"title=Payee"`
	// Payment terms or conditions.
	Terms *pay.Terms `json:"terms,omitempty" jsonschema:"title=Terms"`
	// Any amounts that have been paid in advance and should be deducted from the amount due.
	Advances []*pay.Advance `json:"advances,omitempty" jsonschema:"title=Advances"`
	// Details on how payment should be made.
	Instructions *pay.Instructions `json:"instructions,omitempty" jsonschema:"title=Instructions"`
}

PaymentDetails contains details as to how the invoice should be paid.

func (*PaymentDetails) Normalize added in v0.211.0

func (p *PaymentDetails) Normalize(normalizers tax.Normalizers)

Normalize will try to normalize the payment's data.

func (*PaymentDetails) ResetAdvances added in v0.211.0

func (p *PaymentDetails) ResetAdvances()

ResetAdvances clears the advances list.

type PaymentLine added in v0.211.0

type PaymentLine struct {
	uuid.Identify

	// Line number within the parent document (automatically calculated)
	Index int `json:"i" jsonschema:"title=Index" jsonschema_extras:"calculated=true"`

	// Indicates whether this payment is a refund of a previous payment, effectively reversing
	// the flow of funds between the supplier and customer or their representatives.
	Refund bool `json:"refund,omitempty" jsonschema:"title=Refund"`

	// Reference to the document being paid
	Document *org.DocumentRef `json:"document,omitempty" jsonschema:"title=Document"`

	// When making multiple payments for a single document, this specifies the
	// installment number for this payment line.
	Installment int `json:"installment,omitempty" jsonschema:"title=Installment"`

	// Additional human readable description of the payment line which may be useful for
	// explaining the purpose or special conditions. Notes should be used for more
	// formal comments.
	Description string `json:"description,omitempty" jsonschema:"title=Description"`

	// Payable reflects the amount of the document that is payable. This will be
	// calculated from the embedded document's amount automatically and converted
	// to the currency of the document.
	Payable *num.Amount `json:"payable,omitempty" jsonschema:"title=Payable"`

	// Amount already paid in previous installments, which may be required
	// by some tax regimes or specific use cases.
	Advances *num.Amount `json:"advances,omitempty" jsonschema:"title=Advances"`

	// Amount of the total payment allocated to the referenced document.
	Amount num.Amount `json:"amount" jsonschema:"title=Amount"`

	// Due reflects how much still needs to be paid
	Due *num.Amount `json:"due,omitempty" jsonschema:"title=Due,calculated=true"`

	// Tax contains a breakdown of the taxes that will be applied to this payment line
	// after taking into account currency conversion and the relative amounts.
	Tax *tax.Total `json:"tax,omitempty" jsonschema:"title=Tax"`

	// Additional notes specific to this line item for clarification purposes
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`
}

PaymentLine defines the details of a line item in a payment document.

type Reason added in v0.401.0

type Reason struct {
	// Key helps identify the reason.
	Key cbc.Key `json:"key" jsonschema:"title=Key"`

	// Description contains a simple text that describes the reason why the
	// original document was not processed.
	Description string `json:"description,omitempty" jsonschema:"title=Description"`

	// Condition provides additional details with codes about what has gone
	// wrong with the incoming document.
	Conditions []*Condition `json:"conditions,omitempty" jsonschema:"title=Conditions"`

	// Extensions for local or format focussed data
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`
}

Reason helps the recipient of a message determine why they are receiving it.

func (Reason) JSONSchemaExtend added in v0.401.0

func (Reason) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Reason) Normalize added in v0.401.0

func (r *Reason) Normalize(normalizers tax.Normalizers)

Normalize normalizes the reason's sub-objects.

type Status added in v0.401.0

type Status struct {
	tax.Regime    `json:",inline"`
	tax.Addons    `json:",inline"`
	uuid.Identify `json:",inline"`

	// Type of status being reported (e.g. "system" for internal events).
	Type cbc.Key `json:"type" jsonschema:"title=Type"`

	// IssueDate is the date when the status is to be considered effective.
	IssueDate cal.Date `json:"issue_date" jsonschema:"title=Issue Date"`

	// IssueTime is used when extra precision is required to determine when exactly
	// the status was issued.
	IssueTime *cal.Time `json:"issue_time,omitempty" jsonschema:"title=Issue Time"`

	// Series is an optional code to group related status events together.
	Series cbc.Code `json:"series,omitempty" jsonschema:"title=Series"`

	// Code provides a way to identify the specific status event being reported.
	Code cbc.Code `json:"code" jsonschema:"title=Code"`

	// Ext provides additional structured data specific to the regime or addon.
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`

	// Ordering provides links to related documents and details that may have occurred
	// before this status was created.
	Ordering *Ordering `json:"ordering,omitempty" jsonschema:"title=Ordering"`

	// Supplier represents the entity supplying the goods or services in the
	// original transaction and may not be the issuer of the document.
	Supplier *org.Party `json:"supplier" jsonschema:"title=Supplier"`

	// Customer is optional and describes the recipient of the original
	// services. In the case of a local or system event, this will be empty.
	Customer *org.Party `json:"customer,omitempty" jsonschema:"title=Customer"`

	// Issuer represents an intermediary acting on behalf of either the supplier
	// or customer in order to provide a status update, this is useful
	// specifically if only the third party is registered on a network.
	// (Optional).
	Issuer *org.Party `json:"issuer,omitempty" jsonschema:"title=Issuer"`

	// Recipient represents another intermediary responsible for receiving the
	// event when the supplier or customer do not have networking capabilities.
	// May also be a tax agency in a five corner model.
	// (Optional).
	Recipient *org.Party `json:"recipient,omitempty" jsonschema:"title=Recipient"`

	// Lines contain the main payload of the message used to describe individual
	// documents which have a status.
	Lines []*StatusLine `json:"lines" jsonschema:"title=Lines"`

	// Notes for additional details about the event.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Meta contains unstructured data useful for internal tools.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

Status represents a system or business event that needs to be recorded for compliance purposes. It is intentionally minimal for now; additional fields will be added as more use cases are supported.

func (*Status) Calculate added in v0.401.0

func (st *Status) Calculate() error

Calculate performs all the normalizations and calculations required for the status document.

func (*Status) CanSign added in v0.401.0

func (st *Status) CanSign() bool

CanSign returns a boolean indicating whether the status is ready to be signed or not.

func (Status) JSONSchemaExtend added in v0.401.0

func (Status) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*Status) Normalize added in v0.401.0

func (st *Status) Normalize(normalizers tax.Normalizers)

Normalize is run as part of the Calculate method to ensure that the status is in a consistent state. This will leverage any add-ons alongside the tax regime.

type StatusLine added in v0.401.0

type StatusLine struct {
	// Position of the row inside the message, determined automatically.
	Index int `json:"index" jsonschema:"title=Index"`

	// Status Key indicates the situation of the document
	Key cbc.Key `json:"key" jsonschema:"title=Key"`

	// When this row should be considered effective
	Date *cal.Date `json:"date,omitempty" jsonschema:"title=Date"`

	// Document reference or details about the document that needs to be looked
	// at.
	Doc *org.DocumentRef `json:"doc,omitempty" jsonschema:"title=Document"`

	// Description includes a human readable description that explains the
	// reason for the current status, if necessary.
	Description string `json:"description,omitempty" jsonschema:"title=Description"`

	// Reasons define an array of reason objects that help the recipient
	// determine why the status was provided.
	Reasons []*Reason `json:"reasons,omitempty" jsonschema:"title=Reasons"`

	// Actions contains an array of actions that should be carried out by the
	// recipient of the message. These are suggestions.
	Actions []*Action `json:"actions,omitempty" jsonschema:"title=Actions"`

	// Extensions for local or format focussed data
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`

	// Complements contain regime/addon specific payload data.
	Complements []*schema.Object `json:"complements,omitempty" jsonschema:"title=Complements"`

	// Additional data specific for the source system.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

StatusLine represents a single row inside a message, that describes the situation of another business document.

func (StatusLine) JSONSchemaExtend added in v0.401.0

func (StatusLine) JSONSchemaExtend(js *jsonschema.Schema)

JSONSchemaExtend extends the schema with additional property details

func (*StatusLine) Normalize added in v0.401.0

func (sl *StatusLine) Normalize(normalizers tax.Normalizers)

Normalize normalizes the status line's sub-objects.

type SubLine added in v0.211.0

type SubLine struct {
	uuid.Identify
	// Line number inside the parent (calculated)
	Index int `json:"i" jsonschema:"title=Index" jsonschema_extras:"calculated=true"`
	// Number of items
	Quantity num.Amount `json:"quantity" jsonschema:"title=Quantity"`
	// Single identifier provided by the supplier for an object on which the
	// line item is based and is not considered a universal identity. Examples
	// include a subscription number, telephone number, meter point, etc.
	// Utilize the label property to provide a description of the identifier.
	Identifier *org.Identity `json:"identifier,omitempty" jsonschema:"title=Identifier"`
	// A period of time relevant to when the service or item is delivered.
	Period *cal.Period `json:"period,omitempty" jsonschema:"title=Period"`
	// Order reference for a specific line within a purchase order provided by the buyer.
	Order cbc.Code `json:"order,omitempty" jsonschema:"title=Order Reference"`
	// Buyer accounting reference cost code to associate with the line.
	Cost cbc.Code `json:"cost,omitempty" jsonschema:"title=Cost Reference"`
	// Details about the item, service or good, that is being sold
	Item *org.Item `json:"item" jsonschema:"title=Item"`
	// Result of quantity multiplied by the item's price (calculated)
	Sum *num.Amount `json:"sum,omitempty" jsonschema:"title=Sum" jsonschema_extras:"calculated=true"`
	// Discounts applied to this sub-line
	Discounts []*LineDiscount `json:"discounts,omitempty" jsonschema:"title=Discounts"`
	// Charges applied to this sub-line
	Charges []*LineCharge `json:"charges,omitempty" jsonschema:"title=Charges"`
	// Total sub-line amount after applying discounts to the sum (calculated).
	Total *num.Amount `json:"total,omitempty" jsonschema:"title=Total"  jsonschema_extras:"calculated=true"`
	// Set of specific notes for this sub-line that may be required for
	// clarification.
	Notes []*org.Note `json:"notes,omitempty" jsonschema:"title=Notes"`
}

SubLine provides a simplified line that can be embedded inside other lines to provide a more detailed breakdown of the items being sold or substituted.

func CleanSubLines added in v0.306.0

func CleanSubLines(sls []*SubLine) []*SubLine

CleanSubLines removes any nil or empty sub-lines from the list.

func (*SubLine) IsEmpty added in v0.306.0

func (sl *SubLine) IsEmpty() bool

IsEmpty returns true if the sub-line is empty.

func (*SubLine) Normalize added in v0.211.0

func (sl *SubLine) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the subline and embedded objects using the provided list of normalizers.

type Tax added in v0.20.0

type Tax struct {
	// Category of the tax already included in the line item prices, especially
	// useful for B2C retailers with customers who prefer final prices inclusive of
	// tax.
	PricesInclude cbc.Code `json:"prices_include,omitempty" jsonschema:"title=Prices Include"`

	// Rounding model used to perform tax calculations on the invoice. This
	// will be configured automatically based on the tax regime, or
	// `sum-then-round` by default, but you can override here if needed.
	// Use with caution, as some conversion tools may make assumptions about
	// the rounding model used.
	Rounding cbc.Key `json:"rounding,omitempty" jsonschema:"title=Rounding Model"`

	// Point is a code that identifies the event which triggers the tax liability,
	// such as invoice issuance, delivery of goods, or receipt of payment.
	Point cbc.Key `json:"point,omitempty" jsonschema:"title=Point"`

	// Additional extensions that are applied to the invoice as a whole as opposed to specific
	// sections.
	Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"`

	// Notes contains tax-related notes, typically used for exemption reasons
	// or other tax-specific explanations associated with particular tax categories.
	Notes []*tax.Note `json:"notes,omitempty" jsonschema:"title=Notes"`

	// Any additional data that may be required for processing, but should never
	// be relied upon by recipients.
	Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
	// contains filtered or unexported fields
}

Tax defines a summary of the taxes which may be applied to an invoice.

func (*Tax) GetExt added in v0.220.2

func (t *Tax) GetExt(key cbc.Key) cbc.Code

GetExt is a convenience method to retrieve an extension value while providing nil checks on the tax object.

func (*Tax) HasExt added in v0.220.2

func (t *Tax) HasExt(key cbc.Key) bool

HasExt is a convenience method to check for an extension value while providing nil checks on the tax object.

func (Tax) JSONSchemaExtend added in v0.57.0

func (t Tax) JSONSchemaExtend(schema *jsonschema.Schema)

JSONSchemaExtend is used to add the additional options to the JSON schema.

func (*Tax) MergeExtensions added in v0.207.0

func (t *Tax) MergeExtensions(ext tax.Extensions) *Tax

MergeExtensions makes it easier to add extensions to the tax object by automatically handling nil data, and replying a new updated instance.

func (*Tax) MergeNotes added in v0.309.0

func (t *Tax) MergeNotes(notes ...*tax.Note) *Tax

MergeNotes adds a tax note to the tax object, automatically handling nil data, and returning a new updated instance.

func (*Tax) Normalize added in v0.200.0

func (t *Tax) Normalize(normalizers tax.Normalizers)

Normalize performs normalization on the tax and embedded objects using the provided list of normalizers.

func (*Tax) UnmarshalJSON added in v0.200.0

func (t *Tax) UnmarshalJSON(data []byte) error

UnmarshalJSON helps migrate the desc field to description.

type Totals

type Totals struct {
	// Total of all line item amounts.
	Sum num.Amount `json:"sum" jsonschema:"title=Sum"`
	// Total of all discounts applied at the document level.
	Discount *num.Amount `json:"discount,omitempty" jsonschema:"title=Discount"`
	// Total of all charges applied at the document level.
	Charge *num.Amount `json:"charge,omitempty" jsonschema:"title=Charge"`
	// Total tax amount included in the prices, if prices are tax-inclusive.
	TaxIncluded *num.Amount `json:"tax_included,omitempty" jsonschema:"title=Tax Included"`
	// Net total amount after subtracting discounts and adding charges, excluding tax.
	Total num.Amount `json:"total" jsonschema:"title=Total"`
	// Detailed breakdown of all taxes applied to the invoice.
	Taxes *tax.Total `json:"taxes,omitempty" jsonschema:"title=Tax Totals"`
	// Total indirect tax amount to be applied to the invoice.
	Tax num.Amount `json:"tax,omitempty" jsonschema:"title=Tax"`
	// Final total amount after applying indirect taxes.
	TotalWithTax num.Amount `json:"total_with_tax" jsonschema:"title=Total with Tax"`
	// Total tax amount retained or withheld by the customer to be paid to the tax authority.
	RetainedTax *num.Amount `json:"retained_tax,omitempty" jsonschema:"title=Retained Tax"`
	// Adjustment amount applied to the invoice totals to meet rounding rules or expectations.
	Rounding *num.Amount `json:"rounding,omitempty" jsonschema:"title=Rounding"`
	// Final amount to be paid after retained taxes and rounding adjustments.
	Payable num.Amount `json:"payable" jsonschema:"title=Payable"`
	// Total amount already paid in advance by the customer.
	Advances *num.Amount `json:"advance,omitempty" jsonschema:"title=Advance"`
	// Remaining amount that needs to be paid.
	Due *num.Amount `json:"due,omitempty" jsonschema:"title=Due"`
}

Totals contains the summaries of all calculations for the invoice.

func (*Totals) Paid added in v0.200.0

func (t *Totals) Paid() bool

Paid is a convenience method to quickly determine if the invoice has been paid or not based on the total amount due.

type Tracking added in v0.211.0

type Tracking struct {
	// Code used for tracking
	Code cbc.Code `json:"code,omitempty" jsonschema:"title=Code"`
	// Website to access for more tracking details
	Website *org.Website `json:"website,omitempty" jsonschema:"title=Website"`
}

Tracking stores tracking information about a delivery.

Jump to

Keyboard shortcuts

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