diff -r 69a033e099a2 -r 62b8d701cd88 src/EditProduct.cpp --- a/src/EditProduct.cpp Fri Apr 29 17:07:35 2022 +0200 +++ b/src/EditProduct.cpp Fri Apr 29 20:29:26 2022 +0200 @@ -341,6 +341,8 @@ QJsonObject obj = fermentables.array().at(i).toObject(); //qDebug() << i << obj; Fermentables f; + f.f_inventory = 0; + f.f_avail = false; f.f_name = obj["f_name"].toString(); f.f_origin = obj["f_origin"].toString(); f.f_supplier = obj["f_supplier"].toString(); @@ -366,6 +368,16 @@ if (f.f_adjust_to_total_100) product->fermentables_use100 = true; percentcheck += f.f_percentage; + /* Check and update inventory */ + yquery.prepare("SELECT inventory FROM inventory_fermentables WHERE name=:name AND supplier=:supplier AND origin=:origin"); + yquery.bindValue(":name", f.f_name); + yquery.bindValue(":supplier", f.f_supplier); + yquery.bindValue(":origin", f.f_origin); + yquery.exec(); + if (yquery.first()) { + f.f_avail = true; + f.f_inventory = yquery.value(0).toDouble(); + } product->fermentables.append(f); } qDebug() << "fermentables" << product->fermentables.size() << percentcheck;