utility for generating ledger transactions from ofx
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
687 B

package main
import (
"time"
)
var transactionTemplate = `
{{ range . }}
{{ .Date.Format "2006-01-02" }} {{ .VendorName }}
{{ .Asset }} {{ .TrnAmt }} {{ .Currency }}
{{ .Expense }}
{{ end }}
`
type transaction struct {
Date time.Time `xml:"Date"`
TrnAmt float64 `xml:"Amount"`
Asset string `xml:"Asset"`
Expense string `xml:"Expense,omitempty"`
VendorName string `xml:"VendorName,omitempty"`
Currency string `xml:"Currency"`
}
type byDate []transaction
func (b byDate) Len() int {
return len(b)
}
func (b byDate) Less(i, j int) bool {
return b[i].Date.Before(b[j].Date)
}
func (b byDate) Swap(i, j int) {
b[i], b[j] = b[j], b[i]
}