diff --git a/queue_services/business-filer/src/business_filer/config.py b/queue_services/business-filer/src/business_filer/config.py index d21f8c7052..ce4caa324c 100644 --- a/queue_services/business-filer/src/business_filer/config.py +++ b/queue_services/business-filer/src/business_filer/config.py @@ -111,13 +111,6 @@ class TestConfig(_Config): # pylint: disable=too-few-public-methods DB_PORT = os.getenv("DATABASE_TEST_PORT", "5432") SQLALCHEMY_DATABASE_URI = f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" - # Minio variables - MINIO_ENDPOINT = "localhost:9000" - MINIO_ACCESS_KEY = "minio" - MINIO_ACCESS_SECRET = "minio123" - MINIO_BUCKET_BUSINESSES = "businesses" - MINIO_SECURE = False - NAICS_API_URL = "https://NAICS_API_URL/api/v2/naics" COLIN_API = "https://COLIN_API/api/v2" ACCOUNT_SVC_AUTH_URL = "https://ACCOUNT_SVC_AUTH_URL" diff --git a/queue_services/business-filer/src/business_filer/filing_processors/dissolution.py b/queue_services/business-filer/src/business_filer/filing_processors/dissolution.py index 90c3d2b4e4..722c57f623 100644 --- a/queue_services/business-filer/src/business_filer/filing_processors/dissolution.py +++ b/queue_services/business-filer/src/business_filer/filing_processors/dissolution.py @@ -35,7 +35,7 @@ from contextlib import suppress import dpath -from business_model.models import BatchProcessing, Business, Filing, db +from business_model.models import BatchProcessing, Business, Document, DocumentType, Filing, db from flask import current_app from business_filer.common.datetime import datetime, timezone @@ -97,6 +97,9 @@ def process(business: Business, filing: dict, filing_rec: Filing, filing_meta: F court_order_json = dpath.get(dissolution_filing, "/courtOrder") filings.update_filing_court_order(filing_rec, court_order_json) + if business.legal_type == Business.LegalTypes.COOP: + _update_cooperative(dissolution_filing, business, filing_rec, dissolution_type) + with suppress(IndexError, KeyError, TypeError): filing_meta.dissolution = { **filing_meta.dissolution, @@ -114,6 +117,22 @@ def process(business: Business, filing: dict, filing_rec: Filing, filing_meta: F batch_processing.save() +def _update_cooperative(dissolution_filing: dict, business: Business, filing: Filing, dissolution_type): + """Update COOP data. + + This should not be updated for administrative dissolution + """ + if dissolution_type == DissolutionTypes.ADMINISTRATIVE: + return + + document = Document() + document.type = DocumentType.AFFIDAVIT.value + document.file_key = dissolution_filing.get("affidavitFileKey") + document.business_id = business.id + document.filing_id = filing.id + business.documents.append(document) + + def post_process(business: Business, filing: Filing, correction: bool = False): # pylint: disable=W0613 """Post processing activities for incorporations. diff --git a/queue_services/business-filer/src/business_filer/filing_processors/incorporation_filing.py b/queue_services/business-filer/src/business_filer/filing_processors/incorporation_filing.py index 304440ff98..1fcf9b8c4c 100644 --- a/queue_services/business-filer/src/business_filer/filing_processors/incorporation_filing.py +++ b/queue_services/business-filer/src/business_filer/filing_processors/incorporation_filing.py @@ -34,7 +34,7 @@ """File processing rules and actions for the incorporation of a business.""" import copy -from business_model.models import Business, Filing +from business_model.models import Business, Document, DocumentType, Filing from business_filer.exceptions import QueueException from business_filer.filing_meta import FilingMeta @@ -75,6 +75,9 @@ def process(business: Business, # noqa: PLR0912 business = business_info.update_business_info(corp_num, business, business_info_obj, filing_rec) business.state = Business.State.ACTIVE + if business_info_obj["legalType"] == Business.LegalTypes.COOP.value: + business = _update_cooperative(incorp_filing, business, filing_rec) + if nr_number := business_info_obj.get("nrNumber", None): filing_meta.incorporation_application = {**filing_meta.incorporation_application, "nrNumber": nr_number, @@ -108,3 +111,23 @@ def process(business: Business, # noqa: PLR0912 ia_json["filing"]["business"]["foundingDate"] = business.founding_date.isoformat() filing_rec._filing_json = ia_json # pylint: disable=protected-access; bypass to update filing data return business, filing_rec, filing_meta + +def _update_cooperative(incorp_filing: dict, business: Business, filing: Filing): + """Update the cooperative business with the cooperative specific information.""" + if cooperative_obj := incorp_filing.get("cooperative"): + business.association_type = cooperative_obj.get("cooperativeAssociationType") + document = Document() + document.type = DocumentType.COOP_RULES.value + document.file_key = cooperative_obj.get("rulesFileKey") + document.business_id = business.id + document.filing_id = filing.id + business.documents.append(document) + + document = Document() + document.type = DocumentType.COOP_MEMORANDUM.value + document.file_key = cooperative_obj.get("memorandumFileKey") + document.business_id = business.id + document.filing_id = filing.id + business.documents.append(document) + + return business diff --git a/queue_services/business-filer/tests/unit/filing_processors/test_dissolution.py b/queue_services/business-filer/tests/unit/filing_processors/test_dissolution.py index 6bd029bfbf..5ee1c73404 100644 --- a/queue_services/business-filer/tests/unit/filing_processors/test_dissolution.py +++ b/queue_services/business-filer/tests/unit/filing_processors/test_dissolution.py @@ -158,6 +158,13 @@ def test_dissolution(app, session, legal_type, identifier, dissolution_type): one_or_none() assert custodial_office + if business.legal_type == Business.LegalTypes.COOP.value: + documents = business.documents.all() + assert len(documents) == 1 + assert documents[0].type == DocumentType.AFFIDAVIT.value + affidavit_key = filing_json['filing']['dissolution']['affidavitFileKey'] + assert documents[0].file_key == affidavit_key + assert filing_meta.dissolution['dissolutionType'] == dissolution_type if dissolution_type == 'involuntary': assert batch_processing diff --git a/queue_services/business-filer/tests/unit/filing_processors/test_incorporation_filing.py b/queue_services/business-filer/tests/unit/filing_processors/test_incorporation_filing.py index 55d38f7d4e..e343d24ef9 100644 --- a/queue_services/business-filer/tests/unit/filing_processors/test_incorporation_filing.py +++ b/queue_services/business-filer/tests/unit/filing_processors/test_incorporation_filing.py @@ -118,6 +118,15 @@ def test_incorporation_filing_process_with_nr(app, session, legal_type, filing, if legal_type == 'CP': assert len(filing_rec.filing_party_roles.all()) == 1 assert len(business.offices.all()) == 1 + documents = business.documents.all() + assert len(documents) == 2 + for document in documents: + if document.type == DocumentType.COOP_RULES.value: + assert document.file_key == \ + filing['filing']['incorporationApplication']['cooperative']['rulesFileKey'] + elif document.type == DocumentType.COOP_MEMORANDUM.value: + assert document.file_key == \ + filing['filing']['incorporationApplication']['cooperative']['memorandumFileKey'] mock_get_next_corp_num.assert_called_with( filing['filing']['incorporationApplication']['nameRequest']['legalType'], None)