This repository has been archived on 2023-12-27. You can view files and clone it, but cannot push or open issues or pull requests.
ledger-tui/pkg/transaction/transaction.go

58 lines
1.1 KiB
Go

package transaction
import (
"strings"
"time"
"github.com/tgrosinger/ledger-tui/pkg/collections"
)
// Transaction contains the information stored in a ledger file about a single
// transaction.
type Transaction struct {
Index int
Date time.Time
Description string
Comment string
PreceedingComment string
Postings []Posting
Status string // TODO: Enum?
Tags []string
}
type Posting struct {
Amount float64
Commodity string
Account string
Status string // TODO: Enum?
Type string // TODO: Enum?
Tags []string
}
func (t Transaction) String() string {
return "TODO"
}
type TransactionParseError struct {
Err error
Date string
Description string
Line int
}
func (e TransactionParseError) Error() string {
return e.Err.Error()
}
type TransactionParseErrors struct {
Errors []TransactionParseError
}
func (e TransactionParseErrors) Error() string {
return strings.Join(collections.Map(
e.Errors,
func(t TransactionParseError) string {
return t.Error()
}), "\n")
}