Skip to content

Commit

Permalink
Add description
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jan 6, 2024
1 parent 02802db commit 4ad224f
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 82 deletions.
9 changes: 9 additions & 0 deletions lib/api/db/app_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class BasketTable extends Table {
IntColumn get id => integer().named('ID').autoIncrement()();

TextColumn get name => text().named('NAME').unique()();

TextColumn get description => text().nullable().named('DESCRIPTION')();
}

@DataClassName('InvestmentDO')
Expand All @@ -19,6 +21,8 @@ class InvestmentTable extends Table {

TextColumn get name => text().named('NAME')();

TextColumn get description => text().nullable().named('DESCRIPTION')();

IntColumn get basketId =>
integer().nullable().named('BASKET_ID').references(BasketTable, #id)();

Expand All @@ -38,6 +42,8 @@ class TransactionTable extends Table {

RealColumn get amount => real().named('AMOUNT')();

TextColumn get description => text().nullable().named('DESCRIPTION')();

DateTimeColumn get amountInvestedOn =>
dateTime().named('AMOUNT_INVESTED_ON')();
}
Expand All @@ -48,6 +54,8 @@ class GoalTable extends Table {

TextColumn get name => text().named('NAME')();

TextColumn get description => text().nullable().named('DESCRIPTION')();

RealColumn get amount => real().named('AMOUNT')();

DateTimeColumn get date => dateTime().named('DATE')();
Expand Down Expand Up @@ -89,6 +97,7 @@ abstract class InvestmentEnrichedView extends View {
Query as() => select([
investment.id,
investment.name,
investment.description,
investment.riskLevel,
investment.value,
investment.valueUpdatedOn,
Expand Down
194 changes: 118 additions & 76 deletions lib/api/db/app_database.g.dart

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions lib/domain/models/basket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ import 'package:wealth_wave/api/db/app_database.dart';
class Basket {
final int id;
final String name;
final String? description;
final List<InvestmentDO> investments;

Basket({required this.id, required this.name, required this.investments});
Basket(
{required this.id,
required this.name,
required this.description,
required this.investments});

static Basket from(
{required final BasketDO basket,
required final List<InvestmentDO> investments}) {
return Basket(id: basket.id, name: basket.name, investments: investments);
return Basket(
id: basket.id,
name: basket.name,
description: basket.description,
investments: investments);
}

double get totalValue {
Expand Down
3 changes: 3 additions & 0 deletions lib/domain/models/goal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:wealth_wave/domain/models/investment.dart';
class Goal {
final int id;
final String name;
final String? description;
final double amount;
final DateTime createdDate;
final double inflation;
Expand All @@ -16,6 +17,7 @@ class Goal {
Goal(
{required this.id,
required this.name,
required this.description,
required this.amount,
required this.createdDate,
required this.inflation,
Expand Down Expand Up @@ -87,6 +89,7 @@ class Goal {
Goal(
id: goal.id,
name: goal.name,
description: goal.description,
amount: goal.amount,
createdDate: goal.date,
inflation: goal.inflation,
Expand Down
3 changes: 3 additions & 0 deletions lib/domain/models/investment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:wealth_wave/domain/models/transaction.dart';
class Investment {
final int id;
final String name;
final String? description;
final RiskLevel riskLevel;
final double value;
final DateTime valueUpdatedOn;
Expand All @@ -21,6 +22,7 @@ class Investment {
Investment(
{required this.id,
required this.name,
required this.description,
required this.riskLevel,
required this.value,
required this.valueUpdatedOn,
Expand Down Expand Up @@ -55,6 +57,7 @@ class Investment {
return Investment(
id: investment.id,
name: investment.name,
description: investment.description,
riskLevel: investment.riskLevel,
value: investment.value,
valueUpdatedOn: investment.valueUpdatedOn,
Expand Down
7 changes: 6 additions & 1 deletion lib/domain/models/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import 'package:wealth_wave/api/db/app_database.dart';

class Transaction {
final int id;
final String? description;
final double amount;
final DateTime createdOn;

Transaction(
{required this.id, required this.amount, required this.createdOn});
{required this.id,
required this.description,
required this.amount,
required this.createdOn});

static Transaction from({required final TransactionDO transaction}) {
return Transaction(
id: transaction.id,
description: transaction.description,
amount: transaction.amount,
createdOn: transaction.amountInvestedOn);
}
Expand Down
18 changes: 15 additions & 3 deletions test/domain/irr_calculator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ void main() {
test('calculateIRR returns correct IRR', () {
final calculator = IRRCalculator();
final transactions = [
Transaction(id: 0, amount: 1000.0, createdOn: DateTime(2020, 1, 1)),
Transaction(id: 0, amount: 2000.0, createdOn: DateTime(2021, 1, 1)),
Transaction(id: 0, amount: 3000.0, createdOn: DateTime(2022, 1, 1)),
Transaction(
id: 0,
description: null,
amount: 1000.0,
createdOn: DateTime(2020, 1, 1)),
Transaction(
id: 0,
description: null,
amount: 2000.0,
createdOn: DateTime(2021, 1, 1)),
Transaction(
id: 0,
description: null,
amount: 3000.0,
createdOn: DateTime(2022, 1, 1)),
];
const finalValue = 8000.0;
final finalDate = DateTime(2023, 1, 1);
Expand Down

0 comments on commit 4ad224f

Please sign in to comment.