From ff4a2fc3fbeb243cea8b61ee5fdd887ba3513534 Mon Sep 17 00:00:00 2001 From: Rajandeep Date: Mon, 22 Dec 2025 09:24:47 -0800 Subject: [PATCH 1/2] 31096 - Skip Event Not Completed For Migration --- data-tool/flows/corps/corp_queries.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/data-tool/flows/corps/corp_queries.py b/data-tool/flows/corps/corp_queries.py index dd4c0752fb..06f1fe7216 100644 --- a/data-tool/flows/corps/corp_queries.py +++ b/data-tool/flows/corps/corp_queries.py @@ -127,6 +127,17 @@ def get_corp_event_filing_data_query(corp_num: str, event_id: int): where 1 = 1 and e.corp_num = '{corp_num}' and e.event_id = {event_id} + and not ( + (select corp_name + from corp_name + where corp_num = '{corp_num}' + and start_event_id < {event_id} + and (end_event_id is null or end_event_id >= {event_id}) + and corp_name_typ_cd in ('CO', 'NB') + order by start_event_id desc + limit 1) = null + and (cn.corp_name is null or cn.corp_name = '') + ) order by e.event_id ; """ From 7f2144d72524586149507f319030b235e2dbd71b Mon Sep 17 00:00:00 2001 From: Rajandeep Date: Thu, 8 Jan 2026 14:32:37 -0800 Subject: [PATCH 2/2] Updated Explicitely for NO and in tombstone queries --- data-tool/flows/corps/corp_queries.py | 11 ----------- data-tool/flows/tombstone/tombstone_queries.py | 5 +++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/data-tool/flows/corps/corp_queries.py b/data-tool/flows/corps/corp_queries.py index 06f1fe7216..dd4c0752fb 100644 --- a/data-tool/flows/corps/corp_queries.py +++ b/data-tool/flows/corps/corp_queries.py @@ -127,17 +127,6 @@ def get_corp_event_filing_data_query(corp_num: str, event_id: int): where 1 = 1 and e.corp_num = '{corp_num}' and e.event_id = {event_id} - and not ( - (select corp_name - from corp_name - where corp_num = '{corp_num}' - and start_event_id < {event_id} - and (end_event_id is null or end_event_id >= {event_id}) - and corp_name_typ_cd in ('CO', 'NB') - order by start_event_id desc - limit 1) = null - and (cn.corp_name is null or cn.corp_name = '') - ) order by e.event_id ; """ diff --git a/data-tool/flows/tombstone/tombstone_queries.py b/data-tool/flows/tombstone/tombstone_queries.py index 0183c1dd16..eab8e72426 100644 --- a/data-tool/flows/tombstone/tombstone_queries.py +++ b/data-tool/flows/tombstone/tombstone_queries.py @@ -707,11 +707,12 @@ def get_filings_query(corp_num): left outer join payment p on p.event_id = e.event_id left outer join conv_ledger cl on cl.event_id = e.event_id left outer join conv_event ce on e.event_id = ce.event_id - left outer join corp_name cn_old on e.event_id = cn_old.end_event_id and cn_old.corp_name_typ_cd in ('CO', 'NB') - left outer join corp_name cn_new on e.event_id = cn_new.start_event_id and cn_new.corp_name_typ_cd in ('CO', 'NB') + left outer join corp_name cn_old on e.event_id = cn_old.end_event_id + left outer join corp_name cn_new on e.event_id = cn_new.start_event_id left outer join cont_out co on co.start_event_id = e.event_id where 1 = 1 and e.corp_num = '{corp_num}' + and not (cn_old.corp_name is null AND cn_new.corp_name is not null and cn_new.corp_name_typ_cd in ('CO', 'NB')) -- and e.corp_num = 'BC0068889' -- and e.corp_num = 'BC0449924' -- AR, ADCORP -- and e.trigger_dts is not null