75 lines
2.6 KiB
Dart
75 lines
2.6 KiB
Dart
import '../models/transaction_record.dart';
|
|
import '../models/category.dart';
|
|
import '../models/tag.dart';
|
|
import 'category_utils.dart';
|
|
import 'tag_utils.dart';
|
|
|
|
/// Утилиты для работы с тестовыми транзакциями
|
|
class TransactionUtils {
|
|
/// Возвращает список тестовых транзакций
|
|
static List<TransactionRecord> getSampleTransactions() {
|
|
final categories = CategoryUtils.getDefaultCategories();
|
|
final tags = TagUtils.getDefaultTags();
|
|
|
|
return [
|
|
// Доходы
|
|
TransactionRecord(
|
|
id: '1',
|
|
category: categories.firstWhere((c) => c.id == 'income_salary'),
|
|
tag: tags.firstWhere((t) => t.id == 'tag_work'),
|
|
amount: 100000,
|
|
dateTime: DateTime.now().subtract(const Duration(days: 5)),
|
|
vendor: 'ООО "Рога и копыта"',
|
|
currency: 'RUB',
|
|
),
|
|
TransactionRecord(
|
|
id: '2',
|
|
category: categories.firstWhere((c) => c.id == 'income_freelance'),
|
|
tag: tags.firstWhere((t) => t.id == 'tag_work'),
|
|
amount: 25000,
|
|
dateTime: DateTime.now().subtract(const Duration(days: 2)),
|
|
vendor: 'Фриланс проект',
|
|
currency: 'RUB',
|
|
),
|
|
|
|
// Расходы
|
|
TransactionRecord(
|
|
id: '3',
|
|
category: categories.firstWhere((c) => c.id == 'expense_food'),
|
|
tag: tags.firstWhere((t) => t.id == 'tag_family'),
|
|
amount: -3500,
|
|
dateTime: DateTime.now().subtract(const Duration(days: 1)),
|
|
vendor: 'Пятерочка',
|
|
currency: 'RUB',
|
|
),
|
|
TransactionRecord(
|
|
id: '4',
|
|
category: categories.firstWhere((c) => c.id == 'expense_transport'),
|
|
amount: -500,
|
|
dateTime: DateTime.now().subtract(const Duration(hours: 12)),
|
|
vendor: 'Яндекс Такси',
|
|
currency: 'RUB',
|
|
),
|
|
TransactionRecord(
|
|
id: '5',
|
|
category: categories.firstWhere((c) => c.id == 'expense_entertainment'),
|
|
tag: tags.firstWhere((t) => t.id == 'tag_friends'),
|
|
amount: -2000,
|
|
dateTime: DateTime.now().subtract(const Duration(hours: 6)),
|
|
vendor: 'Кинотеатр',
|
|
currency: 'RUB',
|
|
),
|
|
];
|
|
}
|
|
|
|
/// Возвращает только доходы
|
|
static List<TransactionRecord> getIncomeTransactions() {
|
|
return getSampleTransactions().where((t) => t.isIncome).toList();
|
|
}
|
|
|
|
/// Возвращает только расходы
|
|
static List<TransactionRecord> getExpenseTransactions() {
|
|
return getSampleTransactions().where((t) => !t.isIncome).toList();
|
|
}
|
|
}
|