I am currently building a variable cost calculation function for cost quotations. Craftsman and Installer should be able to create a variable cost quotation for their service which works for different sizes of buildings. Such as the installation of a heat pump or air conditioning.
The calculation should look like this:
(variables are given by the system)
cost block A: variable_1 x 100
cost block B: if variable_2 = true +200
(add all to get the sum)
The current setup works as follows:
1. Create calculation in Form (DnD)
2. Convert to json-logic `https://github.com/jwadhams/json-logic-js`
3. Save to Database in json field
-- Display Product or Service --
4. Get json-logic from DB and apply for each cost block with variables
5. Return in API
6. Display for Customer in Front End
Am I missing something, is there a better way?