diff --git a/ledger_pyreport/__init__.py b/ledger_pyreport/__init__.py index 90f64c9..9bbab30 100644 --- a/ledger_pyreport/__init__.py +++ b/ledger_pyreport/__init__.py @@ -304,6 +304,8 @@ def transactions(): @app.route('/transaction') def transaction(): + date = datetime.strptime(flask.request.args['date'], '%Y-%m-%d') + pstart = datetime.strptime(flask.request.args['pstart'], '%Y-%m-%d') uuid = flask.request.args['uuid'] cash = flask.request.args.get('cash', False) commodity = flask.request.args.get('commodity', False) @@ -314,17 +316,19 @@ def transaction(): if cash: l = accounting.ledger_to_cash(l, report_commodity) + l = accounting.trial_balance(l, date, pstart, report_commodity).ledger + transaction = next((t for t in l.transactions if str(t.uuid) == uuid)) if commodity: total_dr = sum((p.amount for p in transaction.postings if p.amount > 0), Balance()).clean() total_cr = sum((p.amount for p in transaction.postings if p.amount < 0), Balance()).clean() totals = itertools.zip_longest(total_dr.amounts, total_cr.amounts) - return flask.render_template('transaction_commodity.html', ledger=l, transaction=transaction, totals=totals, total_dr=total_dr.exchange(report_commodity, True), total_cr=total_cr.exchange(report_commodity, True), report_commodity=report_commodity, cash=cash) + return flask.render_template('transaction_commodity.html', ledger=l, transaction=transaction, totals=totals, total_dr=total_dr.exchange(report_commodity, True), total_cr=total_cr.exchange(report_commodity, True), report_commodity=report_commodity, cash=cash, date=date, pstart=pstart) else: total_dr = sum((p.amount for p in transaction.postings if p.amount > 0), Balance()).exchange(report_commodity, True) total_cr = sum((p.amount for p in transaction.postings if p.amount < 0), Balance()).exchange(report_commodity, True) - return flask.render_template('transaction.html', ledger=l, transaction=transaction, total_dr=total_dr, total_cr=total_cr, report_commodity=report_commodity, cash=cash) + return flask.render_template('transaction.html', ledger=l, transaction=transaction, total_dr=total_dr, total_cr=total_cr, report_commodity=report_commodity, cash=cash, date=date, pstart=pstart) # Template filters diff --git a/ledger_pyreport/jinja2/transaction.html b/ledger_pyreport/jinja2/transaction.html index 168f6e9..9331e78 100644 --- a/ledger_pyreport/jinja2/transaction.html +++ b/ledger_pyreport/jinja2/transaction.html @@ -22,7 +22,7 @@ {% block links %} {{ super() }} - Show commodity detail + Show commodity detail {% endblock %} {% block report %} diff --git a/ledger_pyreport/jinja2/transactions.html b/ledger_pyreport/jinja2/transactions.html index c6f82d1..95bd639 100644 --- a/ledger_pyreport/jinja2/transactions.html +++ b/ledger_pyreport/jinja2/transactions.html @@ -67,7 +67,7 @@ {% endif %} {% for transaction in transactions %} - {% set trn_url = '/transaction?' + {'uuid': transaction.uuid, 'cash': 'on' if cash else ''}|urlencode %} + {% set trn_url = '/transaction?' + {'date': date_end.strftime('%Y-%m-%d'), 'pstart': date_beg.strftime('%Y-%m-%d'), 'uuid': transaction.uuid, 'cash': 'on' if cash else ''}|urlencode %} {% if transaction.has_comment_detail %} diff --git a/ledger_pyreport/jinja2/transactions_commodity.html b/ledger_pyreport/jinja2/transactions_commodity.html index 38a002d..8a4055d 100644 --- a/ledger_pyreport/jinja2/transactions_commodity.html +++ b/ledger_pyreport/jinja2/transactions_commodity.html @@ -66,7 +66,7 @@ {% set ns.balance = opening_balance %} {% for transaction in transactions %} - {% set trn_url = '/transaction?' + {'uuid': transaction.uuid, 'cash': 'on' if cash else ''}|urlencode %} + {% set trn_url = '/transaction?' + {'date': date_end.strftime('%Y-%m-%d'), 'pstart': date_beg.strftime('%Y-%m-%d'), 'uuid': transaction.uuid, 'cash': 'on' if cash else ''}|urlencode %} {% for posting in transaction.postings if posting.account == account %} {% set ns.balance = ns.balance + posting.amount %} {% endfor %}