-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
133 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:wealth_wave/contract/risk_level.dart'; | ||
import 'package:wealth_wave/domain/models/investment.dart'; | ||
import 'package:wealth_wave/ui/models/sip_vo.dart'; | ||
import 'package:wealth_wave/ui/models/transaction_vo.dart'; | ||
|
||
class InvestmentVO { | ||
final int id; | ||
final String name; | ||
final String? description; | ||
final RiskLevel riskLevel; | ||
final double irr; | ||
final double investedValue; | ||
final double currentValue; | ||
final DateTime? valueUpdatedDate; | ||
final double qty; | ||
final double valuePerQty; | ||
final DateTime? maturityDate; | ||
final int? basketId; | ||
final String? basketName; | ||
final List<SipVO> sips; | ||
final List<TransactionVO> transactions; | ||
final int taggedGoalCount; | ||
final bool hasScript; | ||
|
||
int get transactionCount => transactions.length; | ||
int get sipCount => sips.length; | ||
String get valueUpdateDate => valueUpdatedDate?.toIso8601String() ?? 'Not Updated'; | ||
|
||
InvestmentVO._( | ||
{required this.id, | ||
required this.name, | ||
required this.description, | ||
required this.riskLevel, | ||
required this.irr, | ||
required this.basketId, | ||
required this.basketName, | ||
required this.investedValue, | ||
required this.currentValue, | ||
required this.valueUpdatedDate, | ||
required this.qty, | ||
required this.valuePerQty, | ||
required this.maturityDate, | ||
required this.transactions, | ||
required this.sips, | ||
required this.hasScript, | ||
required this.taggedGoalCount}); | ||
|
||
factory InvestmentVO.from({required final Investment investment}) { | ||
return InvestmentVO._( | ||
id: investment.id, | ||
name: investment.name, | ||
description: investment.description, | ||
riskLevel: investment.riskLevel, | ||
irr: investment.getIRR(), | ||
investedValue: investment.getTotalInvestedAmount(), | ||
currentValue: investment.getValue(), | ||
valueUpdatedDate: investment.valueUpdatedOn, | ||
qty: investment.qty, | ||
valuePerQty: investment.getValuePerUnit(), | ||
basketId: investment.basketId, | ||
basketName: investment.basketName, | ||
transactions: investment.transactions.map((e) => TransactionVO.from(transaction: e)).toList(), | ||
sips: investment.sips.map((e) => SipVO.from(transaction: e)).toList(), | ||
taggedGoalCount: investment.goalsCount, | ||
hasScript: investment.script != null, | ||
maturityDate: investment.maturityDate); | ||
} | ||
} |
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,35 @@ | ||
import 'package:wealth_wave/contract/frequency.dart'; | ||
import 'package:wealth_wave/domain/models/sip.dart'; | ||
|
||
class SipVO { | ||
final int id; | ||
final int investmentId; | ||
final String? description; | ||
final double amount; | ||
final DateTime startDate; | ||
final DateTime? endDate; | ||
final Frequency frequency; | ||
final DateTime? executedTill; | ||
|
||
SipVO._( | ||
{required this.id, | ||
required this.investmentId, | ||
required this.description, | ||
required this.amount, | ||
required this.startDate, | ||
required this.endDate, | ||
required this.frequency, | ||
required this.executedTill}); | ||
|
||
factory SipVO.from({required final Sip transaction}) { | ||
return SipVO._( | ||
id: transaction.id, | ||
investmentId: transaction.investmentId, | ||
description: transaction.description, | ||
amount: transaction.amount, | ||
startDate: transaction.startDate, | ||
endDate: transaction.endDate, | ||
frequency: transaction.frequency, | ||
executedTill: transaction.executedTill); | ||
} | ||
} |
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,28 @@ | ||
import 'package:wealth_wave/domain/models/transaction.dart'; | ||
|
||
class TransactionVO { | ||
final int id; | ||
final int investmentId; | ||
final int? sipId; | ||
final String? description; | ||
final double amount; | ||
final DateTime createdOn; | ||
|
||
TransactionVO._( | ||
{required this.id, | ||
required this.investmentId, | ||
required this.sipId, | ||
required this.description, | ||
required this.amount, | ||
required this.createdOn}); | ||
|
||
factory TransactionVO.from({required final Transaction transaction}) { | ||
return TransactionVO._( | ||
id: transaction.id, | ||
investmentId: transaction.investmentId, | ||
sipId: transaction.sipId, | ||
description: transaction.description, | ||
amount: transaction.amount, | ||
createdOn: transaction.createdOn); | ||
} | ||
} |
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