Can get the list of movements of an account

This commit is contained in:
2025-04-19 21:45:40 +02:00
parent 08538c3911
commit 811e885bf3
3 changed files with 21 additions and 3 deletions

View File

@ -45,9 +45,9 @@ impl UpdateMovementQuery {
}
// Check for conflict with other movements
if let Ok(_) =
get_by_account_label_amount_time(self.account_id, &self.label, self.amount, self.time)
.await
if get_by_account_label_amount_time(self.account_id, &self.label, self.amount, self.time)
.await
.is_ok()
{
return Ok(Some(
"A movement taken at the same time with the same label and the same amount already exists!",
@ -120,3 +120,10 @@ pub async fn get_by_account_label_amount_time(
)
.get_result(&mut db()?)?)
}
/// Get the list of movements of an account
pub async fn get_list_account(account_id: AccountID) -> anyhow::Result<Vec<Movement>> {
Ok(movements::table
.filter(movements::dsl::account_id.eq(account_id.0))
.get_results(&mut db()?)?)
}