diff -r 62b8d701cd88 -r 1091fd9feffe src/EditProduct.cpp --- a/src/EditProduct.cpp Fri Apr 29 20:29:26 2022 +0200 +++ b/src/EditProduct.cpp Fri Apr 29 21:42:00 2022 +0200 @@ -411,6 +411,8 @@ QJsonObject obj = hops.array().at(i).toObject(); //qDebug() << i << obj; Hops h; + h.h_avail = false; + h.h_inventory = 0; h.h_name = obj["h_name"].toString(); h.h_origin = obj["h_origin"].toString(); h.h_amount = obj["h_amount"].toDouble(); @@ -427,6 +429,15 @@ h.h_cohumulone = obj["h_cohumulone"].toDouble(); h.h_myrcene = obj["h_myrcene"].toDouble(); h.h_total_oil = obj["h_total_oil"].toDouble(); + /* Check and update inventory */ + yquery.prepare("SELECT inventory FROM inventory_hops WHERE name=:name AND origin=:origin"); + yquery.bindValue(":name", h.h_name); + yquery.bindValue(":origin", h.h_origin); + yquery.exec(); + if (yquery.first()) { + h.h_avail = true; + h.h_inventory = yquery.value(0).toDouble(); + } product->hops.append(h); } qDebug() << "hops" << product->hops.size();