This commit is contained in:
JMARyA 2024-09-26 13:34:42 +02:00
parent 9468629302
commit 012e5273b1
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -146,8 +146,18 @@ pub async fn unique_field_route(
.ok_or_else(variant_does_not_exist_error)?;
match field {
"origin" => Ok(json!(variant.get_unique_origins().await)),
"destination" => Ok(json!(variant.get_unique_destinations().await)),
"origin" => Ok(json!(variant
.get_unique_origins()
.await
.into_iter()
.filter(|x| !x.starts_with("flow::"))
.collect::<Vec<_>>())),
"destination" => Ok(json!(variant
.get_unique_destinations()
.await
.into_iter()
.filter(|x| !x.starts_with("flow::"))
.collect::<Vec<_>>())),
_ => Err(api_error("Unknown field")),
}
}
@ -196,9 +206,11 @@ pub async fn move_transaction_route(id: &str, form: Json<MoveTransaction>) -> Fa
.await
.ok_or_else(|| api_error("No such transaction"))?
.change()
.location(Some(
reference_of!(Location, new_loc).ok_or_else(|| api_error("No such location"))?,
))
.location(if form.to.is_empty() {
None
} else {
Some(reference_of!(Location, new_loc).ok_or_else(|| api_error("No such location"))?)
})
.update()
.await
.unwrap();