chagne account to vendor
parent
c5c77a2b9b
commit
cea7a30884
|
|
@ -9,15 +9,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Transaction struct {
|
type Transaction struct {
|
||||||
ID string
|
ID string
|
||||||
Bank Bank
|
Bank Bank
|
||||||
Amount string
|
Amount string
|
||||||
Account string
|
Vendor string
|
||||||
Date string
|
Date string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transaction) Format() string {
|
func (t *Transaction) Format() string {
|
||||||
return fmt.Sprintf("(%s) %v: %s @ %s", cleanDate(t.Date), t.Bank, t.Amount, t.Account)
|
return fmt.Sprintf("(%s) %v: %s @ %s", cleanDate(t.Date), t.Bank, t.Amount, t.Vendor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transaction) String() string {
|
func (t *Transaction) String() string {
|
||||||
|
|
@ -27,10 +27,10 @@ func (t *Transaction) String() string {
|
||||||
func NewTransaction(amount, account, date string, bank Bank) *Transaction {
|
func NewTransaction(amount, account, date string, bank Bank) *Transaction {
|
||||||
regexp := regexp.MustCompile(`\s\s+`)
|
regexp := regexp.MustCompile(`\s\s+`)
|
||||||
t := &Transaction{
|
t := &Transaction{
|
||||||
Amount: regexp.ReplaceAllString(amount, " "),
|
Amount: regexp.ReplaceAllString(amount, " "),
|
||||||
Account: regexp.ReplaceAllString(account, " "),
|
Vendor: regexp.ReplaceAllString(account, " "),
|
||||||
Bank: bank,
|
Bank: bank,
|
||||||
Date: date,
|
Date: date,
|
||||||
}
|
}
|
||||||
t.ID = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprint(t))))
|
t.ID = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprint(t))))
|
||||||
return t
|
return t
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ func uploadLedger(config Config, transaction *Transaction) error {
|
||||||
if amount > 0 {
|
if amount > 0 {
|
||||||
remote = "Deposit:"
|
remote = "Deposit:"
|
||||||
}
|
}
|
||||||
remote += strings.ReplaceAll(transaction.Account, " ", "")
|
remote += strings.ReplaceAll(transaction.Vendor, " ", "")
|
||||||
fmt.Fprintf(f, "%-50s%-s\n", formatGMailDate(transaction.Date), transaction.Account)
|
fmt.Fprintf(f, "%-50s%-s\n", formatGMailDate(transaction.Date), transaction.Vendor)
|
||||||
fmt.Fprintf(f, "%-50s%-50s$%.2f\n", "", "AssetAccount:"+transaction.Bank.String(), amount)
|
fmt.Fprintf(f, "%-50s%-50s$%.2f\n", "", "AssetAccount:"+transaction.Bank.String(), amount)
|
||||||
fmt.Fprintf(f, "%-50s%-s\n", "", remote)
|
fmt.Fprintf(f, "%-50s%-s\n", "", remote)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ func TestUploadLedger(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
"simple": {
|
"simple": {
|
||||||
transaction: Transaction{
|
transaction: Transaction{
|
||||||
ID: uuid.New().String(),
|
ID: uuid.New().String(),
|
||||||
Bank: Chase,
|
Bank: Chase,
|
||||||
Amount: "1.10",
|
Amount: "1.10",
|
||||||
Account: "account",
|
Vendor: "vendor",
|
||||||
Date: "today",
|
Date: "today",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue