Finance app: account balance / statement / ledger

Hi,

I’m making a personal finance app on AppGyver.
I’ve looked in the forums and documentation and couldn’t find recomendations on this.
As a non developer, I’m struggling on how to structure my data for this cenario.

  • user should be able to add, remove and edit transactions to different accounts. (that i managed to do)
  • after a transaction is added, account balance should be updated.
  • on a transactions page list, users should be able to see all transactions with a daily balances (something lika a bank account statement / ledger)

So far I have the transactions and account data resources, lookink like this:
transactions: id, date, value, description, account, account.id
Account: id, name, initiral_balance

  • should I use positive negative values for the transctions? or make two propoerties: something like debit for negative values and credit for positive?
  • shoud I make another resource for account daily balances or sould I calculate daily/current balances everytime on page mount/focus (by summing all transactions values on the date resource)?
  • how to “query”, this type of data on a noSQL data resource? (eg: SELECT SUM(values) FROM transactions WHERE account.id = ‘x’ GROUP BY date)

Any help is appreciated.
Thanks,
Ricardo

There are so many different things to consider here.

It will take some time to find the right structure. But quick ideas:

transaction data object:

  • datetime
  • status
  • type (credit / debit) [should be a text property with enum values]
  • amount
    (- currency maybe)
  • destination (if it is a different user of the app)
  • initiator (your user.id)

Then for user you can have some nested objects:

  • personal details
    • name
    • address
    • email
    • phone
  • account details
    • bank information properties…
  • balance

If You want to make an app that helps a user to track their expenses it would be advised to have a way to store a user’s past balances (let’s say daily). You could do the calculation on the app, but that could be resource heavy, so yeah, better use a data resource.

Hi Mihaly,

Thanks for the heads up.
I’ll change my data structure to have transaction type then (debit/credit).

The app idea is to track personal expenses only, so all data is stored locally on the device.
So initiator and other personal details are not necessary for now.
Also, I’ll look into online backup and sync later.

My main question here though is: having a set transactions data objects and accounts data objects, how do I translate that to a account statement (or ledger, not sure of what would be the most appropriate word in this case)?

e.g.
accounts =
[
{
“name”: “cash”,
“initial_balance”: 100,
}
]

transactions =
[
{
“date”: “29/07/2022”,
“value”: 10,
“type”: “c”,
“account”: “cash”
},
{
“date”: “01/08/2022”,
“value”: 5,
“type”: “d”,
“account”: “cash”
},
{
“date”: “02/08/2022”,
“value”: 2,
“type”: “d”,
“account”: “cash”
},
{
“date”: “02/08/2022”,
“value”: 10,
“type”: “c”,
“account”: “cash”
},
{
“date”: “04/08/2022”,
“value”: 5,
“type”: “d”,
“account”: “cash”
},
{
“date”: “05/08/2022”,
“value”: 3,
“type”: “c”,
“account”: “cash”
},
{
“date”: “05/08/2022”,
“value”: 1,
“type”: “c”,
“account”: “cash”
}
]

Cash account statement (inicital balance is 100):
|date |c |d |balance|
|29/07/2022 |10 | |110|
|01/08/2022 | |5 |105|
|02/08/2022 | |2 |103|
|02/08/2022 |10 | |113|
|04/08/2022 | |5 |108|
|05/08/2022 |3 | |111|
|05/08/2022 |1 | |112|

Or maybe even group by day:
|date |c |d |balance|
|29/07/2022|10 | |110|
|01/08/2022| |5 |105|
|02/08/2022|10 |2 |113|
|04/08/2022| |5 |108|
|05/08/2022|4 | |112|

Thank you