diff --git a/lib/api/db/app_database.dart b/lib/api/db/app_database.dart index b7dd4b6..938f6d3 100644 --- a/lib/api/db/app_database.dart +++ b/lib/api/db/app_database.dart @@ -37,8 +37,7 @@ class InvestmentTable extends Table { RealColumn get irr => real().nullable().named('IRR')(); DateTimeColumn get maturityDate => - dateTime().nullable().named('MATURITY_DATE').check(maturityDate.isNull() | - maturityDate.isBiggerThanValue(DateTime.now()))(); + dateTime().nullable().named('MATURITY_DATE')(); DateTimeColumn get valueUpdatedDate => dateTime().nullable().named('VALUE_UPDATED_DATE')(); @@ -59,7 +58,7 @@ class TransactionTable extends Table { integer().nullable().named('SIP_ID').references(SipTable, #id)(); RealColumn get amount => - real().named('AMOUNT').check(amount.isBiggerThanValue(0))(); + real().named('AMOUNT').check(amount.isNotValue(0))(); RealColumn get qty => real().named('QTY').withDefault(const Constant(0))(); @@ -119,8 +118,7 @@ class GoalTable extends Table { real().named('INFLATION').check(inflation.isBetweenValues(1, 100))(); DateTimeColumn get maturityDate => dateTime() - .named('MATURITY_DATE') - .check(maturityDate.isBiggerThanValue(DateTime.now()))(); + .named('MATURITY_DATE')(); TextColumn get importance => textEnum().named('IMPORTANCE')(); } @@ -355,7 +353,9 @@ class AppDatabase extends _$AppDatabase { var tableName = entry.key; var tableDataList = entry.value; + print("Updating table $tableName"); for (var tableData in tableDataList) { + print("Inserting $tableData"); final String columnsString = tableData.keys.where((key) => tableData[key] != null).join(', '); final String valuesString = tableData.keys @@ -378,7 +378,7 @@ class AppDatabase extends _$AppDatabase { } else if (value is bool) { return Variable.withBool(value); } else { - throw Exception('Unknown type $value'); + return Variable.withString(""); } }).toList(), ); diff --git a/lib/api/db/app_database.g.dart b/lib/api/db/app_database.g.dart index 05e51e7..976147b 100644 --- a/lib/api/db/app_database.g.dart +++ b/lib/api/db/app_database.g.dart @@ -278,11 +278,7 @@ class $InvestmentTableTable extends InvestmentTable @override late final GeneratedColumn maturityDate = GeneratedColumn( 'MATURITY_DATE', aliasedName, true, - check: () => - maturityDate.isNull() | - maturityDate.isBiggerThanValue(DateTime.now()), - type: DriftSqlType.dateTime, - requiredDuringInsert: false); + type: DriftSqlType.dateTime, requiredDuringInsert: false); static const VerificationMeta _valueUpdatedDateMeta = const VerificationMeta('valueUpdatedDate'); @override @@ -1197,7 +1193,7 @@ class $TransactionTableTable extends TransactionTable @override late final GeneratedColumn amount = GeneratedColumn( 'AMOUNT', aliasedName, false, - check: () => amount.isBiggerThanValue(0), + check: () => amount.isNotValue(0), type: DriftSqlType.double, requiredDuringInsert: true); static const VerificationMeta _qtyMeta = const VerificationMeta('qty'); @@ -1580,9 +1576,7 @@ class $GoalTableTable extends GoalTable @override late final GeneratedColumn maturityDate = GeneratedColumn( 'MATURITY_DATE', aliasedName, false, - check: () => maturityDate.isBiggerThanValue(DateTime.now()), - type: DriftSqlType.dateTime, - requiredDuringInsert: true); + type: DriftSqlType.dateTime, requiredDuringInsert: true); static const VerificationMeta _importanceMeta = const VerificationMeta('importance'); @override diff --git a/lib/ui/presentation/create_investment_transaction_presenter.dart b/lib/ui/presentation/create_investment_transaction_presenter.dart index b0d89cd..729355e 100644 --- a/lib/ui/presentation/create_investment_transaction_presenter.dart +++ b/lib/ui/presentation/create_investment_transaction_presenter.dart @@ -95,6 +95,6 @@ class CreateTransactionViewState { SingleEvent? onTransactionLoaded; bool isValid() { - return amount > 0; + return amount != 0; } } diff --git a/lib/ui/presentation/investments_presenter.dart b/lib/ui/presentation/investments_presenter.dart index cae09a0..367cba9 100644 --- a/lib/ui/presentation/investments_presenter.dart +++ b/lib/ui/presentation/investments_presenter.dart @@ -14,6 +14,7 @@ class InvestmentsPresenter extends Presenter { .get() .then((investments) => investments .map((investment) => InvestmentVO.from(investment: investment)) + .where((element) => element.qty > 0) .toList()) .then((investmentVOs) { investmentVOs.sort((a, b) => a.currentValue > b.currentValue ? -1 : 1);