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
This commit is contained in:
Eli Ribble 2016-07-01 12:09:36 -06:00
parent b716502b78
commit c26dba6d2e
2 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import logging
import celery import celery
import vanth.download import vanth.download
@ -5,6 +7,9 @@ import vanth.main
import vanth.platform.ofxaccount import vanth.platform.ofxaccount
import vanth.platform.ofxrecord import vanth.platform.ofxrecord
import vanth.platform.ofxsource import vanth.platform.ofxsource
import vanth.platform.ofxupdate
LOGGER = logging.getLogger(__name__)
app = celery.Celery('vanth') app = celery.Celery('vanth')
app.conf.CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml'] app.conf.CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml']
@ -13,7 +18,9 @@ app.conf.CELERY_ALWAYS_EAGER = True
@app.task() @app.task()
def update_account(account_uuid): 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] source = vanth.platform.ofxsource.by_uuid(account['source']['uuid'])[0]
document = vanth.download.transactions(source, account) document = vanth.download.transactions(source, account)
vanth.platform.ofxrecord.ensure_exists(account, document.body.statement.transactions.items) vanth.platform.ofxrecord.ensure_exists(account, document.body.statement.transactions.items)
vanth.platform.ofxupdate.OFXUpdate.create(ofxaccount=account_uuid)

View File

@ -0,0 +1,7 @@
import chryso.resource
import vanth.tables
class OFXUpdate(chryso.resource.Resource):
TABLE = vanth.tables.OFXUpdate