Update account creation to take in the account ID
We need the account ID to uniquely identify the account when we request transactions. So now we require the user to input the data. Over time we may be able to come up with a way to make this less onerous for the user since, in this case, AFCU actually calculates the account ID from the user ID. But we'll get to that as we learn more
This commit is contained in:
parent
f485f03f0c
commit
6d6112de33
|
@ -21,11 +21,13 @@
|
|||
<label for="name">Name</label>
|
||||
<input id="name" type="text" name="name" class="form-control" placeholder="My OFX account"></input>
|
||||
<label for="institution">Institution</label>
|
||||
<input id="institution" type="text" name="institution" class="form-control" list="institutions"></input>
|
||||
<label for="userid">User ID</label>
|
||||
<input id="userid" type="text" name="userid" class="form-control" placeholder="123456"></input>
|
||||
<input id="institution" type="text" name="institution" class="form-control" list="institutions" placeholder="Start typing..."></input>
|
||||
<label for="user_id">User ID</label>
|
||||
<input id="user_id" type="text" name="user_id" class="form-control" placeholder="123456"></input>
|
||||
<label for="password">Password</label>
|
||||
<input id="password" type="password" name="password" class="form-control" placeholder="1234"></input>
|
||||
<label for="account_id">Account ID</label>
|
||||
<input id="account_id" type="text" name="account_id" class="form-control" placeholder="123456-0.9:CHK"></input>
|
||||
<label for="type">Account Type</label>
|
||||
<select id="account_type" value="checking" name="account_type" class="form-control">
|
||||
<option value="checking">Checking</option>
|
||||
|
|
|
@ -13,12 +13,21 @@ def get_accounts():
|
|||
|
||||
@blueprint.route('/account/', methods=['POST'])
|
||||
def post_account():
|
||||
account_id = flask.request.form.get('account_id')
|
||||
account_type = flask.request.form.get('account_type')
|
||||
institution = flask.request.form.get('institution')
|
||||
name = flask.request.form.get('name')
|
||||
password = flask.request.form.get('password')
|
||||
userid = flask.request.form.get('userid')
|
||||
user_id = flask.request.form.get('user_id')
|
||||
|
||||
|
||||
vanth.platform.ofxaccount.create(flask.session['user_id'], name, account_type, institution, password, userid)
|
||||
vanth.platform.ofxaccount.create({
|
||||
'owner' : flask.session['user_id'],
|
||||
'account_id' : account_id,
|
||||
'institution' : institution,
|
||||
'name' : name,
|
||||
'password' : password,
|
||||
'type' : account_type,
|
||||
'user_id' : user_id,
|
||||
})
|
||||
return flask.redirect('/accounts/')
|
||||
|
|
|
@ -31,22 +31,14 @@ def get(user_id):
|
|||
'uuid' : result[vanth.tables.OFXAccount.c.uuid],
|
||||
} for result in results]
|
||||
|
||||
def create(user_id, name, account_type, institution, password, account_user):
|
||||
def create(values):
|
||||
engine = chryso.connection.get()
|
||||
|
||||
source_name = sqlalchemy.select([
|
||||
values['source'] = sqlalchemy.select([
|
||||
vanth.tables.OFXSource.c.uuid
|
||||
]).where(vanth.tables.OFXSource.c.name == institution)
|
||||
]).where(vanth.tables.OFXSource.c.name == values.pop('institution'))
|
||||
|
||||
_uuid = uuid.uuid4()
|
||||
statement = vanth.tables.OFXAccount.insert().values( # pylint: disable=no-value-for-parameter
|
||||
uuid = _uuid,
|
||||
name = name,
|
||||
user_id = account_user,
|
||||
password = password,
|
||||
type = account_type,
|
||||
source = source_name,
|
||||
owner = user_id,
|
||||
)
|
||||
values['uuid'] = uuid.uuid4()
|
||||
statement = vanth.tables.OFXAccount.insert().values(**values) # pylint: disable=no-value-for-parameter
|
||||
engine.execute(statement)
|
||||
return _uuid
|
||||
return values['uuid']
|
||||
|
|
Loading…
Reference in New Issue