Database Models

In this page you can find documentation on how the data is structured and what the convention behind the values are.

It will probably not be up to date all the time, for a bleeding edge documentation refer to the models.py file in the repository.

Foreign keys that link to other database models are stored in the database in a colums called <model_name>_id so for the category of a Split it would be category_id. In the code you can either use obj.category to access the category object, or obj.category_id to only get the id of the object.

Decimals are stored in the database with a maximum of ten digits and two decimal places.

There are a couple of integers used that are named for more readability:

Account Types

NameValueNotes
Personal1These are the accounts that are owned by the user
Foreign2All accounts that the user interacts with, but are not his own.
System3Accounts of this type are hidden from users and only used for housekeeping (initial balances, reconcilation, …)

Recurrence Types

NameValueNotes
Disabled0Can be used to deactivate recurrences that no longer occur.
Weekly1
Monthly2
Yearly3

Transaction Types

NameValueNotes
Deposit1A deposit is from a foreign account to a personal account
Withdraw2A withdraw is from a personal account to a foreign account
Transfer3A transfer involves two personal accounts
System4These transactions involve one System account and are used to satisfy double bookkeeping. It’s used in inital balances and reconciliation

Account

Represents the accounts that are part in transactions. There can’t be multiple accounts with the same name and account_type. There currently can only be one system account, this is not enforced in the database.

AttributeTypeNotes
namechars (64)The name of the account
account_typeintegerOne of the account types
activebooleanwhether or not the account is shown in forms, etc. Has only effect on personal accounts.
last_modifieddatetimeIs set automatically and can’t be modified
show_on_dashboardbooleanWhether or not to include the account in the account listing on the dashboard. Only affects personal accounts

Category

Categories can be used to categorize (duh!) transactions. They are also used during budgeting.

AttributeTypeNotes
activebooleanWhether or not the category is shown in forms, etc.
namechars (64)The name of the category
last_modifieddatetimeIs set automatically and can’t be modified

Recurring Transaction

Recurring Transactions are used to remind you of them. They can be transfers, deposits or withdrawls.

AttributeTypeNotes
titlechars (64)Title of the recurrence and transaction that will be created of it
amountdecimalThe amount of the transaction
datedateThe date of the next expected ocurrence
srcAccountThe account that will loose the money
dstAccountThe account that will gain the money
recurrenceintegerOne of the recurrence types
transaction_typeintegerOne of the transaction types
categoryCategoryThe category of the resulting transactions
last_modifieddatetimeIs set automatically and can’t be modified

Transaction

AttributeTypeNotes
titlechars (64)Title of the transaction
datedatethe date when the transaction happened
recurrenceRecurring TransactionNULL if the transaction is not associated with a recurring transaction
transaction_typeintegerOne of the transaction types
notesText
last_modifieddatetimeIs set automatically and can’t be modified

Split

AttributeTypeNotes
titlechars (64)Title of the split, if the transaction is a simple transaction, it should match the title of the transaction
amountdecimalThe amount of the transaction. A positive amount is a deposit into the account, a negative is a withdrawal from the account
datedatedate the transaction was registered in the source account
accountAccountThe account where the amount is added or deducted from.
opposing_accountAccountThe opposing account
transactionTransactionThe transaction this split belongs to
categoryCategoryOptional. Can be used to categorize transactions and to assign budgets to them.
last_modifieddatetimeIs set automatically and can’t be modified