From 4ad224f4fcd97acf88f28384892e1d610cf7b7bc Mon Sep 17 00:00:00 2001 From: Prasanna Anbazhagan Date: Sat, 6 Jan 2024 10:33:30 +0530 Subject: [PATCH] Add description --- lib/api/db/app_database.dart | 9 ++ lib/api/db/app_database.g.dart | 194 ++++++++++++++++----------- lib/domain/models/basket.dart | 13 +- lib/domain/models/goal.dart | 3 + lib/domain/models/investment.dart | 3 + lib/domain/models/transaction.dart | 7 +- test/domain/irr_calculator_test.dart | 18 ++- 7 files changed, 165 insertions(+), 82 deletions(-) diff --git a/lib/api/db/app_database.dart b/lib/api/db/app_database.dart index f136638..33a4bbe 100644 --- a/lib/api/db/app_database.dart +++ b/lib/api/db/app_database.dart @@ -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') @@ -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)(); @@ -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')(); } @@ -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')(); @@ -89,6 +97,7 @@ abstract class InvestmentEnrichedView extends View { Query as() => select([ investment.id, investment.name, + investment.description, investment.riskLevel, investment.value, investment.valueUpdatedOn, diff --git a/lib/api/db/app_database.g.dart b/lib/api/db/app_database.g.dart index b111925..5ac2bc5 100644 --- a/lib/api/db/app_database.g.dart +++ b/lib/api/db/app_database.g.dart @@ -13,8 +13,11 @@ late final GeneratedColumn id = GeneratedColumn('ID', aliasedName, fal static const VerificationMeta _nameMeta = const VerificationMeta('name'); @override late final GeneratedColumn name = GeneratedColumn('NAME', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE')); +static const VerificationMeta _descriptionMeta = const VerificationMeta('description'); @override -List get $columns => [id, name]; +late final GeneratedColumn description = GeneratedColumn('DESCRIPTION', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false); +@override +List get $columns => [id, name, description]; @override String get aliasedName => _alias ?? actualTableName; @override @@ -29,49 +32,54 @@ context.handle(_idMeta, id.isAcceptableOrUnknown(data['ID']!, _idMeta));}if (dat context.handle(_nameMeta, name.isAcceptableOrUnknown(data['NAME']!, _nameMeta));} else if (isInserting) { context.missing(_nameMeta); } -return context; +if (data.containsKey('DESCRIPTION')) { +context.handle(_descriptionMeta, description.isAcceptableOrUnknown(data['DESCRIPTION']!, _descriptionMeta));}return context; } @override Set get $primaryKey => {id}; @override BasketDO map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return BasketDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, ); +final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return BasketDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, description: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}DESCRIPTION']), ); } @override $BasketTableTable createAlias(String alias) { return $BasketTableTable(attachedDatabase, alias);}}class BasketDO extends DataClass implements Insertable { final int id; final String name; -const BasketDO({required this.id, required this.name});@override +final String? description; +const BasketDO({required this.id, required this.name, this.description});@override Map toColumns(bool nullToAbsent) { final map = {};map['ID'] = Variable(id); map['NAME'] = Variable(name); -return map; +if (!nullToAbsent || description != null){map['DESCRIPTION'] = Variable(description); +}return map; } BasketTableCompanion toCompanion(bool nullToAbsent) { -return BasketTableCompanion(id: Value(id),name: Value(name),); +return BasketTableCompanion(id: Value(id),name: Value(name),description: description == null && nullToAbsent ? const Value.absent() : Value(description),); } factory BasketDO.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; -return BasketDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),);} +return BasketDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),description: serializer.fromJson(json['description']),);} @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { -'id': serializer.toJson(id),'name': serializer.toJson(name),};}BasketDO copyWith({int? id,String? name}) => BasketDO(id: id ?? this.id,name: name ?? this.name,);@override -String toString() {return (StringBuffer('BasketDO(')..write('id: $id, ')..write('name: $name')..write(')')).toString();} +'id': serializer.toJson(id),'name': serializer.toJson(name),'description': serializer.toJson(description),};}BasketDO copyWith({int? id,String? name,Value description = const Value.absent()}) => BasketDO(id: id ?? this.id,name: name ?? this.name,description: description.present ? description.value : this.description,);@override +String toString() {return (StringBuffer('BasketDO(')..write('id: $id, ')..write('name: $name, ')..write('description: $description')..write(')')).toString();} @override - int get hashCode => Object.hash(id, name);@override -bool operator ==(Object other) => identical(this, other) || (other is BasketDO && other.id == this.id && other.name == this.name); + int get hashCode => Object.hash(id, name, description);@override +bool operator ==(Object other) => identical(this, other) || (other is BasketDO && other.id == this.id && other.name == this.name && other.description == this.description); }class BasketTableCompanion extends UpdateCompanion { final Value id; final Value name; -const BasketTableCompanion({this.id = const Value.absent(),this.name = const Value.absent(),}); -BasketTableCompanion.insert({this.id = const Value.absent(),required String name,}): name = Value(name); +final Value description; +const BasketTableCompanion({this.id = const Value.absent(),this.name = const Value.absent(),this.description = const Value.absent(),}); +BasketTableCompanion.insert({this.id = const Value.absent(),required String name,this.description = const Value.absent(),}): name = Value(name); static Insertable custom({Expression? id, Expression? name, +Expression? description, }) { -return RawValuesInsertable({if (id != null)'ID': id,if (name != null)'NAME': name,}); -}BasketTableCompanion copyWith({Value? id, Value? name}) { -return BasketTableCompanion(id: id ?? this.id,name: name ?? this.name,); +return RawValuesInsertable({if (id != null)'ID': id,if (name != null)'NAME': name,if (description != null)'DESCRIPTION': description,}); +}BasketTableCompanion copyWith({Value? id, Value? name, Value? description}) { +return BasketTableCompanion(id: id ?? this.id,name: name ?? this.name,description: description ?? this.description,); } @override Map toColumns(bool nullToAbsent) { @@ -79,10 +87,12 @@ final map = {};if (id.present) { map['ID'] = Variable(id.value);} if (name.present) { map['NAME'] = Variable(name.value);} +if (description.present) { +map['DESCRIPTION'] = Variable(description.value);} return map; } @override -String toString() {return (StringBuffer('BasketTableCompanion(')..write('id: $id, ')..write('name: $name')..write(')')).toString();} +String toString() {return (StringBuffer('BasketTableCompanion(')..write('id: $id, ')..write('name: $name, ')..write('description: $description')..write(')')).toString();} } class $InvestmentTableTable extends InvestmentTable with TableInfo<$InvestmentTableTable, InvestmentDO>{ @override final GeneratedDatabase attachedDatabase; @@ -94,6 +104,9 @@ late final GeneratedColumn id = GeneratedColumn('ID', aliasedName, fal static const VerificationMeta _nameMeta = const VerificationMeta('name'); @override late final GeneratedColumn name = GeneratedColumn('NAME', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true); +static const VerificationMeta _descriptionMeta = const VerificationMeta('description'); +@override +late final GeneratedColumn description = GeneratedColumn('DESCRIPTION', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false); static const VerificationMeta _basketIdMeta = const VerificationMeta('basketId'); @override late final GeneratedColumn basketId = GeneratedColumn('BASKET_ID', aliasedName, true, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways('REFERENCES basket_table (ID)')); @@ -107,7 +120,7 @@ static const VerificationMeta _valueUpdatedOnMeta = const VerificationMeta('valu @override late final GeneratedColumn valueUpdatedOn = GeneratedColumn('VALUE_UPDATED_ON', aliasedName, false, type: DriftSqlType.dateTime, requiredDuringInsert: true); @override -List get $columns => [id, name, basketId, value, riskLevel, valueUpdatedOn]; +List get $columns => [id, name, description, basketId, value, riskLevel, valueUpdatedOn]; @override String get aliasedName => _alias ?? actualTableName; @override @@ -122,7 +135,8 @@ context.handle(_idMeta, id.isAcceptableOrUnknown(data['ID']!, _idMeta));}if (dat context.handle(_nameMeta, name.isAcceptableOrUnknown(data['NAME']!, _nameMeta));} else if (isInserting) { context.missing(_nameMeta); } -if (data.containsKey('BASKET_ID')) { +if (data.containsKey('DESCRIPTION')) { +context.handle(_descriptionMeta, description.isAcceptableOrUnknown(data['DESCRIPTION']!, _descriptionMeta));}if (data.containsKey('BASKET_ID')) { context.handle(_basketIdMeta, basketId.isAcceptableOrUnknown(data['BASKET_ID']!, _basketIdMeta));}if (data.containsKey('VALUE')) { context.handle(_valueMeta, value.isAcceptableOrUnknown(data['VALUE']!, _valueMeta));} else if (isInserting) { context.missing(_valueMeta); @@ -136,60 +150,64 @@ return context; @override Set get $primaryKey => {id}; @override InvestmentDO map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return InvestmentDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, basketId: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}BASKET_ID']), value: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}VALUE'])!, riskLevel: $InvestmentTableTable.$converterriskLevel.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}RISK_LEVEL'])!), valueUpdatedOn: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}VALUE_UPDATED_ON'])!, ); +final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return InvestmentDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, description: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}DESCRIPTION']), basketId: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}BASKET_ID']), value: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}VALUE'])!, riskLevel: $InvestmentTableTable.$converterriskLevel.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}RISK_LEVEL'])!), valueUpdatedOn: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}VALUE_UPDATED_ON'])!, ); } @override $InvestmentTableTable createAlias(String alias) { return $InvestmentTableTable(attachedDatabase, alias);}static JsonTypeConverter2 $converterriskLevel = const EnumNameConverter(RiskLevel.values);}class InvestmentDO extends DataClass implements Insertable { final int id; final String name; +final String? description; final int? basketId; final double value; final RiskLevel riskLevel; final DateTime valueUpdatedOn; -const InvestmentDO({required this.id, required this.name, this.basketId, required this.value, required this.riskLevel, required this.valueUpdatedOn});@override +const InvestmentDO({required this.id, required this.name, this.description, this.basketId, required this.value, required this.riskLevel, required this.valueUpdatedOn});@override Map toColumns(bool nullToAbsent) { final map = {};map['ID'] = Variable(id); map['NAME'] = Variable(name); -if (!nullToAbsent || basketId != null){map['BASKET_ID'] = Variable(basketId); +if (!nullToAbsent || description != null){map['DESCRIPTION'] = Variable(description); +}if (!nullToAbsent || basketId != null){map['BASKET_ID'] = Variable(basketId); }map['VALUE'] = Variable(value); {map['RISK_LEVEL'] = Variable($InvestmentTableTable.$converterriskLevel.toSql(riskLevel)); }map['VALUE_UPDATED_ON'] = Variable(valueUpdatedOn); return map; } InvestmentTableCompanion toCompanion(bool nullToAbsent) { -return InvestmentTableCompanion(id: Value(id),name: Value(name),basketId: basketId == null && nullToAbsent ? const Value.absent() : Value(basketId),value: Value(value),riskLevel: Value(riskLevel),valueUpdatedOn: Value(valueUpdatedOn),); +return InvestmentTableCompanion(id: Value(id),name: Value(name),description: description == null && nullToAbsent ? const Value.absent() : Value(description),basketId: basketId == null && nullToAbsent ? const Value.absent() : Value(basketId),value: Value(value),riskLevel: Value(riskLevel),valueUpdatedOn: Value(valueUpdatedOn),); } factory InvestmentDO.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; -return InvestmentDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),basketId: serializer.fromJson(json['basketId']),value: serializer.fromJson(json['value']),riskLevel: $InvestmentTableTable.$converterriskLevel.fromJson(serializer.fromJson(json['riskLevel'])),valueUpdatedOn: serializer.fromJson(json['valueUpdatedOn']),);} +return InvestmentDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),description: serializer.fromJson(json['description']),basketId: serializer.fromJson(json['basketId']),value: serializer.fromJson(json['value']),riskLevel: $InvestmentTableTable.$converterriskLevel.fromJson(serializer.fromJson(json['riskLevel'])),valueUpdatedOn: serializer.fromJson(json['valueUpdatedOn']),);} @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { -'id': serializer.toJson(id),'name': serializer.toJson(name),'basketId': serializer.toJson(basketId),'value': serializer.toJson(value),'riskLevel': serializer.toJson($InvestmentTableTable.$converterriskLevel.toJson(riskLevel)),'valueUpdatedOn': serializer.toJson(valueUpdatedOn),};}InvestmentDO copyWith({int? id,String? name,Value basketId = const Value.absent(),double? value,RiskLevel? riskLevel,DateTime? valueUpdatedOn}) => InvestmentDO(id: id ?? this.id,name: name ?? this.name,basketId: basketId.present ? basketId.value : this.basketId,value: value ?? this.value,riskLevel: riskLevel ?? this.riskLevel,valueUpdatedOn: valueUpdatedOn ?? this.valueUpdatedOn,);@override -String toString() {return (StringBuffer('InvestmentDO(')..write('id: $id, ')..write('name: $name, ')..write('basketId: $basketId, ')..write('value: $value, ')..write('riskLevel: $riskLevel, ')..write('valueUpdatedOn: $valueUpdatedOn')..write(')')).toString();} +'id': serializer.toJson(id),'name': serializer.toJson(name),'description': serializer.toJson(description),'basketId': serializer.toJson(basketId),'value': serializer.toJson(value),'riskLevel': serializer.toJson($InvestmentTableTable.$converterriskLevel.toJson(riskLevel)),'valueUpdatedOn': serializer.toJson(valueUpdatedOn),};}InvestmentDO copyWith({int? id,String? name,Value description = const Value.absent(),Value basketId = const Value.absent(),double? value,RiskLevel? riskLevel,DateTime? valueUpdatedOn}) => InvestmentDO(id: id ?? this.id,name: name ?? this.name,description: description.present ? description.value : this.description,basketId: basketId.present ? basketId.value : this.basketId,value: value ?? this.value,riskLevel: riskLevel ?? this.riskLevel,valueUpdatedOn: valueUpdatedOn ?? this.valueUpdatedOn,);@override +String toString() {return (StringBuffer('InvestmentDO(')..write('id: $id, ')..write('name: $name, ')..write('description: $description, ')..write('basketId: $basketId, ')..write('value: $value, ')..write('riskLevel: $riskLevel, ')..write('valueUpdatedOn: $valueUpdatedOn')..write(')')).toString();} @override - int get hashCode => Object.hash(id, name, basketId, value, riskLevel, valueUpdatedOn);@override -bool operator ==(Object other) => identical(this, other) || (other is InvestmentDO && other.id == this.id && other.name == this.name && other.basketId == this.basketId && other.value == this.value && other.riskLevel == this.riskLevel && other.valueUpdatedOn == this.valueUpdatedOn); + int get hashCode => Object.hash(id, name, description, basketId, value, riskLevel, valueUpdatedOn);@override +bool operator ==(Object other) => identical(this, other) || (other is InvestmentDO && other.id == this.id && other.name == this.name && other.description == this.description && other.basketId == this.basketId && other.value == this.value && other.riskLevel == this.riskLevel && other.valueUpdatedOn == this.valueUpdatedOn); }class InvestmentTableCompanion extends UpdateCompanion { final Value id; final Value name; +final Value description; final Value basketId; final Value value; final Value riskLevel; final Value valueUpdatedOn; -const InvestmentTableCompanion({this.id = const Value.absent(),this.name = const Value.absent(),this.basketId = const Value.absent(),this.value = const Value.absent(),this.riskLevel = const Value.absent(),this.valueUpdatedOn = const Value.absent(),}); -InvestmentTableCompanion.insert({this.id = const Value.absent(),required String name,this.basketId = const Value.absent(),required double value,required RiskLevel riskLevel,required DateTime valueUpdatedOn,}): name = Value(name), value = Value(value), riskLevel = Value(riskLevel), valueUpdatedOn = Value(valueUpdatedOn); +const InvestmentTableCompanion({this.id = const Value.absent(),this.name = const Value.absent(),this.description = const Value.absent(),this.basketId = const Value.absent(),this.value = const Value.absent(),this.riskLevel = const Value.absent(),this.valueUpdatedOn = const Value.absent(),}); +InvestmentTableCompanion.insert({this.id = const Value.absent(),required String name,this.description = const Value.absent(),this.basketId = const Value.absent(),required double value,required RiskLevel riskLevel,required DateTime valueUpdatedOn,}): name = Value(name), value = Value(value), riskLevel = Value(riskLevel), valueUpdatedOn = Value(valueUpdatedOn); static Insertable custom({Expression? id, Expression? name, +Expression? description, Expression? basketId, Expression? value, Expression? riskLevel, Expression? valueUpdatedOn, }) { -return RawValuesInsertable({if (id != null)'ID': id,if (name != null)'NAME': name,if (basketId != null)'BASKET_ID': basketId,if (value != null)'VALUE': value,if (riskLevel != null)'RISK_LEVEL': riskLevel,if (valueUpdatedOn != null)'VALUE_UPDATED_ON': valueUpdatedOn,}); -}InvestmentTableCompanion copyWith({Value? id, Value? name, Value? basketId, Value? value, Value? riskLevel, Value? valueUpdatedOn}) { -return InvestmentTableCompanion(id: id ?? this.id,name: name ?? this.name,basketId: basketId ?? this.basketId,value: value ?? this.value,riskLevel: riskLevel ?? this.riskLevel,valueUpdatedOn: valueUpdatedOn ?? this.valueUpdatedOn,); +return RawValuesInsertable({if (id != null)'ID': id,if (name != null)'NAME': name,if (description != null)'DESCRIPTION': description,if (basketId != null)'BASKET_ID': basketId,if (value != null)'VALUE': value,if (riskLevel != null)'RISK_LEVEL': riskLevel,if (valueUpdatedOn != null)'VALUE_UPDATED_ON': valueUpdatedOn,}); +}InvestmentTableCompanion copyWith({Value? id, Value? name, Value? description, Value? basketId, Value? value, Value? riskLevel, Value? valueUpdatedOn}) { +return InvestmentTableCompanion(id: id ?? this.id,name: name ?? this.name,description: description ?? this.description,basketId: basketId ?? this.basketId,value: value ?? this.value,riskLevel: riskLevel ?? this.riskLevel,valueUpdatedOn: valueUpdatedOn ?? this.valueUpdatedOn,); } @override Map toColumns(bool nullToAbsent) { @@ -197,6 +215,8 @@ final map = {};if (id.present) { map['ID'] = Variable(id.value);} if (name.present) { map['NAME'] = Variable(name.value);} +if (description.present) { +map['DESCRIPTION'] = Variable(description.value);} if (basketId.present) { map['BASKET_ID'] = Variable(basketId.value);} if (value.present) { @@ -208,7 +228,7 @@ map['VALUE_UPDATED_ON'] = Variable(valueUpdatedOn.value);} return map; } @override -String toString() {return (StringBuffer('InvestmentTableCompanion(')..write('id: $id, ')..write('name: $name, ')..write('basketId: $basketId, ')..write('value: $value, ')..write('riskLevel: $riskLevel, ')..write('valueUpdatedOn: $valueUpdatedOn')..write(')')).toString();} +String toString() {return (StringBuffer('InvestmentTableCompanion(')..write('id: $id, ')..write('name: $name, ')..write('description: $description, ')..write('basketId: $basketId, ')..write('value: $value, ')..write('riskLevel: $riskLevel, ')..write('valueUpdatedOn: $valueUpdatedOn')..write(')')).toString();} } class $TransactionTableTable extends TransactionTable with TableInfo<$TransactionTableTable, TransactionDO>{ @override final GeneratedDatabase attachedDatabase; @@ -223,11 +243,14 @@ late final GeneratedColumn investmentId = GeneratedColumn('INVESTMENT_ static const VerificationMeta _amountMeta = const VerificationMeta('amount'); @override late final GeneratedColumn amount = GeneratedColumn('AMOUNT', aliasedName, false, type: DriftSqlType.double, requiredDuringInsert: true); +static const VerificationMeta _descriptionMeta = const VerificationMeta('description'); +@override +late final GeneratedColumn description = GeneratedColumn('DESCRIPTION', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false); static const VerificationMeta _amountInvestedOnMeta = const VerificationMeta('amountInvestedOn'); @override late final GeneratedColumn amountInvestedOn = GeneratedColumn('AMOUNT_INVESTED_ON', aliasedName, false, type: DriftSqlType.dateTime, requiredDuringInsert: true); @override -List get $columns => [id, investmentId, amount, amountInvestedOn]; +List get $columns => [id, investmentId, amount, description, amountInvestedOn]; @override String get aliasedName => _alias ?? actualTableName; @override @@ -246,7 +269,8 @@ if (data.containsKey('AMOUNT')) { context.handle(_amountMeta, amount.isAcceptableOrUnknown(data['AMOUNT']!, _amountMeta));} else if (isInserting) { context.missing(_amountMeta); } -if (data.containsKey('AMOUNT_INVESTED_ON')) { +if (data.containsKey('DESCRIPTION')) { +context.handle(_descriptionMeta, description.isAcceptableOrUnknown(data['DESCRIPTION']!, _descriptionMeta));}if (data.containsKey('AMOUNT_INVESTED_ON')) { context.handle(_amountInvestedOnMeta, amountInvestedOn.isAcceptableOrUnknown(data['AMOUNT_INVESTED_ON']!, _amountInvestedOnMeta));} else if (isInserting) { context.missing(_amountInvestedOnMeta); } @@ -255,7 +279,7 @@ return context; @override Set get $primaryKey => {id}; @override TransactionDO map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return TransactionDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, investmentId: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}INVESTMENT_ID'])!, amount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}AMOUNT'])!, amountInvestedOn: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}AMOUNT_INVESTED_ON'])!, ); +final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return TransactionDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, investmentId: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}INVESTMENT_ID'])!, amount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}AMOUNT'])!, description: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}DESCRIPTION']), amountInvestedOn: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}AMOUNT_INVESTED_ON'])!, ); } @override $TransactionTableTable createAlias(String alias) { @@ -263,44 +287,48 @@ return $TransactionTableTable(attachedDatabase, alias);}}class TransactionDO ext final int id; final int investmentId; final double amount; +final String? description; final DateTime amountInvestedOn; -const TransactionDO({required this.id, required this.investmentId, required this.amount, required this.amountInvestedOn});@override +const TransactionDO({required this.id, required this.investmentId, required this.amount, this.description, required this.amountInvestedOn});@override Map toColumns(bool nullToAbsent) { final map = {};map['ID'] = Variable(id); map['INVESTMENT_ID'] = Variable(investmentId); map['AMOUNT'] = Variable(amount); -map['AMOUNT_INVESTED_ON'] = Variable(amountInvestedOn); +if (!nullToAbsent || description != null){map['DESCRIPTION'] = Variable(description); +}map['AMOUNT_INVESTED_ON'] = Variable(amountInvestedOn); return map; } TransactionTableCompanion toCompanion(bool nullToAbsent) { -return TransactionTableCompanion(id: Value(id),investmentId: Value(investmentId),amount: Value(amount),amountInvestedOn: Value(amountInvestedOn),); +return TransactionTableCompanion(id: Value(id),investmentId: Value(investmentId),amount: Value(amount),description: description == null && nullToAbsent ? const Value.absent() : Value(description),amountInvestedOn: Value(amountInvestedOn),); } factory TransactionDO.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; -return TransactionDO(id: serializer.fromJson(json['id']),investmentId: serializer.fromJson(json['investmentId']),amount: serializer.fromJson(json['amount']),amountInvestedOn: serializer.fromJson(json['amountInvestedOn']),);} +return TransactionDO(id: serializer.fromJson(json['id']),investmentId: serializer.fromJson(json['investmentId']),amount: serializer.fromJson(json['amount']),description: serializer.fromJson(json['description']),amountInvestedOn: serializer.fromJson(json['amountInvestedOn']),);} @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { -'id': serializer.toJson(id),'investmentId': serializer.toJson(investmentId),'amount': serializer.toJson(amount),'amountInvestedOn': serializer.toJson(amountInvestedOn),};}TransactionDO copyWith({int? id,int? investmentId,double? amount,DateTime? amountInvestedOn}) => TransactionDO(id: id ?? this.id,investmentId: investmentId ?? this.investmentId,amount: amount ?? this.amount,amountInvestedOn: amountInvestedOn ?? this.amountInvestedOn,);@override -String toString() {return (StringBuffer('TransactionDO(')..write('id: $id, ')..write('investmentId: $investmentId, ')..write('amount: $amount, ')..write('amountInvestedOn: $amountInvestedOn')..write(')')).toString();} +'id': serializer.toJson(id),'investmentId': serializer.toJson(investmentId),'amount': serializer.toJson(amount),'description': serializer.toJson(description),'amountInvestedOn': serializer.toJson(amountInvestedOn),};}TransactionDO copyWith({int? id,int? investmentId,double? amount,Value description = const Value.absent(),DateTime? amountInvestedOn}) => TransactionDO(id: id ?? this.id,investmentId: investmentId ?? this.investmentId,amount: amount ?? this.amount,description: description.present ? description.value : this.description,amountInvestedOn: amountInvestedOn ?? this.amountInvestedOn,);@override +String toString() {return (StringBuffer('TransactionDO(')..write('id: $id, ')..write('investmentId: $investmentId, ')..write('amount: $amount, ')..write('description: $description, ')..write('amountInvestedOn: $amountInvestedOn')..write(')')).toString();} @override - int get hashCode => Object.hash(id, investmentId, amount, amountInvestedOn);@override -bool operator ==(Object other) => identical(this, other) || (other is TransactionDO && other.id == this.id && other.investmentId == this.investmentId && other.amount == this.amount && other.amountInvestedOn == this.amountInvestedOn); + int get hashCode => Object.hash(id, investmentId, amount, description, amountInvestedOn);@override +bool operator ==(Object other) => identical(this, other) || (other is TransactionDO && other.id == this.id && other.investmentId == this.investmentId && other.amount == this.amount && other.description == this.description && other.amountInvestedOn == this.amountInvestedOn); }class TransactionTableCompanion extends UpdateCompanion { final Value id; final Value investmentId; final Value amount; +final Value description; final Value amountInvestedOn; -const TransactionTableCompanion({this.id = const Value.absent(),this.investmentId = const Value.absent(),this.amount = const Value.absent(),this.amountInvestedOn = const Value.absent(),}); -TransactionTableCompanion.insert({this.id = const Value.absent(),required int investmentId,required double amount,required DateTime amountInvestedOn,}): investmentId = Value(investmentId), amount = Value(amount), amountInvestedOn = Value(amountInvestedOn); +const TransactionTableCompanion({this.id = const Value.absent(),this.investmentId = const Value.absent(),this.amount = const Value.absent(),this.description = const Value.absent(),this.amountInvestedOn = const Value.absent(),}); +TransactionTableCompanion.insert({this.id = const Value.absent(),required int investmentId,required double amount,this.description = const Value.absent(),required DateTime amountInvestedOn,}): investmentId = Value(investmentId), amount = Value(amount), amountInvestedOn = Value(amountInvestedOn); static Insertable custom({Expression? id, Expression? investmentId, Expression? amount, +Expression? description, Expression? amountInvestedOn, }) { -return RawValuesInsertable({if (id != null)'ID': id,if (investmentId != null)'INVESTMENT_ID': investmentId,if (amount != null)'AMOUNT': amount,if (amountInvestedOn != null)'AMOUNT_INVESTED_ON': amountInvestedOn,}); -}TransactionTableCompanion copyWith({Value? id, Value? investmentId, Value? amount, Value? amountInvestedOn}) { -return TransactionTableCompanion(id: id ?? this.id,investmentId: investmentId ?? this.investmentId,amount: amount ?? this.amount,amountInvestedOn: amountInvestedOn ?? this.amountInvestedOn,); +return RawValuesInsertable({if (id != null)'ID': id,if (investmentId != null)'INVESTMENT_ID': investmentId,if (amount != null)'AMOUNT': amount,if (description != null)'DESCRIPTION': description,if (amountInvestedOn != null)'AMOUNT_INVESTED_ON': amountInvestedOn,}); +}TransactionTableCompanion copyWith({Value? id, Value? investmentId, Value? amount, Value? description, Value? amountInvestedOn}) { +return TransactionTableCompanion(id: id ?? this.id,investmentId: investmentId ?? this.investmentId,amount: amount ?? this.amount,description: description ?? this.description,amountInvestedOn: amountInvestedOn ?? this.amountInvestedOn,); } @override Map toColumns(bool nullToAbsent) { @@ -310,12 +338,14 @@ if (investmentId.present) { map['INVESTMENT_ID'] = Variable(investmentId.value);} if (amount.present) { map['AMOUNT'] = Variable(amount.value);} +if (description.present) { +map['DESCRIPTION'] = Variable(description.value);} if (amountInvestedOn.present) { map['AMOUNT_INVESTED_ON'] = Variable(amountInvestedOn.value);} return map; } @override -String toString() {return (StringBuffer('TransactionTableCompanion(')..write('id: $id, ')..write('investmentId: $investmentId, ')..write('amount: $amount, ')..write('amountInvestedOn: $amountInvestedOn')..write(')')).toString();} +String toString() {return (StringBuffer('TransactionTableCompanion(')..write('id: $id, ')..write('investmentId: $investmentId, ')..write('amount: $amount, ')..write('description: $description, ')..write('amountInvestedOn: $amountInvestedOn')..write(')')).toString();} } class $GoalTableTable extends GoalTable with TableInfo<$GoalTableTable, GoalDO>{ @override final GeneratedDatabase attachedDatabase; @@ -327,6 +357,9 @@ late final GeneratedColumn id = GeneratedColumn('ID', aliasedName, fal static const VerificationMeta _nameMeta = const VerificationMeta('name'); @override late final GeneratedColumn name = GeneratedColumn('NAME', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true); +static const VerificationMeta _descriptionMeta = const VerificationMeta('description'); +@override +late final GeneratedColumn description = GeneratedColumn('DESCRIPTION', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false); static const VerificationMeta _amountMeta = const VerificationMeta('amount'); @override late final GeneratedColumn amount = GeneratedColumn('AMOUNT', aliasedName, false, type: DriftSqlType.double, requiredDuringInsert: true); @@ -346,7 +379,7 @@ static const VerificationMeta _importanceMeta = const VerificationMeta('importan @override late final GeneratedColumnWithTypeConverter importance = GeneratedColumn('IMPORTANCE', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true).withConverter($GoalTableTable.$converterimportance); @override -List get $columns => [id, name, amount, date, inflation, targetAmount, targetDate, importance]; +List get $columns => [id, name, description, amount, date, inflation, targetAmount, targetDate, importance]; @override String get aliasedName => _alias ?? actualTableName; @override @@ -361,7 +394,8 @@ context.handle(_idMeta, id.isAcceptableOrUnknown(data['ID']!, _idMeta));}if (dat context.handle(_nameMeta, name.isAcceptableOrUnknown(data['NAME']!, _nameMeta));} else if (isInserting) { context.missing(_nameMeta); } -if (data.containsKey('AMOUNT')) { +if (data.containsKey('DESCRIPTION')) { +context.handle(_descriptionMeta, description.isAcceptableOrUnknown(data['DESCRIPTION']!, _descriptionMeta));}if (data.containsKey('AMOUNT')) { context.handle(_amountMeta, amount.isAcceptableOrUnknown(data['AMOUNT']!, _amountMeta));} else if (isInserting) { context.missing(_amountMeta); } @@ -386,24 +420,26 @@ context.handle(_importanceMeta, const VerificationResult.success());return conte @override Set get $primaryKey => {id}; @override GoalDO map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return GoalDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, amount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}AMOUNT'])!, date: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}DATE'])!, inflation: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}INFLATION'])!, targetAmount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}TARGET_AMOUNT'])!, targetDate: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}TARGET_DATE'])!, importance: $GoalTableTable.$converterimportance.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}IMPORTANCE'])!), ); +final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return GoalDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, description: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}DESCRIPTION']), amount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}AMOUNT'])!, date: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}DATE'])!, inflation: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}INFLATION'])!, targetAmount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}TARGET_AMOUNT'])!, targetDate: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}TARGET_DATE'])!, importance: $GoalTableTable.$converterimportance.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}IMPORTANCE'])!), ); } @override $GoalTableTable createAlias(String alias) { return $GoalTableTable(attachedDatabase, alias);}static JsonTypeConverter2 $converterimportance = const EnumNameConverter(GoalImportance.values);}class GoalDO extends DataClass implements Insertable { final int id; final String name; +final String? description; final double amount; final DateTime date; final double inflation; final double targetAmount; final DateTime targetDate; final GoalImportance importance; -const GoalDO({required this.id, required this.name, required this.amount, required this.date, required this.inflation, required this.targetAmount, required this.targetDate, required this.importance});@override +const GoalDO({required this.id, required this.name, this.description, required this.amount, required this.date, required this.inflation, required this.targetAmount, required this.targetDate, required this.importance});@override Map toColumns(bool nullToAbsent) { final map = {};map['ID'] = Variable(id); map['NAME'] = Variable(name); -map['AMOUNT'] = Variable(amount); +if (!nullToAbsent || description != null){map['DESCRIPTION'] = Variable(description); +}map['AMOUNT'] = Variable(amount); map['DATE'] = Variable(date); map['INFLATION'] = Variable(inflation); map['TARGET_AMOUNT'] = Variable(targetAmount); @@ -412,32 +448,34 @@ map['TARGET_DATE'] = Variable(targetDate); }return map; } GoalTableCompanion toCompanion(bool nullToAbsent) { -return GoalTableCompanion(id: Value(id),name: Value(name),amount: Value(amount),date: Value(date),inflation: Value(inflation),targetAmount: Value(targetAmount),targetDate: Value(targetDate),importance: Value(importance),); +return GoalTableCompanion(id: Value(id),name: Value(name),description: description == null && nullToAbsent ? const Value.absent() : Value(description),amount: Value(amount),date: Value(date),inflation: Value(inflation),targetAmount: Value(targetAmount),targetDate: Value(targetDate),importance: Value(importance),); } factory GoalDO.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; -return GoalDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),amount: serializer.fromJson(json['amount']),date: serializer.fromJson(json['date']),inflation: serializer.fromJson(json['inflation']),targetAmount: serializer.fromJson(json['targetAmount']),targetDate: serializer.fromJson(json['targetDate']),importance: $GoalTableTable.$converterimportance.fromJson(serializer.fromJson(json['importance'])),);} +return GoalDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),description: serializer.fromJson(json['description']),amount: serializer.fromJson(json['amount']),date: serializer.fromJson(json['date']),inflation: serializer.fromJson(json['inflation']),targetAmount: serializer.fromJson(json['targetAmount']),targetDate: serializer.fromJson(json['targetDate']),importance: $GoalTableTable.$converterimportance.fromJson(serializer.fromJson(json['importance'])),);} @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { -'id': serializer.toJson(id),'name': serializer.toJson(name),'amount': serializer.toJson(amount),'date': serializer.toJson(date),'inflation': serializer.toJson(inflation),'targetAmount': serializer.toJson(targetAmount),'targetDate': serializer.toJson(targetDate),'importance': serializer.toJson($GoalTableTable.$converterimportance.toJson(importance)),};}GoalDO copyWith({int? id,String? name,double? amount,DateTime? date,double? inflation,double? targetAmount,DateTime? targetDate,GoalImportance? importance}) => GoalDO(id: id ?? this.id,name: name ?? this.name,amount: amount ?? this.amount,date: date ?? this.date,inflation: inflation ?? this.inflation,targetAmount: targetAmount ?? this.targetAmount,targetDate: targetDate ?? this.targetDate,importance: importance ?? this.importance,);@override -String toString() {return (StringBuffer('GoalDO(')..write('id: $id, ')..write('name: $name, ')..write('amount: $amount, ')..write('date: $date, ')..write('inflation: $inflation, ')..write('targetAmount: $targetAmount, ')..write('targetDate: $targetDate, ')..write('importance: $importance')..write(')')).toString();} +'id': serializer.toJson(id),'name': serializer.toJson(name),'description': serializer.toJson(description),'amount': serializer.toJson(amount),'date': serializer.toJson(date),'inflation': serializer.toJson(inflation),'targetAmount': serializer.toJson(targetAmount),'targetDate': serializer.toJson(targetDate),'importance': serializer.toJson($GoalTableTable.$converterimportance.toJson(importance)),};}GoalDO copyWith({int? id,String? name,Value description = const Value.absent(),double? amount,DateTime? date,double? inflation,double? targetAmount,DateTime? targetDate,GoalImportance? importance}) => GoalDO(id: id ?? this.id,name: name ?? this.name,description: description.present ? description.value : this.description,amount: amount ?? this.amount,date: date ?? this.date,inflation: inflation ?? this.inflation,targetAmount: targetAmount ?? this.targetAmount,targetDate: targetDate ?? this.targetDate,importance: importance ?? this.importance,);@override +String toString() {return (StringBuffer('GoalDO(')..write('id: $id, ')..write('name: $name, ')..write('description: $description, ')..write('amount: $amount, ')..write('date: $date, ')..write('inflation: $inflation, ')..write('targetAmount: $targetAmount, ')..write('targetDate: $targetDate, ')..write('importance: $importance')..write(')')).toString();} @override - int get hashCode => Object.hash(id, name, amount, date, inflation, targetAmount, targetDate, importance);@override -bool operator ==(Object other) => identical(this, other) || (other is GoalDO && other.id == this.id && other.name == this.name && other.amount == this.amount && other.date == this.date && other.inflation == this.inflation && other.targetAmount == this.targetAmount && other.targetDate == this.targetDate && other.importance == this.importance); + int get hashCode => Object.hash(id, name, description, amount, date, inflation, targetAmount, targetDate, importance);@override +bool operator ==(Object other) => identical(this, other) || (other is GoalDO && other.id == this.id && other.name == this.name && other.description == this.description && other.amount == this.amount && other.date == this.date && other.inflation == this.inflation && other.targetAmount == this.targetAmount && other.targetDate == this.targetDate && other.importance == this.importance); }class GoalTableCompanion extends UpdateCompanion { final Value id; final Value name; +final Value description; final Value amount; final Value date; final Value inflation; final Value targetAmount; final Value targetDate; final Value importance; -const GoalTableCompanion({this.id = const Value.absent(),this.name = const Value.absent(),this.amount = const Value.absent(),this.date = const Value.absent(),this.inflation = const Value.absent(),this.targetAmount = const Value.absent(),this.targetDate = const Value.absent(),this.importance = const Value.absent(),}); -GoalTableCompanion.insert({this.id = const Value.absent(),required String name,required double amount,required DateTime date,required double inflation,required double targetAmount,required DateTime targetDate,required GoalImportance importance,}): name = Value(name), amount = Value(amount), date = Value(date), inflation = Value(inflation), targetAmount = Value(targetAmount), targetDate = Value(targetDate), importance = Value(importance); +const GoalTableCompanion({this.id = const Value.absent(),this.name = const Value.absent(),this.description = const Value.absent(),this.amount = const Value.absent(),this.date = const Value.absent(),this.inflation = const Value.absent(),this.targetAmount = const Value.absent(),this.targetDate = const Value.absent(),this.importance = const Value.absent(),}); +GoalTableCompanion.insert({this.id = const Value.absent(),required String name,this.description = const Value.absent(),required double amount,required DateTime date,required double inflation,required double targetAmount,required DateTime targetDate,required GoalImportance importance,}): name = Value(name), amount = Value(amount), date = Value(date), inflation = Value(inflation), targetAmount = Value(targetAmount), targetDate = Value(targetDate), importance = Value(importance); static Insertable custom({Expression? id, Expression? name, +Expression? description, Expression? amount, Expression? date, Expression? inflation, @@ -445,9 +483,9 @@ Expression? targetAmount, Expression? targetDate, Expression? importance, }) { -return RawValuesInsertable({if (id != null)'ID': id,if (name != null)'NAME': name,if (amount != null)'AMOUNT': amount,if (date != null)'DATE': date,if (inflation != null)'INFLATION': inflation,if (targetAmount != null)'TARGET_AMOUNT': targetAmount,if (targetDate != null)'TARGET_DATE': targetDate,if (importance != null)'IMPORTANCE': importance,}); -}GoalTableCompanion copyWith({Value? id, Value? name, Value? amount, Value? date, Value? inflation, Value? targetAmount, Value? targetDate, Value? importance}) { -return GoalTableCompanion(id: id ?? this.id,name: name ?? this.name,amount: amount ?? this.amount,date: date ?? this.date,inflation: inflation ?? this.inflation,targetAmount: targetAmount ?? this.targetAmount,targetDate: targetDate ?? this.targetDate,importance: importance ?? this.importance,); +return RawValuesInsertable({if (id != null)'ID': id,if (name != null)'NAME': name,if (description != null)'DESCRIPTION': description,if (amount != null)'AMOUNT': amount,if (date != null)'DATE': date,if (inflation != null)'INFLATION': inflation,if (targetAmount != null)'TARGET_AMOUNT': targetAmount,if (targetDate != null)'TARGET_DATE': targetDate,if (importance != null)'IMPORTANCE': importance,}); +}GoalTableCompanion copyWith({Value? id, Value? name, Value? description, Value? amount, Value? date, Value? inflation, Value? targetAmount, Value? targetDate, Value? importance}) { +return GoalTableCompanion(id: id ?? this.id,name: name ?? this.name,description: description ?? this.description,amount: amount ?? this.amount,date: date ?? this.date,inflation: inflation ?? this.inflation,targetAmount: targetAmount ?? this.targetAmount,targetDate: targetDate ?? this.targetDate,importance: importance ?? this.importance,); } @override Map toColumns(bool nullToAbsent) { @@ -455,6 +493,8 @@ final map = {};if (id.present) { map['ID'] = Variable(id.value);} if (name.present) { map['NAME'] = Variable(name.value);} +if (description.present) { +map['DESCRIPTION'] = Variable(description.value);} if (amount.present) { map['AMOUNT'] = Variable(amount.value);} if (date.present) { @@ -470,7 +510,7 @@ map['IMPORTANCE'] = Variable($GoalTableTable.$converterimportance.toSql( return map; } @override -String toString() {return (StringBuffer('GoalTableCompanion(')..write('id: $id, ')..write('name: $name, ')..write('amount: $amount, ')..write('date: $date, ')..write('inflation: $inflation, ')..write('targetAmount: $targetAmount, ')..write('targetDate: $targetDate, ')..write('importance: $importance')..write(')')).toString();} +String toString() {return (StringBuffer('GoalTableCompanion(')..write('id: $id, ')..write('name: $name, ')..write('description: $description, ')..write('amount: $amount, ')..write('date: $date, ')..write('inflation: $inflation, ')..write('targetAmount: $targetAmount, ')..write('targetDate: $targetDate, ')..write('importance: $importance')..write(')')).toString();} } class $GoalInvestmentTableTable extends GoalInvestmentTable with TableInfo<$GoalInvestmentTableTable, GoalInvestmentMappingDO>{ @override final GeneratedDatabase attachedDatabase; @@ -582,6 +622,7 @@ String toString() {return (StringBuffer('GoalInvestmentTableCompanion(')..write( class InvestmentEnrichedDO extends DataClass { final int id; final String name; +final String? description; final RiskLevel riskLevel; final double value; final DateTime valueUpdatedOn; @@ -589,17 +630,17 @@ final int? basketId; final String? basketName; final double? totalInvestedAmount; final int? totalTransactions; -const InvestmentEnrichedDO({required this.id, required this.name, required this.riskLevel, required this.value, required this.valueUpdatedOn, this.basketId, this.basketName, this.totalInvestedAmount, this.totalTransactions});factory InvestmentEnrichedDO.fromJson(Map json, {ValueSerializer? serializer}) { +const InvestmentEnrichedDO({required this.id, required this.name, this.description, required this.riskLevel, required this.value, required this.valueUpdatedOn, this.basketId, this.basketName, this.totalInvestedAmount, this.totalTransactions});factory InvestmentEnrichedDO.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; -return InvestmentEnrichedDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),riskLevel: $InvestmentTableTable.$converterriskLevel.fromJson(serializer.fromJson(json['riskLevel'])),value: serializer.fromJson(json['value']),valueUpdatedOn: serializer.fromJson(json['valueUpdatedOn']),basketId: serializer.fromJson(json['basketId']),basketName: serializer.fromJson(json['basketName']),totalInvestedAmount: serializer.fromJson(json['totalInvestedAmount']),totalTransactions: serializer.fromJson(json['totalTransactions']),);} +return InvestmentEnrichedDO(id: serializer.fromJson(json['id']),name: serializer.fromJson(json['name']),description: serializer.fromJson(json['description']),riskLevel: $InvestmentTableTable.$converterriskLevel.fromJson(serializer.fromJson(json['riskLevel'])),value: serializer.fromJson(json['value']),valueUpdatedOn: serializer.fromJson(json['valueUpdatedOn']),basketId: serializer.fromJson(json['basketId']),basketName: serializer.fromJson(json['basketName']),totalInvestedAmount: serializer.fromJson(json['totalInvestedAmount']),totalTransactions: serializer.fromJson(json['totalTransactions']),);} @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { -'id': serializer.toJson(id),'name': serializer.toJson(name),'riskLevel': serializer.toJson($InvestmentTableTable.$converterriskLevel.toJson(riskLevel)),'value': serializer.toJson(value),'valueUpdatedOn': serializer.toJson(valueUpdatedOn),'basketId': serializer.toJson(basketId),'basketName': serializer.toJson(basketName),'totalInvestedAmount': serializer.toJson(totalInvestedAmount),'totalTransactions': serializer.toJson(totalTransactions),};}InvestmentEnrichedDO copyWith({int? id,String? name,RiskLevel? riskLevel,double? value,DateTime? valueUpdatedOn,Value basketId = const Value.absent(),Value basketName = const Value.absent(),Value totalInvestedAmount = const Value.absent(),Value totalTransactions = const Value.absent()}) => InvestmentEnrichedDO(id: id ?? this.id,name: name ?? this.name,riskLevel: riskLevel ?? this.riskLevel,value: value ?? this.value,valueUpdatedOn: valueUpdatedOn ?? this.valueUpdatedOn,basketId: basketId.present ? basketId.value : this.basketId,basketName: basketName.present ? basketName.value : this.basketName,totalInvestedAmount: totalInvestedAmount.present ? totalInvestedAmount.value : this.totalInvestedAmount,totalTransactions: totalTransactions.present ? totalTransactions.value : this.totalTransactions,);@override -String toString() {return (StringBuffer('InvestmentEnrichedDO(')..write('id: $id, ')..write('name: $name, ')..write('riskLevel: $riskLevel, ')..write('value: $value, ')..write('valueUpdatedOn: $valueUpdatedOn, ')..write('basketId: $basketId, ')..write('basketName: $basketName, ')..write('totalInvestedAmount: $totalInvestedAmount, ')..write('totalTransactions: $totalTransactions')..write(')')).toString();} +'id': serializer.toJson(id),'name': serializer.toJson(name),'description': serializer.toJson(description),'riskLevel': serializer.toJson($InvestmentTableTable.$converterriskLevel.toJson(riskLevel)),'value': serializer.toJson(value),'valueUpdatedOn': serializer.toJson(valueUpdatedOn),'basketId': serializer.toJson(basketId),'basketName': serializer.toJson(basketName),'totalInvestedAmount': serializer.toJson(totalInvestedAmount),'totalTransactions': serializer.toJson(totalTransactions),};}InvestmentEnrichedDO copyWith({int? id,String? name,Value description = const Value.absent(),RiskLevel? riskLevel,double? value,DateTime? valueUpdatedOn,Value basketId = const Value.absent(),Value basketName = const Value.absent(),Value totalInvestedAmount = const Value.absent(),Value totalTransactions = const Value.absent()}) => InvestmentEnrichedDO(id: id ?? this.id,name: name ?? this.name,description: description.present ? description.value : this.description,riskLevel: riskLevel ?? this.riskLevel,value: value ?? this.value,valueUpdatedOn: valueUpdatedOn ?? this.valueUpdatedOn,basketId: basketId.present ? basketId.value : this.basketId,basketName: basketName.present ? basketName.value : this.basketName,totalInvestedAmount: totalInvestedAmount.present ? totalInvestedAmount.value : this.totalInvestedAmount,totalTransactions: totalTransactions.present ? totalTransactions.value : this.totalTransactions,);@override +String toString() {return (StringBuffer('InvestmentEnrichedDO(')..write('id: $id, ')..write('name: $name, ')..write('description: $description, ')..write('riskLevel: $riskLevel, ')..write('value: $value, ')..write('valueUpdatedOn: $valueUpdatedOn, ')..write('basketId: $basketId, ')..write('basketName: $basketName, ')..write('totalInvestedAmount: $totalInvestedAmount, ')..write('totalTransactions: $totalTransactions')..write(')')).toString();} @override - int get hashCode => Object.hash(id, name, riskLevel, value, valueUpdatedOn, basketId, basketName, totalInvestedAmount, totalTransactions);@override -bool operator ==(Object other) => identical(this, other) || (other is InvestmentEnrichedDO && other.id == this.id && other.name == this.name && other.riskLevel == this.riskLevel && other.value == this.value && other.valueUpdatedOn == this.valueUpdatedOn && other.basketId == this.basketId && other.basketName == this.basketName && other.totalInvestedAmount == this.totalInvestedAmount && other.totalTransactions == this.totalTransactions); + int get hashCode => Object.hash(id, name, description, riskLevel, value, valueUpdatedOn, basketId, basketName, totalInvestedAmount, totalTransactions);@override +bool operator ==(Object other) => identical(this, other) || (other is InvestmentEnrichedDO && other.id == this.id && other.name == this.name && other.description == this.description && other.riskLevel == this.riskLevel && other.value == this.value && other.valueUpdatedOn == this.valueUpdatedOn && other.basketId == this.basketId && other.basketName == this.basketName && other.totalInvestedAmount == this.totalInvestedAmount && other.totalTransactions == this.totalTransactions); }class $InvestmentEnrichedViewView extends ViewInfo<$InvestmentEnrichedViewView, InvestmentEnrichedDO> implements HasResultSet { final String? _alias; @override final _$AppDatabase attachedDatabase; @@ -608,7 +649,7 @@ $InvestmentTableTable get investment => attachedDatabase.investmentTable.createA $BasketTableTable get basket => attachedDatabase.basketTable.createAlias('t1'); $TransactionTableTable get transaction => attachedDatabase.transactionTable.createAlias('t2'); @override -List get $columns => [id, name, riskLevel, value, valueUpdatedOn, basketId, basketName, totalInvestedAmount, totalTransactions]; +List get $columns => [id, name, description, riskLevel, value, valueUpdatedOn, basketId, basketName, totalInvestedAmount, totalTransactions]; @override String get aliasedName => _alias ?? entityName; @override @@ -618,10 +659,11 @@ Map?get createViewStatements => null; @override $InvestmentEnrichedViewView get asDslTable => this; @override InvestmentEnrichedDO map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return InvestmentEnrichedDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, riskLevel: $InvestmentTableTable.$converterriskLevel.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}RISK_LEVEL'])!), value: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}VALUE'])!, valueUpdatedOn: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}VALUE_UPDATED_ON'])!, basketId: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}basket_id']), basketName: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}basket_name']), totalInvestedAmount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}total_invested_amount']), totalTransactions: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}total_transactions']), ); +final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return InvestmentEnrichedDO(id: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}ID'])!, name: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}NAME'])!, description: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}DESCRIPTION']), riskLevel: $InvestmentTableTable.$converterriskLevel.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}RISK_LEVEL'])!), value: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}VALUE'])!, valueUpdatedOn: attachedDatabase.typeMapping.read(DriftSqlType.dateTime, data['${effectivePrefix}VALUE_UPDATED_ON'])!, basketId: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}basket_id']), basketName: attachedDatabase.typeMapping.read(DriftSqlType.string, data['${effectivePrefix}basket_name']), totalInvestedAmount: attachedDatabase.typeMapping.read(DriftSqlType.double, data['${effectivePrefix}total_invested_amount']), totalTransactions: attachedDatabase.typeMapping.read(DriftSqlType.int, data['${effectivePrefix}total_transactions']), ); } late final GeneratedColumn id = GeneratedColumn('ID', aliasedName, false, generatedAs: GeneratedAs(investment.id, false), type: DriftSqlType.int); late final GeneratedColumn name = GeneratedColumn('NAME', aliasedName, false, generatedAs: GeneratedAs(investment.name, false), type: DriftSqlType.string); +late final GeneratedColumn description = GeneratedColumn('DESCRIPTION', aliasedName, true, generatedAs: GeneratedAs(investment.description, false), type: DriftSqlType.string); late final GeneratedColumnWithTypeConverter riskLevel = GeneratedColumn('RISK_LEVEL', aliasedName, false, generatedAs: GeneratedAs(investment.riskLevel, false), type: DriftSqlType.string).withConverter($InvestmentTableTable.$converterriskLevel); late final GeneratedColumn value = GeneratedColumn('VALUE', aliasedName, false, generatedAs: GeneratedAs(investment.value, false), type: DriftSqlType.double); late final GeneratedColumn valueUpdatedOn = GeneratedColumn('VALUE_UPDATED_ON', aliasedName, false, generatedAs: GeneratedAs(investment.valueUpdatedOn, false), type: DriftSqlType.dateTime); diff --git a/lib/domain/models/basket.dart b/lib/domain/models/basket.dart index 9c8d659..21cd974 100644 --- a/lib/domain/models/basket.dart +++ b/lib/domain/models/basket.dart @@ -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 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 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 { diff --git a/lib/domain/models/goal.dart b/lib/domain/models/goal.dart index 1b4e96a..a030999 100644 --- a/lib/domain/models/goal.dart +++ b/lib/domain/models/goal.dart @@ -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; @@ -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, @@ -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, diff --git a/lib/domain/models/investment.dart b/lib/domain/models/investment.dart index 29b13d4..97e9f23 100644 --- a/lib/domain/models/investment.dart +++ b/lib/domain/models/investment.dart @@ -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; @@ -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, @@ -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, diff --git a/lib/domain/models/transaction.dart b/lib/domain/models/transaction.dart index a4cf899..8667378 100644 --- a/lib/domain/models/transaction.dart +++ b/lib/domain/models/transaction.dart @@ -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); } diff --git a/test/domain/irr_calculator_test.dart b/test/domain/irr_calculator_test.dart index 2ee1a02..2999811 100644 --- a/test/domain/irr_calculator_test.dart +++ b/test/domain/irr_calculator_test.dart @@ -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);