[eluser]kyleect[/eluser]
I apologize for not having more solid code and asking this question but I'm currently in the process of designing a database for an application I'm creating and I'm having trouble... wrapping my mind around the best approach for this.
Ok. Here is essentially the application I'm designing. I want to create a financial forecast for a checking account. I need to be able to declare a starting balance, enter transactions and defined reoccurring transactions. The forecast will then not only provide my current balance but a running total going out 6, 7, 12 months based on both the transactions I've entered and the predefined reoccurring transactions. This reoccurring transactions would be things like rent, electric bill, cell phone bill but also my paychecks. The format of this forecast would be a table in the following format:
date | transaction description | running balance
I hope I've described what I would like to do clear enough and I think it will help provide context for my questions.
Currently, I have 2 tables
`accounts`
-id
-account_number
-description
`transactions`
-id
-account_id
-amount
-date
-description
1) The running balance calculation. Should that be done in the model or controller?
2) I need to store the starting balance of an account so I can calculate the running balance. I did have a column in the `accounts` table called `starting_balance` then I tried having a transaction with a description of "starting_balance" but neither of these solutions seem ideal. Do I really want to keep calculating a running balance based on a starting balance that could be... 6 months old? A year old? Seems dodgy but I can't seem to think of another way to do this. Suggestions?
I am not looking someone to map out my application or even provide any code, just a push in the right direction. Also, I know someone is going to suggest it, I have looked in to various desktop/web apps to keep track of transactions but none of them really provide a view of the data I need.