From c26dba6d2e8bd0b025d3a247dcd7fecd19541bde Mon Sep 17 00:00:00 2001 From: Eli Ribble <eli@authentise.com> Date: Fri, 1 Jul 2016 12:09:36 -0600 Subject: [PATCH] Insert an update record any time we update an OFX account Makes it a little easier to report to the user what was done and when --- vanth/celery.py | 9 ++++++++- vanth/platform/ofxupdate.py | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 vanth/platform/ofxupdate.py diff --git a/vanth/celery.py b/vanth/celery.py index 468a140..2c0dec9 100644 --- a/vanth/celery.py +++ b/vanth/celery.py @@ -1,3 +1,5 @@ +import logging + import celery import vanth.download @@ -5,6 +7,9 @@ import vanth.main import vanth.platform.ofxaccount import vanth.platform.ofxrecord import vanth.platform.ofxsource +import vanth.platform.ofxupdate + +LOGGER = logging.getLogger(__name__) app = celery.Celery('vanth') app.conf.CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml'] @@ -13,7 +18,9 @@ app.conf.CELERY_ALWAYS_EAGER = True @app.task() def update_account(account_uuid): - account = vanth.platform.ofxaccount.by_uuid(account_uuid)[0] + LOGGER.debug("Updating account %s", account_uuid) + account = vanth.platform.ofxaccount.by_uuid(account_uuid) source = vanth.platform.ofxsource.by_uuid(account['source']['uuid'])[0] document = vanth.download.transactions(source, account) vanth.platform.ofxrecord.ensure_exists(account, document.body.statement.transactions.items) + vanth.platform.ofxupdate.OFXUpdate.create(ofxaccount=account_uuid) diff --git a/vanth/platform/ofxupdate.py b/vanth/platform/ofxupdate.py new file mode 100644 index 0000000..8403dae --- /dev/null +++ b/vanth/platform/ofxupdate.py @@ -0,0 +1,7 @@ +import chryso.resource + +import vanth.tables + + +class OFXUpdate(chryso.resource.Resource): + TABLE = vanth.tables.OFXUpdate