class BovespaAccount(CustomDjangoCassandraModel):

    __table_name__ = "bovespa_account"

    # ID of the company in B3
    ccvm = columns.Text(partition_key=True)

    # Date of the account value
    period = columns.Date(primary_key=True, clustering_order="DESC")

    # The version of the account. The company could present different
    # versions of the files
    version = columns.Text(primary_key=True, clustering_order="DESC")

    # The account number. Ex. "1.01.01"
    number = columns.Text(primary_key=True, max_length=15)

    # Financial type account (instant/individual or consolidated)
    financial_info_type = columns.Text(primary_key=True, max_length=15)

    # Type of financial statement
    balance_type = columns.Text(max_length=15, required=True)

    # The account name. Ex. "Receita de Venda de Bens e/ou Serviços"
    name = columns.Text(max_length=200, required=True)

    # Company sector
    sector = columns.Integer(default=0, required=True)

    # The amount of the account
    amount = Decimal(required=True, max_digits=20, decimal_places=2)

    # The comments. Used for "DFP_BALANCE_DMPL" accounts, explaining the
    # meaning of the account: Shareholder's Equity, Accrued Profit/Loss, etc.
    comments = columns.Text()

    # When was created the entity and the last modification date
    created_at = columns.DateTime(default=datetime.utcnow)
    updated_at = columns.DateTime(default=datetime.utcnow)

    # Controls if the entity is active or has been deleted
    is_deleted = columns.Boolean(default=False)
    deleted_reason = columns.Text()

    class Meta:
        get_pk_field = "ccvm"

    def validate(self):
        super().validate()

        if self.financial_info_type not in FINANCIAL_INFO_TYPES:
            raise ValidationError("Invalid financial type [{0}] for account "
                                  "[{1} {2}]. Valid types are: {3}.".format(
                                      self.financial_info_type, self.number,
                                      self.name, FINANCIAL_INFO_TYPES))

        if self.balance_type not in BALANCE_TYPES:
            raise ValidationError(
                "Invalid balance type [{0}]. Valid types are: {1}.".format(
                    self.balance_type, BALANCE_TYPES))
示例#2
0
class UserModel(Model):
    """Model class that maps to the user table"""
    __table_name__ = 'users'
    user_id = columns.UUID(db_field='userid', primary_key=True)
    first_name = columns.Text(db_field='firstname')
    last_name = columns.Text(db_field='lastname')
    email = columns.Text()
    created_date = columns.Date()
示例#3
0
class BovespaCompany(CustomDjangoCassandraModel):

    __table_name__ = "bovespa_company"

    # Force that all the values will reside in the seam node of the cluster
    entity_type = columns.Text(partition_key=True, default="company")

    # ID of the company in B3
    ccvm = columns.Text(primary_key=True)

    # When was created the entity and the last modification date
    created_at = columns.DateTime(default=datetime.utcnow)
    updated_at = columns.DateTime(default=datetime.utcnow)

    # Controls if the entity is active or has been deleted
    is_deleted = columns.Boolean(default=False)
    deleted_reason = columns.Text()

    company_name = columns.Text(required=True)

    cnpj = columns.Text()

    company_type = columns.Text()

    situation = columns.Text(required=True)

    granted_date = columns.Date()
    canceled_date = columns.Date()

    class Meta:
        get_pk_field = "entity_type"

    def validate(self):
        super().validate()

        if self.situation not in SITUATIONS:
            raise ValidationError(
                "Invalid situation [{0}]. Valid situations are: {1}.".format(
                    self.situation, SITUATIONS))
示例#4
0
class BovespaCompanyFile(CustomDjangoCassandraModel):

    __table_name__ = "bovespa_company_file"

    # ID of the company in B3
    ccvm = columns.Text(partition_key=True)

    # The type of document
    doc_type = columns.Text(max_length=3, primary_key=True)

    # The fiscal date the file is making reference.
    fiscal_date = columns.Date(primary_key=True, clustering_order="DESC")

    # The file version. The company could present different version of
    # the files for a specific fiscal period
    version = columns.Text(primary_key=True, clustering_order="DESC")

    status = columns.Text(default=FILE_STATUS_NOT_PROCESSED)

    # When was created the entity and the last modification date
    created_at = columns.DateTime(default=datetime.utcnow)
    updated_at = columns.DateTime(default=datetime.utcnow)

    # Controls if the entity is active or has been deleted
    is_deleted = columns.Boolean(default=False)
    deleted_reason = columns.Text()

    # The protocol code associated with the file
    protocol = columns.Text(required=True)

    # When the documents were delivered
    delivery_date = columns.DateTime(required=True)

    # Why the files were delivered
    delivery_type = columns.Text(required=True)

    # The official name of the company
    company_name = columns.Text(required=True)

    # The company CNPJ
    company_cnpj = columns.Text(required=True)

    # The Fiscal Period decomposed into year, quarter, month
    # The year of the balance sheet
    # Ex. 2015
    fiscal_date_y = columns.SmallInt()

    # The day of the year of the balance sheet
    # Ex. 2015
    fiscal_date_yd = columns.SmallInt()

    # The quarter of the balance sheet
    # Ex. 1
    fiscal_date_q = columns.SmallInt()

    # The month of the balance sheet
    # Ex. 1
    fiscal_date_m = columns.SmallInt()

    # The day of the month of the balance sheet
    # Ex. 1
    fiscal_date_md = columns.SmallInt()

    # The week of the year
    # Ex. 1
    fiscal_date_w = columns.SmallInt()

    # The day of the week of the year
    # Ex. 1
    fiscal_date_wd = columns.SmallInt()

    # Combination of YEAR-QUARTER in the form of 2018-Q1
    # That allows us to facet results per quarter
    fiscal_date_yq = columns.Text()

    # Combination of YEAR-MONTH in the form of 2018-01
    # That allows us to facet results per month
    fiscal_date_ym = columns.Text()

    # The url to the file that contains the information in bovespa. This
    # will be the url we will use to download the file from the source
    source_url = columns.Text(required=True)

    # The url to the file that contains the information. Is an url to a
    # repository of our own. The file has already beed downloaded and
    # persisted into a custom repository. We do not need to access the source
    file_url = columns.Text()

    # The internal name of the file
    file_name = columns.Text()

    # The extension of the filename
    file_extension = columns.Text()

    # Each key represents the name of the file in the ENER arquive.
    # The value is the original content converted into JSON - when possible -
    # and persisted as Text
    # content = KeyEncodedMap(
    #    key_type=columns.Text, value_type=columns.Text)

    class Meta:
        get_pk_field = "ccvm"

    def validate(self):
        super().validate()

        if self.doc_type not in DOC_TYPES:
            raise ValidationError(
                "Invalid doc type [{0}]. Valid types are: {1}.".format(
                    self.doc_type, DOC_TYPES))

        if self.status not in FILE_STATUSES:
            raise ValidationError(
                "Invalid file status [{0}]. Valid statuses are: {1}.".format(
                    self.status, FILE_STATUSES))
 class Allv4Datatypes(UserType):
     a = columns.Date()
     b = columns.SmallInt()
     c = columns.Time()
     d = columns.TinyInt()
    # Controls if the entity is active or has been deleted
    is_deleted = columns.Boolean(default=False)
    deleted_reason = columns.Text()

    crawl_param = columns.Integer(required=True)

    name = columns.Text(required=True)

    situation = columns.Text(required=True)

    short_description = columns.Text()

    long_description = columns.Text()

    # The date when the company was founded
    foundation_date = columns.Date()

    # Country of the company
    # ISO 3166-1 alpha 3 code
    country_code = columns.Text(min_length=3, max_length=3)

    # A list of specialties of the company
    specialties = columns.List(value_type=columns.Text)

    # A field that represent a map of key-value
    # We use caravaggio KeyEncodedMap that appends the field name
    # to each of the keys in order to make them indexable by the
    # Search Indexer.
    websites = KeyEncodedMap(
        key_type=columns.Text, value_type=columns.Text)
class Company(CustomDjangoCassandraModel):
    """
    A public traded company
    """
    __table_name__ = "company"

    # A unique identifier of the entity
    _id = columns.UUID(partition_key=True, default=uuid.uuid4)

    # The owner of the data. Who own's the company data persisted
    user = columns.Text(primary_key=True)

    # When was created the entity and the last modification date
    created_at = columns.DateTime(default=datetime.utcnow)
    updated_at = columns.DateTime(default=datetime.utcnow)

    # Controls if the entity is active or has been deleted
    is_deleted = columns.Boolean(default=False)
    deleted_reason = columns.Text()

    # The name of the company
    name = columns.Text(required=True)

    # A short description about the company
    short_description = columns.Text()

    # The company domain (e.g. preseries.com)
    domain = columns.Text(max_length=50)

    # The date when the company was founded
    foundation_date = columns.Date()

    # The date of the latest funding round
    last_round = columns.Date()

    # The total number of funding rounds
    round_notes = columns.Text()

    # Country of the company
    # ISO 3166-1 alpha 3 code
    country_code = columns.Text(min_length=3, max_length=3)

    # The stock trading symbol
    stock_symbol = columns.Text()

    # Contact email of the company
    contact_email = columns.Text()

    # The IDs of the founders of the company
    founders = columns.List(value_type=columns.UUID)

    # Address of the headquarters of the company
    address = UserDefinedType(Address)

    # A list of specialties of the company
    specialties = columns.List(value_type=columns.Text)

    # The counters of the latest followers in twitter
    #  (example of list of integers)
    latest_twitter_followers = columns.List(value_type=columns.Integer)

    # A field that represent a map of key-value
    # We use caravaggio KeyEncodedMap that appends the field name
    # to each of the keys in order to make them indexable by the
    # Search Indexer.
    websites = KeyEncodedMap(key_type=columns.Text, value_type=columns.Text)

    # A field that represents a raw JSON with the crawler configurations, each
    # key is a reference to a crawler
    crawler_config = columns.Text()

    # A field that represents a raw JSON content
    extra_data = columns.Text()

    latitude = columns.Float()
    longitude = columns.Float()

    coordinates = columns.Text()

    class Meta:
        get_pk_field = '_id'

    def validate(self):
        super(Company, self).validate()
        if self.name == "test":
            raise ValidationError('The company name cannot be test')
class TestQueryModel(Model):

    test_id = columns.UUID(primary_key=True, default=uuid4)
    date = columns.Date(primary_key=True)
    description = columns.Text()
 class v4DatatypesModel(Model):
     id = columns.Integer(primary_key=True)
     a = columns.Date()
     b = columns.SmallInt()
     c = columns.Time()
     d = columns.TinyInt()