LCOV - code coverage report
Current view: top level - _classes/math - goal_recalculation.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 7 7 100.0 %
Date: 2024-10-04 11:08:31 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2023 The terCAD team. All rights reserved.
       2             : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3             : 
       4             : import 'package:app_finance/_classes/math/abstract_recalculation.dart';
       5             : import 'package:app_finance/_classes/structure/goal_app_data.dart';
       6             : 
       7             : class GoalRecalculation extends AbstractRecalculation {
       8             :   GoalAppData change;
       9             :   GoalAppData? initial;
      10             : 
      11           1 :   GoalRecalculation({
      12             :     required this.change,
      13             :     this.initial,
      14             :   });
      15             : 
      16           1 :   @override
      17             :   double getDelta() {
      18             :     double result = 0.0;
      19           6 :     if (initial != null && !change.hidden && change.details > 0) {
      20           8 :       result = initial!.details * initial!.progress / change.details;
      21             :     }
      22           1 :     return result.clamp(0, 1);
      23             :   }
      24             : 
      25           1 :   GoalRecalculation updateGoal() {
      26           3 :     change.progress = getDelta();
      27             :     return this;
      28             :   }
      29             : }

Generated by: LCOV version 1.14