cashMovements method
Account balance: gets all the cash movements done in the account
Implementation
Future<List<CashMovement>> cashMovements({
DateTime? fromDate,
DateTime? toDate,
bool showFlatexMovements = false,
}) async {
// Setting default filter to last month
fromDate ??= DateTime.now().subtract(Duration(days: 31));
toDate ??= DateTime.now();
final result = await _repository.getCashMovementsRequest(
sessionId,
accountInfo.intAccount,
fromDate,
toDate,
);
List<CashMovement> movements = [];
movements = result.when(
(data) => data,
(error) => throw error..methodName = 'cashMovements',
);
// As default 'showFlatexMovements' is set to false.
// Normally, if you want to know the account cash movements it's more clear to see just the
// real operations because Degiro adds its own operations regarding flatex bank account.
if (!showFlatexMovements) {
movements = movements
.where((m) => m.movementType != MovementType.flatexCashSweep)
.toList();
}
return movements;
}