Skip to content

Commit 86b6eee

Browse files
authored
fix: set availableFrom to next month for imports (#1125)
1 parent a2401db commit 86b6eee

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

internal/controllers/v4/import_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ func (suite *TestSuiteStandard) TestImportYnabImportPreviewAvailableFrom() {
223223
preview := suite.parseCSV(suite.T(), account.Data.ID, "available-from-test.csv")
224224

225225
dates := []types.Month{
226-
types.NewMonth(2019, 2),
227-
types.NewMonth(2019, 4),
226+
types.NewMonth(2019, 3),
228227
types.NewMonth(2019, 5),
228+
types.NewMonth(2019, 6),
229229
}
230230

231231
for i, transaction := range preview.Data {

internal/importer/parser/ynab-import/parse.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ func Parse(f io.Reader, account models.Account) ([]importer.TransactionPreview,
5656

5757
t := importer.TransactionPreview{
5858
Transaction: models.Transaction{
59-
Date: date,
60-
AvailableFrom: types.NewMonth(date.Year(), date.Month()),
61-
ImportHash: helpers.Sha256String(strings.Join(record, ",")),
62-
Note: record[headers["Memo"]],
59+
Date: date,
60+
ImportHash: helpers.Sha256String(strings.Join(record, ",")),
61+
Note: record[headers["Memo"]],
62+
63+
// AvailableFrom is only used for income transactions, for which it defaults to the month after the transaction.
64+
// Since it is only used for income transactions, we can safely set it here.
65+
AvailableFrom: types.NewMonth(date.Year(), date.Month()).AddDate(0, 1),
6366
},
6467
}
6568

0 commit comments

Comments
 (0)