diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt index 9c12162..a173e5f 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/Email.kt @@ -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)" } \ No newline at end of file diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/EmailAttachment.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/EmailAttachment.kt index f292aac..b4a77e8 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/EmailAttachment.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/model/EmailAttachment.kt @@ -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" } \ No newline at end of file