mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Set item due date candidate
After processing, set the due date of an item to the first candidate. The earliest due date is considered best match.
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
package docspell.common
|
||||
|
||||
import cats.implicits._
|
||||
import cats.data.NonEmptyList
|
||||
import docspell.common._
|
||||
import docspell.common.MetaProposal.Candidate
|
||||
import io.circe._
|
||||
import io.circe.generic.semiauto._
|
||||
import java.time.LocalDate
|
||||
|
||||
case class MetaProposal(proposalType: MetaProposalType, values: NonEmptyList[Candidate]) {
|
||||
|
||||
@ -22,6 +25,12 @@ case class MetaProposal(proposalType: MetaProposalType, values: NonEmptyList[Can
|
||||
|
||||
object MetaProposal {
|
||||
|
||||
def parseDate(cand: Candidate): Option[LocalDate] =
|
||||
parseDate(cand.ref.id)
|
||||
|
||||
def parseDate(date: Ident): Option[LocalDate] =
|
||||
Either.catchNonFatal(LocalDate.parse(date.id)).toOption
|
||||
|
||||
case class Candidate(ref: IdRef, origin: Set[NerLabel])
|
||||
object Candidate {
|
||||
implicit val jsonEncoder: Encoder[Candidate] =
|
||||
|
@ -18,7 +18,7 @@ object MetaProposalType {
|
||||
case object DueDate extends MetaProposalType
|
||||
|
||||
val all: List[MetaProposalType] =
|
||||
List(CorrOrg, CorrPerson, ConcPerson, ConcEquip)
|
||||
List(CorrOrg, CorrPerson, ConcPerson, ConcEquip, DocDate, DueDate)
|
||||
|
||||
def fromString(str: String): Either[String, MetaProposalType] =
|
||||
str.toLowerCase match {
|
||||
|
Reference in New Issue
Block a user