From 2516328da8a8002f55e5c130b6bac5dd85aadc54 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 21 Nov 2024 18:40:13 +0100 Subject: [PATCH] Fixed that sent date may is null --- .../src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt | 2 +- .../main/kotlin/net/codinux/invoicing/mail/MailWithInvoice.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt index 20377ec..192b2f5 100644 --- a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailReader.kt @@ -103,7 +103,7 @@ class MailReader( if (attachmentsWithEInvoice.isNotEmpty()) { return@mapNotNull MailWithInvoice( message.from.joinToString(), message.subject, - map(message.sentDate), map(message.receivedDate), message.messageNumber, + message.sentDate?.let { map(it) }, map(message.receivedDate), message.messageNumber, attachmentsWithEInvoice ) } diff --git a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailWithInvoice.kt b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailWithInvoice.kt index 92ad0a1..7052649 100644 --- a/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailWithInvoice.kt +++ b/e-invoicing-domain/src/main/kotlin/net/codinux/invoicing/mail/MailWithInvoice.kt @@ -6,10 +6,10 @@ import java.time.ZoneId class MailWithInvoice( val sender: String, val subject: String, - val sent: Instant, + val sent: Instant?, val received: Instant, val messageNumber: Int, val attachmentsWithEInvoice: List ) { - override fun toString() = "${sent.atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachmentsWithEInvoice.size} invoice(s)" + override fun toString() = "${(sent ?: received).atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachmentsWithEInvoice.size} invoice(s)" } \ No newline at end of file