write banks diff for ledger, filter by bank

This commit is contained in:
bel
2021-07-29 22:50:17 -06:00
parent bbd51ea9c5
commit c5c77a2b9b
4 changed files with 24 additions and 14 deletions

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"local/oauth2"
"log"
"net/http"
"net/url"
"os"
@@ -63,16 +62,20 @@ func uploadLedger(config Config, transaction *Transaction) error {
}
remote += strings.ReplaceAll(transaction.Account, " ", "")
fmt.Fprintf(f, "%-50s%-s\n", formatGMailDate(transaction.Date), transaction.Account)
fmt.Fprintf(f, "%-50s%-50s$%.2f\n", "", transaction.Bank, amount)
fmt.Fprintf(f, "%-50s%-50s$%.2f\n", "", "AssetAccount:"+transaction.Bank.String(), amount)
fmt.Fprintf(f, "%-50s%-s\n", "", remote)
return nil
}
func formatGMailDate(s string) string {
time, err := time.Parse("[Mon, 2 Jan 2006 15:04:05 -0700 (MST)]", s)
if err != nil {
log.Println(s, err)
return s
for _, format := range []string{
"[Mon, 2 Jan 2006 15:04:05 -0700 (MST)]",
"[Mon, 2 Jan 2006 15:04:05 -0700]",
} {
time, err := time.Parse(format, s)
if err == nil {
return time.Format("2006-01-02")
}
}
return time.Format("2006-01-02")
return s
}