My knowledge of Spanish is zero, so I can't follow your code very well, but I do understand recursive SQL quite well. Maybe I can help anyway.

CTE appears to select your child records. temporal creates totals for the child records. Nowhere do you select the parent records for update.

My guess is that you'll want to sum all of the child values for every parent. If you have only 1 level of parent/child, this is pretty easy. You'll also want to sum the child records by parent. The "cleanest" way is another sub-query that sums the results of temporal, grouped by idpadre. UNION ALL of these results with temporal, then join these results in the final query where you join temporal.