예제 #1
0
def test_voluntary_dissolution_completed(session, app):
    """Assert that a Voluntary Dissolution document is returned for a COMPLETED Voluntary Dissolution filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'voluntaryDissolution',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        documents = document_meta.get_documents(filing)
        assert len(documents) == 1

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12356
        assert documents[0]['title'] == 'Voluntary Dissolution'
        assert documents[0][
            'filename'] == 'BC1234567 - Voluntary Dissolution - 2020-07-14.pdf'
예제 #2
0
def test_con_completed_bc(session, app):
    """Assert that Legal Name Change + NOA documents are returned for a COMPLETED BCOMP CON filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'changeOfName',
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        documents = document_meta.get_documents(filing)
        assert len(documents) == 2

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12356
        assert documents[0]['title'] == CON_TITLE
        assert documents[0][
            'filename'] == 'BC1234567 - Legal Name Change - 2020-07-14.pdf'

        assert documents[1]['type'] == 'REPORT'
        assert documents[1]['reportType'] == 'noa'
        assert documents[1]['filingId'] == 12356
        assert documents[1]['title'] == NOA_TITLE
        assert documents[1]['filename'] == NOA_FILENAME
예제 #3
0
def test_con_completed_cp(session, app):
    """Assert that a Legal Name Change document is returned for a COMPLETED COOP CON filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='CP1234567', entity_type='CP')
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'changeOfName',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'CP1234567'
                }
            }
        }
        documents = document_meta.get_documents(filing)
        assert len(documents) == 1

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12356
        assert documents[0]['title'] == CON_TITLE
        assert documents[0][
            'filename'] == 'CP1234567 - Legal Name Change - 2020-07-14.pdf'
예제 #4
0
def test_correction_ia_with_named_to_numbered(session, app):
    """Assert that IA + NOA + Certificate documents are returned for a Correction filing with name change."""
    document_meta = DocumentMetaService()
    b = factory_business(identifier='BC1234567',
                         entity_type=Business.LegalTypes.BCOMP.value)
    original_filing_json = copy.deepcopy(INCORPORATION_FILING_TEMPLATE)
    original_filing_json['filing']['incorporationApplication'][
        'nameRequest'] = {}
    original_filing_json['filing']['incorporationApplication']['nameRequest'][
        'nrNumber'] = 'NR 1234567'
    original_filing_json['filing']['incorporationApplication']['nameRequest'][
        'legalName'] = 'abc'
    original_filing = factory_filing(b, original_filing_json)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12357,
                    'status': 'COMPLETED',
                    'name': 'correction',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                },
                'correction': {
                    'correctedFilingId': original_filing.id
                },
                'incorporationApplication': {
                    'nameRequest': {
                        'legalType': Business.LegalTypes.BCOMP.value
                    }
                }
            }
        }
        documents = document_meta.get_documents(filing)

        assert len(documents) == 3

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12357
        assert documents[0]['title'] == 'Incorporation Application (Corrected)'
        assert documents[0][
            'filename'] == 'BC1234567 - Incorporation Application (Corrected) - 2020-07-14.pdf'

        assert documents[1]['type'] == 'REPORT'
        assert documents[1]['reportType'] == 'certificate'
        assert documents[1]['filingId'] == 12357
        assert documents[1]['title'] == 'Certificate (Corrected)'
        assert documents[1][
            'filename'] == 'BC1234567 - Certificate (Corrected) - 2020-07-14.pdf'

        assert documents[2]['type'] == 'REPORT'
        assert documents[2]['reportType'] == 'noa'
        assert documents[2]['filingId'] == 12357
        assert documents[2]['title'] == NOA_TITLE
        assert documents[2]['filename'] == NOA_FILENAME
예제 #5
0
def test_cod_paid(session, app):
    """Assert that a Director Change document is returned for a PAID COD filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'PAID',
                    'name': 'changeOfDirectors',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }

        documents = document_meta.get_documents(filing)
        assert len(documents) == 1

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12356
        assert documents[0]['title'] == COD_TITLE
        assert documents[0][
            'filename'] == 'BC1234567 - Director Change - 2020-07-14.pdf'
예제 #6
0
def test_transition_bcomp_completed(session, app):
    """Assert that Transition Application + NOA documents are returned for a filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = copy.deepcopy(TRANSITION_FILING_TEMPLATE)
        filing['filing']['header']['date'] = FILING_DATE
        filing['filing']['header']['status'] = 'COMPLETED'
        filing['filing']['header']['availableOnPaperOnly'] = False
        filing['filing']['header']['inColinOnly'] = False
        documents = document_meta.get_documents(filing)

        assert len(documents) == 2

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 1
        assert documents[0]['title'] == 'Transition Application'
        assert documents[0][
            'filename'] == 'BC1234567 - Transition Application - 2020-07-14.pdf'

        assert documents[1]['type'] == 'REPORT'
        assert documents[1]['reportType'] == 'noa'
        assert documents[1]['filingId'] == 1
        assert documents[1]['title'] == NOA_TITLE
        assert documents[1]['filename'] == NOA_FILENAME
예제 #7
0
def test_wrong_filing_status(session, app):
    """Assert that no documents are returned for a non- PAID and COMPLETED filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'NOT_PAID_OR_COMPLETE',
                    'name': 'changeOfAddress',
                    'availableOnPaperOnly': False,
                    'inColinOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        assert len(document_meta.get_documents(filing)) == 0
        # also verify document class properties:
        assert document_meta._business_identifier == 'BC1234567'
        assert document_meta._legal_type == Business.LegalTypes.BCOMP.value
예제 #8
0
def test_ia_paid(app):
    """Assert that an IA - Pending document is returned for a PAID IA filing."""
    document_meta = DocumentMetaService()
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'PAID',
                    'name': 'incorporationApplication',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'effectiveDate': FILING_DATE,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'T12345678'
                },
                'incorporationApplication': {
                    'nameRequest': {
                        'legalType': Business.LegalTypes.BCOMP.value
                    }
                }
            }
        }
        documents = document_meta.get_documents(filing)
        assert len(documents) == 1

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12356
        assert documents[0]['title'] == 'Incorporation Application - Pending'
        assert documents[0][
            'filename'] == 'T12345678 - Incorporation Application (Pending) - 2020-07-14.pdf'
예제 #9
0
def test_alteration(status, filing_id, business_identifier, expected_number,
                    alteration_json, session, app):
    """Assert that the correct number of documents are returned for alterations in 3 scenarios."""
    document_meta = DocumentMetaService()
    factory_business(identifier=business_identifier,
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': filing_id,
                    'status': status,
                    'name': 'alteration',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': business_identifier,
                    'legalName': 'HAULER MEDIA INC.',
                    'legalType': 'BC'
                },
                'alteration': alteration_json
            }
        }

        documents = document_meta.get_documents(filing)
        assert len(documents) == expected_number
예제 #10
0
def test_business_not_found(session, app):
    """Assert that no documents are returned when the filing's business is not found."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'DONT_CARE',
                    'name': 'changeOfAddress',
                    'availableOnPaperOnly': False,
                    'inColinOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC7654321'
                }
            }
        }
        assert len(document_meta.get_documents(filing)) == 0
        # also verify document class properties:
        assert document_meta._business_identifier == 'BC7654321'
        assert document_meta._legal_type is None
예제 #11
0
def test_ia_completed_coop(session, app):
    """Assert that documents are returned for a COMPLETED IA filing when business is a COOP."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.COOP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'incorporationApplication',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'effectiveDate': FILING_DATE,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }

        with patch.object(Filing, 'find_by_id', return_value=Filing()):
            documents = document_meta.get_documents(filing)
            assert len(documents) == 4

            assert documents[0]['type'] == 'REPORT'
            assert documents[0]['reportType'] is None
            assert documents[0]['filingId'] == 12356
            assert documents[0]['title'] == 'Incorporation Application'
            assert documents[0][
                'filename'] == 'BC1234567 - Incorporation Application - 2020-07-14.pdf'

            assert documents[1]['type'] == 'REPORT'
            assert documents[1]['reportType'] == 'certificate'
            assert documents[1]['filingId'] == 12356
            assert documents[1]['title'] == 'Certificate'
            assert documents[1][
                'filename'] == 'BC1234567 - Certificate - 2020-07-14.pdf'

            assert documents[2]['type'] == 'REPORT'
            assert documents[2]['reportType'] == 'certifiedRules'
            assert documents[2]['filingId'] == 12356
            assert documents[2]['title'] == 'Certified Rules'
            assert documents[2][
                'filename'] == 'BC1234567 - Certified Rules - 2020-07-14.pdf'

            assert documents[3]['type'] == 'REPORT'
            assert documents[3]['reportType'] == 'certifiedMemorandum'
            assert documents[3]['filingId'] == 12356
            assert documents[3]['title'] == 'Certified Memorandum'
            assert documents[3][
                'filename'] == 'BC1234567 - Certified Memorandum - 2020-07-14.pdf'
예제 #12
0
def test_ia_status(session, app, status, number_of_docs):
    """Assert that IA + NOA + Certificate documents are returned for a COMPLETED IA filing."""
    document_meta = DocumentMetaService()
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': status,
                    'name': 'incorporationApplication',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'effectiveDate': FILING_DATE,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'T12345678'
                },
                'incorporationApplication': {
                    'nameRequest': {
                        'legalType': Business.LegalTypes.BCOMP.value
                    }
                }
            }
        }

        with patch.object(Filing, 'find_by_id', return_value=Filing()):
            documents = document_meta.get_documents(filing)
            assert len(documents) == number_of_docs

            if number_of_docs:
                assert documents[0]['type'] == 'REPORT'
                assert documents[0]['reportType'] is None
                assert documents[0]['filingId'] == 12356
                assert documents[0]['title'] == 'Incorporation Application'
                assert documents[0][
                    'filename'] == 'T12345678 - Incorporation Application - 2020-07-14.pdf'

                assert documents[1]['type'] == 'REPORT'
                assert documents[1]['reportType'] == 'noa'
                assert documents[1]['filingId'] == 12356
                assert documents[1]['title'] == 'Notice of Articles'
                assert documents[1][
                    'filename'] == 'T12345678 - Notice of Articles - 2020-07-14.pdf'

                assert documents[2]['type'] == 'REPORT'
                assert documents[2]['reportType'] == 'certificate'
                assert documents[2]['filingId'] == 12356
                assert documents[2]['title'] == 'Certificate'
                assert documents[2][
                    'filename'] == 'T12345678 - Certificate - 2020-07-14.pdf'
예제 #13
0
def test_ia_completed_bcomp_original(session, app):
    """Assert that IA + Certificate documents with (Original) are returned for a COMPLETED IA."""
    document_meta = DocumentMetaService()
    b = factory_business(identifier='BC1234567',
                         entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        original_filing = factory_filing(b, INCORPORATION_FILING_TEMPLATE)
        CORRECTION_INCORPORATION['filing']['correction'][
            'correctedFilingId'] = original_filing.id
        corrected_filing = factory_filing(b, CORRECTION_INCORPORATION)
        filing = {
            'filing': {
                'header': {
                    'filingId': original_filing.id,
                    'status': 'COMPLETED',
                    'name': 'incorporationApplication',
                    'inColinOnly': False,
                    'availableOnPaperOnly': False,
                    'effectiveDate': FILING_DATE,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        original_filing.parent_filing_id = corrected_filing.id
        original_filing.save()
        documents = document_meta.get_documents(filing)
        assert len(documents) == 3

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == original_filing.id
        assert documents[0]['title'] == 'Incorporation Application (Original)'
        assert documents[0][
            'filename'] == 'BC1234567 - Incorporation Application (Original) - 2020-07-14.pdf'

        assert documents[1]['type'] == 'REPORT'
        assert documents[1]['reportType'] == 'noa'
        assert documents[1]['filingId'] == original_filing.id
        assert documents[1]['title'] == NOA_TITLE
        assert documents[1]['filename'] == NOA_FILENAME

        assert documents[2]['type'] == 'REPORT'
        assert documents[2]['reportType'] == 'certificate'
        assert documents[2]['filingId'] == original_filing.id
        assert documents[2]['title'] == 'Certificate (Original)'
        assert documents[2][
            'filename'] == 'BC1234567 - Certificate (Original) - 2020-07-14.pdf'
예제 #14
0
def test_ia_fed(app):
    """Assert that an IA - FED document is returned for a future effective IA filing."""
    from legal_api.utils.legislation_datetime import LegislationDatetime
    document_meta = DocumentMetaService()
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId':
                    12356,
                    'status':
                    'PAID',
                    'name':
                    'incorporationApplication',
                    'inColinOnly':
                    False,
                    'availableOnPaperOnly':
                    False,
                    'effectiveDate':
                    LegislationDatetime.tomorrow_midnight().isoformat(),
                    'date':
                    FILING_DATE
                },
                'business': {
                    'identifier': 'T12345678'
                },
                'incorporationApplication': {
                    'nameRequest': {
                        'legalType': Business.LegalTypes.BCOMP.value
                    }
                }
            }
        }
        documents = document_meta.get_documents(filing)
        assert len(documents) == 1

        assert documents[0]['type'] == 'REPORT'
        assert documents[0]['reportType'] is None
        assert documents[0]['filingId'] == 12356
        assert documents[0][
            'title'] == 'Incorporation Application - Future Effective Incorporation'
        assert documents[0][
            'filename'] == 'T12345678 - Incorporation Application (Future Effective) - 2020-07-14.pdf'
예제 #15
0
def test_available_on_paper_only(session, app):
    """Assert that no documents are returned for a paper-only filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'changeOfAddress',
                    'availableOnPaperOnly': True,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        assert len(document_meta.get_documents(filing)) == 0
예제 #16
0
def test_voluntary_dissolution_paid(session, app):
    """Assert that no documents are returned for a PAID Voluntary Dissolution filing."""
    document_meta = DocumentMetaService()
    factory_business(identifier='BC1234567',
                     entity_type=Business.LegalTypes.BCOMP.value)
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'PAID',
                    'name': 'voluntaryDissolution',
                    'availableOnPaperOnly': False,
                    'date': FILING_DATE
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        documents = document_meta.get_documents(filing)
        assert len(documents) == 0
예제 #17
0
    def get_single_filing(identifier: str, filing_id: int):
        """Return a single filing and all of its components."""
        original_filing = str(request.args.get('original',
                                               None)).lower() == 'true'
        rv = CoreFiling.get(identifier, filing_id)
        if not rv:
            return jsonify({'message': f'{identifier} no filings found'
                            }), HTTPStatus.NOT_FOUND

        if original_filing:
            return jsonify(rv.redacted(rv.raw, jwt))

        if rv.filing_type == CoreFiling.FilingTypes.CORRECTION.value:
            # This is required until #5302 ticket implements
            rv.storage._filing_json['filing']['correction']['diff'] = rv.json[
                'filing']['correction']['diff']  # pylint: disable=protected-access; # noqa: E501;

        if str(request.accept_mimetypes) == 'application/pdf':
            report_type = request.args.get('type', None)
            return legal_api.reports.get_pdf(rv.storage, report_type)

        filing_json = rv.json
        if documents := DocumentMetaService().get_documents(filing_json):
            filing_json['filing']['documents'] = documents
예제 #18
0
    def get(identifier, filing_id=None):  # pylint: disable=too-many-return-statements,too-many-branches;
        # fix this while refactoring this whole module
        """Return a JSON object with meta information about the Service."""
        original_filing = str(request.args.get('original',
                                               None)).lower() == 'true'
        if identifier.startswith('T'):
            rv = CoreFiling.get(identifier, filing_id)

            if not rv.storage:
                return jsonify({'message': f'{identifier} no filings found'
                                }), HTTPStatus.NOT_FOUND
            if str(request.accept_mimetypes
                   ) == 'application/pdf' and filing_id:
                if rv.filing_type == 'incorporationApplication':
                    return legal_api.reports.get_pdf(rv.storage, None)

            if original_filing:
                filing_json = rv.raw
            else:
                filing_json = rv.json
                filing_json['filing']['documents'] = DocumentMetaService(
                ).get_documents(filing_json)

            if filing_json['filing']['header'][
                    'status'] == Filing.Status.PENDING.value:
                try:
                    headers = {
                        'Authorization':
                        f'Bearer {jwt.get_token_auth_header()}',
                        'Content-Type': 'application/json'
                    }
                    payment_svc_url = current_app.config.get('PAYMENT_SVC_URL')
                    pay_response = requests.get(
                        url=
                        f'{payment_svc_url}/{filing_json["filing"]["header"]["paymentToken"]}',
                        headers=headers)
                    pay_details = {
                        'isPaymentActionRequired':
                        pay_response.json().get('isPaymentActionRequired',
                                                False),
                        'paymentMethod':
                        pay_response.json().get('paymentMethod', '')
                    }
                    filing_json['filing']['header'].update(pay_details)

                except (exceptions.ConnectionError, exceptions.Timeout) as err:
                    current_app.logger.error(
                        f'Payment connection failure for getting {identifier} filing payment details. ',
                        err)

            return jsonify(filing_json)

        business = Business.find_by_identifier(identifier)

        if not business:
            return jsonify(filings=[]), HTTPStatus.NOT_FOUND

        if filing_id:
            rv = CoreFiling.get(identifier, filing_id)
            if not rv:
                return jsonify({'message': f'{identifier} no filings found'
                                }), HTTPStatus.NOT_FOUND

            if str(request.accept_mimetypes) == 'application/pdf':
                report_type = request.args.get('type', None)

                if rv.filing_type == CoreFiling.FilingTypes.CORRECTION.value:
                    # This is required until #5302 ticket implements
                    rv.storage._filing_json['filing']['correction'][
                        'diff'] = rv.json['filing']['correction']['diff']  # pylint: disable=protected-access; # noqa: E501;

                return legal_api.reports.get_pdf(rv.storage, report_type)
            return jsonify(rv.raw if original_filing else rv.json)

        # Does it make sense to get a PDF of all filings?
        if str(request.accept_mimetypes) == 'application/pdf':
            return jsonify({'message': _('Cannot return a single PDF of multiple filing submissions.')}),\
                HTTPStatus.NOT_ACCEPTABLE

        rv = []
        filings = CoreFiling.get_filings_by_status(
            business.id,
            [Filing.Status.COMPLETED.value, Filing.Status.PAID.value])
        for filing in filings:
            filing_json = filing.raw
            filing_json['filing']['documents'] = DocumentMetaService(
            ).get_documents(filing_json)
            rv.append(filing_json)

        return jsonify(filings=rv)