test new and old scrape for chase

This commit is contained in:
bel
2021-07-29 23:38:27 -06:00
parent cea7a30884
commit 1ebaf9eac8
6 changed files with 533 additions and 20 deletions

View File

@@ -9,28 +9,30 @@ import (
)
type Transaction struct {
ID string
Bank Bank
Amount string
Vendor string
Date string
ID string
Bank Bank
Amount string
Vendor string
Date string
Account string
}
func (t *Transaction) Format() string {
return fmt.Sprintf("(%s) %v: %s @ %s", cleanDate(t.Date), t.Bank, t.Amount, t.Vendor)
return fmt.Sprintf("(%s) %v/%v: %s @ %s", cleanDate(t.Date), t.Account, t.Bank, t.Amount, t.Vendor)
}
func (t *Transaction) String() string {
return fmt.Sprint(*t)
}
func NewTransaction(amount, account, date string, bank Bank) *Transaction {
func NewTransaction(account, amount, vendor, date string, bank Bank) *Transaction {
regexp := regexp.MustCompile(`\s\s+`)
t := &Transaction{
Amount: regexp.ReplaceAllString(amount, " "),
Vendor: regexp.ReplaceAllString(account, " "),
Bank: bank,
Date: date,
Account: account,
Amount: regexp.ReplaceAllString(amount, " "),
Vendor: regexp.ReplaceAllString(vendor, " "),
Bank: bank,
Date: date,
}
t.ID = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprint(t))))
return t