use jiff::{SignedDuration, Timestamp, civil};
use crate::{
Ampere, Kw, Kwh, Money, Price, Weekday, currency, money::VatOrigin, tariff::v2x::DimensionType,
};
pub(super) struct Explanation {
pub currency: currency::Code,
pub body: Body,
}
pub(super) enum Body {
Sections(Vec<Section>),
Fallback(Fallback),
}
pub(super) enum Section {
Dimension(Dimension),
Flat(Flat),
Bounds(Bounds),
Validity(Validity),
}
pub(super) struct Dimension {
pub kind: DimensionType,
pub tiers: Vec<Tier>,
pub uniform_step: Option<u64>,
pub dropped_unreachable: bool,
pub dropped_shadowed: bool,
}
pub(super) struct Tier {
pub condition: Condition,
pub rate: Rate,
pub step: Option<u64>,
}
pub(super) enum Rate {
Free,
Priced { amount: Money, vat: VatOrigin },
}
pub(super) struct Flat {
pub tiers: Vec<FlatTier>,
pub dropped_shadowed: bool,
}
pub(super) struct FlatTier {
pub condition: Condition,
pub fee: FlatFee,
}
pub(super) enum FlatFee {
NoFee,
Charged { amount: Money, vat: VatOrigin },
}
pub(super) enum Condition {
Always,
Remaining,
Otherwise,
When(Vec<ConditionPart>),
}
pub(super) enum ConditionPart {
TimeWindow(TimeWindow),
Weekdays(Vec<Weekday>),
DateRange {
start: Option<civil::Date>,
end: Option<civil::Date>,
},
MinPower(Kw),
MaxPower(Kw),
MinCurrent(Ampere),
MaxCurrent(Ampere),
DurationScope(Scope<SignedDuration>),
EnergyScope(Scope<Kwh>),
}
pub(super) enum TimeWindow {
Empty { at: civil::Time },
Wrapping {
start: civil::Time,
end: civil::Time,
},
Between {
start: civil::Time,
end: civil::Time,
},
From { start: civil::Time },
Before { end: civil::Time },
}
pub(super) enum Scope<T> {
UpTo(T),
After(T),
Between(T, T),
}
pub(super) struct Bounds {
pub min: Option<Price>,
pub max: Option<Price>,
}
pub(super) enum Validity {
Between { start: Timestamp, end: Timestamp },
From { start: Timestamp },
Until { end: Timestamp },
}
pub(super) enum Fallback {
ReservationOnly,
NoPriceComponents,
FreeFlatOnly,
}