src/database/db_product.cpp

changeset 282
d1d208a857b0
parent 280
efc213beb605
child 283
242a68fa7186
--- a/src/database/db_product.cpp	Mon Jun 13 12:26:27 2022 +0200
+++ b/src/database/db_product.cpp	Mon Jun 13 15:47:16 2022 +0200
@@ -346,32 +346,32 @@
 		for (int i = 0; i < hops.array().size(); i++) {
 		    QJsonObject obj = hops.array().at(i).toObject();
 		    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();
-		    h.h_cost = obj["h_cost"].toDouble();
-		    h.h_type = obj["h_type"].toInt();
-		    h.h_form = obj["h_form"].toInt();
-		    h.h_useat = obj["h_useat"].toInt();
-		    h.h_time = obj["h_time"].toInt();
-		    h.h_alpha = obj["h_alpha"].toDouble();
-		    h.h_beta = obj["h_beta"].toDouble();
-		    h.h_hsi = obj["h_hsi"].toDouble();
-		    h.h_humulene = obj["h_humulene"].toDouble();
-		    h.h_caryophyllene = obj["h_caryophyllene"].toDouble();
-		    h.h_cohumulone = obj["h_cohumulone"].toDouble();
-		    h.h_myrcene = obj["h_myrcene"].toDouble();
-		    h.h_total_oil = obj["h_total_oil"].toDouble();
+		    h.avail = false;
+		    h.inventory = 0;
+		    h.name = obj["h_name"].toString();
+		    h.origin = obj["h_origin"].toString();
+		    h.amount = obj["h_amount"].toDouble();
+		    h.cost = obj["h_cost"].toDouble();
+		    h.type = obj["h_type"].toInt();
+		    h.form = obj["h_form"].toInt();
+		    h.useat = obj["h_useat"].toInt();
+		    h.time = obj["h_time"].toInt();
+		    h.alpha = obj["h_alpha"].toDouble();
+		    h.beta = obj["h_beta"].toDouble();
+		    h.hsi = obj["h_hsi"].toDouble();
+		    h.humulene = obj["h_humulene"].toDouble();
+		    h.caryophyllene = obj["h_caryophyllene"].toDouble();
+		    h.cohumulone = obj["h_cohumulone"].toDouble();
+		    h.myrcene = obj["h_myrcene"].toDouble();
+		    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.bindValue(":name", h.name);
+                    yquery.bindValue(":origin", h.origin);
                     yquery.exec();
                     if (yquery.first()) {
-                        h.h_avail = true;
-                        h.h_inventory = yquery.value(0).toDouble();
+                        h.avail = true;
+                        h.inventory = yquery.value(0).toDouble();
                     }
 		    prod->hops.append(h);
 		}
@@ -875,22 +875,22 @@
         QJsonArray array;
         for (int i = 0; i < prod->hops.size(); i++) {
                 QJsonObject obj;
-		obj.insert("h_name", prod->hops.at(i).h_name);
-                obj.insert("h_origin", prod->hops.at(i).h_origin);
-		obj.insert("h_amount", round(prod->hops.at(i).h_amount * 100000) / 100000);
-		obj.insert("h_cost", round(prod->hops.at(i).h_cost * 100) / 100);
-		obj.insert("h_type", prod->hops.at(i).h_type);
-		obj.insert("h_form", prod->hops.at(i).h_form);
-		obj.insert("h_useat", prod->hops.at(i).h_useat);
-		obj.insert("h_time", round(prod->hops.at(i).h_time));
-		obj.insert("h_alpha", round(prod->hops.at(i).h_alpha * 100) / 100);
-		obj.insert("h_beta", round(prod->hops.at(i).h_beta * 100) / 100);
-		obj.insert("h_hsi", round(prod->hops.at(i).h_hsi * 100) / 100);
-		obj.insert("h_humulene", round(prod->hops.at(i).h_humulene * 100) / 100);
-		obj.insert("h_caryophyllene", round(prod->hops.at(i).h_caryophyllene * 100) / 100);
-		obj.insert("h_cohumulone", round(prod->hops.at(i).h_cohumulone * 100) / 100);
-		obj.insert("h_myrcene", round(prod->hops.at(i).h_myrcene * 100) / 100);
-		obj.insert("h_total_oil", round(prod->hops.at(i).h_total_oil * 100) / 100);
+		obj.insert("h_name", prod->hops.at(i).name);
+                obj.insert("h_origin", prod->hops.at(i).origin);
+		obj.insert("h_amount", round(prod->hops.at(i).amount * 100000) / 100000);
+		obj.insert("h_cost", round(prod->hops.at(i).cost * 100) / 100);
+		obj.insert("h_type", prod->hops.at(i).type);
+		obj.insert("h_form", prod->hops.at(i).form);
+		obj.insert("h_useat", prod->hops.at(i).useat);
+		obj.insert("h_time", round(prod->hops.at(i).time));
+		obj.insert("h_alpha", round(prod->hops.at(i).alpha * 100) / 100);
+		obj.insert("h_beta", round(prod->hops.at(i).beta * 100) / 100);
+		obj.insert("h_hsi", round(prod->hops.at(i).hsi * 100) / 100);
+		obj.insert("h_humulene", round(prod->hops.at(i).humulene * 100) / 100);
+		obj.insert("h_caryophyllene", round(prod->hops.at(i).caryophyllene * 100) / 100);
+		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);
 //		qDebug() << "hops_Json" << i << obj;
                 array.append(obj);      /* Append this object */
         }

mercurial