use thiserror::Error;

#[derive(Debug, Error)]
pub(crate) enum Error {
    #[error("The working interval ({0}) must fit into a day of 1440 minutes (24 hours)")]
    InvalidWorkingInterval(String),
    #[error("Could not parse payment rate ({0}): {1}")]
    CouldNotParseRate(String, String),
    #[error(
        "Could not parse billing period '{0}' (possible values: daily/d, weekly/w, 2weeks/2 or m/monthly)"
    )]
    CouldNotParseBillingPeriod(String),
    #[error("Could not parse date/time: {0}")]
    CouldNotParseDateTime(String),
    #[error("Could not parse date values: {0}-{1}-{2}")]
    InvalidDateValues(i32, u32, u32),
    #[error("Money error: {0}")]
    Money(#[from] rusty_money::MoneyError),
    #[error("Unknown working interval: '{0}")]
    UnknownInterval(String),
    #[error("Rate not defined")]
    NoRate,
    #[error("Date or time parse error: {0}")]
    DateTimeParse(#[from] chrono::ParseError),
    #[error("Job {0} misses a valid working scheme")]
    JobMissingScheme(usize),
}

pub(crate) type Result<T> = std::result::Result<T, Error>;
