Skip to content

Commit

Permalink
save commit
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jan 18, 2024
1 parent 82af735 commit 0dee35a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/domain/models/basket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Basket {
.then((investments) => Future.wait(investments
.map((investment) => investment.getTotalInvestedAmount())))
.then((investedAmounts) =>
investedAmounts.reduce((value, element) => value + element));
investedAmounts.fold(0, (value, element) => value + element));
}

Future<double> getValue({final bool considerFuturePayments = false}) async {
Expand All @@ -38,7 +38,7 @@ class Basket {
.map((investmentDO) => Investment.from(investmentDO: investmentDO)))
.then((investments) => Future.wait(investments
.map((investment) => investment.getValueOn(date: DateTime.now(), considerFuturePayments: considerFuturePayments))))
.then((values) => values.reduce((value, element) => value + element));
.then((values) => values.fold(0, (value, element) => value + element));
}

Future<List<Investment>> getInvestments() {
Expand Down
8 changes: 3 additions & 5 deletions lib/domain/models/goal.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ffi';

import 'package:wealth_wave/api/apis/goal_investment_api.dart';
import 'package:wealth_wave/api/apis/investment_api.dart';
import 'package:wealth_wave/api/db/app_database.dart';
Expand Down Expand Up @@ -89,7 +87,7 @@ class Goal {
{required final int investmentId, required final double split}) async {
return _goalInvestmentApi
.create(goalId: id, investmentId: investmentId, split: split)
.then((goalInvestmentDO) => Void);
.then((goalInvestmentDO) => {});
}

Future<void> updateTaggedInvestment(
Expand All @@ -98,13 +96,13 @@ class Goal {
required final double split}) async {
return _goalInvestmentApi
.update(id: id, goalId: id, investmentId: investmentId, split: split)
.then((goalInvestmentDO) => Void);
.then((goalInvestmentDO) => {});
}

Future<void> deleteTaggedInvestment({required final int investmentId}) {
return _goalInvestmentApi
.deleteBy(goalId: id, investmentId: investmentId)
.then((count) => Void);
.then((count) => {});
}

Future<double> getIRR() async {
Expand Down
12 changes: 5 additions & 7 deletions lib/domain/models/investment.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ffi';

import 'package:wealth_wave/api/apis/basket_api.dart';
import 'package:wealth_wave/api/apis/goal_api.dart';
import 'package:wealth_wave/api/apis/goal_investment_api.dart';
Expand Down Expand Up @@ -166,7 +164,7 @@ class Investment {
}

Future<void> deleteSIP({required final int sipId}) async {
return _sipApi.delete(id: sipId).then((count) => Void);
return _sipApi.delete(id: sipId).then((count) => {});
}

Future<Transaction> createTransaction(
Expand Down Expand Up @@ -203,14 +201,14 @@ class Investment {

Future<void> deleteTransaction(
{required final int id}) async {
return _transactionApi.deleteBy(id: id).then((count) => Void);
return _transactionApi.deleteBy(id: id).then((count) => {});
}

Future<void> tagGoal(
{required final int goalId, required final double split}) async {
return _goalInvestmentApi
.create(goalId: goalId, investmentId: id, split: split)
.then((goalInvestmentDO) => Void);
.then((goalInvestmentDO) => {});
}

Future<void> updateTaggedGoal(
Expand All @@ -219,13 +217,13 @@ class Investment {
required final double split}) async {
return _goalInvestmentApi
.update(id: id, goalId: goalId, investmentId: id, split: split)
.then((goalInvestmentDO) => Void);
.then((goalInvestmentDO) => {});
}

Future<void> deleteTaggedGoal({required final int goalId}) {
return _goalInvestmentApi
.deleteBy(goalId: goalId, investmentId: id)
.then((count) => Void);
.then((count) => {});
}

Future<double> getIRR() async {
Expand Down
6 changes: 2 additions & 4 deletions lib/domain/models/sip.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ffi';

import 'package:wealth_wave/api/apis/investment_api.dart';
import 'package:wealth_wave/api/apis/transaction_api.dart';
import 'package:wealth_wave/api/db/app_database.dart';
Expand Down Expand Up @@ -94,11 +92,11 @@ class SIP {
}

Future<void> deleteTransaction({required final int transactionId}) async {
return _transactionApi.deleteBy(id: transactionId).then((count) => Void);
return _transactionApi.deleteBy(id: transactionId).then((count) => {});
}

Future<void> deleteTransactions() async {
return _transactionApi.deleteBy(sipId: id).then((count) => Void);
return _transactionApi.deleteBy(sipId: id).then((count) => {});
}

static SIP from({required final SipDO sipDO}) {
Expand Down

0 comments on commit 0dee35a

Please sign in to comment.