diff --git a/lib/api/db/app_database.dart b/lib/api/db/app_database.dart index 79df581..c231065 100644 --- a/lib/api/db/app_database.dart +++ b/lib/api/db/app_database.dart @@ -153,8 +153,6 @@ abstract class InvestmentEnrichedView extends View { TransactionTable get transaction; - GoalInvestmentTable get goalInvestment; - SipTable get sip; ScriptTable get script; @@ -172,11 +170,7 @@ abstract class InvestmentEnrichedView extends View { Expression get totalSips => sip.id .count(distinct: true, filter: sip.investmentId.equalsExp(investment.id)); - - Expression get taggedGoals => goalInvestment.goalId.count( - distinct: true, - filter: goalInvestment.investmentId.equalsExp(investment.id)); - + @override Query as() => select([ investment.id, @@ -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)) ]) diff --git a/lib/api/db/app_database.g.dart b/lib/api/db/app_database.g.dart index 5622d86..4e04e4e 100644 --- a/lib/api/db/app_database.g.dart +++ b/lib/api/db/app_database.g.dart @@ -2447,7 +2447,6 @@ class InvestmentDO extends DataClass { final String? basketName; final int? totalTransactions; final int? totalSips; - final int? taggedGoals; final double? qty; const InvestmentDO( {required this.id, @@ -2462,7 +2461,6 @@ class InvestmentDO extends DataClass { this.basketName, this.totalTransactions, this.totalSips, - this.taggedGoals, this.qty}); factory InvestmentDO.fromJson(Map json, {ValueSerializer? serializer}) { @@ -2481,7 +2479,6 @@ class InvestmentDO extends DataClass { basketName: serializer.fromJson(json['basketName']), totalTransactions: serializer.fromJson(json['totalTransactions']), totalSips: serializer.fromJson(json['totalSips']), - taggedGoals: serializer.fromJson(json['taggedGoals']), qty: serializer.fromJson(json['qty']), ); } @@ -2502,7 +2499,6 @@ class InvestmentDO extends DataClass { 'basketName': serializer.toJson(basketName), 'totalTransactions': serializer.toJson(totalTransactions), 'totalSips': serializer.toJson(totalSips), - 'taggedGoals': serializer.toJson(taggedGoals), 'qty': serializer.toJson(qty), }; } @@ -2520,7 +2516,6 @@ class InvestmentDO extends DataClass { Value basketName = const Value.absent(), Value totalTransactions = const Value.absent(), Value totalSips = const Value.absent(), - Value taggedGoals = const Value.absent(), Value qty = const Value.absent()}) => InvestmentDO( id: id ?? this.id, @@ -2539,7 +2534,6 @@ class InvestmentDO extends DataClass { ? totalTransactions.value : this.totalTransactions, totalSips: totalSips.present ? totalSips.value : this.totalSips, - taggedGoals: taggedGoals.present ? taggedGoals.value : this.taggedGoals, qty: qty.present ? qty.value : this.qty, ); @override @@ -2557,7 +2551,6 @@ class InvestmentDO extends DataClass { ..write('basketName: $basketName, ') ..write('totalTransactions: $totalTransactions, ') ..write('totalSips: $totalSips, ') - ..write('taggedGoals: $taggedGoals, ') ..write('qty: $qty') ..write(')')) .toString(); @@ -2577,7 +2570,6 @@ class InvestmentDO extends DataClass { basketName, totalTransactions, totalSips, - taggedGoals, qty); @override bool operator ==(Object other) => @@ -2595,7 +2587,6 @@ class InvestmentDO extends DataClass { other.basketName == this.basketName && other.totalTransactions == this.totalTransactions && other.totalSips == this.totalSips && - other.taggedGoals == this.taggedGoals && other.qty == this.qty); } @@ -2612,11 +2603,9 @@ class $InvestmentEnrichedViewView attachedDatabase.basketTable.createAlias('t1'); $TransactionTableTable get transaction => attachedDatabase.transactionTable.createAlias('t2'); - $GoalInvestmentTableTable get goalInvestment => - attachedDatabase.goalInvestmentTable.createAlias('t3'); - $SipTableTable get sip => attachedDatabase.sipTable.createAlias('t4'); + $SipTableTable get sip => attachedDatabase.sipTable.createAlias('t3'); $ScriptTableTable get script => - attachedDatabase.scriptTable.createAlias('t5'); + attachedDatabase.scriptTable.createAlias('t4'); @override List get $columns => [ id, @@ -2631,7 +2620,6 @@ class $InvestmentEnrichedViewView basketName, totalTransactions, totalSips, - taggedGoals, qty ]; @override @@ -2671,8 +2659,6 @@ class $InvestmentEnrichedViewView .read(DriftSqlType.int, data['${effectivePrefix}total_transactions']), totalSips: attachedDatabase.typeMapping .read(DriftSqlType.int, data['${effectivePrefix}total_sips']), - taggedGoals: attachedDatabase.typeMapping - .read(DriftSqlType.int, data['${effectivePrefix}tagged_goals']), qty: attachedDatabase.typeMapping .read(DriftSqlType.double, data['${effectivePrefix}qty']), ); @@ -2732,14 +2718,6 @@ class $InvestmentEnrichedViewView filter: sip.investmentId.equalsExp(investment.id)), false), type: DriftSqlType.int); - late final GeneratedColumn taggedGoals = GeneratedColumn( - 'tagged_goals', aliasedName, true, - generatedAs: GeneratedAs( - goalInvestment.goalId.count( - distinct: true, - filter: goalInvestment.investmentId.equalsExp(investment.id)), - false), - type: DriftSqlType.int); late final GeneratedColumn qty = GeneratedColumn( 'qty', aliasedName, true, generatedAs: GeneratedAs( @@ -2759,8 +2737,6 @@ class $InvestmentEnrichedViewView 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)) ]) ..groupBy([investment.id]); @@ -2769,7 +2745,6 @@ class $InvestmentEnrichedViewView 'investment_table', 'basket_table', 'transaction_table', - 'goal_investment_table', 'sip_table', 'script_table' }; diff --git a/lib/domain/models/investment.dart b/lib/domain/models/investment.dart index 4ed228c..ce6d4fd 100644 --- a/lib/domain/models/investment.dart +++ b/lib/domain/models/investment.dart @@ -18,7 +18,6 @@ class Investment { final DateTime? maturityDate; final int? basketId; final String? basketName; - final int goalsCount; final List transactions; final List sips; final Script? script; @@ -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}) @@ -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) => diff --git a/lib/ui/models/investment_vo.dart b/lib/ui/models/investment_vo.dart index c6040e9..d20d750 100644 --- a/lib/ui/models/investment_vo.dart +++ b/lib/ui/models/investment_vo.dart @@ -19,7 +19,6 @@ class InvestmentVO { final String? basketName; final List sips; final List transactions; - final int taggedGoalCount; final bool hasScript; int get transactionCount => transactions.length; @@ -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._( @@ -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); } diff --git a/lib/ui/pages/investments_page.dart b/lib/ui/pages/investments_page.dart index e270a08..ae94d9e 100644 --- a/lib/ui/pages/investments_page.dart +++ b/lib/ui/pages/investments_page.dart @@ -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'; @@ -175,17 +174,6 @@ class _InvestmentsPage extends PageState - presenter.fetchInvestments()); - }, - child: - Text('${investmentVO.taggedGoalCount} goals'), - ), Text( ('Qty ${NumberFormat.compact().format(investmentVO.qty)}'), ), diff --git a/lib/ui/presentation/investment_presenter.dart b/lib/ui/presentation/investment_presenter.dart index 04d0ead..ac241af 100644 --- a/lib/ui/presentation/investment_presenter.dart +++ b/lib/ui/presentation/investment_presenter.dart @@ -102,7 +102,6 @@ class InvestmentVO { final String? basketName; final List sips; final List transactions; - final int taggedGoalCount; final bool hasScript; final Map investmentOverTime; final Map valueOverTime; @@ -125,7 +124,6 @@ class InvestmentVO { required this.transactions, required this.sips, required this.hasScript, - required this.taggedGoalCount, required this.investmentOverTime, required this.valueOverTime}); @@ -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, diff --git a/lib/ui/widgets/view_tagged_goal_dialog.dart b/lib/ui/widgets/view_tagged_goal_dialog.dart deleted file mode 100644 index c66a1ca..0000000 --- a/lib/ui/widgets/view_tagged_goal_dialog.dart +++ /dev/null @@ -1,64 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:wealth_wave/core/page_state.dart'; -import 'package:wealth_wave/ui/presentation/tagged_goals_presenter.dart'; -import 'package:wealth_wave/utils/ui_utils.dart'; - -Future showTaggedGoalDialog( - {required final BuildContext context, required final int investmentId}) { - return showDialog( - context: context, - builder: (context) => _TaggedGoalsWidget( - investmentId: investmentId, - )); -} - -class _TaggedGoalsWidget extends StatefulWidget { - final int investmentId; - - const _TaggedGoalsWidget({required this.investmentId}); - - @override - State<_TaggedGoalsWidget> createState() => _TaggedGoalsPage(); -} - -class _TaggedGoalsPage extends PageState { - @override - void initState() { - super.initState(); - presenter.fetchTaggedInvestment(); - } - - @override - Widget buildWidget(BuildContext context, TaggedGoalsViewState snapshot) { - return AlertDialog( - title: const Text('Investments'), - content: SizedBox( - width: double.maxFinite, - child: ListView.builder( - shrinkWrap: true, - itemCount: snapshot.taggedGoalVOs.length, - itemBuilder: (context, index) { - TaggedGoalVO taggedGoalVO = - snapshot.taggedGoalVOs.elementAt(index); - return ListTile( - title: Text( - '${formatToCurrency(taggedGoalVO.currentValue)} (${formatToPercentage(taggedGoalVO.split)}) to ${taggedGoalVO.goalName}')); - }, - )), - actions: [ - OutlinedButton( - child: const Text('Close'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ); - } - - @override - TaggedGoalsPresenter initializePresenter() { - return TaggedGoalsPresenter(investmentId: widget.investmentId); - } -}