From c433e61f9d1dcaa03dedcca28d5d137e96653344 Mon Sep 17 00:00:00 2001 From: Prasanna Anbazhagan Date: Sat, 15 Jun 2024 19:35:20 +0530 Subject: [PATCH] Add price per qty --- lib/domain/models/investment.dart | 4 ++++ lib/presentation/investments_presenter.dart | 3 +++ lib/ui/pages/investments_page.dart | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/lib/domain/models/investment.dart b/lib/domain/models/investment.dart index 1f68549..4ed228c 100644 --- a/lib/domain/models/investment.dart +++ b/lib/domain/models/investment.dart @@ -90,6 +90,10 @@ class Investment { } } + double getValuePerUnit() { + return getValue() / qty; + } + double getValueOn( {required final DateTime date, bool considerFuturePayments = false}) { final maturityDate = this.maturityDate; diff --git a/lib/presentation/investments_presenter.dart b/lib/presentation/investments_presenter.dart index dead5ab..9116316 100644 --- a/lib/presentation/investments_presenter.dart +++ b/lib/presentation/investments_presenter.dart @@ -116,6 +116,7 @@ class InvestmentVO { final double investedValue; final double currentValue; final double qty; + final double valuePerQty; final DateTime? maturityDate; final int? basketId; final String? basketName; @@ -138,6 +139,7 @@ class InvestmentVO { required this.investedValue, required this.currentValue, required this.qty, + required this.valuePerQty, required this.maturityDate, required this.transactions, required this.sips, @@ -154,6 +156,7 @@ class InvestmentVO { investedValue: investment.getTotalInvestedAmount(), currentValue: investment.getValue(), qty: investment.qty, + valuePerQty: investment.getValuePerUnit(), basketId: investment.basketId, basketName: investment.basketName, transactions: investment.transactions, diff --git a/lib/ui/pages/investments_page.dart b/lib/ui/pages/investments_page.dart index a8806ee..870bd26 100644 --- a/lib/ui/pages/investments_page.dart +++ b/lib/ui/pages/investments_page.dart @@ -188,6 +188,10 @@ class _InvestmentsPage extends PageState