go-hledger-types – git.sr.ht/~dhruvin/go-hledger-types Index | Files

package ht

import "git.sr.ht/~dhruvin/go-hledger-types"

Index

Variables

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

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"`
}

Source Files

ht.go

Version
v0.0.0-20220603202322-e3a058da519a (latest)
Published
Jun 3, 2022
Platform
linux/amd64
Imports
4 packages
Last checked
1 week ago

Tools for package owners.