use alloc::collections::BTreeSet;
use alloc::string::String;
use alloc::vec::Vec;
use core::fmt;
use crate::types::{DateTime, Decimal};
pub const CONVERSION_SCALE: u8 = 3;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RateUnit {
W,
A,
}
impl fmt::Display for RateUnit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
RateUnit::W => "W",
RateUnit::A => "A",
})
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum Purpose {
ChargingStationMaxProfile,
TxDefaultProfile,
TxProfile,
ChargingStationExternalConstraints,
PriorityCharging,
LocalGeneration,
}
impl Purpose {
#[must_use]
pub const fn settable_by_csms(self) -> bool {
!matches!(
self,
Purpose::ChargingStationExternalConstraints | Purpose::LocalGeneration
)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum ProfileKind {
Absolute,
Recurring,
Relative,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Recurrency {
Daily,
Weekly,
}
impl Recurrency {
const fn seconds(self) -> i64 {
match self {
Recurrency::Daily => 86_400,
Recurrency::Weekly => 604_800,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Period {
pub start_period: i64,
pub limit: Decimal,
pub number_phases: Option<i32>,
pub phase_to_use: Option<i32>,
}
impl Period {
#[must_use]
pub const fn new(start_period: i64, limit: Decimal) -> Self {
Self {
start_period,
limit,
number_phases: None,
phase_to_use: None,
}
}
#[must_use]
pub const fn phases(mut self, phases: i32) -> Self {
self.number_phases = Some(phases);
self
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct Schedule {
pub id: i32,
pub start: Option<DateTime>,
pub duration: Option<i64>,
pub rate_unit: RateUnit,
pub periods: Vec<Period>,
pub min_charging_rate: Option<Decimal>,
}
impl Schedule {
#[must_use]
pub fn new(id: i32, rate_unit: RateUnit, mut periods: Vec<Period>) -> Self {
periods.sort_by_key(|period| period.start_period);
Self {
id,
start: None,
duration: None,
rate_unit,
periods,
min_charging_rate: None,
}
}
#[must_use]
pub fn starting(mut self, start: DateTime) -> Self {
self.start = Some(start);
self
}
#[must_use]
pub fn lasting(mut self, seconds: i64) -> Self {
self.duration = Some(seconds);
self
}
#[must_use]
pub fn period_at(&self, offset: i64) -> Option<&Period> {
if offset < 0 || self.duration.is_some_and(|duration| offset >= duration) {
return None;
}
self.periods
.iter()
.rev()
.find(|period| period.start_period <= offset)
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct Profile {
pub id: i32,
pub stack_level: i32,
pub purpose: Purpose,
pub kind: ProfileKind,
pub recurrency: Option<Recurrency>,
pub valid_from: Option<DateTime>,
pub valid_to: Option<DateTime>,
pub transaction_id: Option<String>,
pub evse_id: u32,
pub schedules: Vec<Schedule>,
}
impl Profile {
#[must_use]
pub fn new(
id: i32,
stack_level: i32,
purpose: Purpose,
kind: ProfileKind,
schedule: Schedule,
) -> Self {
Self {
id,
stack_level,
purpose,
kind,
recurrency: None,
valid_from: None,
valid_to: None,
transaction_id: None,
evse_id: 0,
schedules: alloc::vec![schedule],
}
}
#[must_use]
pub fn on_evse(mut self, evse_id: u32) -> Self {
self.evse_id = evse_id;
self
}
#[must_use]
pub fn for_transaction(mut self, transaction_id: impl Into<String>) -> Self {
self.transaction_id = Some(transaction_id.into());
self
}
#[must_use]
pub fn valid(mut self, from: Option<DateTime>, to: Option<DateTime>) -> Self {
self.valid_from = from;
self.valid_to = to;
self
}
#[must_use]
pub fn recurring(mut self, recurrency: Recurrency) -> Self {
self.kind = ProfileKind::Recurring;
self.recurrency = Some(recurrency);
self
}
fn valid_at(&self, at: i64) -> bool {
self.valid_from.is_none_or(|from| epoch(from) <= at)
&& self.valid_to.is_none_or(|to| at < epoch(to))
}
fn offset_at(&self, at: i64, transaction_start: Option<i64>) -> Option<i64> {
let schedule = self.schedules.first()?;
match self.kind {
ProfileKind::Absolute => {
let start = schedule.start.map(epoch)?;
(at >= start).then_some(at - start)
}
ProfileKind::Relative => {
let start = transaction_start?;
(at >= start).then_some(at - start)
}
ProfileKind::Recurring => {
let start = schedule.start.map(epoch)?;
let period = self.recurrency?.seconds();
if at < start {
return None;
}
Some((at - start) % period)
}
}
}
fn limit_at(
&self,
at: i64,
transaction_start: Option<i64>,
) -> Option<(Decimal, RateUnit, Option<i32>)> {
if !self.valid_at(at) {
return None;
}
let schedule = self.schedules.first()?;
let offset = self.offset_at(at, transaction_start)?;
let period = schedule.period_at(offset)?;
Some((period.limit, schedule.rate_unit, period.number_phases))
}
}
pub const DEFAULT_PHASES: i32 = 3;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct Supply {
pub voltage: Decimal,
}
impl Default for Supply {
fn default() -> Self {
Self::new(Decimal::from(230))
}
}
impl Supply {
#[must_use]
pub const fn new(voltage: Decimal) -> Self {
Self { voltage }
}
#[must_use]
pub fn convert(
self,
limit: Decimal,
from: RateUnit,
to: RateUnit,
phases: Option<i32>,
) -> Option<Decimal> {
if from == to {
return Some(limit);
}
let phases = Decimal::from(phases.unwrap_or(DEFAULT_PHASES).max(1));
let factor = self.voltage.checked_mul(phases)?;
match (from, to) {
(RateUnit::A, RateUnit::W) => limit.checked_mul(factor),
(RateUnit::W, RateUnit::A) => limit.checked_div(factor, CONVERSION_SCALE),
_ => Some(limit),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CompositePeriod {
pub start_period: i64,
pub limit: Option<Decimal>,
pub number_phases: Option<i32>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct CompositeSchedule {
pub evse_id: u32,
pub start: DateTime,
pub duration: i64,
pub rate_unit: RateUnit,
pub periods: Vec<CompositePeriod>,
}
impl CompositeSchedule {
#[must_use]
pub fn fill_gaps(mut self, rated_maximum: impl Into<Decimal>) -> Self {
let rated_maximum = rated_maximum.into();
for period in &mut self.periods {
if period.limit.is_none() {
period.limit = Some(rated_maximum);
}
}
self.periods
.dedup_by(|next, previous| same_step(*previous, *next));
self
}
#[must_use]
pub fn has_gaps(&self) -> bool {
self.periods.iter().any(|period| period.limit.is_none())
}
}
#[derive(Clone, Debug, Default)]
pub struct ProfileStore {
profiles: Vec<Profile>,
pub supply: Supply,
}
impl ProfileStore {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn install(&mut self, profile: Profile) {
self.profiles.retain(|existing| existing.id != profile.id);
self.profiles.push(profile);
}
#[must_use]
pub fn profiles(&self) -> &[Profile] {
&self.profiles
}
pub fn clear(
&mut self,
id: Option<i32>,
evse_id: Option<u32>,
purpose: Option<Purpose>,
stack_level: Option<i32>,
) -> usize {
let before = self.profiles.len();
self.profiles.retain(|profile| {
let matches = id.is_none_or(|id| profile.id == id)
&& evse_id.is_none_or(|evse| profile.evse_id == evse)
&& purpose.is_none_or(|purpose| profile.purpose == purpose)
&& stack_level.is_none_or(|level| profile.stack_level == level);
!matches
});
before - self.profiles.len()
}
pub fn clear_transaction(&mut self, transaction_id: &str) -> usize {
let before = self.profiles.len();
self.profiles
.retain(|profile| profile.transaction_id.as_deref() != Some(transaction_id));
before - self.profiles.len()
}
#[must_use]
pub fn composite(
&self,
evse_id: u32,
from: DateTime,
duration: i64,
rate_unit: RateUnit,
transaction: Option<(&str, DateTime)>,
) -> CompositeSchedule {
let start = epoch(from);
let end = start + duration.max(0);
let transaction_start = transaction.map(|(_, at)| epoch(at));
let applicable: Vec<&Profile> = self
.profiles
.iter()
.filter(|profile| profile.evse_id == 0 || profile.evse_id == evse_id)
.filter(|profile| match profile.purpose {
Purpose::TxProfile | Purpose::PriorityCharging => {
match (&profile.transaction_id, transaction) {
(Some(id), Some((running, _))) => id == running,
(None, Some(_)) => true,
_ => false,
}
}
_ => true,
})
.collect();
let boundaries = Self::boundaries(&applicable, start, end, transaction_start);
let mut periods: Vec<CompositePeriod> = Vec::new();
for at in boundaries {
let effective = self.limit_at(&applicable, at, rate_unit, transaction_start);
let step = CompositePeriod {
start_period: at - start,
limit: effective.map(|(limit, _)| limit),
number_phases: effective.and_then(|(_, phases)| phases),
};
match periods.last() {
Some(previous) if same_step(*previous, step) => {}
None if step.limit.is_none() => {}
_ => periods.push(step),
}
}
CompositeSchedule {
evse_id,
start: from,
duration,
rate_unit,
periods,
}
}
fn boundaries(
profiles: &[&Profile],
start: i64,
end: i64,
transaction_start: Option<i64>,
) -> Vec<i64> {
let mut points: BTreeSet<i64> = BTreeSet::new();
points.insert(start);
for profile in profiles {
for at in [profile.valid_from.map(epoch), profile.valid_to.map(epoch)]
.into_iter()
.flatten()
{
if (start..end).contains(&at) {
points.insert(at);
}
}
let Some(schedule) = profile.schedules.first() else {
continue;
};
let anchors: Vec<i64> = match profile.kind {
ProfileKind::Absolute => schedule.start.map(epoch).into_iter().collect(),
ProfileKind::Relative => transaction_start.into_iter().collect(),
ProfileKind::Recurring => {
let Some(first) = schedule.start.map(epoch) else {
continue;
};
let Some(period) = profile.recurrency.map(Recurrency::seconds) else {
continue;
};
let mut anchors = Vec::new();
let skipped = (start - first).div_euclid(period);
let mut at = first + skipped * period;
while at < end && anchors.len() < 4096 {
anchors.push(at);
at += period;
}
anchors
}
};
for anchor in anchors {
for step in &schedule.periods {
let at = anchor + step.start_period;
if (start..end).contains(&at) {
points.insert(at);
}
}
if let Some(duration) = schedule.duration {
let at = anchor + duration;
if (start..end).contains(&at) {
points.insert(at);
}
}
}
}
points.into_iter().collect()
}
fn limit_at(
&self,
profiles: &[&Profile],
at: i64,
rate_unit: RateUnit,
transaction_start: Option<i64>,
) -> Option<(Decimal, Option<i32>)> {
let leading = |purpose: Purpose| -> Option<(Decimal, Option<i32>)> {
profiles
.iter()
.filter(|profile| profile.purpose == purpose)
.filter_map(|profile| {
profile
.limit_at(at, transaction_start)
.map(|limit| (profile.stack_level, limit))
})
.max_by_key(|(stack_level, _)| *stack_level)
.and_then(|(_, (limit, unit, phases))| {
Some((self.supply.convert(limit, unit, rate_unit, phases)?, phases))
})
};
let session = leading(Purpose::PriorityCharging)
.or_else(|| leading(Purpose::TxProfile))
.or_else(|| leading(Purpose::TxDefaultProfile));
let mut effective = session;
for purpose in [
Purpose::ChargingStationMaxProfile,
Purpose::ChargingStationExternalConstraints,
] {
if let Some((limit, phases)) = leading(purpose) {
effective = Some(match effective {
Some((current, current_phases)) if current <= limit => {
(current, current_phases)
}
_ => (limit, phases),
});
}
}
let generation = leading(Purpose::LocalGeneration);
let lowest_phases = [
Purpose::ChargingStationMaxProfile,
Purpose::ChargingStationExternalConstraints,
]
.into_iter()
.filter_map(|purpose| leading(purpose).and_then(|(_, phases)| phases))
.chain(session.and_then(|(_, phases)| phases))
.chain(generation.and_then(|(_, phases)| phases))
.min();
if let Some((generation, phases)) = generation {
effective = match effective {
Some((current, current_phases)) => Some((
current.checked_add(generation).unwrap_or(current),
current_phases,
)),
None => Some((generation, phases)),
};
}
effective.map(|(limit, _)| (limit, lowest_phases))
}
}
fn same_step(previous: CompositePeriod, next: CompositePeriod) -> bool {
previous.limit == next.limit && previous.number_phases == next.number_phases
}
fn epoch(at: DateTime) -> i64 {
at.timestamp().as_second()
}
#[cfg(test)]
mod tests {
use super::*;
use crate::decimal;
fn at(text: &str) -> DateTime {
DateTime::parse(text).unwrap()
}
fn schedule(rate_unit: RateUnit, steps: &[(i64, Decimal)]) -> Schedule {
Schedule::new(
1,
rate_unit,
steps
.iter()
.map(|(start, limit)| Period::new(*start, *limit))
.collect(),
)
}
#[test]
fn external_constraints_and_local_generation_are_not_the_csmss_to_set() {
assert!(!Purpose::ChargingStationExternalConstraints.settable_by_csms());
assert!(!Purpose::LocalGeneration.settable_by_csms());
for purpose in [
Purpose::ChargingStationMaxProfile,
Purpose::TxDefaultProfile,
Purpose::TxProfile,
Purpose::PriorityCharging,
] {
assert!(purpose.settable_by_csms(), "{purpose:?}");
}
}
#[test]
fn the_composite_uses_the_lowest_phase_count_k01_fr_140() {
let start = at("2024-01-01T00:00:00Z");
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
0,
Purpose::ChargingStationMaxProfile,
ProfileKind::Absolute,
Schedule::new(
1,
RateUnit::A,
alloc::vec![Period::new(0, decimal!(32.0)).phases(1)],
)
.starting(start),
));
store.install(Profile::new(
2,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
Schedule::new(
1,
RateUnit::A,
alloc::vec![Period::new(0, decimal!(16.0)).phases(3)],
)
.starting(start),
));
let composite = store.composite(1, start, 60, RateUnit::A, None);
assert_eq!(
composite.periods,
alloc::vec![CompositePeriod {
start_period: 0,
limit: Some(decimal!(16.0)),
number_phases: Some(1)
}]
);
}
#[test]
fn an_absent_phase_count_converts_as_three_k01_fr_49() {
let supply = Supply::default();
assert_eq!(
supply.convert(decimal!(6900), RateUnit::W, RateUnit::A, None),
Some(decimal!(10.000))
);
assert_eq!(
supply.convert(decimal!(2300), RateUnit::W, RateUnit::A, Some(1)),
Some(decimal!(10.000))
);
}
#[test]
fn a_single_absolute_profile_becomes_its_own_composite() {
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(16.0)), (3600, decimal!(10.0))])
.starting(at("2024-01-01T00:00:00Z")),
));
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 7200, RateUnit::A, None);
assert_eq!(
composite.periods,
alloc::vec![
CompositePeriod {
start_period: 0,
limit: Some(decimal!(16.0)),
number_phases: None
},
CompositePeriod {
start_period: 3600,
limit: Some(decimal!(10.0)),
number_phases: None
},
]
);
}
#[test]
fn the_highest_stack_level_wins_within_a_purpose() {
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(32.0))]).starting(at("2024-01-01T00:00:00Z")),
));
store.install(Profile::new(
2,
5,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(6.0))]).starting(at("2024-01-01T00:00:00Z")),
));
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 60, RateUnit::A, None);
assert_eq!(composite.periods[0].limit, Some(decimal!(6.0)));
}
#[test]
fn the_station_maximum_is_a_ceiling_over_the_session_profile() {
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(32.0))]).starting(at("2024-01-01T00:00:00Z")),
));
store.install(Profile::new(
2,
0,
Purpose::ChargingStationMaxProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(20.0)), (1800, decimal!(40.0))])
.starting(at("2024-01-01T00:00:00Z")),
));
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 3600, RateUnit::A, None);
assert_eq!(composite.periods[0].limit, Some(decimal!(20.0)));
assert_eq!(composite.periods[1].start_period, 1800);
assert_eq!(composite.periods[1].limit, Some(decimal!(32.0)));
}
#[test]
fn a_higher_stack_level_outside_its_window_does_not_shadow_a_lower_one() {
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(32.0))]).starting(at("2024-01-01T00:00:00Z")),
));
store.install(
Profile::new(
2,
5,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(6.0))]).starting(at("2024-01-01T00:00:00Z")),
)
.valid(None, Some(at("2024-01-01T01:00:00Z"))),
);
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 7200, RateUnit::A, None);
assert_eq!(
composite.periods[0].limit,
Some(decimal!(6.0)),
"inside the exception's window it leads"
);
assert_eq!(
composite.periods.last().and_then(|period| period.limit),
Some(decimal!(32.0)),
"outside it, the weekly default leads again: {:?}",
composite.periods
);
}
#[test]
fn local_generation_is_added_on_top_rather_than_minimised() {
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::W, &[(0, decimal!(11_000.0))]).starting(at("2024-01-01T00:00:00Z")),
));
store.install(Profile::new(
2,
0,
Purpose::LocalGeneration,
ProfileKind::Absolute,
schedule(RateUnit::W, &[(0, decimal!(4_000.0))]).starting(at("2024-01-01T00:00:00Z")),
));
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 60, RateUnit::W, None);
assert_eq!(composite.periods[0].limit, Some(decimal!(15_000.0)));
}
#[test]
fn a_tx_profile_replaces_the_default_rather_than_combining_with_it() {
let mut store = ProfileStore::new();
store.install(Profile::new(
1,
9,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(6.0))]).starting(at("2024-01-01T00:00:00Z")),
));
store.install(
Profile::new(
2,
0,
Purpose::TxProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(32.0))]).starting(at("2024-01-01T00:00:00Z")),
)
.for_transaction("tx-1"),
);
let without = store.composite(1, at("2024-01-01T00:00:00Z"), 60, RateUnit::A, None);
assert_eq!(without.periods[0].limit, Some(decimal!(6.0)));
let with = store.composite(
1,
at("2024-01-01T00:00:00Z"),
60,
RateUnit::A,
Some(("tx-1", at("2024-01-01T00:00:00Z"))),
);
assert_eq!(with.periods[0].limit, Some(decimal!(32.0)));
}
#[test]
fn a_recurring_profile_repeats_within_the_window() {
let mut store = ProfileStore::new();
store.install(
Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Recurring,
schedule(RateUnit::A, &[(0, decimal!(6.0)), (43_200, decimal!(32.0))])
.starting(at("2024-01-01T00:00:00Z")),
)
.recurring(Recurrency::Daily),
);
let composite = store.composite(1, at("2024-01-03T00:00:00Z"), 172_800, RateUnit::A, None);
let limits: Vec<Option<Decimal>> = composite.periods.iter().map(|p| p.limit).collect();
assert_eq!(
limits,
alloc::vec![
Some(decimal!(6.0)),
Some(decimal!(32.0)),
Some(decimal!(6.0)),
Some(decimal!(32.0))
]
);
assert_eq!(composite.periods[1].start_period, 43_200);
assert_eq!(composite.periods[2].start_period, 86_400);
}
#[test]
fn a_validity_window_bounds_a_profile() {
let mut store = ProfileStore::new();
store.install(
Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(16.0))]).starting(at("2024-01-01T00:00:00Z")),
)
.valid(None, Some(at("2024-01-01T01:00:00Z"))),
);
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 7200, RateUnit::A, None);
assert_eq!(composite.periods.len(), 2, "{:?}", composite.periods);
assert_eq!(composite.periods[0].limit, Some(decimal!(16.0)));
assert_eq!(composite.periods[1].start_period, 3600);
assert_eq!(composite.periods[1].limit, None);
assert!(composite.has_gaps());
let filled = composite.fill_gaps(decimal!(32.0));
assert_eq!(filled.periods[1].limit, Some(decimal!(32.0)));
assert!(!filled.has_gaps());
}
#[test]
fn limits_convert_between_amperes_and_watts() {
let mut store = ProfileStore::new();
store.supply = Supply::new(decimal!(230.0));
store.install(Profile::new(
1,
0,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(16.0))]).starting(at("2024-01-01T00:00:00Z")),
));
let composite = store.composite(1, at("2024-01-01T00:00:00Z"), 60, RateUnit::W, None);
assert_eq!(composite.periods[0].limit, Some(decimal!(11040)));
}
#[test]
fn clearing_by_criteria_removes_only_what_matches() {
let mut store = ProfileStore::new();
for id in 1..=3 {
store.install(
Profile::new(
id,
id,
Purpose::TxDefaultProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(16.0))])
.starting(at("2024-01-01T00:00:00Z")),
)
.on_evse(u32::try_from(id).unwrap()),
);
}
assert_eq!(store.clear(None, Some(2), None, None), 1);
assert_eq!(store.profiles().len(), 2);
assert_eq!(
store.clear(None, None, None, None),
2,
"no criteria clears everything"
);
}
#[test]
fn an_ended_transaction_takes_its_profile_with_it() {
let mut store = ProfileStore::new();
store.install(
Profile::new(
1,
0,
Purpose::TxProfile,
ProfileKind::Absolute,
schedule(RateUnit::A, &[(0, decimal!(32.0))]).starting(at("2024-01-01T00:00:00Z")),
)
.for_transaction("tx-1"),
);
assert_eq!(store.clear_transaction("tx-2"), 0);
assert_eq!(store.clear_transaction("tx-1"), 1);
assert!(store.profiles().is_empty(), "{:?}", store.profiles());
}
}