Skip to content

Commit

Permalink
Add price per qty
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jun 15, 2024
1 parent be4ae0f commit c433e61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/domain/models/investment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class Investment {
}
}

double getValuePerUnit() {
return getValue() / qty;
}

double getValueOn(
{required final DateTime date, bool considerFuturePayments = false}) {
final maturityDate = this.maturityDate;
Expand Down
3 changes: 3 additions & 0 deletions lib/presentation/investments_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/pages/investments_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ class _InvestmentsPage extends PageState<InvestmentsViewState, InvestmentsPage,
Text(
('Qty ${NumberFormat.compact().format(investmentVO.qty)}'),
),
const Padding(padding: EdgeInsets.all(AppDimen.minPadding)),
Text(
('Price ${NumberFormat.compact().format(investmentVO.valuePerQty)}'),
),
],
),
]),
Expand Down

0 comments on commit c433e61

Please sign in to comment.