Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPR account drafts mark as used. #1950

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions ppr-api/src/database/patch/21975-ppr-drafts-used.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
-- 21975 begin PPR API build 1.2.5

-- 3635874 PROD 2024-06-24
select max(id)
from drafts
;

-- 1886177
select max(id)
from drafts
where account_id = '0'
;

-- 1746001
select count(d.id)
from drafts d, registrations r
where d.account_id != '0'
and d.account_id not like '%_USED'
and d.id = r.draft_id
and d.id between 1886177 and 2300000 -- 412787
-- and d.id between 2300001 and 2800000 -- 498879
-- and d.id between 2800001 and 3300000 -- 499138
-- and d.id > 3300000 -- 335219
;
update drafts
set account_id = account_id || '_USED'
where id in (select d.id
from drafts d, registrations r
where d.account_id != '0'
and d.account_id not like '%_USED'
and d.id = r.draft_id
and d.id between 1886177 and 2300000)
;

update drafts
set account_id = account_id || '_USED'
where id in (select d.id
from drafts d, registrations r
where d.account_id != '0'
and d.account_id not like '%_USED'
and d.id = r.draft_id
and d.id between 2300001 and 2800000)
;
update drafts
set account_id = account_id || '_USED'
where id in (select d.id
from drafts d, registrations r
where d.account_id != '0'
and d.account_id not like '%_USED'
and d.id = r.draft_id
and d.id between 2800001 and 3300000)
;
update drafts
set account_id = account_id || '_USED'
where id in (select d.id
from drafts d, registrations r
where d.account_id != '0'
and d.account_id not like '%_USED'
and d.id = r.draft_id
and d.id > 3300000)
;

-- 21975 end PPR API build 1.2.5
3 changes: 3 additions & 0 deletions ppr-api/src/ppr_api/models/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@


FINANCING_PATH = '/ppr/api/v1/financing-statements/'
ACCOUNT_DRAFT_USED_SUFFIX = '_USED'


class CrownChargeTypes(BaseEnum):
Expand Down Expand Up @@ -597,6 +598,7 @@ def create_from_json(json_data,
draft = Draft.create_from_registration(registration, json_data)
else:
draft.draft = json_data
draft.account_id = draft.account_id + ACCOUNT_DRAFT_USED_SUFFIX
registration.draft = draft
registration.registration_type_cl = registration_type_cl
if registration_type_cl in (model_utils.REG_CLASS_AMEND,
Expand Down Expand Up @@ -734,6 +736,7 @@ def create_financing_from_json(json_data, account_id: str = None, user_id: str =
draft = Draft.create_from_registration(registration, json_data, user_id)
else:
draft.draft = json_data
draft.account_id = draft.account_id + ACCOUNT_DRAFT_USED_SUFFIX
registration.draft = draft
if reg_type == MiscellaneousTypes.SECURITIES_NOTICE and json_data.get('securitiesActNotices'):
registration = registration_utils.create_securities_act_notices(registration, json_data)
Expand Down
Loading