parent
1ebaf9eac8
commit
a6c5121d54
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -60,7 +61,10 @@ func uploadLedger(config Config, transaction *Transaction) error {
|
||||||
if amount > 0 {
|
if amount > 0 {
|
||||||
remote = "Deposit:"
|
remote = "Deposit:"
|
||||||
}
|
}
|
||||||
remote += strings.ReplaceAll(transaction.Vendor, " ", "")
|
regexp := regexp.MustCompile(`[0-9a-zA-Z]`)
|
||||||
|
for _, substr := range regexp.FindAllString(transaction.Vendor, -1) {
|
||||||
|
remote += substr
|
||||||
|
}
|
||||||
fmt.Fprintf(f, "%-50s%-s\n", formatGMailDate(transaction.Date), transaction.Vendor)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"local/storage"
|
"local/storage"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -18,7 +19,7 @@ func TestUploadLedger(t *testing.T) {
|
||||||
ID: uuid.New().String(),
|
ID: uuid.New().String(),
|
||||||
Bank: Chase,
|
Bank: Chase,
|
||||||
Amount: "1.10",
|
Amount: "1.10",
|
||||||
Vendor: "vendor",
|
Vendor: "my's totally realistic!!! VENDOR 11",
|
||||||
Date: "today",
|
Date: "today",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -39,6 +40,9 @@ func TestUploadLedger(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if !bytes.Contains(b, []byte("mystotallyrealisticVENDOR11")) {
|
||||||
|
t.Fatal(string(b))
|
||||||
|
}
|
||||||
t.Logf("\n%s", b)
|
t.Logf("\n%s", b)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue