Handle errors of Write and add dots to comments

This commit is contained in:
Jan Bader 2022-02-23 19:37:32 +00:00
parent ece610419f
commit a7cd3512bb
2 changed files with 10 additions and 4 deletions

View File

@ -47,7 +47,10 @@ func (ynab *YNABExport) ExportAssignments(context context.Context, w io.Writer)
"0,00€",
}
csv.Write(row)
err := csv.Write(row)
if err != nil {
return fmt.Errorf("write assignment: %w", err)
}
count++
}
csv.Flush()
@ -59,7 +62,7 @@ func (ynab *YNABExport) ExportAssignments(context context.Context, w io.Writer)
// ImportTransactions expects a TSV-file as exported by YNAB in the following format:
// "Account" "Flag" "Date" "Payee" "Category Group/Category" "Category Group" "Category" "Memo" "Outflow" "Inflow" "Cleared"
// "Cash" "" "11.12.2021" "Transfer : Checking" "" "" "" "Brought to bank" 500,00€ 0,00€ "Cleared"
// "Cash" "" "11.12.2021" "Transfer : Checking" "" "" "" "Brought to bank" 500,00€ 0,00€ "Cleared".
func (ynab *YNABExport) ExportTransactions(context context.Context, w io.Writer) error {
csv := csv.NewWriter(w)
csv.Comma = '\t'
@ -90,7 +93,10 @@ func (ynab *YNABExport) ExportTransactions(context context.Context, w io.Writer)
row = append(row, string(transaction.Status))
csv.Write(row)
err := csv.Write(row)
if err != nil {
return fmt.Errorf("write transaction: %w", err)
}
count++
}

View File

@ -118,7 +118,7 @@ type Transfer struct {
// ImportTransactions expects a TSV-file as exported by YNAB in the following format:
// "Account" "Flag" "Date" "Payee" "Category Group/Category" "Category Group" "Category" "Memo" "Outflow" "Inflow" "Cleared"
// "Cash" "" "11.12.2021" "Transfer : Checking" "" "" "" "Brought to bank" 500,00€ 0,00€ "Cleared"
// "Cash" "" "11.12.2021" "Transfer : Checking" "" "" "" "Brought to bank" 500,00€ 0,00€ "Cleared".
func (ynab *YNABImport) ImportTransactions(context context.Context, r io.Reader) error {
csv := csv.NewReader(r)
csv.Comma = '\t'