How to modify a list of things in complex structure


I am building a finance app where the user can input transaction and relate them to a pre-established budget. So in step 1 the user creates a monthly budget for each category such as:
Food: $500
etc… all these data are stored in the data type budget_data that has the following structure:
Screenshot 2024-02-07 at 15.54.10
For instance the Allocated budget for february 2024 is $500 in the food category.

When a user enters an transaction, they are saved to a transaction_data data type which has the following structure:

I have a worfklow update the fields “budget_let_to_spend”. and “consumed_budget”, so for instance, the user creates 2 food transactions of $20 each, so in the table budget_data, the entry for Feb.2024 in the category “food” will have $460 in the field “left_to_spend” and $40 in the field “consumed_budget”. as transaction’s values add up. All this works fine.

Now, a user has the possibility to delete previously created transactions.
Each transaction is a line of a repeating group each having a checkbox. Deletion works through the selection of one of more transaction by checking the corresponding checkboxes, all transaction that are to be deleted have their checkbox marked. When a checkbox is marked, the entry is added to a list (which is a custom state of the type transaction data). So, after clicking the delete button, via workflow, I delete a list of things, where the list is the content of the custom state. All this works fine too:
Screenshot 2024-02-07 at 16.07.02

Where i am struggling is, after deleting a given transaction data, I need to also update the budget_data entry in the corresponding category, so in the above example, let’s assume the user now deletes the two $20 transactions previously created, I need to update the budget_data entry back to:
“left_to_spend” = $500
“Consumed_budget” = $0

I could not figure out how to do this from my custom state (list of transaction_data which contains the list to be deleted) above. I have been running around in circles for a few days with not clear path. I suspect I might need backend worfklows for this, but do not know how to set it up. Any help would be highly appreciated !

Before deleting the list of transactions, you will update the budget_data’s consumed budget to consumed_budget - CS_selected_transactions' each item's transaction value:sum and left_to_spend to left_to_spend + CS_selected_transactions' each item's transaction value:sum

Hi @hergin thank you very much ! problem solved,
I wasnt sure how to use the sum operator with a list of things, but thats what I wrote and it worked perfectly:
Screenshot 2024-02-07 at 18.42.14