Beispiel #1
0
    def json(self):
        """Return a json representation of this object."""
        try:
            json_submission = copy.deepcopy(self.filing_json)
            json_submission['filing']['header']['date'] = self._filing_date.isoformat()
            json_submission['filing']['header']['filingId'] = self.id
            json_submission['filing']['header']['name'] = self.filing_type
            json_submission['filing']['header']['status'] = self.status

            # if availableOnPaper is not defined in filing json, use the flag on the filing record
            if json_submission['filing']['header'].get('availableOnPaperOnly', None) is None:
                json_submission['filing']['header']['availableOnPaperOnly'] = self.paper_only

            if self.effective_date:
                json_submission['filing']['header']['effectiveDate'] = self.effective_date.isoformat()
            if self._payment_token:
                json_submission['filing']['header']['paymentToken'] = self.payment_token
            if self.submitter_id:
                json_submission['filing']['header']['submitter'] = self.filing_submitter.username

            # add colin_event_ids
            json_submission['filing']['header']['colinIds'] = ColinEventId.get_by_filing_id(self.id)

            # add comments
            json_submission['filing']['header']['comments'] = [comment.json for comment in self.comments]

            return json_submission
        except Exception:  # noqa: B901, E722
            raise KeyError
Beispiel #2
0
    def json(self):
        """Return a json representation of this object."""
        try:
            json_submission = copy.deepcopy(self.filing_json)
            json_submission['filing']['header']['date'] = self._filing_date.isoformat()
            json_submission['filing']['header']['filingId'] = self.id
            json_submission['filing']['header']['name'] = self.filing_type
            json_submission['filing']['header']['status'] = self.status

            # if availableOnPaper is not defined in filing json, use the flag on the filing record
            if json_submission['filing']['header'].get('availableOnPaperOnly', None) is None:
                json_submission['filing']['header']['availableOnPaperOnly'] = self.paper_only

            if self.effective_date:
                json_submission['filing']['header']['effectiveDate'] = self.effective_date.isoformat()
            if self._payment_status_code:
                json_submission['filing']['header']['paymentStatusCode'] = self.payment_status_code
            if self._payment_token:
                json_submission['filing']['header']['paymentToken'] = self.payment_token
            if self.submitter_id:
                json_submission['filing']['header']['submitter'] = self.filing_submitter.username
            if self.payment_account:
                json_submission['filing']['header']['paymentAccount'] = self.payment_account

            # add colin_event_ids
            json_submission['filing']['header']['colinIds'] = ColinEventId.get_by_filing_id(self.id)

            # add comments
            json_submission['filing']['header']['comments'] = [comment.json for comment in self.comments]

            # add affected filings list
            json_submission['filing']['header']['affectedFilings'] = [filing.id for filing in self.children]

            # add corrected flags
            json_submission['filing']['header']['isCorrected'] = self.is_corrected
            json_submission['filing']['header']['isCorrectionPending'] = self.is_correction_pending

            return json_submission
        except Exception as err:  # noqa: B901, E722
            raise KeyError from err
Beispiel #3
0
def test_patch_internal_filings(session, client, jwt):
    """Assert that the internal filings patch endpoint updates the colin_event_id."""
    from legal_api.models.colin_event_id import ColinEventId
    # setup
    identifier = 'CP7654321'
    b = factory_business(identifier)
    factory_business_mailing_address(b)
    filing = factory_completed_filing(b, ANNUAL_REPORT)
    colin_id = 1234

    # make request
    rv = client.patch(f'/api/v1/businesses/internal/filings/{filing.id}',
                      json={'colinIds': [colin_id]},
                      headers=create_header(jwt, [COLIN_SVC_ROLE])
                      )

    # test result
    assert rv.status_code == HTTPStatus.ACCEPTED
    filing = Filing.find_by_id(filing.id)
    assert colin_id in ColinEventId.get_by_filing_id(filing.id)
    assert rv.json['filing']['header']['filingId'] == filing.id
    assert colin_id in rv.json['filing']['header']['colinIds']
Beispiel #4
0
    def get(status=None):
        """Get filings by status formatted in json."""
        pending_filings = []
        filings = []

        if status is None:
            pending_filings = Filing.get_completed_filings_for_colin()
            for filing in pending_filings:
                filing_json = filing.filing_json
                business = Business.find_by_internal_id(filing.business_id)
                if filing_json and filing.filing_type != 'lear_epoch' and \
                        (filing.filing_type != 'correction' or business.legal_type != business.LegalTypes.COOP.value):
                    filing_json['filingId'] = filing.id
                    filing_json['filing']['header'][
                        'learEffectiveDate'] = filing.effective_date.isoformat(
                        )
                    if not filing_json['filing']['business'].get('legalName'):
                        business = Business.find_by_internal_id(
                            filing.business_id)
                        filing_json['filing']['business'][
                            'legalName'] = business.legal_name
                    if filing.filing_type == 'correction':
                        colin_ids = \
                            ColinEventId.get_by_filing_id(filing_json['filing']['correction']['correctedFilingId'])
                        if not colin_ids:
                            continue
                        filing_json['filing']['correction'][
                            'correctedFilingColinId'] = colin_ids[
                                0]  # should only be 1
                    filings.append(filing_json)
            return jsonify(filings), HTTPStatus.OK

        pending_filings = Filing.get_all_filings_by_status(status)
        for filing in pending_filings:
            filings.append(filing.json)
        return jsonify(filings), HTTPStatus.OK