This is Custom Code, that we cannot assist.
Let me explain why:
1. It uses no API of Toolset
2. It uses no Fields, or contents of Toolset
3. It applies common WordPress API on a Toolset Post Type.
Toolset is designed to avoid PHP writing.
I unterstand that sometimes you need to add functionality to it.
I cannot provide you a working code or help you deeply in the issue - but I can try to help you get to the goal with the code and your description of the task.
1. You have a Parent and a Child Post Type.
2. In the Child Post Type, you have some Fields, and with them, you would like to perform some calculations, so to probably update another value somewhere.
3. This actions on the Child Post should happen when the related Parent Post gets saved (updated).
I hope I did get the task correctly, otherwise please correct me.
So, you can do 2 things:
- use the WordPress API as you did (backend)
- or you can use the CRED API (frontend)
https://toolset.com/documentation/programmer-reference/cred-api/
In either cases, you need to start with the Parent Post Type (when it is saved/updated).
When that happens (save_post of your parent post type), you need to get a list of Child Posts (get_posts of child post type)
This list of Child Posts needs to be refined. You need only the posts that belong to the current Parent Post that is being saved.
So you will get_posts of Child Type with Custom Field "_wpcf_belongs_{your-parent-post-type-slug}_id" and value equal to the Parent Post ID (which is currently saved)
This will give you all Child Posts belonging to that parent.
Now, you can start to use wp_update_post() for those Child Posts:
https://codex.wordpress.org/Function_Reference/wp_update_post
You will of course have your values to calculate, and then you can wp_update_post() those results to another place.
I suggest to create a function for the calculations, a function for updating the child posts, and a function to hook into the save_post of the parent.
So you can subsequently call all the functions - it makes it easier to control and write.
Your current code presents a few errors, I think, specially how you get the parent post ID and the function to calculate the values.