diff --git a/austax/__init__.py b/austax/__init__.py index df24417..4a6e337 100644 --- a/austax/__init__.py +++ b/austax/__init__.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from flask import render_template +from flask import render_template, url_for from drcr.models import AccountConfiguration, Posting, Transaction, TrialBalancer from drcr.database import db @@ -24,9 +24,9 @@ from .reports import eofy_date, tax_summary_report from . import views def plugin_init(): - drcr.plugins.data_sources.append(('/tax/cgt-adjustments', 'CGT adjustments')) - drcr.plugins.advanced_reports.append(('/tax/cgt-assets', 'CGT assets')) - drcr.plugins.advanced_reports.append(('/tax/summary', 'Tax summary')) + drcr.plugins.data_sources.append(('cgt_adjustments', 'CGT adjustments')) + drcr.plugins.advanced_reports.append(('cgt_assets', 'CGT assets')) + drcr.plugins.advanced_reports.append(('tax_summary', 'Tax summary')) drcr.plugins.account_kinds.append(('austax.income1', 'Salary or wages (1)')) drcr.plugins.account_kinds.append(('austax.income5', 'Australian Government allowances and payments (5)')) diff --git a/austax/templates/cgt_adjustments.html b/austax/templates/cgt_adjustments.html index 5c6f5c5..3015a55 100644 --- a/austax/templates/cgt_adjustments.html +++ b/austax/templates/cgt_adjustments.html @@ -22,8 +22,8 @@

CGT adjustments

- New CGT adjustment - Multiple CGT adjustments + New CGT adjustment + Multiple CGT adjustments
@@ -51,7 +51,7 @@ - + {% endfor %} diff --git a/austax/templates/cgt_assets.html b/austax/templates/cgt_assets.html index b6bd644..5b999dc 100644 --- a/austax/templates/cgt_assets.html +++ b/austax/templates/cgt_assets.html @@ -50,14 +50,14 @@ {% for asset in assets %} - + - + - + diff --git a/austax/views.py b/austax/views.py index 94f60d4..58b6138 100644 --- a/austax/views.py +++ b/austax/views.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from flask import redirect, render_template, request +from flask import redirect, render_template, request, url_for from drcr.models import AccountConfiguration, Amount, Posting, Transaction from drcr.database import db @@ -60,7 +60,7 @@ def cgt_adjustment_new(): db.session.add(adjustment) db.session.commit() - return redirect('/tax/cgt-adjustments') + return redirect(url_for('cgt_adjustments')) @app.route('/tax/cgt-adjustments/edit', methods=['GET', 'POST']) def cgt_adjustment_edit(): @@ -80,7 +80,7 @@ def cgt_adjustment_edit(): db.session.add(adjustment) db.session.commit() - return redirect('/tax/cgt-adjustments') + return redirect(url_for('cgt_adjustments')) @app.route('/tax/cgt-adjustments/multi-new', methods=['GET', 'POST']) def cgt_adjustment_multinew(): @@ -166,7 +166,7 @@ def cgt_adjustment_multinew(): db.session.commit() - return redirect('/tax/cgt-adjustments') + return redirect(url_for('cgt_adjustments')) @app.route('/tax/cgt-assets') def cgt_assets(): diff --git a/drcr/journal/views.py b/drcr/journal/views.py index e666c35..13a066f 100644 --- a/drcr/journal/views.py +++ b/drcr/journal/views.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from flask import abort, redirect, render_template, request +from flask import abort, redirect, render_template, request, url_for from .. import AMOUNT_DPS from ..database import db @@ -31,7 +31,7 @@ def journal(): return render_template( 'journal/journal.html', - commodity_detail=request.args.get('commodity-detail', '0') == '1', + commodity_detail=request.args.get('commodity_detail', '0') == '1', transactions=transactions ) @@ -64,7 +64,7 @@ def journal_new_transaction(): db.session.add(transaction) db.session.commit() - return redirect('/journal') + return redirect(url_for('journal')) @app.route('/journal/edit-transaction', methods=['GET', 'POST']) def journal_edit_transaction(): @@ -109,7 +109,7 @@ def journal_edit_transaction(): db.session.commit() - return redirect('/journal') + return redirect(url_for('journal')) @app.route('/balance-assertions') def balance_assertions(): @@ -151,7 +151,7 @@ def balance_assertions_new(): db.session.add(assertion) db.session.commit() - return redirect('/balance-assertions') + return redirect(url_for('balance_assertions')) @app.route('/balance-assertions/edit', methods=['GET', 'POST']) def balance_assertions_edit(): @@ -174,4 +174,4 @@ def balance_assertions_edit(): db.session.commit() - return redirect('/balance-assertions') + return redirect(url_for('balance_assertions')) diff --git a/drcr/plugins.py b/drcr/plugins.py index a530c78..caed990 100644 --- a/drcr/plugins.py +++ b/drcr/plugins.py @@ -21,8 +21,8 @@ from .webapp import app import importlib -data_sources = [] # list of tuplet (url, label) -advanced_reports = [] # list of tuplet (url, label) +data_sources = [] # list of tuplet (view name, label) +advanced_reports = [] # list of tuplet (view name, label) account_kinds = [ # list of tuplet (id, label) diff --git a/drcr/reports.py b/drcr/reports.py index caa1602..300da65 100644 --- a/drcr/reports.py +++ b/drcr/reports.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from flask import url_for + from .models import AccountConfiguration, Amount, TrialBalancer from .webapp import all_transactions @@ -123,7 +125,7 @@ def entries_for_kind(account_configurations, accounts, kind, neg=False, floor=0) amount = -amount if floor: amount.quantity = (amount.quantity // floor) * floor - entries.append(Entry(text=account_name, amount=amount, link='/account-transactions?account=' + account_name)) + entries.append(Entry(text=account_name, amount=amount, link=url_for('account_transactions', account=account_name))) return entries def balance_sheet_report(): @@ -156,7 +158,7 @@ def balance_sheet_report(): Calculated( 'Current year surplus (deficit)', lambda _: income_statement_report().by_id('net_surplus').amount, - link='/income-statement' + link=url_for('income_statement') ), Subtotal('Total equity', bordered=True) ] diff --git a/drcr/statements/views.py b/drcr/statements/views.py index 7171725..344d5e7 100644 --- a/drcr/statements/views.py +++ b/drcr/statements/views.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from flask import abort, redirect, render_template, request +from flask import abort, redirect, render_template, request, url_for from .. import AMOUNT_DPS from ..database import db @@ -94,7 +94,7 @@ def statement_line_reconcile_transfer(): db.session.add(transaction) db.session.commit() - return redirect('/statement-lines') + return redirect(url_for('statement_lines')) @app.route('/statement-lines/import', methods=['GET', 'POST']) def statement_lines_import(): @@ -123,4 +123,4 @@ def statement_lines_import(): db.session.add(statement_line) db.session.commit() - return redirect('/statement-lines') + return redirect(url_for('statement_lines')) diff --git a/drcr/templates/base.html b/drcr/templates/base.html index ba0d01d..1db8b46 100644 --- a/drcr/templates/base.html +++ b/drcr/templates/base.html @@ -35,12 +35,12 @@ {% block body %}
{{ cgt_adjustment.dt.strftime('%Y-%m-%d') }} {{ cgt_adjustment.description }} {{ cgt_adjustment.cost_adjustment_amount().format_accounting() }}
{{ asset.account }}{{ asset.account }} {{ asset.commodity_name() }} {{ asset.format('hide') }} {{ asset.acquisition_date.strftime('%Y-%m-%d') }} {{ asset.as_cost().format() }}{{ asset.cost_adjustment().format_accounting(link="/tax/cgt-adjustments?account={}&commodity={}&quantity={}&acquisition_date={:%Y-%m-%d}".format(asset.account, asset.commodity, asset.quantity, asset.acquisition_date)) if asset.cost_adjustments }}{{ asset.cost_adjustment().format_accounting(link=url_for('cgt_adjustments', account=asset.account, commodity=asset.commodity, quantity=asset.quantity, acquisition_date=asset.acquisition_date.strftime('%Y-%m-%d'))) if asset.cost_adjustments }} {# TODO #} {{ asset.disposal_date.strftime('%Y-%m-%d') if asset.disposal_date else '' }} {{ asset.disposal_value.format() if asset.disposal_value else '' }} {% if asset.disposal_date %}{{ asset.gain().format_accounting() }}{% endif %}
@@ -46,7 +46,7 @@ - + {% endfor %} diff --git a/drcr/templates/journal/journal.html b/drcr/templates/journal/journal.html index 84b9a49..57d74eb 100644 --- a/drcr/templates/journal/journal.html +++ b/drcr/templates/journal/journal.html @@ -22,11 +22,11 @@

Journal

- New transaction + New transaction {% if commodity_detail %} - Hide commodity detail + Hide commodity detail {% else %} - Show commodity detail + Show commodity detail {% endif %}
@@ -43,7 +43,7 @@ {% for transaction in transactions %} - + diff --git a/drcr/templates/statements/statement_lines.html b/drcr/templates/statements/statement_lines.html index 9d92d8f..f4f55b4 100644 --- a/drcr/templates/statements/statement_lines.html +++ b/drcr/templates/statements/statement_lines.html @@ -25,7 +25,7 @@
{##}
@@ -103,7 +103,7 @@ alert('Error when charging statement line'); } }); - xhr.open('POST', '/statement-lines/charge'); + xhr.open('POST', '{{ url_for("statement_line_charge") }}'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('line-id=' + lineId + '&charge-account=' + chargeAccount); } diff --git a/drcr/templates/transactions.html b/drcr/templates/transactions.html index ba2a3be..f817a59 100644 --- a/drcr/templates/transactions.html +++ b/drcr/templates/transactions.html @@ -22,8 +22,8 @@

Account transactions

- New transaction - Show commodity detail + New transaction + Show commodity detail
{{ (assertion.balance()|abs).format() }} {{ 'Dr' if assertion.quantity >= 0 else 'Cr' }} {% if assertion_status[assertion] %}{% else %}{% endif %}
{{ transaction.dt.strftime('%Y-%m-%d') }}{{ transaction.description }} {{ transaction.description }}
{{ line.amount().format() if line.quantity >= 0 else '' }}
@@ -47,7 +47,7 @@ @@ -61,7 +61,7 @@ diff --git a/drcr/templates/transactions_commodity_detail.html b/drcr/templates/transactions_commodity_detail.html index 35db3d6..424954f 100644 --- a/drcr/templates/transactions_commodity_detail.html +++ b/drcr/templates/transactions_commodity_detail.html @@ -22,7 +22,7 @@

Account transactions

- Hide commodity detail + Hide commodity detail
{{ transaction.dt.strftime('%Y-%m-%d') }} {{ transaction.description }} - {% if transaction.id %}{% endif %} + {% if transaction.id %}{% endif %} {% for p in transaction.postings if p.account != account %}{{ p.account }}{% endfor %} {{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}{{ transaction.dt.strftime('%Y-%m-%d') }} {{ transaction.description }} - {% if transaction.id %}{% endif %} + {% if transaction.id %}{% endif %}
@@ -42,7 +42,7 @@ diff --git a/drcr/templates/trial_balance.html b/drcr/templates/trial_balance.html index 4744e88..32ed2d7 100644 --- a/drcr/templates/trial_balance.html +++ b/drcr/templates/trial_balance.html @@ -32,7 +32,7 @@ {% for name, balance in accounts.items() %} - + diff --git a/drcr/views.py b/drcr/views.py index c084717..781588f 100644 --- a/drcr/views.py +++ b/drcr/views.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from flask import redirect, render_template, request +from flask import redirect, render_template, request, url_for from .database import db from .models import AccountConfiguration, Amount, Balance, Posting, TrialBalancer @@ -57,13 +57,13 @@ def account_add_kind(): db.session.commit() - return redirect('/chart-of-accounts') + return redirect(url_for('chart_of_accounts')) @app.route('/general-ledger') def general_ledger(): return render_template( 'general_ledger.html', - commodity_detail=request.args.get('commodity-detail', '0') == '1', + commodity_detail=request.args.get('commodity_detail', '0') == '1', transactions=sorted(all_transactions(), key=lambda t: t.dt) ) @@ -82,7 +82,7 @@ def account_transactions(): # FIXME: Filter in SQL transactions = [t for t in all_transactions() if any(p.account == request.args['account'] for p in t.postings)] - if request.args.get('commodity-detail', '0') == '1': + if request.args.get('commodity_detail', '0') == '1': return render_template( 'transactions_commodity_detail.html', account=request.args['account'],
{{ transaction.dt.strftime('%Y-%m-%d') }} {{ transaction.description }} - {% if transaction.id %}{% endif %} + {% if transaction.id %}{% endif %}
{{ name }}{{ name }} {{ balance.format() if balance.quantity >= 0 else '' }} {{ (balance|abs).format() if balance.quantity < 0 else '' }}