Add data
This commit is contained in:
@@ -136,8 +136,12 @@ class UserSeeder {
|
||||
DateTime daysAgo(int d, [int h = 12, int m = 0]) =>
|
||||
DateTime(now.year, now.month, now.day, h, m)
|
||||
.subtract(Duration(days: d));
|
||||
// now.month - 1 == 0 корректно даёт декабрь прошлого года (Dart нормализует)
|
||||
DateTime inPrevMonth(int day, [int h = 12, int m = 0]) =>
|
||||
DateTime(now.year, now.month - 1, day, h, m);
|
||||
|
||||
final demo = <_Demo>[
|
||||
// ── Май (текущий месяц) ────────────────────────────────────────────────
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.food.id,
|
||||
@@ -177,6 +181,13 @@ class UserSeeder {
|
||||
date: atYesterday(19, 30),
|
||||
note: 'Кинотеатр',
|
||||
extraInfo: '2 билета · зал IMAX'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
transferToAccountId: a.cash.id,
|
||||
type: TransactionType.transfer,
|
||||
amount: 200000,
|
||||
date: daysAgo(2, 16, 30),
|
||||
note: 'Снятие наличных'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.rent.id,
|
||||
@@ -184,7 +195,7 @@ class UserSeeder {
|
||||
amount: 3200000,
|
||||
date: daysAgo(3, 12, 0),
|
||||
note: 'Аренда квартиры',
|
||||
extraInfo: 'Май 2025 · ул. Ленина 12'),
|
||||
extraInfo: 'Май 2026 · ул. Ленина 12'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.salary.id,
|
||||
@@ -215,6 +226,87 @@ class UserSeeder {
|
||||
amount: 89000,
|
||||
date: daysAgo(5, 9, 20),
|
||||
note: 'Магнит'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
transferToAccountId: a.savings.id,
|
||||
type: TransactionType.transfer,
|
||||
amount: 500000,
|
||||
date: daysAgo(7, 11, 0),
|
||||
note: 'Пополнение копилки'),
|
||||
// ── Апрель ────────────────────────────────────────────────────────────
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.entertainment.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 120000,
|
||||
date: inPrevMonth(27, 20, 0),
|
||||
note: 'Концерт',
|
||||
extraInfo: '2 билета'),
|
||||
_Demo(
|
||||
accountId: a.cash.id,
|
||||
categoryId: c.food.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 88000,
|
||||
date: inPrevMonth(25, 11, 10),
|
||||
note: 'Перекрёсток'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.transport.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 38000,
|
||||
date: inPrevMonth(22, 19, 0),
|
||||
note: 'Яндекс Такси'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.food.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 195000,
|
||||
date: inPrevMonth(19, 17, 40),
|
||||
note: 'Лента'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
transferToAccountId: a.cash.id,
|
||||
type: TransactionType.transfer,
|
||||
amount: 150000,
|
||||
date: inPrevMonth(17, 10, 0),
|
||||
note: 'Снятие наличных'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.transport.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 6200,
|
||||
date: inPrevMonth(14, 8, 45),
|
||||
note: 'Метро'),
|
||||
_Demo(
|
||||
accountId: a.cash.id,
|
||||
categoryId: c.cafe.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 55000,
|
||||
date: inPrevMonth(12, 13, 30),
|
||||
note: 'Шоколадница'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
transferToAccountId: a.savings.id,
|
||||
type: TransactionType.transfer,
|
||||
amount: 500000,
|
||||
date: inPrevMonth(11, 12, 0),
|
||||
note: 'Пополнение копилки'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.salary.id,
|
||||
type: TransactionType.income,
|
||||
amount: 9500000,
|
||||
date: inPrevMonth(10, 11, 0),
|
||||
note: 'Зарплата',
|
||||
extraInfo: 'Оклад за март'),
|
||||
_Demo(
|
||||
accountId: a.card.id,
|
||||
categoryId: c.rent.id,
|
||||
type: TransactionType.expense,
|
||||
amount: 3200000,
|
||||
date: inPrevMonth(5, 12, 0),
|
||||
note: 'Аренда квартиры',
|
||||
extraInfo: 'Апрель 2026 · ул. Ленина 12'),
|
||||
];
|
||||
|
||||
for (final d in demo) {
|
||||
@@ -227,6 +319,7 @@ class UserSeeder {
|
||||
date: d.date,
|
||||
note: d.note,
|
||||
extraInfo: d.extraInfo,
|
||||
transferToAccountId: d.transferToAccountId,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -261,18 +354,20 @@ class _SeededCategories {
|
||||
class _Demo {
|
||||
_Demo({
|
||||
required this.accountId,
|
||||
required this.categoryId,
|
||||
this.categoryId,
|
||||
required this.type,
|
||||
required this.amount,
|
||||
required this.date,
|
||||
required this.note,
|
||||
this.note,
|
||||
this.extraInfo,
|
||||
this.transferToAccountId,
|
||||
});
|
||||
final String accountId;
|
||||
final String categoryId;
|
||||
final String? categoryId;
|
||||
final TransactionType type;
|
||||
final int amount;
|
||||
final DateTime date;
|
||||
final String note;
|
||||
final String? note;
|
||||
final String? extraInfo;
|
||||
final String? transferToAccountId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user