2đź‘Ť
Regardless if you define this as simple or not you should still adhere to standards when developing your design. I am sure many others can speak to my points with greater detail but a few things to keep in mind in regards to your questions.
1) If you want to maintain a spreadsheet then get rid of the database altogether. I am sure that is not what you are after. So don’t create fields for credit and debit and allow a swisscheese pattern of nulls. If you are building a database you can easily avoid this. All transactions (debit/credit) should be handled in one column of Amount. Yes this will have a (-) sign in the database. Don’t model the data in your database to a “pretty” format that you customer wants to see. Let standards dictate how data is stored and worry about the presentation (delivering that “pretty”) in a different respect.
2) You can create a type field but leave it as boolean if anything
3) I am still working through a solution here myself. Deriving this value on the fly in a relatively small or inactive database is not a problem. I am not sure about the scalability though. I have heard differing OPINIONS as to this so I will hold my breath here until I see a scalable solution that properly handles the load.
2đź‘Ť
It’s about ones taste how one would approach the developing of a ledger.
If it were up to me, I’d have separate Debit
and Credit
classes each of which will have a column called Trailing Balance
that would be updated on the respective save.
Another alternative could be that you have a same model called the Entry
that could store all the debit values as negative. That way, the aggregate of the entries is the current balance
and the aggregate of the values until that time, an entry was made, is the trial balance
– You can make it a little cache heavy, that another table stores the username, entry FK and the trial balance. – When you try to access the trial balance
at a given time, or for a given transaction, if it doesn’t exist, it gets calculated, via the aggregates.
- [Django]-Can I deploy a django app which uses sqlite3 as backend on google app engine?
- [Django]-How to get a list of all custom Django commands in a project?
- [Django]-View didn't return an HttpResponse object. It returned None instead
- [Django]-Password-Protect a development or staging Django app