64 lines
1.9 KiB
Dart
64 lines
1.9 KiB
Dart
enum SubmissionStatus { pending, sending, success, failed }
|
|
|
|
enum AttachmentStatus { none, uploading, success, failed }
|
|
|
|
/// Hasil pengiriman satu grup transaksi ke Firefly III.
|
|
class GroupSubmissionResult {
|
|
final String groupId;
|
|
final String label;
|
|
final double amount;
|
|
final bool isTip;
|
|
SubmissionStatus status;
|
|
String? transactionId;
|
|
String? journalId;
|
|
String? error;
|
|
AttachmentStatus attachmentStatus;
|
|
String? attachmentError;
|
|
String? invoiceLocalPath;
|
|
|
|
GroupSubmissionResult({
|
|
required this.groupId,
|
|
required this.label,
|
|
required this.amount,
|
|
this.isTip = false,
|
|
this.status = SubmissionStatus.pending,
|
|
this.transactionId,
|
|
this.journalId,
|
|
this.error,
|
|
this.attachmentStatus = AttachmentStatus.none,
|
|
this.attachmentError,
|
|
this.invoiceLocalPath,
|
|
});
|
|
|
|
bool get isSuccess => status == SubmissionStatus.success;
|
|
bool get isFailed => status == SubmissionStatus.failed;
|
|
bool get isSending => status == SubmissionStatus.sending;
|
|
bool get isPending => status == SubmissionStatus.pending;
|
|
bool get isAttachmentFailed => attachmentStatus == AttachmentStatus.failed;
|
|
bool get isAttachmentSuccess => attachmentStatus == AttachmentStatus.success;
|
|
|
|
GroupSubmissionResult copyWith({
|
|
SubmissionStatus? status,
|
|
String? transactionId,
|
|
String? journalId,
|
|
String? error,
|
|
AttachmentStatus? attachmentStatus,
|
|
String? attachmentError,
|
|
String? invoiceLocalPath,
|
|
}) {
|
|
return GroupSubmissionResult(
|
|
groupId: groupId,
|
|
label: label,
|
|
amount: amount,
|
|
isTip: isTip,
|
|
status: status ?? this.status,
|
|
transactionId: transactionId ?? this.transactionId,
|
|
journalId: journalId ?? this.journalId,
|
|
error: error ?? this.error,
|
|
attachmentStatus: attachmentStatus ?? this.attachmentStatus,
|
|
attachmentError: attachmentError ?? this.attachmentError,
|
|
invoiceLocalPath: invoiceLocalPath ?? this.invoiceLocalPath,
|
|
);
|
|
}
|
|
}
|