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 0 : GoalRecalculation({ 12 : required this.change, 13 : this.initial, 14 : }); 15 : 16 0 : @override 17 : double getDelta() { 18 : double result = 0.0; 19 0 : if (initial != null && !change.hidden && change.details > 0) { 20 0 : result = initial!.details * initial!.progress / change.details; 21 : } 22 0 : return result.clamp(0, 1); 23 : } 24 : 25 0 : GoalRecalculation updateGoal() { 26 0 : change.progress = getDelta(); 27 : return this; 28 : } 29 : }