Exemplo n.º 1
0
def test_ar_documents(app):
    """Assert that annual report documents are returned."""
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'annualReport',
                    'availableOnPaperOnly': False,
                    'date': LegislationDatetime.now().isoformat()
                },
                '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'] == filing['filing']['header'][
            'filingId']
        assert documents[0]['title'] == 'Annual Report'

        business_identifier = filing['filing']['business']['identifier']
        filing_date = filing['filing']['header']['date']
        filename = document_meta.get_general_filename(business_identifier,
                                                      'Annual Report',
                                                      filing_date, 'pdf')
        assert documents[0]['filename'] == filename
Exemplo n.º 2
0
def test_incorporation_application_pending_documents(app):
    """Assert that pending incorporation application documents are returned."""
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'PAID',
                    'name': 'incorporationApplication',
                    'availableOnPaperOnly': False,
                    'effectiveDate': LegislationDatetime.now().isoformat(),
                    'date': LegislationDatetime.now().isoformat()
                },
                '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'] == filing['filing']['header'][
            'filingId']
        assert documents[0]['title'] == 'Incorporation Application - Pending'

        business_identifier = filing['filing']['business']['identifier']
        filing_date = filing['filing']['header']['date']
        filename = document_meta.get_general_filename(
            business_identifier, 'Incorporation Application (Pending)',
            filing_date, 'pdf')
        assert documents[0]['filename'] == filename
Exemplo n.º 3
0
def test_incorporation_application_documents(app):
    """Assert that incorporation documents are returned."""
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'incorporationApplication',
                    'availableOnPaperOnly': False,
                    'effectiveDate': LegislationDatetime.now().isoformat(),
                    'date': LegislationDatetime.now().isoformat()
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        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'] == filing['filing']['header'][
            'filingId']
        assert documents[0]['title'] == 'Incorporation Application'

        business_identifier = filing['filing']['business']['identifier']
        filing_date = filing['filing']['header']['date']
        ia_filename = document_meta.get_general_filename(
            business_identifier, 'Incorporation Application', filing_date,
            'pdf')
        noa_filename = document_meta.get_general_filename(
            business_identifier, 'Notice of Articles', filing_date, 'pdf')
        certificate_filename = document_meta.get_general_filename(
            business_identifier, 'Certificate', filing_date, 'pdf')

        assert documents[0]['filename'] == ia_filename

        assert documents[1]['type'] == 'REPORT'
        assert documents[1]['reportType'] == 'noa'
        assert documents[1]['filingId'] == filing['filing']['header'][
            'filingId']
        assert documents[1]['title'] == 'Notice of Articles'
        assert documents[1]['filename'] == noa_filename

        assert documents[2]['type'] == 'REPORT'
        assert documents[2]['reportType'] == 'certificate'
        assert documents[2]['filingId'] == filing['filing']['header'][
            'filingId']
        assert documents[2]['title'] == 'Certificate'
        assert documents[2]['filename'] == certificate_filename
Exemplo n.º 4
0
def test_coa_paid_documents_empty(app):
    """Assert that no documents are returned for a not complete change of address."""
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'PAID',
                    'name': 'changeOfAddress',
                    'availableOnPaperOnly': False,
                    'date': LegislationDatetime.now().isoformat()
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        assert len(document_meta.get_documents(filing)) == 0
Exemplo n.º 5
0
def test_paper_only_documents_empty(app):
    """Assert that no documents are returned for non PAID and COMPLETED filing."""
    with app.app_context():
        filing = {
            'filing': {
                'header': {
                    'filingId': 12356,
                    'status': 'COMPLETED',
                    'name': 'changeOfAddress',
                    'availableOnPaperOnly': True,
                    'date': LegislationDatetime.now().isoformat()
                },
                'business': {
                    'identifier': 'BC1234567'
                }
            }
        }
        assert len(document_meta.get_documents(filing)) == 0
Exemplo n.º 6
0
    def get(identifier, filing_id=None):  # pylint: disable=too-many-return-statements;
        # fix this while refactoring this whole module
        """Return a JSON object with meta information about the Service."""
        if identifier.startswith('T'):
            q = db.session.query(Filing). \
                filter(Filing.temp_reg == identifier)

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

            rv = q.one_or_none()

            if not rv:
                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, None)
            filing_json = rv.json
            filing_json['filing']['documents'] = document_meta.get_documents(
                filing_json)
            return jsonify(filing_json)

        business = Business.find_by_identifier(identifier)

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

        if filing_id:
            rv = db.session.query(Business, Filing). \
                filter(Business.id == Filing.business_id).\
                filter(Business.identifier == identifier).\
                filter(Filing.id == filing_id).\
                one_or_none()
            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[1].filing_type == 'incorporationApplication':
                    ListFilingResource._populate_business_info_to_filing(
                        rv[1], business)
                return legal_api.reports.get_pdf(rv[1], report_type)
            return jsonify(rv[1].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 = Filing.get_filings_by_status(
            business.id,
            [Filing.Status.COMPLETED.value, Filing.Status.PAID.value])
        for filing in filings:
            filing_json = filing.json
            filing_json['filing']['documents'] = document_meta.get_documents(
                filing_json)
            rv.append(filing_json)

        return jsonify(filings=rv)