diff --git a/drcr/plugins.py b/drcr/plugins.py
index b3f4cad..712b8fc 100644
--- a/drcr/plugins.py
+++ b/drcr/plugins.py
@@ -19,7 +19,14 @@ from .webapp import app
import importlib
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
def init_plugins():
diff --git a/drcr/templates/chart_of_accounts.html b/drcr/templates/chart_of_accounts.html
index 4f350aa..356f031 100644
--- a/drcr/templates/chart_of_accounts.html
+++ b/drcr/templates/chart_of_accounts.html
@@ -25,13 +25,12 @@
@@ -57,7 +56,7 @@
{% if account in account_configurations %}
{% for account_configuration in account_configurations[account] %}
- - {{ account_configuration.kind }}
+ - {{ account_kinds_map[account_configuration.kind] }}
{% endfor %}
{% endif %}
diff --git a/drcr/views.py b/drcr/views.py
index 5ec7401..7e256f5 100644
--- a/drcr/views.py
+++ b/drcr/views.py
@@ -22,6 +22,8 @@ from .plugins import account_kinds, advanced_reports
from .reports import balance_sheet_report, income_statement_report
from .webapp import all_transactions, app
+from itertools import groupby
+
@app.route('/')
def index():
return render_template('index.html', advanced_reports=advanced_reports)
@@ -34,8 +36,18 @@ def chart_of_accounts():
# Get existing AccountConfiguration's
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
- 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'])
def account_add_kind():