aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn/views.py')
-rw-r--r--python/Dawn/views.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index 90c807ef..dcc0e195 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -46,6 +46,11 @@ def cp_choices(kind='bond'):
def account_codes():
return Accounts.query.order_by('code').with_entities(Accounts.code, Accounts.name)
+def fcm_accounts():
+ return (Accounts.query.
+ order_by('code').
+ filter(Accounts.name.ilike('%FCM%')).
+ with_entities(Accounts.code, Accounts.name))
def get_queue():
q = getattr(g, 'queue', None)
@@ -97,7 +102,7 @@ class CDSForm(ModelForm):
model = CDSDeal
include_foreign_keys = True
exclude = ['dealid', 'lastupdate', 'termination_amount',
- 'termination_cp', 'termination_date']
+ 'termination_cp', 'termination_date', 'custodian', 'cashaccount']
class SwaptionForm(ModelForm):
@@ -172,6 +177,8 @@ def get_form(trade, kind):
form = Form(trade_date=today.date(),
effective_date=tomorrow.date(),
upfront_settle_date=today.date() + 3 * bus_day)
+ if kind == 'cds':
+ form.account_code.choices = fcm_accounts()
else:
form = Form(trade_date=today.date(),
settle_date=today.date() + 2 * bus_day)
@@ -309,12 +316,14 @@ def trade_manage(tradeid, kind):
form = _get_form(kind)()
form.cp_code.choices = form.cp_code.choices + list(cp_choices(kind))
+ form.account_code.choices = list(fcm_accounts())
if kind == 'bond':
old_ticket_name = trade.ticket
if kind == 'capfloor':
old_confirm = trade.trade_confirm
if form.validate_on_submit():
form.populate_obj(trade)
+ trade.cashaccount = trade.fcm_account.cash_account
session = form.get_session()
if not tradeid:
session.add(trade)
@@ -336,8 +345,11 @@ def trade_manage(tradeid, kind):
q.rpush(f'{kind}_trades', simple_serialize(trade))
return redirect(url_for('list_trades', kind=kind))
else:
+ if form.errors:
+ app.logger.error(form.errors)
form = get_form(trade, kind)
form.cp_code.choices = form.cp_code.choices + list(cp_choices(kind))
+ form.account_code.choices = list(fcm_accounts())
return render_template('trade_entry.html', form=form,
action_url=url_for('trade_manage', tradeid=tradeid, kind=kind))