Skip to content

Commit

Permalink
Add rate in transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Nov 4, 2024
1 parent 4954121 commit 6941e55
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ui/presentation/dashboard_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class DashboardPresenter extends Presenter<DashboardViewState> {
.map((e) => MapEntry(e.createdOn, e.amount))
.forEach((entry) {
if (entry.key
.isAfter(DateTime.now().subtract(const Duration(days: 365)))) {
.isAfter(DateTime.now().subtract(const Duration(days: 330)))) {
DateTime month = DateTime(entry.key.year, entry.key.month);
investmentByMonth.update(month, (value) => value + entry.value,
ifAbsent: () => entry.value);
Expand Down
5 changes: 5 additions & 0 deletions lib/ui/presentation/transactions_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ class TransactionVO {
final int? sipId;
final String? description;
final double amount;
final double qty;
final DateTime createdOn;

double get rate => qty > 0 ? amount / qty : 0;

TransactionVO._(
{required this.id,
required this.investmentId,
required this.sipId,
required this.description,
required this.amount,
required this.qty,
required this.createdOn});

factory TransactionVO.from({required final Transaction transaction}) {
Expand All @@ -58,6 +62,7 @@ class TransactionVO {
sipId: transaction.sipId,
description: transaction.description,
amount: transaction.amount,
qty: transaction.qty,
createdOn: transaction.createdOn);
}
}
11 changes: 10 additions & 1 deletion lib/ui/widgets/view_transactions_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ class _TransactionPage extends PageState<TransactionsViewState,
),
const SizedBox(
height: AppDimen.minPadding), // Add some spacing
Text('Amount: ${formatToCurrency(transaction.amount)}'),
Row(
children: [
Text('Amount: ${formatToCurrency(transaction.amount)}'),
if (transaction.qty > 0) ...[
Text('Rate: ${formatToCurrency(transaction.rate)}'),
const Text(' | '),
Text('Qty: ${transaction.qty}'),
],
],
)
],
),
trailing: Row(mainAxisSize: MainAxisSize.min, children: [
Expand Down

0 comments on commit 6941e55

Please sign in to comment.