I need to store data about Transactions in Django (Postgres).
There are different type of transactions (replenishment of balance, withdrawal from balance, payment of salaries, purchase of equipment, parking expenses, bonuses and etc.).
Depend on type of transaction I need to store different data, for example:
- For replenishment of balance and withdrawal from balance - customer (Id of customer, can be empty), date, comment, total
- For salaries - employee (Id of employee), date, comment, sub total and total (there may be bonus or fine)
- For purchase of equipment - provider (Text), date, comment, total
- For parking expenses - date, comment, total
Also I need to implement API (to retrieve salaries, transactions of client, all transactions, sum of all expenses, sum of all income and etc.)
Also it will be good if Admin would be able to add custom transaction types (I think that it’s not a good idea to store transaction type as a String, because it may cause some problems if Admin put wrong data (For example: “Salari” instead of “Salary”))
So, here are my questions:
- Is it a good approach to store all Transactions in one table (Model) or it’s better to split them and why?
- Any ideas on how to store Transaction Types?