Hello everyone! I’m facing a problem while developing an application and could really use some help.
I own a visual communication company, and each product has a list of materials that make it up. To calculate the final price of the product, I need to calculate the cost of each material. However, each material has different variables and unique formulas for calculating its final cost.
For example, the ABC PANEL is composed of ADHESIVE X and PLATE Y.
To calculate the cost of ADHESIVE X for this panel, I need to know the HEIGHT and WIDTH of the panel, and the formula is:
HEIGHT * WIDTH * AdhesiveCost
To calculate the cost of PLATE Y, I need the HEIGHT, WIDTH, and also the DEPTH, and the formula is:
((HEIGHT * WIDTH) + DEPTH) * PlateCost
I have a product database where, during product registration, I link (using another data table) all the necessary variables for calculating the materials of the product (which are diverse, so I cannot standardize the variables. In the example above: HEIGHT, WIDTH, and DEPTH). I also link (using another data table) all the materials that make up the product, each with its respective formula. In the formulas, I use the variable names so that I can later replace them with the variable values provided by the user when creating a quote.
When quoting, after the user selects the ABC PANEL, the product configuration popup displays two tables (or repeating groups): one with the list of all materials that make up the product, and another with the list of all variables needed to calculate the product price, so the user can fill in the value of each variable for that specific quote. Here’s a mockup of this configuration screen during the quote creation process:
I managed to make this work for a single material outside a repeating group using the Orchestra plugin:
- I fetch the material’s formula.
- Loop through the rows in the repeating group of variables.
- Replace the variable names with the values provided by the user for each row.
- With this, I get the final formula, and I use Math.js to calculate the value.
Since I don’t know which of all the product’s variables are present in a specific material’s formula (for example, the DEPTH variable is only used in the formula for PLATE Y), I have to loop through all the variable rows.
However, for the example above, with multiple materials in a repeating group, I need to:
- For each material, fetch its formula.
- Loop through the variables, replacing them to finalize the formula.
- Then calculate the cost.
I tried using a Maestro element outside everything, activating Musicians inside each material row. These would, in turn, activate another Maestro inside the row to trigger the variables’ Musicians. But it didn’t work!
I’m having trouble planning this part of the application. I’m not sure if I’m on the right track or if there’s a better way to achieve this. I haven’t developed much of the app yet (especially this part), as I’m trying to design the functionality first to build it correctly. I tested the Orchestra plugin with the scenario of just one material and multiple variables, and it works perfectly in that case. The challenge is to repeat this process for multiple materials inside a repeating group rather than just a single material on the page.
I’m not necessarily looking for a solution, but I’d like to know if you’re aware of any applications with similar functionality that I could analyze, or if you have any ideas on how I can approach this. I’ve searched a lot in the community, tutorials, and online but haven’t found anything that addresses this specific issue or an app with similar functionality to use as a reference.
Thank you so much!!