Improve display of chart of accounts
Group account kinds by plugin Display label instead of ID
This commit is contained in:
parent
d7289bd2d0
commit
66b3ddff54
@ -19,7 +19,14 @@ from .webapp import app
|
|||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
advanced_reports = [] # list of tuplet (url, label)
|
advanced_reports = [] # list of tuplet (url, label)
|
||||||
account_kinds = [] # list of tuplet (id, label)
|
account_kinds = [
|
||||||
|
# list of tuplet (id, label)
|
||||||
|
('drcr.asset', 'Asset'),
|
||||||
|
('drcr.liability', 'Liability'),
|
||||||
|
('drcr.income', 'Income'),
|
||||||
|
('drcr.expense', 'Expense'),
|
||||||
|
('drcr.equity', 'Equity')
|
||||||
|
]
|
||||||
transaction_providers = [] # list of callable
|
transaction_providers = [] # list of callable
|
||||||
|
|
||||||
def init_plugins():
|
def init_plugins():
|
||||||
|
@ -25,14 +25,13 @@
|
|||||||
<div class="d-flex py-2 bg-white sticky-top">
|
<div class="d-flex py-2 bg-white sticky-top">
|
||||||
<div class="me-2">
|
<div class="me-2">
|
||||||
<select class="form-select" name="kind">
|
<select class="form-select" name="kind">
|
||||||
<option value="drcr.asset">Asset</option>
|
{% for plugin_name, plugin_account_kinds in account_kinds_by_plugin.items() %}
|
||||||
<option value="drcr.liability">Liability</option>
|
<optgroup label="{{ plugin_name }}">
|
||||||
<option value="drcr.income">Income</option>
|
{% for account_kind in plugin_account_kinds %}
|
||||||
<option value="drcr.expense">Expense</option>
|
|
||||||
<option value="drcr.equity">Equity</option>
|
|
||||||
{% for account_kind in account_kinds %}
|
|
||||||
<option value="{{ account_kind[0] }}">{{ account_kind[1] }}</option>
|
<option value="{{ account_kind[0] }}">{{ account_kind[1] }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</optgroup>
|
||||||
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -57,7 +56,7 @@
|
|||||||
{% if account in account_configurations %}
|
{% if account in account_configurations %}
|
||||||
<ul class="mb-0">
|
<ul class="mb-0">
|
||||||
{% for account_configuration in account_configurations[account] %}
|
{% for account_configuration in account_configurations[account] %}
|
||||||
<li>{{ account_configuration.kind }}</li>
|
<li>{{ account_kinds_map[account_configuration.kind] }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -22,6 +22,8 @@ from .plugins import account_kinds, advanced_reports
|
|||||||
from .reports import balance_sheet_report, income_statement_report
|
from .reports import balance_sheet_report, income_statement_report
|
||||||
from .webapp import all_transactions, app
|
from .webapp import all_transactions, app
|
||||||
|
|
||||||
|
from itertools import groupby
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html', advanced_reports=advanced_reports)
|
return render_template('index.html', advanced_reports=advanced_reports)
|
||||||
@ -34,8 +36,18 @@ def chart_of_accounts():
|
|||||||
# Get existing AccountConfiguration's
|
# Get existing AccountConfiguration's
|
||||||
account_configurations = AccountConfiguration.get_all()
|
account_configurations = AccountConfiguration.get_all()
|
||||||
|
|
||||||
|
# Preprocess account kinds
|
||||||
|
account_kinds_by_plugin = {v: list(g) for v, g in groupby(account_kinds, key=lambda k: k[0][:k[0].index('.')])}
|
||||||
|
account_kinds_map = {name: label for name, label in account_kinds}
|
||||||
|
|
||||||
# TODO: Handle orphans
|
# TODO: Handle orphans
|
||||||
return render_template('chart_of_accounts.html', accounts=accounts, account_configurations=account_configurations, account_kinds=account_kinds)
|
return render_template(
|
||||||
|
'chart_of_accounts.html',
|
||||||
|
accounts=accounts,
|
||||||
|
account_configurations=account_configurations,
|
||||||
|
account_kinds_by_plugin=account_kinds_by_plugin,
|
||||||
|
account_kinds_map=account_kinds_map
|
||||||
|
)
|
||||||
|
|
||||||
@app.route('/chart-of-accounts/add-kind', methods=['POST'])
|
@app.route('/chart-of-accounts/add-kind', methods=['POST'])
|
||||||
def account_add_kind():
|
def account_add_kind():
|
||||||
|
Loading…
Reference in New Issue
Block a user