prasule/lib/api/recurring_entry.dart
Matyáš Caras cfd4d6200e
chore: cosmetic changes
Change some comment text, also change current balance to a getter
2024-01-31 07:54:29 +01:00

52 lines
1.4 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
import 'package:prasule/api/category.dart';
import 'package:prasule/api/entry_data.dart';
import 'package:prasule/api/wallet_entry.dart';
part 'recurring_entry.g.dart';
/// This is a [WalletSingleEntry] that is automatically recurring
@JsonSerializable()
class RecurringWalletEntry extends WalletSingleEntry {
/// This is a [WalletSingleEntry] that is automatically recurring
RecurringWalletEntry({
required super.data,
required super.type,
required super.date,
required super.category,
required super.id,
required this.lastRunDate,
required this.recurType,
this.repeatAfter = 1,
});
/// Connects the generated fromJson method
factory RecurringWalletEntry.fromJson(Map<String, dynamic> json) =>
_$RecurringWalletEntryFromJson(json);
/// Connects the generated toJson method
@override
Map<String, dynamic> toJson() => _$RecurringWalletEntryToJson(this);
/// Last date the recurring entry was added into the single entry list
DateTime lastRunDate;
/// After how many {recurType} should the entry recur
int repeatAfter;
/// What type of recurrence should happen
RecurType recurType;
}
/// How a [RecurringWalletEntry] should recur
@JsonEnum()
enum RecurType {
/// Will recur every {repeatAfter} months
month,
/// Will recur every {repeatAfter} years
year,
/// Will recur every {repeatAfter} days
day
}