Ejemplo n.º 1
0
    def __json_filings(cls, filings):
        filings_json_list = []

        for filing in filings:
            d = {
                'completionDate':
                format_date(filing._completion_date),  # pylint: disable=protected-access
                'filingDate':
                format_date(filing._filing_date),  # pylint: disable=protected-access
                'filingId':
                filing.id,
                'filingType':
                format_non_date(filing._filing_type),  # pylint: disable=protected-access
                'effectiveDate':
                format_date(filing.effective_date),
                'paymentToken':
                format_non_date(filing._payment_token),  # pylint: disable=protected-access
                'paymentCompletionDate':
                format_date(filing._payment_completion_date),  # pylint: disable=protected-access
                'colinEventIds':
                [x.colin_event_id for x in filing.colin_event_ids],
                'status':
                format_non_date(filing._status),  # pylint: disable=protected-access
                'paperOnly':
                format_boolean(filing.paper_only),
                # Don't want to use format_json here because we're
                # running jsonify later and it will get all escaped
                'filingJson':
                format_non_date(filing._filing_json)  # pylint: disable=protected-access
            }
            filings_json_list.append(d)

        return filings_json_list
Ejemplo n.º 2
0
    def __json_directors(self, directors):
        directors_json_list = []

        for director in directors:
            d = {
                'firstName':
                format_non_date(director.party.first_name),
                'middleInitial':
                format_non_date(director.party.middle_initial),
                'lastName':
                format_non_date(director.party.last_name),
                'title':
                format_non_date(director.party.title),
                'appointmentDate':
                format_date(director.appointment_date),
                'cessationDate':
                format_date(director.cessation_date),
                'deliveryAddress':
                self.__format_address(director.party.delivery_address),
                'mailingAddress':
                self.__format_address(director.party.mailing_address)
            }
            directors_json_list.append(d)

        return directors_json_list
Ejemplo n.º 3
0
    def __write_business_address_to_excel(self, business_identifier,
                                          office_type, business_address):
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 0,
            format_non_date(business_identifier))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 1,
            format_non_date(office_type))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 2,
            format_non_date(business_address.address_type))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 3,
            format_non_date(business_address.street))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 4,
            format_non_date(business_address.street_additional))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 5,
            format_non_date(business_address.city))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 6,
            format_non_date(business_address.region))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 7,
            format_non_date(business_address.country))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 8,
            format_non_date(business_address.postal_code))
        self.__business_address_sheet.write(
            self.__business_address_sheet_row_index, 9,
            format_non_date(business_address.delivery_instructions))

        self.__business_address_sheet_row_index += 1
Ejemplo n.º 4
0
    def __write_filing_to_excel(self, business_identifier, filing):
        self.__filing_sheet.write(self.__filing_sheet_row_index, 0,
                                  format_non_date(business_identifier))

        self.__filing_sheet.write(self.__filing_sheet_row_index, 1,
                                  format_json(filing._filing_json))  # pylint: disable=protected-access
        self.__filing_sheet.write(self.__filing_sheet_row_index, 2,
                                  format_date(filing._completion_date))  # pylint: disable=protected-access
        self.__filing_sheet.write(self.__filing_sheet_row_index, 3,
                                  format_date(filing._filing_date))  # pylint: disable=protected-access
        self.__filing_sheet.write(self.__filing_sheet_row_index, 4,
                                  format_non_date(filing._filing_type))  # pylint: disable=protected-access
        self.__filing_sheet.write(self.__filing_sheet_row_index, 5,
                                  format_date(filing.effective_date))
        self.__filing_sheet.write(self.__filing_sheet_row_index, 6,
                                  format_non_date(filing._payment_token))  # pylint: disable=protected-access

        self.__filing_sheet.write(self.__filing_sheet_row_index, 7,
                                  format_date(filing._payment_completion_date))  # pylint: disable=protected-access
        self.__filing_sheet.write(
            self.__filing_sheet_row_index, 8,
            format_json([x.colin_event_id for x in filing.colin_event_ids]))
        self.__filing_sheet.write(self.__filing_sheet_row_index, 9,
                                  format_non_date(filing.status))
        self.__filing_sheet.write(self.__filing_sheet_row_index, 10,
                                  format_boolean(filing.paper_only))

        self.__filing_sheet_row_index += 1
Ejemplo n.º 5
0
    def __write_director_to_excel(self, business_identifier, director):
        self.__director_sheet.write(self.__director_sheet_row_index, 0,
                                    format_non_date(business_identifier))
        self.__director_sheet.write(self.__director_sheet_row_index, 1,
                                    format_non_date(director.first_name))
        self.__director_sheet.write(self.__director_sheet_row_index, 2,
                                    format_non_date(director.middle_initial))
        self.__director_sheet.write(self.__director_sheet_row_index, 3,
                                    format_non_date(director.last_name))
        self.__director_sheet.write(self.__director_sheet_row_index, 4,
                                    format_non_date(director.title))
        self.__director_sheet.write(self.__director_sheet_row_index, 5,
                                    format_date(director.appointment_date))
        self.__director_sheet.write(self.__director_sheet_row_index, 6,
                                    format_date(director.cessation_date))

        delivery_address = director.delivery_address
        if delivery_address:
            self.__write_director_address_to_excel(
                business_identifier, director, delivery_address,
                self.__director_sheet_row_index)

        mailing_address = director.mailing_address
        if mailing_address:
            self.__write_director_address_to_excel(
                business_identifier, director, mailing_address,
                self.__director_sheet_row_index)

        self.__director_sheet_row_index += 1
Ejemplo n.º 6
0
    def __json_filings(self, filings):
        filings_json_list = []

        for filing in filings:
            d = {
                'completionDate':
                format_date(filing._completion_date),
                'filingDate':
                format_date(filing._filing_date),
                'filingType':
                format_non_date(filing._filing_type),
                'effectiveDate':
                format_date(filing.effective_date),
                'paymentToken':
                format_non_date(filing._payment_token),
                'paymentCompletionDate':
                format_date(filing._payment_completion_date),
                'colinEventId':
                format_non_date(filing.colin_event_id),
                'status':
                format_non_date(filing._status),
                'paperOnly':
                format_boolean(filing.paper_only),
                # Don't want to use format_json here because we're
                # running jsonify later and it will get all escaped
                'filingJson':
                format_non_date(filing._filing_json)
            }
            filings_json_list.append(d)

        return filings_json_list
Ejemplo n.º 7
0
    def __write_header_lines(self):
        business_sheet_headings = [
            'identifier', 'legal_name', 'legal_type', 'founding_date',
            'dissolution_date', 'last_ar_date', 'last_agm_date',
            'fiscal_year_end_date', 'tax_id', 'last_ledger_id',
            'last_remote_ledger_id', 'last_ledger_timestamp', 'last_modified'
        ]
        for i, business_sheet_heading in enumerate(business_sheet_headings):
            self.__business_sheet.write(
                0, i, format_non_date(business_sheet_heading))

        business_address_sheet_headings = [
            'business', 'address_type', 'street', 'street_additional', 'city',
            'region', 'country', 'postal_code', 'delivery_instructions'
        ]
        for i, business_address_sheet_heading in enumerate(
                business_address_sheet_headings):
            self.__business_address_sheet.write(
                0, i, format_non_date(business_address_sheet_heading))

        director_sheet_headings = [
            'business',
            'first_name',
            'middle_initial',
            'last_name',
            'title',
            'appointment_date',
            'cessation_date',
        ]
        for i, director_sheet_heading in enumerate(director_sheet_headings):
            self.__director_sheet.write(
                0, i, format_non_date(director_sheet_heading))

        director_address_sheet_headings = [
            'business', 'first_name', 'last_name', 'address_type', 'street',
            'street_additional', 'city', 'region', 'country', 'postal_code',
            'delivery_instructions'
        ]
        for i, director_address_sheet_heading in enumerate(
                director_address_sheet_headings):
            self.__director_address_sheet.write(
                0, i, format_non_date(director_address_sheet_heading))

        filing_sheet_headings = [
            'business',
            'filing_json',
            'completion_date',
            'filing_date',
            'filing_type',
            'effective_date',
            'payment_id',
            'payment_completion_date',
            'colin_event_ids',
            'status',
            'paper_only',
        ]
        for i, filing_sheet_heading in enumerate(filing_sheet_headings):
            self.__filing_sheet.write(0, i,
                                      format_non_date(filing_sheet_heading))
Ejemplo n.º 8
0
    def __json_business(self, business):

        offices = business.offices.all()
        registered_office = self.__create_office_addresses(offices, OfficeType.REGISTERED)
        records_office = self.__create_office_addresses(offices, OfficeType.RECORDS)

        d = {
            'identifier': format_non_date(business.identifier),
            'legalName': format_non_date(business.legal_name),
            'legalType': format_non_date(business.legal_type),
            'foundingDate': format_date(business.founding_date),
            'dissolutionDate': format_date(business.dissolution_date),
            'lastAnnualReport': format_date(business.last_ar_date),
            'lastAnnualGeneralMeetingDate': format_date(business.last_agm_date),
            'fiscalYearEndDate': format_date(business.fiscal_year_end_date),
            'taxId': format_non_date(business.tax_id),
            'lastLedgerId': format_non_date(business.last_ledger_id),
            'lastRemoteLedgerId': format_non_date(business.last_remote_ledger_id),
            'lastLedgerTimestamp': format_date(business.last_ledger_timestamp),
            'submitterUserId': format_non_date(business.submitter_userid),
            'lastModified': format_date(business.last_modified),
            'directors': self.__json_directors(business.directors),
            'registeredOffice': registered_office,
            OfficeType.REGISTERED: format_non_date(registered_office),
            OfficeType.RECORDS: format_non_date(records_office),
            'filings': self.__json_filings(business.filings)
        }

        return d
Ejemplo n.º 9
0
 def __format_address(cls, value):
     return_value = None
     if value:
         return_value = {
             'addressType': format_non_date(value.address_type),
             'street': format_non_date(value.street),
             'streetAdditional': format_non_date(value.street_additional),
             'city': format_non_date(value.city),
             'region': format_non_date(value.region),
             'country': format_non_date(value.country),
             'postalCode': format_non_date(value.postal_code)
         }
     return return_value
Ejemplo n.º 10
0
    def __write_business_to_excel(self, business):

        self.__business_sheet.write(self.__business_sheet_row_index, 0,
                                    format_non_date(business.identifier))
        self.__business_sheet.write(self.__business_sheet_row_index, 1,
                                    format_non_date(business.legal_name))
        self.__business_sheet.write(self.__business_sheet_row_index, 2,
                                    format_non_date(business.legal_type))
        self.__business_sheet.write(self.__business_sheet_row_index, 3,
                                    format_date(business.founding_date))
        self.__business_sheet.write(self.__business_sheet_row_index, 4,
                                    format_date(business.dissolution_date))
        self.__business_sheet.write(self.__business_sheet_row_index, 5,
                                    format_date(business.last_ar_date))
        self.__business_sheet.write(self.__business_sheet_row_index, 6,
                                    format_date(business.last_agm_date))
        self.__business_sheet.write(self.__business_sheet_row_index, 7,
                                    format_date(business.fiscal_year_end_date))
        self.__business_sheet.write(self.__business_sheet_row_index, 8,
                                    format_non_date(business.tax_id))
        self.__business_sheet.write(self.__business_sheet_row_index, 9,
                                    format_non_date(business.last_ledger_id))
        self.__business_sheet.write(
            self.__business_sheet_row_index, 10,
            format_non_date(business.last_remote_ledger_id))
        self.__business_sheet.write(
            self.__business_sheet_row_index, 11,
            format_date(business.last_ledger_timestamp))
        self.__business_sheet.write(self.__business_sheet_row_index, 12,
                                    format_date(business.last_modified))

        self.__business_sheet_row_index += 1

        directors = business.directors.all()
        for director in directors:
            self.__write_director_to_excel(business.identifier, director)

        offices = business.offices.all()
        for office in offices:
            office_addresses = office.addresses.all()
            for office_address in office_addresses:
                self.__write_business_address_to_excel(business.identifier,
                                                       office.office_type,
                                                       office_address)

        filings = business.filings.all()
        for filing in filings:
            self.__write_filing_to_excel(business.identifier, filing)
Ejemplo n.º 11
0
    def __write_director_address_to_excel(self, business_identifier, director,
                                          director_address,
                                          director_row_reference):
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 0,
            format_non_date(business_identifier))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 1,
            format_non_date(director.first_name))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 2,
            format_non_date(director.last_name))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 3,
            format_non_date(director_address.address_type))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 4,
            format_non_date(director_address.street))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 5,
            format_non_date(director_address.street_additional))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 6,
            format_non_date(director_address.city))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 7,
            format_non_date(director_address.region))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 8,
            format_non_date(director_address.country))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 9,
            format_non_date(director_address.postal_code))
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 10,
            format_non_date(director_address.delivery_instructions))
        # Need to add the row reference so that it can be linked with a specific director (matching by name was bad)
        self.__director_address_sheet.write(
            self.__director_address_sheet_row_index, 11,
            format_non_date(director_row_reference))

        self.__director_address_sheet_row_index += 1