bill

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 10 Imported by: 24

Documentation

Index

Constants

View Source
const (
	InvoiceType = "bill.Invoice"
)

Standard billing model types that can be incorporated into an envelope.

Variables

View Source
var UNTDID1001TypeCodeMap = map[TypeCode]string{
	PartialTypeCode:    "326",
	CommercialTypeCode: "380",
	SimplifiedTypeCode: "380",
	CorrectedTypeCode:  "384",
	CreditNoteTypeCode: "381",
	SelfBilledTypeCode: "389",
}

UNTDID1001CodeMap offers a way to convert the GOBL invoice type code into one supported by our subset of the UNTDID 1001 official list.

Functions

This section is empty.

Types

type Delivery

type Delivery struct {
	Receiver *org.Party `` /* 171-byte string literal not displayed */
}

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

type Invoice

type Invoice struct {
	UUID             *uuid.UUID             `` /* 139-byte string literal not displayed */
	Code             string                 `json:"code" jsonschema:"title=Code,description=Sequential code used to identify this invoice in tax declarations."`
	TypeCode         TypeCode               `` /* 130-byte string literal not displayed */
	Currency         currency.Code          `json:"currency" jsonschema:"title=Currency,description=Currency for all invoice totals."`
	ExchangeRates    currency.ExchangeRates `` /* 162-byte string literal not displayed */
	PricesIncludeTax bool                   `` /* 249-byte string literal not displayed */

	Preceding *Preceding `json:"preceding,omitempty" jsonschema:"title=Preceding Reference,description=Key information regarding a previous invoice."`

	IssueDate     *org.Date `json:"issue_date" jsonschema:"title=Issue Date,description=When the invoice was created."`
	OperationDate *org.Date `` /* 135-byte string literal not displayed */
	ValueDate     *org.Date `` /* 157-byte string literal not displayed */

	Supplier *org.Party `json:"supplier" jsonschema:"title=Supplier,description=The taxable entity supplying the goods or services."`
	Customer *org.Party `` /* 181-byte string literal not displayed */

	Lines   Lines   `json:"lines,omitempty" jsonschema:"title=Lines,description=The items sold to the customer."`
	Outlays Outlays `` /* 136-byte string literal not displayed */

	Totals *Totals `json:"totals" jsonschema:"title=Totals"`

	Ordering *Ordering `json:"ordering,omitempty" jsonschema:"title=Ordering Details"`
	Payment  *Payment  `json:"payment,omitempty" jsonschema:"title=Payment Details"`
	Delivery *Delivery `json:"delivery,omitempty" jsonschema:"title=Delivery Details"`

	Notes string   `` /* 145-byte string literal not displayed */
	Meta  org.Meta `` /* 136-byte string literal not displayed */
}

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(r region.Region) error

Calculate performs all the 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) Type

func (Invoice) Type() string

Type provides the body type used for mapping.

func (*Invoice) Validate

func (inv *Invoice) Validate(r region.Region) error

Validate checks to ensure the invoice is valid and contains all the information we need.

type Line

type Line struct {
	UUID     string        `json:"uuid,omitempty"`
	Index    int           `json:"i" jsonschema:"title=Index,description=Line number inside the invoice."`
	Quantity num.Amount    `json:"quantity"`
	Item     *org.Item     `json:"item"`
	Sum      num.Amount    `json:"sum" jsonschema:"title=Sum,description=Result of quantity multiplied by item price"`
	Discount *org.Discount `json:"discount,omitempty" jsonschema:"title=Discount,description=Discount applied to this line."`
	Taxes    tax.Rates     `json:"taxes,omitempty" jsonschema:"title=Taxes,description=List of taxes to be applied to the line in the invoice totals."`
	Total    num.Amount    `json:"total" jsonschema:"title=Total,description=Total line amount after applying discounts to the sum."`
}

Line is a single row in an invoice.

func (*Line) GetTaxRates

func (l *Line) GetTaxRates() tax.Rates

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

func (*Line) GetTotal

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

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

func (*Line) Validate

func (l *Line) Validate() error

Validate ensures the line contains everything required.

type Lines

type Lines []*Line

Lines holds an array of Line objects.

type Ordering

type Ordering struct {
	Seller *org.Party `` /* 126-byte string literal not displayed */
}

Ordering allows additional order details to be appended

type Outlay

type Outlay struct {
	UUID        string     `json:"uuid,omitempty"`
	Index       int        `json:"i" jsonschema:"title=Index,description=Line number inside the invoice, starting from 0."`
	Ref         string     `` /* 140-byte string literal not displayed */
	Description string     `json:"desc" jsonschema:"title=Description,description=Details on what the outlay was."`
	Paid        num.Amount `json:"paid" jsonschema:"title=Paid,description=Amount paid by the supplier."`
}

Outlay represents a expense that was paid for by the supplier and invoiced separately by the third party directly to the customer. Most suppliers will want to include the expenses of their providers as part of their own operational costs. However, outlays are common in countries like Spain, for example when an accountant or lawyer will pay for notary fees, but forward the invoice to the customer.

type Outlays

type Outlays []*Outlay

Outlays holds an array of Outlay objects used inside a billing document.

type Payment

type Payment struct {
	Terms   *pay.Terms    `json:"terms,omitempty" jsonschema:"title=Terms,description=Payment terms or conditions."`
	Methods []*pay.Method `` /* 130-byte string literal not displayed */
	Payer   *org.Party    `` /* 130-byte string literal not displayed */
}

Payment contains details as to how the invoice should be paid. TODO: Add terms here.

type Preceding

type Preceding struct {
	UUID      *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID,description=Preceding document's UUID if available can be useful for tracing."`
	Code      string     `json:"code" jsonschema:"title=Code,description=Identity code of the previous invoice."`
	IssueDate *org.Date  `json:"issue_date" jsonschema:"title=Issue Date,description=When the preceding invoices was issued."`
	Meta      org.Meta   `` /* 129-byte string literal not displayed */
}

Preceding allows for information to be provided about a previous invoice that this one will replace or subtract from. If this is used, the invoice type code will most likely need to be set to `corrected` or `credit-note`.

type Totals

type Totals struct {
	Sum      num.Amount `json:"sum" jsonschema:"title=Sum,description=Sum of all line item sums"`
	Discount num.Amount `json:"discount,omitempty" jsonschema:"title=Discount,description=Sum of all discounts applied to each line."`
	Total    num.Amount `json:"total,omitempty" jsonschema:"title=Total,description=Sum of all line sums minus the discounts."`
	Taxes    *tax.Total `` /* 144-byte string literal not displayed */
	Outlays  num.Amount `json:"outlays,omitempty" jsonschema:"title=Outlay Totals,description=Total paid in outlays that need to be reimbursed."`
	Payable  num.Amount `json:"payable" jsonschema:"title=Payable,description=Total amount to be paid after applying taxes."`
}

Totals contains the summaries of all calculations for the invoice.

type TypeCode

type TypeCode string

TypeCode defines the "Invoice Type Code" according to a subset of the UNTDID 1001 standard list.

const (
	CommercialTypeCode TypeCode = ""            // Commercial Invoice, default
	SimplifiedTypeCode TypeCode = "simplified"  // Simplified Invoice
	PartialTypeCode    TypeCode = "partial"     // Partial Invoice
	CorrectedTypeCode  TypeCode = "corrected"   // Corrected Invoice
	CreditNoteTypeCode TypeCode = "credit-note" // Credit Note
	SelfBilledTypeCode TypeCode = "self-billed" // Self Billed Invoice
)

Predefined list of the invoice type codes officially supported.

func (TypeCode) UNTDID1001

func (c TypeCode) UNTDID1001() string

UNTDID1001 provides the official code number assigned to the type.

func (TypeCode) Validate

func (c TypeCode) Validate() error

Validate is used to ensure the code provided is one of those we know about.

Jump to

Keyboard shortcuts

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