Added the action button to convert a cash income or cash expense transaction to a transfer transaction.
This commit is contained in:
parent
4c17310ebf
commit
f0d39bb27b
@ -21,6 +21,13 @@ First written: 2023/2/26
|
|||||||
#}
|
#}
|
||||||
{% extends "accounting/transaction/include/detail.html" %}
|
{% extends "accounting/transaction/include/detail.html" %}
|
||||||
|
|
||||||
|
{% block to_transfer %}
|
||||||
|
<a class="btn btn-primary" href="{{ url_for("accounting.transaction.edit", txn=obj)|accounting_txn_to_transfer|accounting_inherit_next }}">
|
||||||
|
<i class="fa-solid fa-bars-staggered"></i>
|
||||||
|
{{ A_("To Transfer") }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block transaction_currencies %}
|
{% block transaction_currencies %}
|
||||||
{% for currency in obj.currencies %}
|
{% for currency in obj.currencies %}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -41,6 +41,7 @@ First written: 2023/2/26
|
|||||||
{{ A_("Order") }}
|
{{ A_("Order") }}
|
||||||
</a>
|
</a>
|
||||||
{% if accounting_can_edit() %}
|
{% if accounting_can_edit() %}
|
||||||
|
{% block to_transfer %}{% endblock %}
|
||||||
<button class="btn btn-danger" type="button" data-bs-toggle="modal" data-bs-target="#accounting-delete-modal">
|
<button class="btn btn-danger" type="button" data-bs-toggle="modal" data-bs-target="#accounting-delete-modal">
|
||||||
<i class="fa-solid fa-trash"></i>
|
<i class="fa-solid fa-trash"></i>
|
||||||
{{ A_("Delete") }}
|
{{ A_("Delete") }}
|
||||||
|
@ -21,6 +21,13 @@ First written: 2023/2/26
|
|||||||
#}
|
#}
|
||||||
{% extends "accounting/transaction/include/detail.html" %}
|
{% extends "accounting/transaction/include/detail.html" %}
|
||||||
|
|
||||||
|
{% block to_transfer %}
|
||||||
|
<a class="btn btn-primary" href="{{ url_for("accounting.transaction.edit", txn=obj)|accounting_txn_to_transfer|accounting_inherit_next }}">
|
||||||
|
<i class="fa-solid fa-bars-staggered"></i>
|
||||||
|
{{ A_("To Transfer") }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block transaction_currencies %}
|
{% block transaction_currencies %}
|
||||||
{% for currency in obj.currencies %}
|
{% for currency in obj.currencies %}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -47,6 +47,21 @@ def with_type(uri: str) -> str:
|
|||||||
return urlunparse(parts)
|
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:
|
def format_amount(value: Decimal | None) -> str:
|
||||||
"""Formats an amount for readability.
|
"""Formats an amount for readability.
|
||||||
|
|
||||||
|
@ -36,12 +36,14 @@ from accounting.utils.user import get_current_user_pk
|
|||||||
from .dispatcher import TransactionType, get_txn_type, TXN_TYPE_OBJ
|
from .dispatcher import TransactionType, get_txn_type, TXN_TYPE_OBJ
|
||||||
from .forms import sort_transactions_in, TransactionReorderForm
|
from .forms import sort_transactions_in, TransactionReorderForm
|
||||||
from .query import get_transaction_query
|
from .query import get_transaction_query
|
||||||
from .template import with_type, format_amount, format_amount_input, \
|
from .template import with_type, to_transfer, format_amount, \
|
||||||
format_date, text2html, currency_options, default_currency_code
|
format_amount_input, format_date, text2html, currency_options, \
|
||||||
|
default_currency_code
|
||||||
|
|
||||||
bp: Blueprint = Blueprint("transaction", __name__)
|
bp: Blueprint = Blueprint("transaction", __name__)
|
||||||
"""The view blueprint for the transaction management."""
|
"""The view blueprint for the transaction management."""
|
||||||
bp.add_app_template_filter(with_type, "accounting_txn_with_type")
|
bp.add_app_template_filter(with_type, "accounting_txn_with_type")
|
||||||
|
bp.add_app_template_filter(to_transfer, "accounting_txn_to_transfer")
|
||||||
bp.add_app_template_filter(format_amount, "accounting_txn_format_amount")
|
bp.add_app_template_filter(format_amount, "accounting_txn_format_amount")
|
||||||
bp.add_app_template_filter(format_amount_input,
|
bp.add_app_template_filter(format_amount_input,
|
||||||
"accounting_txn_format_amount_input")
|
"accounting_txn_format_amount_input")
|
||||||
|
Loading…
Reference in New Issue
Block a user