types

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfigPath string

Functions

This section is empty.

Types

type Address

type Address struct {
	Name     string `json:"name" yaml:"name"`
	Address  string `json:"address" yaml:"address"`
	Address2 string `json:"address2" yaml:"address2"`
	City     string `json:"city" yaml:"city"`
	State    string `json:"state" yaml:"state"`
	ZipCode  string `json:"zipCode" yaml:"zipCode"`
	Country  string `json:"country" yaml:"country"`
}

func (*Address) String

func (a *Address) String() string

func (*Address) Strings

func (a *Address) Strings() []string

type BankAccount

type BankAccount struct {
	*Address `json:",inline" yaml:",inline"`

	AccountNumber string `json:"accountNumber" yaml:"accountNumber"`
	RoutingNumber string `json:"routingNumber" yaml:"routingNumber"`
}

type Billable

type Billable struct {
	Alias       string  `json:"alias" yaml:"alias"`
	Description string  `json:"description" yaml:"description"`
	Quantity    float64 `json:"quantity" yaml:"quantity"`
	UnitPrice   float64 `json:"unitPrice" yaml:"unitPrice"`
	Discount    float64 `json:"discount" yaml:"discount"`
	Tax         float64 `json:"tax" yaml:"tax"`
}

Billable represents a billable item in an invoice.

func (*Billable) FormattedDiscount

func (b *Billable) FormattedDiscount() string

func (*Billable) FormattedQuantity

func (b *Billable) FormattedQuantity() string

func (*Billable) FormattedSubtotal

func (b *Billable) FormattedSubtotal(currency string) string

func (*Billable) FormattedTax

func (b *Billable) FormattedTax() string

func (*Billable) FormattedUnitPrice

func (b *Billable) FormattedUnitPrice(currency string) string

func (*Billable) Subtotal

func (b *Billable) Subtotal() float64

func (*Billable) Total

func (b *Billable) Total() float64

type BillableList

type BillableList []*Billable

func (BillableList) FormattedSubtotal

func (b BillableList) FormattedSubtotal(currency string) string

func (BillableList) FormattedTotal

func (b BillableList) FormattedTotal(currency string) string

func (BillableList) LongestDiscount

func (b BillableList) LongestDiscount() string

func (BillableList) LongestQuantity

func (b BillableList) LongestQuantity() string

func (BillableList) LongestSubtotal

func (b BillableList) LongestSubtotal(currency string) string

func (BillableList) LongestTax

func (b BillableList) LongestTax() string

func (BillableList) LongestUnitPrice

func (b BillableList) LongestUnitPrice(currency string) string

func (BillableList) Subtotal

func (b BillableList) Subtotal() float64

func (BillableList) Total

func (b BillableList) Total() float64

type BuildOutput

type BuildOutput string
const (
	BuildOutputPDF BuildOutput = "pdf"
)

type Builder

type Builder interface {
	// Builders can be used as readers after they have generated the invoice.
	io.ReadCloser

	// Set the font family to use when BuildInvoice is called.
	SetFontFamily(FontFamily)

	// Build an invoice with the given details
	BuildInvoice(*InvoiceDetails) error

	// Write the generated invoice to the given path
	WriteFile(path string) error

	// A convenience method for building an invoice and automatically
	// writing it to an output file.
	BuildAndWriteInvoice(info *InvoiceDetails, outpath string) error
}

Builder represents an invoice builder saving to various formats. Currently only PDF is implemented.

type Config

type Config struct {
	// The configuration for invoices
	Invoices InvoicesConfig `json:"invoices" yaml:"invoices"`
	// The entity issuing invoices
	Payee *Entity `json:"payee" yaml:"payee"`
	// Entities eligible for invoicing.
	Payers []*Entity `json:"payers" yaml:"payers"`
	// Items that can be added to invoices
	Billables BillableList `json:"billables" yaml:"billables"`
}

func (*Config) FormatInvoiceNumber

func (c *Config) FormatInvoiceNumber(num int) string

func (*Config) GetNextInvoiceNumber

func (c *Config) GetNextInvoiceNumber() int

type Entity

type Entity struct {
	*Address `json:",inline" yaml:",inline"`

	Alias          string       `json:"alias" yaml:"alias"`
	BankAccount    *BankAccount `json:"bankAccount" yaml:"bankAccount"`
	RegistrationNo string       `json:"registrationNo" yaml:"registrationNo"`
	Email          string       `json:"email" yaml:"email"`
	Currency       string       `json:"currency" yaml:"currency"`
}

func (*Entity) TextWidth

func (e *Entity) TextWidth() float64

type FontFamily

type FontFamily string
const (
	FontFamilyHack           FontFamily = "Hack"
	FontFamilyUbuntuMono     FontFamily = "UbuntuMono"
	FontFamilyAnonymousPro   FontFamily = "AnonymousPro"
	FontFamilyGoMono         FontFamily = "GoMono"
	FontFamilySpaceMono      FontFamily = "SpaceMono"
	FontFamilyLiberationMono FontFamily = "LiberationMono"
	FontFamilyLuxiMono       FontFamily = "LuxiMono"
)

func (FontFamily) String

func (f FontFamily) String() string

type InvoiceDetails

type InvoiceDetails struct {
	// The invoice number
	InvoiceNumber string
	// The date the invoice is being issued
	InvoiceDate time.Time
	// The date the invoice is due
	DueDate time.Time

	// The entity sending the invoice
	Payee *Entity
	// The entity responsible for paying the invoice
	Payer *Entity

	// The billable items in the invoice
	Items BillableList
}

InvoiceDetails represents the details required for building an invoice.

type InvoicesConfig

type InvoicesConfig struct {
	// A prefix appended to invoice numbers
	Prefix string `json:"prefix" yaml:"prefix"`
	// A directory to store invoices by default
	Directory string `json:"directory" yaml:"directory"`
	// The font family to use for invoices
	FontFamily FontFamily `json:"fontFamily" yaml:"fontFamily"`
	// The number of zeroes to pad invoice numbers with
	ZeroPadding int `json:"zeroPadding" yaml:"zeroPadding"`
}

Jump to

Keyboard shortcuts

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