Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category struct { Code Code `json:"code" jsonschema:"title=Code"` Name i18n.String `json:"name" jsonschema:"title=Name"` Desc i18n.String `json:"desc,omitempty" jsonschema:"title=Description"` // Retained when true implies that the tax amount will be retained // by the buyer on behalf of the supplier, and thus subtracted from // the invoice taxable base total. Retained bool `json:"retained,omitempty" jsonschema:"title=Retained,description=This tax should be retained, not added, from the sum."` // Rates array Defs []Def `json:"defs" jsonschema:"title=Definitions,descriptions=Specific tax definitions inside this category."` }
Category
type CategoryTotal ¶
type CategoryTotal struct { Code Code `json:"code" jsonschema:"title=Code"` Retained bool `json:"retained,omitempty" jsonschema:"title=Retained"` Rates []*RateTotal `json:"rates" jsonschema:"title=Rates"` Base num.Amount `json:"base" jsonschema:"title=Base"` Value num.Amount `json:"value" jsonschema:"title=Value"` }
CategoryTotal groups together all rates inside a given category.
func NewCategoryTotal ¶
func NewCategoryTotal(code Code, retained bool, zero num.Amount) *CategoryTotal
NewCategoryTotal prepares a category total calculation.
type Code ¶
type Code string
Code represents a string used to uniquely identify the data we're looking at. We use "code" instead of "id", to reenforce the fact that codes should be more easily set and used by humans within definitions than IDs or UUIDs. Codes are standardised so that when validated they must contain between 2 and 6 inclusive upper-case letters or numbers.
type Def ¶
type Def struct { // Code identifies this rate within the system Code Code `json:"code" jsonschema:"title=Code"` Name i18n.String `json:"name" jsonschema:"title=Name"` Desc i18n.String `json:"desc,omitempty" jsonschema:"title=Description"` // Values contains a list of Value objects that contain the // current and historical percentage values for the rate. // Order is important, newer values should come before // older values. Values []Value `` /* 128-byte string literal not displayed */ }
Def defines a tax combination of category and rate.
type Rate ¶
type Rate struct { Category Code `json:"cat" jsonschema:"title=Category Code,description=From the available options for the region."` Code Code `json:"code" jsonschema:"title=Code,description=As defined for the region and category."` }
Rate references the tax category and rate code that should be applied to this line item when calculating the final taxes.
type RateTotal ¶
type RateTotal struct { Code Code `json:"code" jsonschema:"title=Code"` Base num.Amount `json:"base" jsonschema:"title=Base"` Percent num.Percentage `json:"percent" jsonschema:"title=Percent"` Value num.Amount `json:"value" jsonschema:"title=Value"` // contains filtered or unexported fields }
RateTotal contains a sum of all the tax rates in the document with a matching category and definition.
func NewRateTotal ¶
type Rates ¶
type Rates []*Rate
Rates contains a list of taxes, usually applied to an invoice line or item.
type Region ¶
type Region struct { Code Code `json:"code" jsonschema:"title=Code"` Name i18n.String `json:"name" jsonschema:"title=Name"` Categories []Category `json:"categories" jsonschema:"title=Categories"` }
Region defines the holding structure for a regions categories and subsequent Rates and Values.
type TaxableLine ¶
TaxableLine defines what we expect from a line in order to subsequently calculate the taxes that need to be added or retained.
type Total ¶
type Total struct { Categories []*CategoryTotal `json:"categories,omitempty" jsonschema:"title=Categories"` Sum num.Amount `json:"sum" jsonschema:"title=Sum,description=Total value of all the taxes to be added or retained."` }
Total contains a set of Category Totals which in turn contain all the accumulated taxes contained in the document. The resulting `sum` is that value that should be added to the payable total.
type Value ¶
type Value struct { Since *org.Date `json:"since,omitempty" jsonschema:"title=Since,description=Date from which this value should be applied."` Percent num.Percentage `json:"percent" jsonschema:"title=Percent,description=Rate that should be applied."` Disabled bool `json:"disabled,omitempty" jsonschema:"title=Disabled,description=When true, this value should no longer be used."` }
Value contains a percentage rate or fixed amount for a given date range. Fiscal policy changes mean that rates are not static so we need to be able to apply the correct rate for a given period.