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 872461e..ba4618b 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 @@ -15,8 +15,7 @@ import net.codinux.invoicing.reader.EInvoiceReader import net.codinux.log.logger import org.eclipse.angus.mail.imap.IMAPFolder import java.io.File -import java.time.LocalDate -import java.time.ZoneId +import java.time.Instant import java.util.* import java.util.concurrent.Executors @@ -101,7 +100,11 @@ class MailReader( } if (attachmentsWithEInvoice.isNotEmpty()) { - return@mapNotNull MailWithInvoice(message.from.joinToString(), message.subject, map(message.sentDate), attachmentsWithEInvoice) + return@mapNotNull MailWithInvoice( + message.from.joinToString(), message.subject, + map(message.sentDate), map(message.receivedDate), message.messageNumber, + attachmentsWithEInvoice + ) } } } catch (e: Throwable) { @@ -153,9 +156,8 @@ class MailReader( null } - // TODO: same code as in MustangMapper - private fun map(date: Date): LocalDate = - date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() + private fun map(date: Date): Instant = + date.toInstant() private fun connect(account: MailAccount, connected: (Store) -> T?): T? { 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 835a3a3..92ad0a1 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 @@ -1,12 +1,15 @@ package net.codinux.invoicing.mail -import java.time.LocalDate +import java.time.Instant +import java.time.ZoneId class MailWithInvoice( val sender: String, val subject: String, - val date: LocalDate, + val sent: Instant, + val received: Instant, + val messageNumber: Int, val attachmentsWithEInvoice: List ) { - override fun toString() = "$date $sender: $subject, ${attachmentsWithEInvoice.size} invoices" + override fun toString() = "${sent.atZone(ZoneId.systemDefault()).toLocalDate()} $sender: $subject, ${attachmentsWithEInvoice.size} invoice(s)" } \ No newline at end of file