Skip to content

Commit

Permalink
fix: set availableFrom to next month for imports (#1125)
Browse files Browse the repository at this point in the history
  • Loading branch information
morremeyer authored Jan 25, 2025
1 parent a2401db commit 86b6eee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/controllers/v4/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ func (suite *TestSuiteStandard) TestImportYnabImportPreviewAvailableFrom() {
preview := suite.parseCSV(suite.T(), account.Data.ID, "available-from-test.csv")

dates := []types.Month{
types.NewMonth(2019, 2),
types.NewMonth(2019, 4),
types.NewMonth(2019, 3),
types.NewMonth(2019, 5),
types.NewMonth(2019, 6),
}

for i, transaction := range preview.Data {
Expand Down
11 changes: 7 additions & 4 deletions internal/importer/parser/ynab-import/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ func Parse(f io.Reader, account models.Account) ([]importer.TransactionPreview,

t := importer.TransactionPreview{
Transaction: models.Transaction{
Date: date,
AvailableFrom: types.NewMonth(date.Year(), date.Month()),
ImportHash: helpers.Sha256String(strings.Join(record, ",")),
Note: record[headers["Memo"]],
Date: date,
ImportHash: helpers.Sha256String(strings.Join(record, ",")),
Note: record[headers["Memo"]],

// AvailableFrom is only used for income transactions, for which it defaults to the month after the transaction.
// Since it is only used for income transactions, we can safely set it here.
AvailableFrom: types.NewMonth(date.Year(), date.Month()).AddDate(0, 1),
},
}

Expand Down

0 comments on commit 86b6eee

Please sign in to comment.