more models
This commit is contained in:
parent
b9dc545ebb
commit
df31c1aa49
@ -1,8 +1,28 @@
|
||||
from django.db.models import Model, CharField, ForeignKey, TextChoices, PROTECT
|
||||
from django.db.models import Model
|
||||
from django.db.models.fields import CharField, FloatField, BooleanField, DateField, DateTimeField
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
from django.db.models.deletion import PROTECT, CASCADE
|
||||
from django.db.models.enums import TextChoices
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class FinancialPosition(Model):
|
||||
class AbstractBaseModel(Model):
|
||||
|
||||
date_created = DateTimeField(
|
||||
auto_now_add=True,
|
||||
verbose_name=_("Time of creation")
|
||||
)
|
||||
date_modified = DateTimeField(
|
||||
auto_now=True,
|
||||
verbose_name=_("Time of last modification")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class FinancialPosition(AbstractBaseModel):
|
||||
|
||||
class FinStmt(TextChoices):
|
||||
BS = 'BS', _("Balance Sheet")
|
||||
@ -27,3 +47,66 @@ class FinancialPosition(Model):
|
||||
blank=True,
|
||||
verbose_name=_("Parent position")
|
||||
)
|
||||
|
||||
|
||||
class ReportingPeriod(AbstractBaseModel):
|
||||
|
||||
date_end = DateField(
|
||||
db_index=True,
|
||||
verbose_name=_("Period end date")
|
||||
)
|
||||
date_start = DateField(
|
||||
db_index=True,
|
||||
verbose_name=_("Period start date")
|
||||
)
|
||||
verified = BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("Exact dates verified")
|
||||
)
|
||||
|
||||
|
||||
class Company(AbstractBaseModel):
|
||||
|
||||
symbol = CharField(
|
||||
max_length=16,
|
||||
unique=True,
|
||||
verbose_name=_("Stock ticker symbol")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = _("Companies")
|
||||
|
||||
|
||||
class CompanyName(AbstractBaseModel):
|
||||
|
||||
company = ForeignKey(
|
||||
to=Company,
|
||||
on_delete=CASCADE
|
||||
)
|
||||
name = CharField(
|
||||
db_index=True,
|
||||
verbose_name=_("Name")
|
||||
)
|
||||
name_since = DateField(
|
||||
db_index=True,
|
||||
verbose_name=_("Has this name since")
|
||||
)
|
||||
|
||||
|
||||
class Figure(AbstractBaseModel):
|
||||
|
||||
position = ForeignKey(
|
||||
to=FinancialPosition,
|
||||
on_delete=PROTECT
|
||||
)
|
||||
period = ForeignKey(
|
||||
to=ReportingPeriod,
|
||||
on_delete=PROTECT
|
||||
)
|
||||
company = ForeignKey(
|
||||
to=Company,
|
||||
on_delete=PROTECT
|
||||
)
|
||||
value = FloatField(
|
||||
verbose_name=_("Figure on financial statement")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user