This commit is contained in:
JMARyA 2024-09-12 10:58:49 +02:00
parent a8dfe5f0e9
commit 37475460e2
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 93 additions and 2 deletions

View file

@ -43,3 +43,20 @@ impl ItemDB {
ret
}
}
/// Get all item variants which inventory is under the minimum. Returns a Vec with the item variants id and the missing quanity to reach minimum.
pub async fn get_items_without_min_satisfied(db: &ItemDB) -> Vec<(String, i64)> {
let mut ret = Vec::new();
for item in db.items() {
let item = db.get_item(&item).unwrap();
for var in &item.variants {
let res = var.1.is_below_min().await;
if res.0 {
ret.push((format!("{}::{}", var.1.item, var.1.variant), res.1));
}
}
}
ret
}