Django: Begginer Problems

40 views
Skip to first unread message

David Zárate

unread,
May 29, 2016, 7:24:16 PM5/29/16
to Django users
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.

These are my models so far:

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.name


class Statement(models.Model):
"""
Hold info about a Financial Statement.
"""
name = models.CharField(max_length=255)

def __str__(self):
return self.name


class 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.name


class 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.name


class 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.

Ryan Nowakowski

unread,
May 31, 2016, 9:22:34 AM5/31/16
to Django users
When you say "form", do you mean a Django Form[1]?

1. https://docs.djangoproject.com/en/1.9/topics/forms/

Akhil Lawrence

unread,
May 31, 2016, 2:17:44 PM5/31/16
to Django users
As Ryan mentioned. Go through the forms tutorial. Formsets may also help. Have a look.


Reply all
Reply to author
Forward
0 new messages