write banks diff for ledger, filter by bank
This commit is contained in:
17
upload.go
17
upload.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user