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

25328 - Support Update and Save NoW Draft for Bootstrap Filing #3183

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
2 changes: 1 addition & 1 deletion legal-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ PyPDF2==1.26.0
reportlab==3.6.12
html-sanitizer==2.4.1
lxml==5.2.2
git+https://github.com/bcgov/[email protected].32#egg=registry_schemas
git+https://github.com/bcgov/[email protected].33#egg=registry_schemas
git+https://github.com/bcgov/lear.git#egg=sql-versioning&subdirectory=python/common/sql-versioning
2 changes: 1 addition & 1 deletion legal-api/requirements/bcregistry-libraries.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git+https://github.com/bcgov/[email protected].32#egg=registry_schemas
git+https://github.com/bcgov/[email protected].33#egg=registry_schemas
git+https://github.com/bcgov/lear.git#egg=sql-versioning&subdirectory=python/common/sql-versioning
2 changes: 1 addition & 1 deletion legal-api/src/legal_api/core/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def validate():
def get(identifier, filing_id=None) -> Optional[Filing]:
"""Return a Filing domain by the id."""
if identifier.startswith('T'):
storage = FilingStorage.get_temp_reg_filing(identifier)
storage = FilingStorage.get_temp_reg_filing(identifier, filing_id)
else:
storage = Business.get_filing_by_id(identifier, filing_id)

Expand Down
28 changes: 20 additions & 8 deletions legal-api/src/legal_api/models/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,14 +861,26 @@ def find_by_id(cls, filing_id: str = None):

@staticmethod
def get_temp_reg_filing(temp_reg_id: str, filing_id: str = None):
"""Return a Filing by it's payment token."""
q = db.session.query(Filing).filter(Filing.temp_reg == temp_reg_id)

if filing_id:
q = q.filter(Filing.id == filing_id)

filing = q.one_or_none()
return filing
"""Return a filing by the temp id and filing id (if applicable)."""
if not filing_id:
return db.session.query(Filing).filter(Filing.temp_reg == temp_reg_id).one_or_none()

return (
db.session.query(Filing).filter(
db.or_(
db.and_(
Filing.id == filing_id,
Filing.temp_reg == temp_reg_id
),
db.and_( # special case for NoW
Filing.id == filing_id,
Filing._filing_type == 'noticeOfWithdrawal',
Filing.withdrawn_filing_id == db.session.query(Filing.id)
.filter(Filing.temp_reg == temp_reg_id)
.scalar_subquery()
)
)
).one_or_none())

@staticmethod
def get_filing_by_payment_token(token: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1764,3 +1764,16 @@ def test_notice_of_withdrawal_filing(session, client, jwt, test_name, legal_type
assert now_filing.withdrawal_pending == False
if is_temp:
assert now_filing.temp_reg == None

# update and save notice of withdrawal draft filing
now_json_data['filing']['header']['certifiedBy'] = 'test123'

rv_draft = client.put(f'/api/v2/businesses/{identifier}/filings/{now_filing.id}?draft=true',
json=now_json_data,
headers=create_header(jwt, [STAFF_ROLE], identifier))

# validate
assert rv_draft.status_code == HTTPStatus.ACCEPTED
assert rv_draft.json['filing']['header']['certifiedBy'] == 'test123'