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