aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn')
-rw-r--r--python/Dawn/views.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index 5f479878..ae4a0d58 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -188,17 +188,18 @@ def split_direction(g, direction):
raise ValueError("direction can be one of 'outgoing' or 'incoming'")
def gen_cashflow_deals(form, session, wire_id=None):
- action = form.get("action")
to_date = lambda s: datetime.datetime.strptime(s, "%Y-%m-%d")
- trade_date = form.get("trade_date", None, to_date)
+ d = {'action': form.get("action"),
+ 'trade_date': form.get("trade_date", None, to_date)}
+
for direction in ["incoming", "outgoing"]:
count = 1
while True:
if f"{direction}-code-{count}" not in form:
break
else:
- d = {field: form.get(f"{direction}-{field}-{count}") for field \
- in ["folder", "code", "amount", "currency"]}
+ d .update({field: form.get(f"{direction}-{field}-{count}") for field \
+ in ["folder", "code", "amount", "currency"]})
count += 1
if direction == "outgoing":
d['amount'] = - float(d['amount'])
@@ -212,9 +213,7 @@ def gen_cashflow_deals(form, session, wire_id=None):
setattr(cf, k, v)
yield cf
else:
- cf = CashFlowDeal(trade_date=trade_date,
- action=action,
- **d)
+ cf = CashFlowDeal(**d)
session.add(cf); yield cf
@app.route('/wires/<int:wire_id>', methods = ['GET', 'POST'])