Personal Finance App Monthly Reports Database Design ( SQLite )

database-designmobile-reports

I am building a personal finance mobile app that supposed to generate monthly reports, now I have a problem, confused about how to design the database to be monthly, I need the wallet to get archived after a month from the day it's created and transfer the remains/loss to the new wallet ( next month ) if exist.

enter image description here

Now my idea is to generate one wallet with xx money and let the user change the start date and make the mobile app automatically generate a new wallet every month on that day with the necessary transactions like there a loss/remain from the old wallet, and archive or prevent the user to make any transaction to the old wallets.

does my logic make sense or …? ( Note I'm still learning and this my first app using SQL/Database so please be patient with me )

Best Answer

From what I'm understanding you need to design a database which will be record transactions of a user and draw some conclusion like a profit/loss at the end of a month. To achieve this you don't necessarily need to create a wallet every month this is just basic accounting. You will need Transaction table and Transaction_History_Log and Charts_Of_Accounts for more detail check this. Your Transaction table will have a one-to-many relationship to your Transaction_History_Log and Transaction_History_Log will have many-to-one with your Charts_Of_Accounts. So just basically you will need to record journal entries this will help you get a more understanding about what journal entries are in accounting. You can set a createDate attribute in your Transaction_History_Log to just get the a snapshot of month or a whole year or whatever the user likes.