Add simple page for showing details about a single account

For now this just includes the transactions that we know about on the
account. It'll grow. Give it time
This commit is contained in:
Eli Ribble 2016-06-28 16:07:59 -06:00
parent 2cc0cfb2bb
commit ccdd03b04b
4 changed files with 46 additions and 1 deletions

25
templates/account.html Normal file
View File

@ -0,0 +1,25 @@
{% extends 'layout.html' %}
{% block main_content %}
<h1>{{ account.name }}</h1>
{% if records %}
<table class="table">
<tr><th>Name</th><th>Type</th><th>Amount</th><th>Posted</th><th></th></tr>
{% for record in records %}
<tr>
<td>{{ record.name }}</a></td>
<td>{{ record.type }}</td>
<td>{{ record.amount }}</td>
<td>{{ account.posted }}</td>
<td>
<form method="POST" action="/update/">
<input type="hidden" name="account_uuid" value="{{ account.uuid }}"></input>
<input type="submit" value="Update" class="btn btn-primary"></input>
</form>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>This account does not have any transactions yet</p>
{% endif %}
{% endblock %}

View File

@ -6,7 +6,7 @@
<tr><th>Name</th><th>Type</th><th>Institution</th><th>Last Update</th><th></th></tr> <tr><th>Name</th><th>Type</th><th>Institution</th><th>Last Update</th><th></th></tr>
{% for account in accounts %} {% for account in accounts %}
<tr> <tr>
<td>{{ account.name }}</td> <td><a href="/accounts/{{ account.uuid }}/">{{ account.name }}</a></td>
<td>{{ account.type }}</td> <td>{{ account.type }}</td>
<td>{{ account.source.name }}</td> <td>{{ account.source.name }}</td>
<td>{{ account.last_updated }}</td> <td>{{ account.last_updated }}</td>

View File

@ -13,6 +13,12 @@ def get_accounts():
sources = vanth.platform.ofxsource.get() sources = vanth.platform.ofxsource.get()
return flask.render_template('accounts.html', accounts=my_accounts, sources=sources) return flask.render_template('accounts.html', accounts=my_accounts, sources=sources)
@blueprint.route('/accounts/<uuid:account_uuid>/', methods=['GET'])
def get_account(account_uuid):
account = vanth.platform.ofxaccount.by_uuid(account_uuid)
records = vanth.platform.ofxrecord.by_account(account_uuid)
return flask.render_template('account.html', account=account, records=records)
@blueprint.route('/account/', methods=['POST']) @blueprint.route('/account/', methods=['POST'])
@vanth.pages.tools.parse({ @vanth.pages.tools.parse({
'account_id' : str, 'account_id' : str,

View File

@ -32,3 +32,17 @@ def ensure_exists(account, transactions):
if to_insert: if to_insert:
engine.execute(vanth.tables.OFXRecord.insert(), to_insert) # pylint: disable=no-value-for-parameter engine.execute(vanth.tables.OFXRecord.insert(), to_insert) # pylint: disable=no-value-for-parameter
LOGGER.debug("Done inserting %d records", len(new_records)) LOGGER.debug("Done inserting %d records", len(new_records))
def by_account(account_uuid):
engine = chryso.connection.get()
query = sqlalchemy.select([
vanth.tables.OFXRecord.c.amount,
vanth.tables.OFXRecord.c.available,
vanth.tables.OFXRecord.c.fid,
vanth.tables.OFXRecord.c.name,
vanth.tables.OFXRecord.c.memo,
vanth.tables.OFXRecord.c.posted,
vanth.tables.OFXRecord.c.type,
]).where(vanth.tables.OFXRecord.c.ofxaccount == account_uuid)
rows = engine.execute(query).fetchall()
return [dict(row) for row in rows]