From defbbd18849253f6afea47ada46e6d03b9575c98 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Fri, 10 Dec 2021 16:39:56 +0000 Subject: [PATCH] Improve documentation for YNAB Import --- postgres/ynab-import.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/postgres/ynab-import.go b/postgres/ynab-import.go index 262c767..cb7af94 100644 --- a/postgres/ynab-import.go +++ b/postgres/ynab-import.go @@ -55,6 +55,11 @@ func NewYNABImport(context context.Context, q *Queries, budgetID uuid.UUID) (*YN } +// ImportAssignments expects a TSV-file as exported by YNAB in the following format: +//"Month" "Category Group/Category" "Category Group" "Category" "Budgeted" "Activity" "Available" +//"Apr 2019" "Income: Next Month" "Income" "Next Month" 0,00€ 0,00€ 0,00€ +// +// Activity and Available are not imported, since they are determined by the transactions and historic assignments func (ynab *YNABImport) ImportAssignments(r io.Reader) error { csv := csv.NewReader(r) csv.Comma = '\t' @@ -67,8 +72,7 @@ func (ynab *YNABImport) ImportAssignments(r io.Reader) error { count := 0 for _, record := range csvData[1:] { - //"Month" "Category Group/Category" "Category Group" "Category" "Budgeted" "Activity" "Available" - //"Apr 2019" "Income: Next Month" "Income" "Next Month" 0,00€ 0,00€ 0,00€ + dateString := record[0] date, err := time.Parse("Jan 2006", dateString) if err != nil { @@ -109,6 +113,8 @@ func (ynab *YNABImport) ImportAssignments(r io.Reader) error { return nil } +// ImportTransactions expects a TSV-file as exported by YNAB in the following format: + func (ynab *YNABImport) ImportTransactions(r io.Reader) error { csv := csv.NewReader(r) csv.Comma = '\t' @@ -156,7 +162,7 @@ func (ynab *YNABImport) ImportTransactions(r io.Reader) error { return fmt.Errorf("could not parse amount from (%s/%s): %w", inflow, outflow, err) } - //cleared := record[10] + //status := record[10] transaction := CreateTransactionParams{ Date: date,