@@ -35,6 +35,8 @@ type TransactionLinks struct {
3535type TransactionQueryFilter struct {
3636 Date time.Time `form:"date"`
3737 Amount decimal.Decimal `form:"amount"`
38+ AmountLessOrEqual decimal.Decimal `form:"amountLessOrEqual" filterField:"false"` // Amount less than or equal to this
39+ AmountMoreOrEqual decimal.Decimal `form:"amountMoreOrEqual" filterField:"false"` // Amount more than or equal to this
3840 Note string `form:"note" filterField:"false"`
3941 BudgetID string `form:"budget"`
4042 SourceAccountID string `form:"source"`
@@ -199,17 +201,19 @@ func (co Controller) CreateTransaction(c *gin.Context) {
199201// @Failure 404
200202// @Failure 500 {object} httperrors.HTTPError
201203// @Router /v1/transactions [get]
202- // @Param date query time.Time false "Filter by date"
203- // @Param amount query decimal.Decimal false "Filter by amount"
204- // @Param note query string false "Filter by note"
205- // @Param budget query string false "Filter by budget ID"
206- // @Param account query string false "Filter by ID of associated account, regardeless of source or destination"
207- // @Param source query string false "Filter by source account ID"
208- // @Param destination query string false "Filter by destination account ID"
209- // @Param envelope query string false "Filter by envelope ID"
210- // @Param reconciled query bool false "DEPRECATED. Filter by reconcilication state"
211- // @Param reconciledSource query bool false "Reconcilication state in source account"
212- // @Param reconciledDestination query bool false "Reconcilication state in destination account"
204+ // @Param date query time.Time false "Filter by date"
205+ // @Param amount query string false "Filter by amount"
206+ // @Param amountLessOrEqual query string false "Amount less than or equal to this"
207+ // @Param amountMoreOrEqual query string false "Amount more than or equal to this"
208+ // @Param note query string false "Filter by note"
209+ // @Param budget query string false "Filter by budget ID"
210+ // @Param account query string false "Filter by ID of associated account, regardeless of source or destination"
211+ // @Param source query string false "Filter by source account ID"
212+ // @Param destination query string false "Filter by destination account ID"
213+ // @Param envelope query string false "Filter by envelope ID"
214+ // @Param reconciled query bool false "DEPRECATED. Filter by reconcilication state"
215+ // @Param reconciledSource query bool false "Reconcilication state in source account"
216+ // @Param reconciledDestination query bool false "Reconcilication state in destination account"
213217func (co Controller ) GetTransactions (c * gin.Context ) {
214218 var filter TransactionQueryFilter
215219 if err := c .Bind (& filter ); err != nil {
@@ -248,6 +252,14 @@ func (co Controller) GetTransactions(c *gin.Context) {
248252 })
249253 }
250254
255+ if ! filter .AmountLessOrEqual .IsZero () {
256+ query = query .Where ("transactions.amount <= ?" , filter .AmountLessOrEqual )
257+ }
258+
259+ if ! filter .AmountMoreOrEqual .IsZero () {
260+ query = query .Where ("transactions.amount >= ?" , filter .AmountMoreOrEqual )
261+ }
262+
251263 if filter .Note != "" {
252264 query = query .Where ("note LIKE ?" , fmt .Sprintf ("%%%s%%" , filter .Note ))
253265 } else if slices .Contains (setFields , "Note" ) {
0 commit comments