diff --git a/database/model/category_rule.go b/database/model/category_rule.go index 269510d..2ce1d24 100644 --- a/database/model/category_rule.go +++ b/database/model/category_rule.go @@ -5,14 +5,15 @@ import ( ) type CategoryRule struct { - ID uint `gorm:"primaryKey" json:"id"` - Contain *string `json:"contain"` - Match *string `json:"match"` - Amount *float64 `json:"amount"` - DateFrom *time.Time `json:"date_from"` - DateTo *time.Time `json:"date_to"` - CategoryID int `gorm:"not null" json:"-"` - Category *Category + ID uint `gorm:"primaryKey" json:"id"` + Contain *string `json:"contain"` + Match *string `json:"match"` + Amount *float64 `json:"amount"` + DateFrom *time.Time `json:"date_from"` + DateTo *time.Time `json:"date_to"` + BankCategory *string `json:"bank_category"` + CategoryID int `gorm:"not null" json:"-"` + Category *Category } func NewCategoryRule(label, color string) *CategoryRule { diff --git a/database/model/transaction.go b/database/model/transaction.go index 1315fed..6e08556 100644 --- a/database/model/transaction.go +++ b/database/model/transaction.go @@ -65,6 +65,17 @@ func (t *Transaction) MatchRule(rule CategoryRule) (bool, int) { match = match && true } + if rule.BankCategory != nil { + v := strings.ToLower(*rule.BankCategory) + match = match && (strings.Contains(strings.ToLower(t.BankCategory), v) || strings.Contains(strings.ToLower(t.BankSubCategory), v)) + + if match { + counter += 6 + } + } else { + match = match && true + } + if rule.Amount != nil { match = match && t.Debit == *rule.Amount diff --git a/frontend/js/views/CategoriesView.vue b/frontend/js/views/CategoriesView.vue index 76adf6e..8c92d1d 100644 --- a/frontend/js/views/CategoriesView.vue +++ b/frontend/js/views/CategoriesView.vue @@ -68,23 +68,30 @@ class="list-group" >