-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25038 25039 putbackoff filing (#3151)
- Loading branch information
1 parent
71abcb9
commit 80b86c3
Showing
18 changed files
with
246 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
legal-api/migrations/versions/f99e7bda56bb_hide_in_ledger.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""hide-in-ledger | ||
Revision ID: f99e7bda56bb | ||
Revises: f3b30f43aa86 | ||
Create Date: 2024-12-20 13:59:15.359911 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'f99e7bda56bb' | ||
down_revision = 'f3b30f43aa86' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('filings', sa.Column('hide_in_ledger', sa.Boolean(), nullable=False, server_default='False')) | ||
op.execute("UPDATE filings SET hide_in_ledger = true WHERE filing_type = 'adminFreeze'") | ||
op.execute("UPDATE filings SET hide_in_ledger = true WHERE filing_type = 'dissolution' and filing_sub_type = 'involuntary'") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('filings', 'hide_in_ledger') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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].31#egg=registry_schemas | ||
git+https://github.com/bcgov/[email protected].32#egg=registry_schemas | ||
git+https://github.com/bcgov/lear.git#egg=sql-versioning&subdirectory=python/common/sql-versioning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
git+https://github.com/bcgov/[email protected].31#egg=registry_schemas | ||
git+https://github.com/bcgov/lear.git#egg=sql-versioning&subdirectory=python/common/sql-versioning | ||
git+https://github.com/bcgov/[email protected].32#egg=registry_schemas | ||
git+https://github.com/bcgov/lear.git#egg=sql-versioning&subdirectory=python/common/sql-versioning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
legal-api/src/legal_api/services/filings/validations/put_back_off.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright © 2024 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Validation for the Put Back Off filing.""" | ||
from http import HTTPStatus | ||
from typing import Dict, Final, Optional | ||
|
||
from flask_babel import _ as babel # noqa: N813, I004, I001; importing camelcase '_' as a name | ||
# noqa: I004 | ||
from legal_api.errors import Error | ||
from legal_api.models import Business | ||
|
||
from .common_validations import validate_court_order | ||
from ...utils import get_str # noqa: I003; needed as the linter gets confused from the babel override above. | ||
|
||
|
||
def validate(business: Business, put_back_off: Dict) -> Optional[Error]: | ||
"""Validate the Court Order filing.""" | ||
if not business or not put_back_off: | ||
return Error(HTTPStatus.BAD_REQUEST, [{'error': babel('A valid business and filing are required.')}]) | ||
msg = [] | ||
|
||
if not get_str(put_back_off, '/filing/putBackOff/details'): | ||
msg.append({'error': babel('Put Back Off details are required.'), 'path': '/filing/putBackOff/details'}) | ||
|
||
msg.extend(_validate_court_order(put_back_off)) | ||
|
||
if msg: | ||
return Error(HTTPStatus.BAD_REQUEST, msg) | ||
return None | ||
|
||
|
||
def _validate_court_order(filing): | ||
"""Validate court order.""" | ||
if court_order := filing.get('filing', {}).get('putBackOff', {}).get('courtOrder', None): | ||
court_order_path: Final = '/filing/putBackOff/courtOrder' | ||
err = validate_court_order(court_order_path, court_order) | ||
if err: | ||
return err | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
legal-api/tests/unit/services/filings/validations/test_put_back_off.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright © 2024 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Test Put back off validations.""" | ||
import copy | ||
|
||
from registry_schemas.example_data import PUT_BACK_OFF, FILING_HEADER | ||
|
||
from legal_api.services.filings.validations.put_back_off import validate | ||
|
||
from tests.unit.models import factory_business | ||
|
||
|
||
def test_put_back_off(session): | ||
"""Assert valid put back off.""" | ||
identifier = 'CP1234567' | ||
business = factory_business(identifier) | ||
|
||
filing_json = copy.deepcopy(FILING_HEADER) | ||
filing_json['filing']['business']['identifier'] = identifier | ||
filing_json['filing']['putBackOff'] = copy.deepcopy(PUT_BACK_OFF) | ||
|
||
err = validate(business, filing_json) | ||
assert err is None |
Oops, something went wrong.