45 lines
1 KiB
Dart
45 lines
1 KiB
Dart
// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:prasule/api/category.dart';
|
|
import 'package:prasule/api/entry_data.dart';
|
|
|
|
part 'wallet_entry.g.dart';
|
|
|
|
@JsonSerializable()
|
|
|
|
/// This is an entry containing a single item
|
|
class WalletSingleEntry {
|
|
/// This is an entry containing a single item
|
|
WalletSingleEntry({
|
|
required this.data,
|
|
required this.type,
|
|
required this.date,
|
|
required this.category,
|
|
required this.id,
|
|
});
|
|
|
|
/// Generates a class instance from a Map
|
|
factory WalletSingleEntry.fromJson(Map<String, dynamic> json) =>
|
|
_$WalletSingleEntryFromJson(json);
|
|
|
|
/// Expense or income
|
|
EntryType type;
|
|
|
|
/// Actual entry data
|
|
EntryData data;
|
|
|
|
/// Date of entry creation
|
|
DateTime date;
|
|
|
|
/// Selected category
|
|
WalletCategory category;
|
|
|
|
/// Unique entry ID
|
|
int id;
|
|
|
|
/// Converts the data in this instance into a Map
|
|
Map<String, dynamic> toJson() => _$WalletSingleEntryToJson(this);
|
|
}
|