Added properties to easy filter emails and attachments

This commit is contained in:
dankito 2024-11-28 16:11:38 +01:00
parent 8e461b43a5
commit c516969cb0
2 changed files with 11 additions and 0 deletions

View File

@ -34,5 +34,12 @@ class Email(
) {
val plainTextOrHtmlBody: String? by lazy { plainTextBody ?: htmlBody }
val hasAttachments: Boolean by lazy { attachments.isNotEmpty() }
val hasEInvoiceAttachment: Boolean by lazy { attachments.any { it.containsEInvoice } }
val hasPdfAttachment: Boolean by lazy { attachments.any { it.isPdfFile } }
override fun toString() = "${date.atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachments.size} attachment(s)"
}

View File

@ -18,5 +18,9 @@ class EmailAttachment(
val invoice: Invoice? = null,
val file: File? = null
) {
val containsEInvoice: Boolean by lazy { invoice != null }
val isPdfFile: Boolean by lazy { extension == "pdf" || mediaType == "application/pdf" }
override fun toString() = "$filename: $invoice"
}