~mendelmaleh/pfin

ref: 1f051309601a4da2841fade1e72cb120bccab370 pfin/parser/capitalone/interface.go -rw-r--r-- 590 bytes
1f051309Mendel E Add license 7 months ago
                                                                                
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
package capitalone

import (
	"fmt"
	"time"

	"git.sr.ht/~mendelmaleh/pfin"
)

func (tx RawTransaction) Date() time.Time {
	return tx.TransactionDate.Time
}

func (tx RawTransaction) Amount() float64 {
	if tx.Debit != 0 {
		return tx.Debit
	}

	if tx.Credit != 0 {
		return -tx.Credit
	}

	// TODO
	panic("both credit and debit are zero: " + fmt.Sprintln(tx))

	return tx.Debit
}

func (tx RawTransaction) Card() string {
	return tx.CardNumber
}

func (tx RawTransaction) Name() string {
	return tx.Description
}

func (tx RawTransaction) String() string {
	return pfin.TxString(tx, " ")
}