mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 02:15:29 +03:00
50 lines
1.9 KiB
Dart
50 lines
1.9 KiB
Dart
import 'package:drift/drift.dart';
|
|
|
|
/// Transactions table
|
|
class Transactions extends Table {
|
|
TextColumn get id => text()();
|
|
RealColumn get amount => real()();
|
|
TextColumn get category => text()();
|
|
TextColumn get type => text()(); // 'income' or 'expense'
|
|
DateTimeColumn get date => dateTime()();
|
|
TextColumn get note => text().nullable()();
|
|
TextColumn get recurrence => text().withDefault(const Constant('none'))();
|
|
DateTimeColumn get lastOccurrence => dateTime().nullable()();
|
|
TextColumn get currency => text().withDefault(const Constant('\$'))();
|
|
TextColumn get currencyCode => text().withDefault(const Constant('USD'))();
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id};
|
|
}
|
|
|
|
/// Categories table for custom categories
|
|
class Categories extends Table {
|
|
IntColumn get id => integer().autoIncrement()();
|
|
TextColumn get name => text().withLength(min: 1, max: 50)();
|
|
TextColumn get type => text()(); // 'income' or 'expense'
|
|
TextColumn get icon => text().nullable()();
|
|
TextColumn get color => text().nullable()();
|
|
BoolColumn get isDefault => boolean().withDefault(const Constant(false))();
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
}
|
|
|
|
/// Budgets table for monthly budgets
|
|
class Budgets extends Table {
|
|
IntColumn get id => integer().autoIncrement()();
|
|
RealColumn get amount => real()();
|
|
TextColumn get categoryId => text().nullable()();
|
|
IntColumn get month => integer()();
|
|
IntColumn get year => integer()();
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
}
|
|
|
|
/// Exchange rates cache
|
|
class ExchangeRates extends Table {
|
|
IntColumn get id => integer().autoIncrement()();
|
|
TextColumn get fromCurrency => text()();
|
|
TextColumn get toCurrency => text()();
|
|
RealColumn get rate => real()();
|
|
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
|
}
|