Files
BudgetApp/lib/utils/transaction_utils.dart
T
Sanders 8b75299d41 Refactors data repositories for single-user mode
This commit refactors the data repositories to remove user-specific filtering. It simplifies the data access logic by retrieving all data from the Hive boxes and removing the need to filter by `userId` in the repository methods.

This change makes the app function in single-user mode and removes the need to manage multiple user contexts within the data layer.

Specifically:
- Removes `userId` parameter from repository methods.
- Updates the setting repository to use fixed keys.
- Removes user ID filtering from queries.
- Removes user ID parameters from Cubits and Blocs
- Updates initial data creation
2025-07-12 21:54:00 +03:00

60 lines
2.3 KiB
Dart

import '../models/transaction_record.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(
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(
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(
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(
category: categories.firstWhere((c) => c.id == 'expense_transport'),
// tag: null, // Тег может быть null
amount: -500,
dateTime: DateTime.now().subtract(const Duration(hours: 12)),
vendor: 'Яндекс Такси',
currency: 'RUB',
),
TransactionRecord(
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',
),
];
}
}