-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from flow-mn/feat-stats
Add stats tab
- Loading branch information
Showing
56 changed files
with
1,662 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flow/data/money_flow.dart'; | ||
|
||
class FlowAnalytics<T> { | ||
final DateTime from; | ||
final DateTime to; | ||
|
||
final Map<String, MoneyFlow<T>> flow; | ||
|
||
const FlowAnalytics({ | ||
required this.from, | ||
required this.to, | ||
required this.flow, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class MoneyFlow<T> implements Comparable<MoneyFlow> { | ||
final T? associatedData; | ||
|
||
double totalExpense; | ||
double totalIncome; | ||
|
||
double get flow => totalExpense + totalIncome; | ||
|
||
bool get isEmpty => totalExpense.abs() == 0.0 && totalIncome.abs() == 0.0; | ||
|
||
MoneyFlow({ | ||
this.associatedData, | ||
this.totalExpense = 0.0, | ||
this.totalIncome = 0.0, | ||
}); | ||
|
||
@override | ||
int compareTo(MoneyFlow other) { | ||
return flow.compareTo(other.flow); | ||
} | ||
|
||
void addExpense(double expense) => totalExpense += expense; | ||
void addIncome(double income) => totalIncome += income; | ||
void add(double amount) => | ||
amount.isNegative ? addExpense(amount) : addIncome(amount); | ||
void addAll(Iterable<double> amounts) => amounts.forEach(add); | ||
|
||
operator +(MoneyFlow other) { | ||
return MoneyFlow( | ||
totalExpense: totalExpense + other.totalExpense, | ||
totalIncome: totalIncome + other.totalIncome, | ||
); | ||
} | ||
|
||
operator -(MoneyFlow other) { | ||
return MoneyFlow( | ||
totalExpense: totalExpense - other.totalExpense, | ||
totalIncome: totalIncome - other.totalIncome, | ||
); | ||
} | ||
|
||
operator -() { | ||
return MoneyFlow( | ||
totalExpense: -totalExpense, | ||
totalIncome: -totalIncome, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.