36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
import 'receipt_group.dart';
|
|
|
|
/// Satu tugas kirim ke Firefly III: satu grup deposit atau satu tip.
|
|
///
|
|
/// Kalau [group] tidak null → deposit transaksi grup.
|
|
/// Kalau [group] null → transaksi tip, pakai [tipSourceAccountId]/[tipAmount].
|
|
class SubmissionTask {
|
|
final String taskId;
|
|
final ReceiptGroup? group;
|
|
final double? tipAmount;
|
|
final String? tipSourceAccountId;
|
|
final String? tipSourceAccountName;
|
|
final String destinationAccountId;
|
|
final String destinationAccountName;
|
|
final DateTime transactionDate;
|
|
|
|
SubmissionTask({
|
|
required this.taskId,
|
|
this.group,
|
|
this.tipAmount,
|
|
this.tipSourceAccountId,
|
|
this.tipSourceAccountName,
|
|
required this.destinationAccountId,
|
|
required this.destinationAccountName,
|
|
required this.transactionDate,
|
|
}) : assert(
|
|
(group != null) ||
|
|
(tipAmount != null && tipSourceAccountId != null),
|
|
'Harus punya group atau data tip');
|
|
|
|
bool get isTip => group == null;
|
|
String get label =>
|
|
isTip ? 'Tip (${tipSourceAccountName ?? '?'})' : (group?.sourceAccountName ?? 'Grup');
|
|
double get amount => isTip ? (tipAmount ?? 0) : (group?.total ?? 0);
|
|
}
|