I'm quite a newbie with Flutterflow and I'm really struggling try to something quite simple... so here goes...
Use case: this is for a personal trainer (PT) - the PT buys 'slots' at the gym. With each booking, the PT uses up one of the slots. I'm wanting to display the slots remaining, which is: total slots purchased minus total bookings made
I thought it'd be easy but for a couple of days now, I've been going nowhere fast.
My firebase is as follows:
In my users collection, I have a sub-collection called 'purchases'. For each purchase document there will be a field called qty_value which is an integer stating how many slots were purchased (e.g. 20 or 40). A PT will make many purchases so the function has to sum the qty_value field from all records of the PT.
Also in my users collection, I have a sub-collection called 'booking' and the total count of all the bookings is the number that needs to be subtracted from the sum of qty_value to determine 'slots remaining' that will then be displayed for this PT.
Any thoughts on how to resolve this (I assume with a custom function) would help - or alternatively if you can think of a better approach.
Thanks for your brain power!
John