package de.krisenvorrat.app.ui.item

import java.time.LocalDate

internal data class ItemUiModel(
    val id: String,
    val name: String,
    val categoryName: String,
    val quantity: Double,
    val unit: String,
    val locationName: String,
    val expiryDate: LocalDate?,
    val categoryId: Int
) {

    val isExpired: Boolean
        get() = expiryDate != null && expiryDate.isBefore(LocalDate.now())

    val isExpiringSoon: Boolean
        get() = expiryDate != null &&
            !isExpired &&
            expiryDate.isBefore(LocalDate.now().plusDays(EXPIRY_WARNING_DAYS))

    companion object {
        private const val EXPIRY_WARNING_DAYS = 30L
    }
}
