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