ht

package module
v0.0.0-...-e3a058d Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

README

go-hledger-types

A go library to un/marshal hledger json output

Go Documentation

license

GPL-3.0-or-later

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDecimalMark = errors.New("invalid decimal mark")
View Source
var ErrInvalidPostingType = errors.New("invalid posting type")
View Source
var ErrInvalidPriceType = errors.New("invalid price type")
View Source
var ErrInvalidSide = errors.New("invalid side")
View Source
var ErrInvalidStatus = errors.New("invalid status")

Functions

This section is empty.

Types

type Amount

type Amount struct {
	Commodity string       `json:"acommodity"`
	Quantity  Quantity     `json:"aquantity"`
	Style     AmountStyle  `json:"astyle"`
	Price     *AmountPrice `json:"aprice"`
}

type AmountPrice

type AmountPrice struct {
	Type   PriceType `json:"tag"`
	Amount Amount    `json:"contents"`
}

type AmountStyle

type AmountStyle struct {
	CommoditySide   Side             `json:"ascommodityside"`
	CommoditySpaced bool             `json:"ascommodityspaced"`
	Precision       *uint8           `json:"asprecision"`
	DecimalPoint    *DecimalMark     `json:"asdecimalpoint"`
	DigitGroups     *DigitGroupStyle `json:"asdigitgroups"`
}

type BalanceAssertion

type BalanceAssertion struct {
	Amount    Amount         `json:"baamount"`
	Total     bool           `json:"batotal"`
	Inclusive bool           `json:"bainclusive"`
	Position  SourcePosition `json:"baposition"`
}

type Date

type Date struct {
	time.Time
}

func (*Date) MarshalJSON

func (self *Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (self *Date) UnmarshalJSON(data []byte) error

type DecimalMark

type DecimalMark uint8
const (
	Period DecimalMark = iota
	Comma
)

func (*DecimalMark) MarshalJSON

func (self *DecimalMark) MarshalJSON() ([]byte, error)

func (*DecimalMark) UnmarshalJSON

func (self *DecimalMark) UnmarshalJSON(data []byte) error

type DigitGroupStyle

type DigitGroupStyle struct {
	Separator DecimalMark
	Groups    []uint8
}

func (*DigitGroupStyle) MarshalJSON

func (self *DigitGroupStyle) MarshalJSON() ([]byte, error)

func (*DigitGroupStyle) UnmarshalJSON

func (self *DigitGroupStyle) UnmarshalJSON(data []byte) error

type Posting

type Posting struct {
	Date             *Date             `json:"pdate"`
	Date2            *Date             `json:"pdate2"`
	Status           Status            `json:"pstatus"`
	Account          string            `json:"paccount"`
	Amounts          []Amount          `json:"pamount"`
	Comment          string            `json:"pcomment"`
	Type             PostingType       `json:"ptype"`
	Tags             []Tag             `json:"ptags"`
	BalanceAssertion *BalanceAssertion `json:"pbalanceassertion"`
}

type PostingType

type PostingType uint8
const (
	RegularPosting PostingType = iota
	VirtualPosting
	BalancedVirtualPosting
)

func (*PostingType) MarshalJSON

func (self *PostingType) MarshalJSON() ([]byte, error)

func (*PostingType) UnmarshalJSON

func (self *PostingType) UnmarshalJSON(data []byte) error

type PriceType

type PriceType uint8
const (
	UnitPrice PriceType = iota
	TotalPrice
)

func (*PriceType) MarshalJSON

func (self *PriceType) MarshalJSON() ([]byte, error)

func (*PriceType) UnmarshalJSON

func (self *PriceType) UnmarshalJSON(data []byte) error

type Quantity

type Quantity struct {
	DecimalMantissa int64   `json:"decimalMantissa"`
	DecimalPlaces   int     `json:"decimalPlaces"`
	FloatingPoint   float64 `json:"floatingPoint"`
}

type Side

type Side uint8
const (
	Left Side = iota
	Right
)

func (*Side) MarshalJSON

func (self *Side) MarshalJSON() ([]byte, error)

func (*Side) UnmarshalJSON

func (self *Side) UnmarshalJSON(data []byte) error

type SourcePosition

type SourcePosition struct {
	Name   string `json:"sourceName"`
	Column uint64 `json:"sourceColumn"`
	Line   uint64 `json:"sourceLine"`
}

type Status

type Status uint8
const (
	Unmarked Status = iota
	Pending
	Cleared
)

func (*Status) MarshalJSON

func (self *Status) MarshalJSON() ([]byte, error)

func (*Status) UnmarshalJSON

func (self *Status) UnmarshalJSON(data []byte) error

type Tag

type Tag struct {
	Name  string
	Value string
}

func (*Tag) MarshalJSON

func (self *Tag) MarshalJSON() ([]byte, error)

func (*Tag) UnmarshalJSON

func (self *Tag) UnmarshalJSON(data []byte) error

type Transaction

type Transaction struct {
	Index            uint64            `json:"tindex"`
	PrecedingComment string            `json:"tprecedingcomment"`
	Position         [2]SourcePosition `json:"tsourcepos"`
	Date             Date              `json:"tdate"`
	Date2            *Date             `json:"tdate2"`
	Status           Status            `json:"tstatus"`
	Code             string            `json:"tcode"`
	Description      string            `json:"tdescription"`
	Comment          string            `json:"tcomment"`
	Tags             []Tag             `json:"ttags"`
	Postings         []Posting         `json:"tpostings"`
}

Jump to

Keyboard shortcuts

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