add rule property: bank_category
This commit is contained in:
parent
e11f2d78f9
commit
55a83619fc
3 changed files with 31 additions and 11 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -68,23 +68,30 @@
|
|||
class="list-group"
|
||||
>
|
||||
<div v-for="(rule, key) in form.data[field.key]" class="list-group-item">
|
||||
<div class="d-block d-lg-flex justify-content-between">
|
||||
<div class="d-block d-lg-flex justify-content-between gap-1">
|
||||
<BFormInput v-if="form.data[field.key][key].id !== null" type="hidden" v-model="form.data[field.key][key].id" />
|
||||
|
||||
<BFormGroup
|
||||
class="mb-2"
|
||||
label="Contient"
|
||||
label="Libellé contient"
|
||||
:label-for="'form-rule-contain-' + key"
|
||||
>
|
||||
<BFormInput :id="'form-rule-contain-' + key" v-model="form.data[field.key][key].contain" />
|
||||
</BFormGroup>
|
||||
<BFormGroup
|
||||
class="mb-2"
|
||||
label="Regex"
|
||||
label="Regex libellé"
|
||||
:label-for="'form-rule-match-' + key"
|
||||
>
|
||||
<BFormInput :id="'form-rule-match-' + key" v-model="form.data[field.key][key].match" />
|
||||
</BFormGroup>
|
||||
<BFormGroup
|
||||
class="mb-2"
|
||||
label="Catégorie banque"
|
||||
:label-for="'form-rule-contain-' + key"
|
||||
>
|
||||
<BFormInput :id="'form-rule-bank-category-contain-' + key" v-model="form.data[field.key][key].bank_category" />
|
||||
</BFormGroup>
|
||||
<BFormGroup
|
||||
class="mb-2"
|
||||
label="Montant"
|
||||
|
|
@ -203,6 +210,7 @@ const doAddRule = (item) => {
|
|||
const rule = {
|
||||
contain: null,
|
||||
match: null,
|
||||
bank_category: null,
|
||||
amount: null,
|
||||
date_from: null,
|
||||
date_to: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue