I have a database that has amounts owed between different people but want to have a query that provides netted/summed amounts that involve the active user. My current database structure is as follows:
On the user's dashboard page I want any amounts/database entries that involve them as debtor or creditor to be shown in a query. The Before Send mapping I have mapped a local storage user variable to the where parameter using the JS [return{"$or":[{"Creditor":"'+value+'"},{"Debtor":"'+value+'"}]}'].
I’ve been able to produce responses on a row by row basis mapped to button components, however, where there are multiple amounts between the same pair of users, I would like the response to calculate a net amount. The response would also then be dependent on whether the user owes or is owed the final amount.
I imagine I may need to use a combination of if/else and for statements, but I’m struggle to gain any progress. Please can you help me with what JS I need and also whether my mapping is correct. My current Success mapping is as below: