This commit is contained in:
JMARyA 2024-08-27 23:33:09 +02:00
parent 0be7fff77d
commit 74b07a0ea3
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
8 changed files with 107 additions and 10 deletions

View file

@ -128,6 +128,18 @@ impl Variant {
t._id
}
pub async fn stat(&self) -> serde_json::Value {
let active_transactions = self.inventory().await;
// fix : ignores currency
let total_price: f64 = active_transactions.iter().map(|x| x.price.value).sum();
json!({
"amount": active_transactions.len(),
"total_price": total_price
})
}
pub fn api_json(&self) -> serde_json::Value {
json!({
"item": self.item,