Hi! I'm making a financial analysis app in Django and to have some data to play with i have to store historical data of balance sheets and profit/loss statements. I need some suggestions on how i can accomplish that.
class Entity(models.Model):
"""
Holds information about entities as banks, finance and insurance companies.
"""
ENTITY_TYPE = (
('BNK', 'Bank'),
('FNC', 'Finance'),
('INS', 'Insurance'),
('UNK', 'Otros'),
)
name = models.CharField(max_length=255, unique=True)
type = models.CharField(choices=ENTITY_TYPE, max_length=3)
def __str__(self):
return
self.nameclass Statement(models.Model):
"""
Hold info about a Financial Statement.
"""
name = models.CharField(max_length=255)
def __str__(self):
return
self.nameclass AccountGroup(models.Model):
"""
Model to group accounts together i.e.: Asset, Liability, Equity, Income, Expense
"""
parent_group = models.ForeignKey('AccountGroup', null=True, blank=True)
name = models.CharField(max_length=255)
def __str__(self):
return
self.nameclass Account(models.Model):
"""
Represents each account of a Financial Statement.
"""
# TODO this needs to be improved
order = models.IntegerField(unique=True, default='0000')
group = models.ForeignKey('AccountGroup')
name = models.CharField(max_length=255)
def __str__(self):
return
self.nameclass FinancialStatement(models.Model):
entity = models.ForeignKey('Entity')
statement = models.ForeignKey('Statement')
period = models.DateField()
accounts = models.ForeignKey('Account', default='0.00')
amount = models.DecimalField(max_digits=12, decimal_places=2, default='0.00')
def __str__(self):
return self.entity
Since it's not an accounting app i have to only store data from a monthly statement report, my question here is how can i make a form that brings all accounts for a statement in a column and helps me introduce its corresponding amount in other column. My Account model really needs better logic for the account "order" or "number" part. For comparison purposes every instance of FinancialStatement() needs to hold a date representing the date when the statement was published. And that's my problem.
Hope you can help me.