Forum Academy Marketplace Showcase Pricing Features

Dividing a Budget Among Group Members

Hello,

I’m working on creating an application that enables participatory budgeting.
Here is a link to the development test for the app: Dev test

The issue I am facing is figuring out how to split out the total budget amount that is available among the members added to a budget equally.

Here are my data types and fields present on them:

Budget

  • Amount - Number
  • Budget Admins - List of users
  • Budget Members - List of users
  • Budget Status - Status (open/closed)
  • Items - List of items
  • Title - Text

Items

  • Amount - Number
  • Budget - Budget
  • Title - Text
  • Total Funded - number

User

  • First Name
  • Last Name

User Budget

  • Parent Budget - Budget
  • User - User
  • User Budget Amount - number
  • User Permissions - Permissions Option Status (Member/Admin)

What I need to do is when a budget status is moved to open take the Amount from the Budget data type and divide it equally among all those listed as members and apply that value to their User Budget data type field of User Budget Amount. I can’t seem to find a way to do those calculations using the data structure as it is today. I believe I would need to get a count of the members, but then how would I take that count and reallocate it back to the members after determining what their share should be?