Categories and statistics

Hi, how it’s going? I hope that everything’s fine and you can not wait to read another post, another brick towards the completion of the application 🙂 Today we’re going to dive into categories and create first statistics to see, how much we spend. Let’s start!

Last time we did few things. Displaying all transactions in very easy way and adding a possibility to quick search among them. Let’s try to add a function to save category for every transaction. There will be seven of them:

  • Apparel/Accessory
  • Entertainment
  • Food/Beverage
  • Skincare/Cosmetics
  • Computer/Mobile
  • Books/Newspapers
  • Other

In order to make it, we should make some changes in our models. We have to add a field called “category” and add a new option for it – “choices”. In this easy way, we can limit options for the user. I assumed that it should be a drop-down list. Choosing a category will be also obligatory. Without it, we won’t be able to add a transaction. Now, look at the adding transactions page:

There is a new input, called “Category”. Let’s spread it:

Great! Now we should look at the table. There should be a transaction with our new category:

Yeah! We definitely rock 😉 Now it’s time to count money. Let’s start from something easy and display the total amount of spent money. We use a loop in order to add every price from every transaction. The final statement is:

Perfect! Everything works great. In the navbar, there is also a new icon:

I hope that you’re still with me. That’s all for today. Next time we will be dealing with more difficult statistics and be creating some animated charts. If you have any questions, fell free to ask! Bye 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *