--- a/src/database/db_product.cpp Tue Jul 26 19:46:44 2022 +0200 +++ b/src/database/db_product.cpp Fri Jul 29 13:12:26 2022 +0200 @@ -364,14 +364,20 @@ h.cohumulone = obj["h_cohumulone"].toDouble(); h.myrcene = obj["h_myrcene"].toDouble(); h.total_oil = obj["h_total_oil"].toDouble(); + h.utilisation = obj["h_utilisation"].toDouble(); + h.bu_factor = obj["h_bu_factor"].toDouble(); /* Check and update inventory */ - yquery.prepare("SELECT inventory FROM inventory_hops WHERE name=:name AND origin=:origin"); + yquery.prepare("SELECT inventory,utilisation,bu_factor FROM inventory_hops WHERE name=:name AND origin=:origin"); yquery.bindValue(":name", h.name); yquery.bindValue(":origin", h.origin); yquery.exec(); if (yquery.first()) { h.avail = true; - h.inventory = yquery.value(0).toDouble(); + h.inventory = yquery.value("inventory").toDouble(); + if (h.utilisation == 0) + h.utilisation = yquery.value("utilisation").toDouble(); + if (h.bu_factor == 0) + h.bu_factor = yquery.value("bu_factor").toDouble(); } prod->hops.append(h); } @@ -891,6 +897,8 @@ obj.insert("h_cohumulone", round(prod->hops.at(i).cohumulone * 100) / 100); obj.insert("h_myrcene", round(prod->hops.at(i).myrcene * 100) / 100); obj.insert("h_total_oil", round(prod->hops.at(i).total_oil * 100) / 100); + obj.insert("h_utilisation", round(prod->hops.at(i).utilisation * 100) / 100); + obj.insert("h_bu_factor", round(prod->hops.at(i).bu_factor * 100) / 100); // qDebug() << "hops_Json" << i << obj; array.append(obj); /* Append this object */ }