Skip to content

Commit

Permalink
23522-23562 continuation in workflow change (bcgov#3026)
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot authored Oct 15, 2024
1 parent dbbbf8b commit 5360c65
Show file tree
Hide file tree
Showing 23 changed files with 505 additions and 587 deletions.
30 changes: 30 additions & 0 deletions legal-api/migrations/versions/698885b80fc0_review_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""review-update
Revision ID: 698885b80fc0
Revises: 83a110e10979
Create Date: 2024-10-10 15:17:32.903859
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '698885b80fc0'
down_revision = '83a110e10979'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('reviews', sa.Column('contact_email', sa.String(length=150), nullable=True))
op.drop_column('reviews', 'completing_party')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('reviews', sa.Column('completing_party', sa.VARCHAR(length=150), nullable=True))
op.drop_column('reviews', 'contact_email')
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion legal-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ PyPDF2==1.26.0
reportlab==3.6.12
html-sanitizer==2.4.1
lxml==5.2.2
git+https://github.com/bcgov/[email protected].30#egg=registry_schemas
git+https://github.com/bcgov/[email protected].31#egg=registry_schemas
2 changes: 1 addition & 1 deletion legal-api/requirements/bcregistry-libraries.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git+https://github.com/bcgov/[email protected].28#egg=registry_schemas
git+https://github.com/bcgov/[email protected].31#egg=registry_schemas
14 changes: 6 additions & 8 deletions legal-api/src/legal_api/core/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ def is_future_effective(self) -> bool:
def get_json(self) -> Optional[Dict]:
"""Return a dict representing the filing json."""
if not self._storage or (self._storage and self._storage.status not in [Filing.Status.COMPLETED.value,
Filing.Status.APPROVED.value,
Filing.Status.PAID.value,
Filing.Status.PENDING.value,
]):
Expand All @@ -208,8 +207,7 @@ def get_json(self) -> Optional[Dict]:
# This ASSUMES that the JSONSchemas remain valid for that period of time
# which fits with the N-1 approach to versioning, and
# that handling of filings stuck in PENDING are handled appropriately.
elif self._storage.status in [Filing.Status.APPROVED.value,
Filing.Status.PAID.value,
elif self._storage.status in [Filing.Status.PAID.value,
Filing.Status.PENDING.value]:
if self._storage.tech_correction_json:
filing = self._storage.tech_correction_json
Expand Down Expand Up @@ -489,6 +487,10 @@ def get_document_list(business, # pylint: disable=too-many-locals disable=too-m
Filing.Status.PAPER_ONLY,
Filing.Status.DRAFT,
Filing.Status.PENDING,
Filing.Status.AWAITING_REVIEW,
Filing.Status.CHANGE_REQUESTED,
Filing.Status.APPROVED,
Filing.Status.REJECTED,
): # noqa: E125; lint conflicts on the indenting
return None

Expand Down Expand Up @@ -523,11 +525,7 @@ def get_document_list(business, # pylint: disable=too-many-locals disable=too-m
Filing.FilingTypes.AGMEXTENSION.value,
Filing.FilingTypes.AGMLOCATIONCHANGE.value,
]
if filing.status in [Filing.Status.PAID,
Filing.Status.AWAITING_REVIEW,
Filing.Status.CHANGE_REQUESTED,
Filing.Status.APPROVED,
Filing.Status.REJECTED] and \
if filing.status == Filing.Status.PAID and \
not (filing.filing_type in no_legal_filings_in_paid_status
or (filing.filing_type == Filing.FilingTypes.DISSOLUTION.value and
business.legal_type in [
Expand Down
2 changes: 1 addition & 1 deletion legal-api/src/legal_api/core/meta/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def get_static_documents(filing, url_prefix):
continuation_in = filing.meta_data.get('continuationIn', {})
if file_key := continuation_in.get('affidavitFileKey'):
outputs.append({
'name': 'Director Affidavit',
'name': 'Unlimited Liability Corporation Information',
'url': f'{url_prefix}/{file_key}'
})
if authorization_files := continuation_in.get('authorizationFiles'):
Expand Down
30 changes: 12 additions & 18 deletions legal-api/src/legal_api/models/filing.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def filing_json(self):
@filing_json.setter
def filing_json(self, json_data: dict):
"""Property containing the filings data."""
if self.locked and not self.in_change_requested_status:
if self.locked:
self._raise_default_lock_exception()

try:
Expand All @@ -676,7 +676,7 @@ def filing_json(self, json_data: dict):

self._filing_sub_type = self.get_filings_sub_type(self._filing_type, json_data)

if self._payment_token and not self.in_change_requested_status:
if self._payment_token:
valid, err = rsbc_schemas.validate(json_data, 'filing')
if not valid:
self._filing_type = None
Expand Down Expand Up @@ -778,11 +778,6 @@ def is_amalgamation_application(self):
"""Is this an amalgamation application filing."""
return self.filing_type == Filing.FILINGS['amalgamationApplication'].get('name')

@property
def in_change_requested_status(self):
"""Filing is in change requested status."""
return self._status == Filing.Status.CHANGE_REQUESTED.value

@hybrid_property
def comments_count(self):
"""Return the number of commentson this filing."""
Expand Down Expand Up @@ -1029,8 +1024,7 @@ def get_completed_filings_for_colin(page=1, limit=20):
def get_future_effective_filing_ids() -> List[int]:
"""Return filing ids which should be effective now."""
filings = db.session.query(Filing.id). \
filter(Filing._status.in_([Filing.Status.PAID.value,
Filing.Status.APPROVED.value])). \
filter(Filing._status == Filing.Status.PAID.value). \
filter(Filing.effective_date <= datetime.now(timezone.utc)).all()
return [filing.id for filing in filings]

Expand Down Expand Up @@ -1110,7 +1104,9 @@ def delete(self):

def reset_filing_to_draft(self):
"""Reset Filing to draft and remove payment token."""
self._status = Filing.Status.DRAFT.value
self._status = (Filing.Status.APPROVED.value
if self.FILINGS[self._filing_type].get('staffApprovalRequired', False)
else Filing.Status.DRAFT.value)
self._payment_token = None
self.save()

Expand All @@ -1124,16 +1120,14 @@ def set_review_decision(self, filing_status):
status_code=HTTPStatus.FORBIDDEN
)
self._status = filing_status
if (self._status == Filing.Status.APPROVED.value and
self.effective_date < datetime.now(timezone.utc)): # if not future effective
self.effective_date = datetime.now(timezone.utc)
self.save()

def resubmit_filing_to_awaiting_review(self, submission_date):
"""Resubmit filing to awaiting review."""
if self._status != Filing.Status.CHANGE_REQUESTED.value:
def submit_filing_to_awaiting_review(self, submission_date):
"""Submit filing to awaiting review."""
if self._status not in [Filing.Status.DRAFT.value,
Filing.Status.CHANGE_REQUESTED.value]:
raise BusinessException(
error='Cannot resubmit this filing to awaiting review status.',
error='Cannot submit this filing to awaiting review status.',
status_code=HTTPStatus.FORBIDDEN
)
self._status = Filing.Status.AWAITING_REVIEW.value
Expand Down Expand Up @@ -1182,7 +1176,7 @@ def receive_before_change(mapper, connection, target): # pylint: disable=unused
if (filing._status in [Filing.Status.AWAITING_REVIEW.value,
Filing.Status.CHANGE_REQUESTED.value,
Filing.Status.REJECTED.value] or
(filing._status == Filing.Status.APPROVED.value and not filing.transaction_id)):
(filing._status == Filing.Status.APPROVED.value and not filing.payment_token)):
return # should not override status in the review process

# skip this status updater if the flag is set
Expand Down
10 changes: 5 additions & 5 deletions legal-api/src/legal_api/models/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Review(db.Model): # pylint: disable=too-many-instance-attributes
id = db.Column(db.Integer, primary_key=True)
nr_number = db.Column('nr_number', db.String(15))
identifier = db.Column('identifier', db.String(50))
completing_party = db.Column('completing_party', db.String(150))
contact_email = db.Column('contact_email', db.String(150))
status = db.Column('status', db.Enum(ReviewStatus), nullable=False)
submission_date = db.Column('submission_date',
db.DateTime(timezone=True),
Expand Down Expand Up @@ -110,8 +110,8 @@ def get_paginated_reviews(cls, review_filter, mapped_sort_by_column):
query = query.filter(Review.nr_number.ilike(f'%{review_filter.nr_number}%'))
if review_filter.identifier:
query = query.filter(Review.identifier.ilike(f'%{review_filter.identifier}%'))
if review_filter.completing_party:
query = query.filter(Review.completing_party.ilike(f'%{review_filter.completing_party}%'))
if review_filter.contact_email:
query = query.filter(Review.contact_email.ilike(f'%{review_filter.contact_email}%'))
if review_filter.status:
query = query.filter(Review.status.in_(review_filter.status))
if review_filter.submitted_sort_by:
Expand Down Expand Up @@ -157,7 +157,7 @@ def json(self) -> dict:
'id': self.id,
'nrNumber': self.nr_number,
'identifier': self.identifier,
'completingParty': self.completing_party,
'contactEmail': self.contact_email,
'status': self.status.name,
'submissionDate': self.submission_date.isoformat(),
'creationDate': self.creation_date.isoformat(),
Expand All @@ -176,7 +176,7 @@ class ReviewFilter:
end_effective_date: str = ''
nr_number: str = ''
identifier: str = ''
completing_party: str = ''
contact_email: str = ''
submitted_sort_by: str = ''
submitted_sort_order: bool = ''
page: int = 1
Expand Down
22 changes: 7 additions & 15 deletions legal-api/src/legal_api/resources/v2/admin/reviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""API endpoints for retrieving review data."""
from datetime import datetime, timezone
from http import HTTPStatus

from flask import current_app, g, jsonify, request
Expand All @@ -37,7 +36,7 @@ def get_reviews():
end_effective_date=request.args.get('endEffectiveDate', None),
nr_number=request.args.get('nrNumber', None),
identifier=request.args.get('identifier', None),
completing_party=request.args.get('completingParty', None),
contact_email=request.args.get('contactEmail', None),
status=request.args.getlist('status', None),
submitted_sort_by=request.args.get('sortBy', None),
submitted_sort_order=request.args.get('sortDesc', None),
Expand Down Expand Up @@ -94,15 +93,15 @@ def get_mapped_column(submitted_sort_by):
if submitted_sort_by:
if submitted_sort_by == 'nrNumber':
mapped_column = 'nr_number'
if submitted_sort_by == 'completingParty':
mapped_column = 'completing_party'
if submitted_sort_by == 'submissionDate':
elif submitted_sort_by == 'contactEmail':
mapped_column = 'contact_email'
elif submitted_sort_by == 'submissionDate':
mapped_column = 'submission_date'
if submitted_sort_by == 'status':
elif submitted_sort_by == 'status':
mapped_column = 'status'
if submitted_sort_by == 'identifier':
elif submitted_sort_by == 'identifier':
mapped_column = 'identifier'
if submitted_sort_by == 'futureEffectiveDate':
elif submitted_sort_by == 'futureEffectiveDate':
mapped_column = 'effective_date'
return mapped_column

Expand Down Expand Up @@ -163,13 +162,6 @@ def save_review(review_id: int):
current_app.config.get('NATS_EMAILER_SUBJECT')
)

if (filing.status == Filing.Status.APPROVED.value and
filing.effective_date <= datetime.now(timezone.utc)):
# filer notification
queue.publish_json(
{'filing': {'id': filing.id}},
current_app.config.get('NATS_FILER_SUBJECT'))

return jsonify({'message': 'Review saved.'}), HTTPStatus.CREATED


Expand Down
2 changes: 1 addition & 1 deletion legal-api/src/legal_api/resources/v2/business/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def search_businesses():
'draftStatus': draft_dao.status
}

if (draft_dao.status in [Filing.Status.PAID.value, Filing.Status.APPROVED.value] and
if (draft_dao.status == Filing.Status.PAID.value and
draft_dao.effective_date and draft_dao.effective_date > datetime.now(timezone.utc)):
draft['effectiveDate'] = draft_dao.effective_date.isoformat()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def _get_receipt(business: Business, filing: Filing, token):
Filing.Status.COMPLETED,
Filing.Status.CORRECTED,
Filing.Status.PAID,
Filing.Status.AWAITING_REVIEW,
Filing.Status.CHANGE_REQUESTED,
Filing.Status.APPROVED,
Filing.Status.REJECTED,
):
return {}, HTTPStatus.BAD_REQUEST

Expand Down
Loading

0 comments on commit 5360c65

Please sign in to comment.