Skip to content

Commit

Permalink
cleanup investment
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jul 1, 2024
1 parent 8a8c645 commit 08f4622
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 123 deletions.
11 changes: 1 addition & 10 deletions lib/api/db/app_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ abstract class InvestmentEnrichedView extends View {

TransactionTable get transaction;

GoalInvestmentTable get goalInvestment;

SipTable get sip;

ScriptTable get script;
Expand All @@ -172,11 +170,7 @@ abstract class InvestmentEnrichedView extends View {

Expression<int> get totalSips => sip.id
.count(distinct: true, filter: sip.investmentId.equalsExp(investment.id));

Expression<int> get taggedGoals => goalInvestment.goalId.count(
distinct: true,
filter: goalInvestment.investmentId.equalsExp(investment.id));


@override
Query as() => select([
investment.id,
Expand All @@ -191,15 +185,12 @@ abstract class InvestmentEnrichedView extends View {
basketName,
totalTransactions,
totalSips,
taggedGoals,
qty
]).from(investment).join([
leftOuterJoin(basket, basket.id.equalsExp(investment.basketId)),
leftOuterJoin(
transaction, transaction.investmentId.equalsExp(investment.id)),
leftOuterJoin(sip, sip.investmentId.equalsExp(investment.id)),
leftOuterJoin(goalInvestment,
goalInvestment.investmentId.equalsExp(investment.id)),
leftOuterJoin(script,
script.investmentId.equalsExp(investment.id))
])
Expand Down
29 changes: 2 additions & 27 deletions lib/api/db/app_database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions lib/domain/models/investment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Investment {
final DateTime? maturityDate;
final int? basketId;
final String? basketName;
final int goalsCount;
final List<Transaction> transactions;
final List<Sip> sips;
final Script? script;
Expand All @@ -35,7 +34,6 @@ class Investment {
required this.basketId,
required this.maturityDate,
required this.basketName,
required this.goalsCount,
required this.transactions,
required this.sips,
required this.script})
Expand Down Expand Up @@ -160,7 +158,6 @@ class Investment {
basketId: investmentDO.basketId,
maturityDate: investmentDO.maturityDate,
basketName: investmentDO.basketName,
goalsCount: investmentDO.taggedGoals ?? 0,
script: scriptDO != null ? Script.from(scriptDO: scriptDO) : null,
transactions: transactionsDOs
.map((transactionDO) =>
Expand Down
5 changes: 1 addition & 4 deletions lib/ui/models/investment_vo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class InvestmentVO {
final String? basketName;
final List<SipVO> sips;
final List<TransactionVO> transactions;
final int taggedGoalCount;
final bool hasScript;

int get transactionCount => transactions.length;
Expand All @@ -42,8 +41,7 @@ class InvestmentVO {
required this.maturityDate,
required this.transactions,
required this.sips,
required this.hasScript,
required this.taggedGoalCount});
required this.hasScript});

factory InvestmentVO.from({required final Investment investment}) {
return InvestmentVO._(
Expand All @@ -61,7 +59,6 @@ class InvestmentVO {
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);
}
Expand Down
12 changes: 0 additions & 12 deletions lib/ui/pages/investments_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:wealth_wave/ui/widgets/create_script_dialog.dart';
import 'package:wealth_wave/ui/widgets/create_sip_dialog.dart';
import 'package:wealth_wave/ui/widgets/create_transaction_dialog.dart';
import 'package:wealth_wave/ui/widgets/view_sips_dialog.dart';
import 'package:wealth_wave/ui/widgets/view_tagged_goal_dialog.dart';
import 'package:wealth_wave/ui/widgets/view_transactions_dialog.dart';
import 'package:wealth_wave/utils/ui_utils.dart';

Expand Down Expand Up @@ -175,17 +174,6 @@ class _InvestmentsPage extends PageState<InvestmentsViewState, InvestmentsPage,
child:
Text('${investmentVO.sipCount} sips'),
),
TextButton(
onPressed: () {
showTaggedGoalDialog(
context: context,
investmentId: investmentVO.id)
.then((value) =>
presenter.fetchInvestments());
},
child:
Text('${investmentVO.taggedGoalCount} goals'),
),
Text(
('Qty ${NumberFormat.compact().format(investmentVO.qty)}'),
),
Expand Down
3 changes: 0 additions & 3 deletions lib/ui/presentation/investment_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class InvestmentVO {
final String? basketName;
final List<Sip> sips;
final List<Transaction> transactions;
final int taggedGoalCount;
final bool hasScript;
final Map<DateTime, double> investmentOverTime;
final Map<DateTime, double> valueOverTime;
Expand All @@ -125,7 +124,6 @@ class InvestmentVO {
required this.transactions,
required this.sips,
required this.hasScript,
required this.taggedGoalCount,
required this.investmentOverTime,
required this.valueOverTime});

Expand All @@ -146,7 +144,6 @@ class InvestmentVO {
basketName: investment.basketName,
transactions: investment.transactions,
sips: investment.sips,
taggedGoalCount: investment.goalsCount,
hasScript: investment.script != null,
maturityDate: investment.maturityDate,
investmentOverTime: investmentOverTime,
Expand Down
64 changes: 0 additions & 64 deletions lib/ui/widgets/view_tagged_goal_dialog.dart

This file was deleted.

0 comments on commit 08f4622

Please sign in to comment.