forked from mitch000001/go-hbci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_transaction.go
43 lines (40 loc) · 1.1 KB
/
account_transaction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package domain
import (
"bytes"
"fmt"
"text/tabwriter"
"time"
)
// AccountTransaction represents one transaction entry for a given account
type AccountTransaction struct {
Account AccountConnection
Amount Amount
ValutaDate time.Time
BookingDate time.Time
BankID string
AccountID string
Purpose string
Purpose2 string
AccountBalanceBefore Balance
AccountBalanceAfter Balance
}
func (a AccountTransaction) String() string {
var buf bytes.Buffer
buf.WriteString("\n")
buf.WriteString("BookingDate\tAmount\tBankID\tAccountID\tPurpose")
buf.WriteString("\n")
buf.WriteString(a.ValutaDate.Format("2006-01-02"))
buf.WriteString("\t")
buf.WriteString(fmt.Sprintf("%.2f %s", a.Amount.Amount, a.Amount.Currency))
buf.WriteString("\t")
buf.WriteString(a.BankID)
buf.WriteString("\t")
buf.WriteString(a.AccountID)
buf.WriteString("\t")
buf.WriteString(a.Purpose)
var out bytes.Buffer
tabw := tabwriter.NewWriter(&out, 0, 4, 0, '\t', 0)
fmt.Fprint(tabw, buf.String())
tabw.Flush()
return out.String()
}