aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/Dawn/views.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index 707c5999..fa48f63b 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -393,13 +393,18 @@ def terminate(dealid, kind):
form.populate_obj(termination)
session = form.get_session()
rec = db.session.execute(
- "SELECT notional, coalesce(terminated_amount, 0.), currency, globeop_id, cp_code "
+ "SELECT notional, coalesce(terminated_amount, 0.), currency, b.globeop_id, cp_code "
f"FROM {table} "
"LEFT JOIN "
"(SELECT dealid, sum(termination_amount) AS terminated_amount "
" FROM terminations group by dealid) term USING (dealid) "
+ "LEFT JOIN LATERAL ( "
+ " SELECT globeop_id FROM id_mapping "
+ " WHERE serenitas_id=id AND date <= :date "
+ " ORDER BY date DESC LIMIT 1"
+ ") b ON true "
"WHERE dealid = :dealid",
- {"dealid": dealid},
+ {"dealid": dealid, "date": termination.termination_date},
)
notional, terminated_amount, currency, globeop_id, cp_code = next(rec)
is_assignment = True