Added the action button to convert a cash income or cash expense transaction to a transfer transaction.

This commit is contained in:
2023-02-27 18:59:42 +08:00
parent 4c17310ebf
commit f0d39bb27b
5 changed files with 34 additions and 2 deletions
src/accounting
templates
accounting
transaction
transaction

@ -47,6 +47,21 @@ def with_type(uri: str) -> str:
return urlunparse(parts)
def to_transfer(uri: str) -> str:
"""Adds the transfer transaction type to the URI.
:param uri: The URI.
:return: The result URL, with the transfer transaction type added.
"""
uri_p: ParseResult = urlparse(uri)
params: list[tuple[str, str]] = parse_qsl(uri_p.query)
params = [x for x in params if x[0] != "as"]
params.append(("as", "transfer"))
parts: list[str] = list(uri_p)
parts[4] = urlencode(params)
return urlunparse(parts)
def format_amount(value: Decimal | None) -> str:
"""Formats an amount for readability.