feat: gleiches Schlagwort für Einnahme UND Ausgabe erlaubt (Art je Regel)
- CategorizationRule bekommt `kind` (expense|income|transfer); Unique jetzt (owner, match_field, pattern, kind) statt ohne kind - Konfliktprüfung/Anlage (add/update Keyword, Transfer-Keyword, gelernte Regeln) arbeiten kind-bewusst: dasselbe Wort je einmal pro Art möglich - Migration 0009 mit Backfill (kind aus Kategorie-Art bzw. is_transfer) - Tests angepasst: quer über Arten erlaubt, gleiche Art weiterhin Konflikt (71 grün) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -551,6 +551,10 @@ class CategorizationRule(Base):
|
||||
amount_cents: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
# Wenn True: passende Buchung wird zum Transfer (category_id bleibt leer).
|
||||
is_transfer: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
# Art der Regel: "expense" | "income" | "transfer". Erlaubt, dasselbe Wort je
|
||||
# einmal für eine Ausgabe- UND eine Einnahme-Kategorie zu verwenden (das
|
||||
# Matching filtert ohnehin nach Buchungsart).
|
||||
kind: Mapped[str] = mapped_column(String(16), nullable=False, default="expense")
|
||||
source: Mapped[RuleSource] = mapped_column(_enum(RuleSource), nullable=False, default=RuleSource.learned)
|
||||
priority: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
hits: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
@@ -561,5 +565,5 @@ class CategorizationRule(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now)
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("owner_id", "match_field", "pattern", name="uq_rule_owner_field_pattern"),
|
||||
UniqueConstraint("owner_id", "match_field", "pattern", "kind", name="uq_rule_owner_field_pattern_kind"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user