Skip to content

Commit

Permalink
PPR account drafts mark as used. (#1950)
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Lovett <[email protected]>
  • Loading branch information
doug-lovett authored Jun 24, 2024
1 parent 429fe35 commit bb3d0ed
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
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

0 comments on commit bb3d0ed

Please sign in to comment.