Route: Transaction Transform Rule#
- class means.types.Route.Route(*, accts: list[~typing.Annotated[~_regex.Pattern, ~pydantic.types.GetPydanticSchema(get_pydantic_core_schema=~my.utils.SyntaxUtils.SyntaxUtils.pyd_schemify.<locals>.<lambda>, get_pydantic_json_schema=None)]] = [], memos: list[~typing.Annotated[~_regex.Pattern, ~pydantic.types.GetPydanticSchema(get_pydantic_core_schema=~my.utils.SyntaxUtils.SyntaxUtils.pyd_schemify.<locals>.<lambda>, get_pydantic_json_schema=None)]] = [], period: ~collections.abc.Callable[[~datetime.date], bool] | None = None, users: list[str] = [], repl: str | None = None, drop: bool = False)#
Defines a route for transforming transactions based on regex filters and date ranges.
I Construction and Registry#
- classmethod Route.new(**kwargs: Any) Route#
Build a route from raw YAML keyword arguments.
Normalizes singular
acct/memokeys into their plural list forms, compiles the regexes, and convertsmin/maxdate bounds into aperiodpredicate.- Parameters:
**kwargs – Raw route parameters as loaded from
routes.yaml.- Returns:
The constructed route.
- classmethod Route.setup(root: Annotated[Path, PathType(path_type=dir)]) None#
Load the
Routeregistry fromparameters/routes.yamlin the given data directory.
II Application#
- Route.apply(tr: Transaction) bool#
Apply this route to a transaction, rewriting it in place on a match.
Checks the date filter first, then the account and memo regexes; on a match, applies any account/memo replacement and user reassignments directly to the transaction.
- Parameters:
tr – The transaction to test and potentially rewrite.
- Returns:
True if any filter matched (and its consequents were applied).