DWUVE75BTYH56NS2I4J2XSPCU3XTJBJQB567CC3BFMEMFUIE4KLQC #[derive(Clone, Copy, Debug)]struct CurrencyExchangeInformation {exchange_rate: Amount,foreign_total: Amount,}impl CurrencyExchangeInformation {fn extract_from_description(description: &str) -> Result<Option<Self>, Error> {description.find("Original ").map(|index| {let (foreign_total, rest) = split_off_amount(&description[index + 9..])?;
let exchange_rate = if let Some(rest) = rest.strip_prefix("1 Euro=") {split_off_amount(rest)?.0} else if let Some(rest) = rest.strip_prefix("Kurs ") {let (amount, _rest) = rest.split_once(' ').unwrap_or((rest, ""));Amount::new(Decimal::from_str_exact(amount).map_err(|_| todo!())?,foreign_total.commodity,)} else {todo!("handle {rest:?}")};Ok(Self {exchange_rate,foreign_total,})}).transpose()}}
fn split_off_amount(v: &str) -> Result<(Amount, &str), Error> {let index = v.find(' ').ok_or_else(|| todo!())?;let index = v[index + 1..].find(' ').map_or(v.len(), |new| new + index + 1);let (amount, rest) = v.split_at(index);let amount = parse_german_amount(amount)?;// Remove whitespace from the beginninglet rest = rest.trim_start();Ok((amount, rest))}