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 6941e55 commit 9e5e56c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/ui/presentation/transactions_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TransactionVO {
final double qty;
final DateTime createdOn;

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

TransactionVO._(
{required this.id,
Expand Down
9 changes: 5 additions & 4 deletions lib/ui/widgets/view_transactions_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ class _TransactionPage extends PageState<TransactionsViewState,
height: AppDimen.minPadding), // Add some spacing
Row(
children: [
Text('Amount: ${formatToCurrency(transaction.amount)}'),
if (transaction.qty > 0) ...[
if (transaction.qty != 0) ...[
Text('Rate: ${formatToCurrency(transaction.rate)}'),
const Text(' | '),
Text('Qty: ${transaction.qty}'),
const Text(' x '),
Text('${transaction.qty}'),
const Text(' = '),
],
Text('Amount: ${formatToCurrency(transaction.amount)}'),
],
)
],
Expand Down

0 comments on commit 9e5e56c

Please sign in to comment.