Feat: Fügt die Spalte "checked" für Transactions hinzu

This commit is contained in:
2026-01-02 00:32:42 +01:00
parent 58cbd2a462
commit 7324cd94f3
2 changed files with 81 additions and 4 deletions

View File

@@ -28,6 +28,9 @@ class Transactions extends Table {
/// Betrag der Transaktion
RealColumn get amount => real().withDefault(const Constant(0))();
/// Ob diese Transaktion bereits geprüft wurde
BoolColumn get checked => boolean().withDefault(const Constant(true))();
/// Fremdschlüssel zum zugehörigen Konto
IntColumn get accountId => integer().references(Accounts, #id)();

View File

@@ -655,6 +655,21 @@ class $TransactionsTable extends Transactions
requiredDuringInsert: false,
defaultValue: const Constant(0),
);
static const VerificationMeta _checkedMeta = const VerificationMeta(
'checked',
);
@override
late final GeneratedColumn<bool> checked = GeneratedColumn<bool>(
'checked',
aliasedName,
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("checked" IN (0, 1))',
),
defaultValue: const Constant(true),
);
static const VerificationMeta _accountIdMeta = const VerificationMeta(
'accountId',
);
@@ -688,6 +703,7 @@ class $TransactionsTable extends Transactions
name,
date,
amount,
checked,
accountId,
recurringTransactionId,
];
@@ -724,6 +740,12 @@ class $TransactionsTable extends Transactions
amount.isAcceptableOrUnknown(data['amount']!, _amountMeta),
);
}
if (data.containsKey('checked')) {
context.handle(
_checkedMeta,
checked.isAcceptableOrUnknown(data['checked']!, _checkedMeta),
);
}
if (data.containsKey('account_id')) {
context.handle(
_accountIdMeta,
@@ -766,6 +788,10 @@ class $TransactionsTable extends Transactions
DriftSqlType.double,
data['${effectivePrefix}amount'],
)!,
checked: attachedDatabase.typeMapping.read(
DriftSqlType.bool,
data['${effectivePrefix}checked'],
)!,
accountId: attachedDatabase.typeMapping.read(
DriftSqlType.int,
data['${effectivePrefix}account_id'],
@@ -796,6 +822,9 @@ class Transaction extends DataClass implements Insertable<Transaction> {
/// Betrag der Transaktion
final double amount;
/// Ob diese Transaktion bereits geprüft wurde
final bool checked;
/// Fremdschlüssel zum zugehörigen Konto
final int accountId;
@@ -807,6 +836,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
required this.name,
this.date,
required this.amount,
required this.checked,
required this.accountId,
this.recurringTransactionId,
});
@@ -819,6 +849,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
map['date'] = Variable<DateTime>(date);
}
map['amount'] = Variable<double>(amount);
map['checked'] = Variable<bool>(checked);
map['account_id'] = Variable<int>(accountId);
if (!nullToAbsent || recurringTransactionId != null) {
map['recurring_transaction_id'] = Variable<int>(recurringTransactionId);
@@ -832,6 +863,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
name: Value(name),
date: date == null && nullToAbsent ? const Value.absent() : Value(date),
amount: Value(amount),
checked: Value(checked),
accountId: Value(accountId),
recurringTransactionId: recurringTransactionId == null && nullToAbsent
? const Value.absent()
@@ -849,6 +881,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
name: serializer.fromJson<String>(json['name']),
date: serializer.fromJson<DateTime?>(json['date']),
amount: serializer.fromJson<double>(json['amount']),
checked: serializer.fromJson<bool>(json['checked']),
accountId: serializer.fromJson<int>(json['accountId']),
recurringTransactionId: serializer.fromJson<int?>(
json['recurringTransactionId'],
@@ -863,6 +896,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
'name': serializer.toJson<String>(name),
'date': serializer.toJson<DateTime?>(date),
'amount': serializer.toJson<double>(amount),
'checked': serializer.toJson<bool>(checked),
'accountId': serializer.toJson<int>(accountId),
'recurringTransactionId': serializer.toJson<int?>(recurringTransactionId),
};
@@ -873,6 +907,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
String? name,
Value<DateTime?> date = const Value.absent(),
double? amount,
bool? checked,
int? accountId,
Value<int?> recurringTransactionId = const Value.absent(),
}) => Transaction(
@@ -880,6 +915,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
name: name ?? this.name,
date: date.present ? date.value : this.date,
amount: amount ?? this.amount,
checked: checked ?? this.checked,
accountId: accountId ?? this.accountId,
recurringTransactionId: recurringTransactionId.present
? recurringTransactionId.value
@@ -891,6 +927,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
name: data.name.present ? data.name.value : this.name,
date: data.date.present ? data.date.value : this.date,
amount: data.amount.present ? data.amount.value : this.amount,
checked: data.checked.present ? data.checked.value : this.checked,
accountId: data.accountId.present ? data.accountId.value : this.accountId,
recurringTransactionId: data.recurringTransactionId.present
? data.recurringTransactionId.value
@@ -904,7 +941,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
..write('id: $id, ')
..write('name: $name, ')
..write('date: $date, ')
..write('amount: $amount, ')
..write('amount: $amount, ')..write('checked: $checked, ')
..write('accountId: $accountId, ')
..write('recurringTransactionId: $recurringTransactionId')
..write(')'))
@@ -912,8 +949,15 @@ class Transaction extends DataClass implements Insertable<Transaction> {
}
@override
int get hashCode =>
Object.hash(id, name, date, amount, accountId, recurringTransactionId);
int get hashCode => Object.hash(
id,
name,
date,
amount,
checked,
accountId,
recurringTransactionId,
);
@override
bool operator ==(Object other) =>
identical(this, other) ||
@@ -922,6 +966,7 @@ class Transaction extends DataClass implements Insertable<Transaction> {
other.name == this.name &&
other.date == this.date &&
other.amount == this.amount &&
other.checked == this.checked &&
other.accountId == this.accountId &&
other.recurringTransactionId == this.recurringTransactionId);
}
@@ -931,6 +976,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
final Value<String> name;
final Value<DateTime?> date;
final Value<double> amount;
final Value<bool> checked;
final Value<int> accountId;
final Value<int?> recurringTransactionId;
const TransactionsCompanion({
@@ -938,6 +984,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
this.name = const Value.absent(),
this.date = const Value.absent(),
this.amount = const Value.absent(),
this.checked = const Value.absent(),
this.accountId = const Value.absent(),
this.recurringTransactionId = const Value.absent(),
});
@@ -946,6 +993,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
this.name = const Value.absent(),
this.date = const Value.absent(),
this.amount = const Value.absent(),
this.checked = const Value.absent(),
required int accountId,
this.recurringTransactionId = const Value.absent(),
}) : accountId = Value(accountId);
@@ -954,6 +1002,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
Expression<String>? name,
Expression<DateTime>? date,
Expression<double>? amount,
Expression<bool>? checked,
Expression<int>? accountId,
Expression<int>? recurringTransactionId,
}) {
@@ -962,6 +1011,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
if (name != null) 'name': name,
if (date != null) 'date': date,
if (amount != null) 'amount': amount,
if (checked != null) 'checked': checked,
if (accountId != null) 'account_id': accountId,
if (recurringTransactionId != null)
'recurring_transaction_id': recurringTransactionId,
@@ -973,6 +1023,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
Value<String>? name,
Value<DateTime?>? date,
Value<double>? amount,
Value<bool>? checked,
Value<int>? accountId,
Value<int?>? recurringTransactionId,
}) {
@@ -981,6 +1032,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
name: name ?? this.name,
date: date ?? this.date,
amount: amount ?? this.amount,
checked: checked ?? this.checked,
accountId: accountId ?? this.accountId,
recurringTransactionId:
recurringTransactionId ?? this.recurringTransactionId,
@@ -1002,6 +1054,9 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
if (amount.present) {
map['amount'] = Variable<double>(amount.value);
}
if (checked.present) {
map['checked'] = Variable<bool>(checked.value);
}
if (accountId.present) {
map['account_id'] = Variable<int>(accountId.value);
}
@@ -1019,7 +1074,7 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
..write('id: $id, ')
..write('name: $name, ')
..write('date: $date, ')
..write('amount: $amount, ')
..write('amount: $amount, ')..write('checked: $checked, ')
..write('accountId: $accountId, ')
..write('recurringTransactionId: $recurringTransactionId')
..write(')'))
@@ -1846,6 +1901,7 @@ typedef $$TransactionsTableCreateCompanionBuilder =
Value<String> name,
Value<DateTime?> date,
Value<double> amount,
Value<bool> checked,
required int accountId,
Value<int?> recurringTransactionId,
});
@@ -1855,6 +1911,7 @@ typedef $$TransactionsTableUpdateCompanionBuilder =
Value<String> name,
Value<DateTime?> date,
Value<double> amount,
Value<bool> checked,
Value<int> accountId,
Value<int?> recurringTransactionId,
});
@@ -1938,6 +1995,11 @@ class $$TransactionsTableFilterComposer
builder: (column) => ColumnFilters(column),
);
ColumnFilters<bool> get checked => $composableBuilder(
column: $table.checked,
builder: (column) => ColumnFilters(column),
);
$$AccountsTableFilterComposer get accountId {
final $$AccountsTableFilterComposer composer = $composerBuilder(
composer: this,
@@ -2015,6 +2077,11 @@ class $$TransactionsTableOrderingComposer
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<bool> get checked => $composableBuilder(
column: $table.checked,
builder: (column) => ColumnOrderings(column),
);
$$AccountsTableOrderingComposer get accountId {
final $$AccountsTableOrderingComposer composer = $composerBuilder(
composer: this,
@@ -2084,6 +2151,9 @@ class $$TransactionsTableAnnotationComposer
GeneratedColumn<double> get amount =>
$composableBuilder(column: $table.amount, builder: (column) => column);
GeneratedColumn<bool> get checked =>
$composableBuilder(column: $table.checked, builder: (column) => column);
$$AccountsTableAnnotationComposer get accountId {
final $$AccountsTableAnnotationComposer composer = $composerBuilder(
composer: this,
@@ -2164,6 +2234,7 @@ class $$TransactionsTableTableManager
Value<String> name = const Value.absent(),
Value<DateTime?> date = const Value.absent(),
Value<double> amount = const Value.absent(),
Value<bool> checked = const Value.absent(),
Value<int> accountId = const Value.absent(),
Value<int?> recurringTransactionId = const Value.absent(),
}) => TransactionsCompanion(
@@ -2171,6 +2242,7 @@ class $$TransactionsTableTableManager
name: name,
date: date,
amount: amount,
checked: checked,
accountId: accountId,
recurringTransactionId: recurringTransactionId,
),
@@ -2180,6 +2252,7 @@ class $$TransactionsTableTableManager
Value<String> name = const Value.absent(),
Value<DateTime?> date = const Value.absent(),
Value<double> amount = const Value.absent(),
Value<bool> checked = const Value.absent(),
required int accountId,
Value<int?> recurringTransactionId = const Value.absent(),
}) => TransactionsCompanion.insert(
@@ -2187,6 +2260,7 @@ class $$TransactionsTableTableManager
name: name,
date: date,
amount: amount,
checked: checked,
accountId: accountId,
recurringTransactionId: recurringTransactionId,
),