Skip to content

Commit e159546

Browse files
authored
fix(v4): filtering transactions by note (#940)
1 parent 3bc4d6e commit e159546

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pkg/controllers/v4/transaction.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ func GetTransactions(c *gin.Context) {
216216
}
217217

218218
if filter.Note != "" {
219-
q = q.Where("note LIKE ?", fmt.Sprintf("%%%s%%", filter.Note))
219+
q = q.Where("transactions.note LIKE ?", fmt.Sprintf("%%%s%%", filter.Note))
220220
} else if slices.Contains(setFields, "Note") {
221-
q = q.Where("note = ''")
221+
q = q.Where("transactions.note = ''")
222222
}
223223

224224
// Set the offset. Does not need checking since the default is 0

pkg/controllers/v4/transaction_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ func (suite *TestSuiteStandard) TestTransactionsGetFilter() {
231231
{"Before date", fmt.Sprintf("untilDate=%s", time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC).Format(time.RFC3339Nano)), 1},
232232
{"Between two dates", fmt.Sprintf("untilDate=%s&fromDate=%s", time.Date(2019, 8, 17, 0, 0, 0, 0, time.UTC).Format(time.RFC3339Nano), time.Date(2015, 12, 24, 0, 0, 0, 0, time.UTC).Format(time.RFC3339Nano)), 2},
233233
{"Budget Match", fmt.Sprintf("budget=%s", b.Data.ID), 3},
234+
{"Budget and Note", fmt.Sprintf("budget=%s&note=Not", b.Data.ID), 1},
234235
{"Destination Account", fmt.Sprintf("destination=%s", a2.Data.ID), 2},
235236
{"Envelope 2", fmt.Sprintf("envelope=%s", e2.Data.ID), 1},
236237
{"Exact Amount", fmt.Sprintf("amount=%s", decimal.NewFromFloat(2.718).String()), 2},

0 commit comments

Comments
 (0)