From af2818b6ae1cff93ad3cbaeeedb136613f03af98 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 6 Apr 2024 01:42:34 +1100 Subject: [PATCH] Apply custom accounts combobox to other simple forms --- austax/templates/cgt_adjustments_edit.html | 9 +++-- .../templates/cgt_adjustments_multinew.html | 9 +++-- austax/views.py | 9 ++--- drcr/journal/views.py | 4 +-- drcr/statements/views.py | 6 ++-- .../components/accounts_combobox_inner.html | 34 +++++++++++++++++++ .../journal/balance_assertions_edit.html | 18 +--------- drcr/templates/statements/import.html | 14 +++++--- 8 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 drcr/templates/components/accounts_combobox_inner.html diff --git a/austax/templates/cgt_adjustments_edit.html b/austax/templates/cgt_adjustments_edit.html index 9518f45..9aa6510 100644 --- a/austax/templates/cgt_adjustments_edit.html +++ b/austax/templates/cgt_adjustments_edit.html @@ -33,8 +33,9 @@ -
- +
+ + {% include 'components/accounts_combobox_inner.html' %}
@@ -66,3 +67,7 @@
{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/austax/templates/cgt_adjustments_multinew.html b/austax/templates/cgt_adjustments_multinew.html index 34b971a..aeaaefb 100644 --- a/austax/templates/cgt_adjustments_multinew.html +++ b/austax/templates/cgt_adjustments_multinew.html @@ -29,8 +29,9 @@

CGT assets

-
- +
+ + {% include 'components/accounts_combobox_inner.html' %}
@@ -75,3 +76,7 @@
{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/austax/views.py b/austax/views.py index 38feeba..abc4459 100644 --- a/austax/views.py +++ b/austax/views.py @@ -19,7 +19,7 @@ from flask import redirect, render_template, request, url_for from drcr.models import AccountConfiguration, Amount, Posting, Transaction from drcr.database import db from drcr.plugins import render_plugin_template -from drcr.webapp import app, eofy_date +from drcr.webapp import all_accounts, app, eofy_date from .models import CGTAsset, CGTCostAdjustment from .reports import tax_summary_report @@ -45,7 +45,7 @@ def cgt_adjustments(): @app.route('/tax/cgt-adjustments/new', methods=['GET', 'POST']) def cgt_adjustment_new(): if request.method == 'GET': - return render_plugin_template('austax', 'cgt_adjustments_edit.html', adjustment=None) + return render_plugin_template('austax', 'cgt_adjustments_edit.html', adjustment=None, all_accounts=all_accounts()) asset = Amount.parse(request.form['asset']) adjustment = CGTCostAdjustment( @@ -65,7 +65,7 @@ def cgt_adjustment_new(): @app.route('/tax/cgt-adjustments/edit', methods=['GET', 'POST']) def cgt_adjustment_edit(): if request.method == 'GET': - return render_plugin_template('austax', 'cgt_adjustments_edit.html', adjustment=db.session.get(CGTCostAdjustment, request.args['id'])) + return render_plugin_template('austax', 'cgt_adjustments_edit.html', adjustment=db.session.get(CGTCostAdjustment, request.args['id']), all_accounts=all_accounts()) asset = Amount.parse(request.form['asset']) adjustment = db.session.get(CGTCostAdjustment, request.args['id']) @@ -91,7 +91,8 @@ def cgt_adjustment_multinew(): commodity=None, dt=None, description=None, - cost_adjustment=None + cost_adjustment=None, + all_accounts=all_accounts() ) # TODO: Preview mode? diff --git a/drcr/journal/views.py b/drcr/journal/views.py index 465ccf0..add4ef5 100644 --- a/drcr/journal/views.py +++ b/drcr/journal/views.py @@ -146,7 +146,7 @@ def balance_assertions(): @app.route('/balance-assertions/new', methods=['GET', 'POST']) def balance_assertions_new(): if request.method == 'GET': - return render_template('journal/balance_assertions_edit.html', assertion=None, accounts=all_accounts()) + return render_template('journal/balance_assertions_edit.html', assertion=None, all_accounts=all_accounts()) quantity = round(float(request.form['amount']) * (10**AMOUNT_DPS)) if request.form['sign'] == 'cr': @@ -172,7 +172,7 @@ def balance_assertions_edit(): abort(404) if request.method == 'GET': - return render_template('journal/balance_assertions_edit.html', assertion=assertion, accounts=all_accounts()) + return render_template('journal/balance_assertions_edit.html', assertion=assertion, all_accounts=all_accounts()) if request.form.get('action', None) == 'delete': # Delete balance assertion diff --git a/drcr/statements/views.py b/drcr/statements/views.py index 4f0b5f8..f72207b 100644 --- a/drcr/statements/views.py +++ b/drcr/statements/views.py @@ -19,7 +19,7 @@ from flask import abort, redirect, render_template, request, url_for from .. import AMOUNT_DPS from ..database import db from ..models import Amount, Posting, Transaction -from ..webapp import app +from ..webapp import all_accounts, app from .models import StatementLine, StatementLineReconciliation from datetime import datetime @@ -39,7 +39,7 @@ def statement_lines(): page = db.paginate(statement_lines, per_page=int(request.args.get('per_page', 1000))) - return render_template('statements/statement_lines.html', page=page) + return render_template('statements/statement_lines.html', page=page, all_accounts=all_accounts()) @app.route('/statement-lines/charge', methods=['POST']) def statement_line_charge(): @@ -172,7 +172,7 @@ def statement_line_reconcile_transfer(): @app.route('/statement-lines/import', methods=['GET', 'POST']) def statement_lines_import(): if request.method == 'GET': - return render_template('statements/import.html') + return render_template('statements/import.html', all_accounts=all_accounts()) # Import using importer if request.form['format'] == 'ofx1': diff --git a/drcr/templates/components/accounts_combobox_inner.html b/drcr/templates/components/accounts_combobox_inner.html new file mode 100644 index 0000000..d6ac009 --- /dev/null +++ b/drcr/templates/components/accounts_combobox_inner.html @@ -0,0 +1,34 @@ +{# DrCr: Web-based double-entry bookkeeping framework + Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +#} + + + diff --git a/drcr/templates/journal/balance_assertions_edit.html b/drcr/templates/journal/balance_assertions_edit.html index 104ec36..185e985 100644 --- a/drcr/templates/journal/balance_assertions_edit.html +++ b/drcr/templates/journal/balance_assertions_edit.html @@ -37,23 +37,7 @@
- - + {% include 'components/accounts_combobox_inner.html' %}
diff --git a/drcr/templates/statements/import.html b/drcr/templates/statements/import.html index 21d7b1c..087dfd6 100644 --- a/drcr/templates/statements/import.html +++ b/drcr/templates/statements/import.html @@ -28,8 +28,9 @@
-
- +
+ + {% include 'components/accounts_combobox_inner.html' %}
@@ -51,8 +52,9 @@
-
- +
+ + {% include 'components/accounts_combobox_inner.html' %}
@@ -69,3 +71,7 @@
{% endblock %} + +{% block scripts %} + +{% endblock %}