@@ -33,7 +33,7 @@ type TransactionLinks struct {
3333}
3434
3535type TransactionQueryFilter struct {
36- Date time.Time `form:"date"`
36+ Date time.Time `form:"date" filterField:"false" `
3737 Amount decimal.Decimal `form:"amount"`
3838 AmountLessOrEqual decimal.Decimal `form:"amountLessOrEqual" filterField:"false"` // Amount less than or equal to this
3939 AmountMoreOrEqual decimal.Decimal `form:"amountMoreOrEqual" filterField:"false"` // Amount more than or equal to this
@@ -76,7 +76,6 @@ func (f TransactionQueryFilter) ToCreate(c *gin.Context) (models.TransactionCrea
7676 }
7777
7878 return models.TransactionCreate {
79- Date : f .Date ,
8079 Amount : f .Amount ,
8180 BudgetID : budgetID ,
8281 SourceAccountID : sourceAccountID ,
@@ -201,19 +200,19 @@ func (co Controller) CreateTransaction(c *gin.Context) {
201200// @Failure 404
202201// @Failure 500 {object} httperrors.HTTPError
203202// @Router /v1/transactions [get]
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"
203+ // @Param date query string false "Date of the transaction. Ignores exact time, matches on the day of the RFC3339 timestamp provided. "
204+ // @Param amount query string false "Filter by amount"
205+ // @Param amountLessOrEqual query string false "Amount less than or equal to this"
206+ // @Param amountMoreOrEqual query string false "Amount more than or equal to this"
207+ // @Param note query string false "Filter by note"
208+ // @Param budget query string false "Filter by budget ID"
209+ // @Param account query string false "Filter by ID of associated account, regardeless of source or destination"
210+ // @Param source query string false "Filter by source account ID"
211+ // @Param destination query string false "Filter by destination account ID"
212+ // @Param envelope query string false "Filter by envelope ID"
213+ // @Param reconciled query bool false "DEPRECATED. Filter by reconcilication state"
214+ // @Param reconciledSource query bool false "Reconcilication state in source account"
215+ // @Param reconciledDestination query bool false "Reconcilication state in destination account"
217216func (co Controller ) GetTransactions (c * gin.Context ) {
218217 var filter TransactionQueryFilter
219218 if err := c .Bind (& filter ); err != nil {
@@ -235,6 +234,12 @@ func (co Controller) GetTransactions(c *gin.Context) {
235234 TransactionCreate : create ,
236235 }, queryFields ... )
237236
237+ // Filter for the transaction being at the same date
238+ if ! filter .Date .IsZero () {
239+ date := time .Date (filter .Date .Year (), filter .Date .Month (), filter .Date .Day (), 0 , 0 , 0 , 0 , time .UTC )
240+ query = query .Where ("transactions.date >= date(?)" , date ).Where ("transactions.date < date(?)" , date .AddDate (0 , 0 , 1 ))
241+ }
242+
238243 if filter .AccountID != "" {
239244 accountID , ok := httputil .UUIDFromString (c , filter .AccountID )
240245 if ! ok {
0 commit comments