Add simple function for uploading OFX-based transactions
The OFX direct connection for my bank isn't working right now. I have a support ticket in. Until then I'm going to work on doing a manual upload and parse of transactions from this OFX document
This commit is contained in:
parent
8d0d8d72b1
commit
438c073e0f
|
@ -29,4 +29,10 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>This account does not have any transactions yet</p>
|
<p>This account does not have any transactions yet</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<form method="POST" action="/transactions/" enctype="multipart/form-data">
|
||||||
|
<p>Want to upload your own transactions? Cool. Do it here.</p>
|
||||||
|
<input type="hidden" name="account_uuid" value="{{ account.uuid }}">
|
||||||
|
<input type="file" name="transactions" id="transactions">
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
import werkzeug.utils
|
||||||
|
|
||||||
import vanth.celery
|
import vanth.celery
|
||||||
import vanth.pages.tools
|
import vanth.pages.tools
|
||||||
import vanth.platform.ofxaccount
|
import vanth.platform.ofxaccount
|
||||||
import vanth.platform.ofxsource
|
import vanth.platform.ofxsource
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger()
|
||||||
blueprint = flask.Blueprint('accounts', __name__)
|
blueprint = flask.Blueprint('accounts', __name__)
|
||||||
|
|
||||||
@blueprint.route('/accounts/', methods=['GET'])
|
@blueprint.route('/accounts/', methods=['GET'])
|
||||||
|
@ -40,3 +44,18 @@ def post_account(arguments):
|
||||||
def post_update(arguments):
|
def post_update(arguments):
|
||||||
vanth.celery.update_account.delay(**arguments)
|
vanth.celery.update_account.delay(**arguments)
|
||||||
return flask.redirect('/accounts/')
|
return flask.redirect('/accounts/')
|
||||||
|
|
||||||
|
@blueprint.route('/transactions/', methods=['POST'])
|
||||||
|
@vanth.pages.tools.parse({
|
||||||
|
'account_uuid' : str,
|
||||||
|
})
|
||||||
|
def post_transactions(arguments):
|
||||||
|
if 'transactions' not in flask.request.files:
|
||||||
|
return flask.render_template('error.html', error="You did not include the content of the file in your upload")
|
||||||
|
transactions = flask.request.files['transactions']
|
||||||
|
if transactions.filename == '':
|
||||||
|
return flask.redirect('/accounts/{}/'.format(arguments['account_uuid']))
|
||||||
|
filename = werkzeug.utils.secure_filename(transactions.filename)
|
||||||
|
LOGGER.info("Saving uploaded file %s to %s", transactions.filename, filename)
|
||||||
|
transactions.save(filename)
|
||||||
|
return flask.redirect('/accounts/{}/'.format(arguments['account_uuid']))
|
||||||
|
|
Loading…
Reference in New Issue