firebase – firestore flutter recalculate all data stored if another data is updated

enter image description hereI have data stored in firebase as below

The planned Start and planned finish are calculated mathematically
planned finish = planned start +duration
planned Start = planned finish of dependent sl no
for sl no 10 dependent is 9 so planned Start of 10 is equal to planned finish of 9
So my problem is if I updated planned finish of sl no 9 then how can I make 10 to automatically update it planned start and finish
The code on how data is saved is as below

 if (slno != null && activity != null) {
                      if (action == 'create') {
                        // Persist a new product to Firestore
                        Future<Timestamp> getslno() async {
                          var document =
                              await _schedule.doc(dependent.toString()).get();
                          Timestamp sl = await document('plannedfinish');
                          return sl;

                        var planneds = await getslno();
                        await _schedule.doc(slno.toString()).set({
                          "slno": slno,
                          "activity": activity,
                          "duration": duration,
                          "dependent": dependent,
                          "plannedstart": planneds,
                          "plannedfinish": planneds
                              .add(Duration(days: duration!.toInt()))

                      if (action == 'update') {
                        // Update the product
                        await _schedule.doc(documentSnapshot!.id).update({
                          "slno": slno,
                          "activity": activity,
                          "duration": duration,
                          "dependent": dependent

I need all the data stored to be automatically updated if at least one data is changed
Any suggestions on how to do it