diff -r 242a68fa7186 -r 33bb98c33e6a src/database/db_recipe.cpp --- a/src/database/db_recipe.cpp Mon Jun 13 16:47:52 2022 +0200 +++ b/src/database/db_recipe.cpp Mon Jun 13 17:34:51 2022 +0200 @@ -251,67 +251,67 @@ QJsonObject obj = yeasts.array().at(i).toObject(); Yeasts y; /* First some defaults for newer fields. */ - y.y_tolerance = y.y_harvest_time = y.y_pitch_temperature = y.y_zymocide = 0; - y.y_sta1 = y.y_bacteria = y.y_harvest_top = y.y_pofpos = false; - y.y_gr_hl_lo = 50; - y.y_sg_lo = 1.04; - y.y_gr_hl_hi = 80; - y.y_sg_hi = 1.08; + y.tolerance = y.harvest_time = y.pitch_temperature = y.zymocide = 0; + y.sta1 = y.bacteria = y.harvest_top = y.pofpos = false; + y.gr_hl_lo = 50; + y.sg_lo = 1.04; + y.gr_hl_hi = 80; + y.sg_hi = 1.08; /* Now get what we have got */ - y.y_name = obj["y_name"].toString(); - y.y_laboratory = obj["y_laboratory"].toString(); - y.y_product_id = obj["y_product_id"].toString(); - y.y_amount = obj["y_amount"].toDouble(); - y.y_type = obj["y_type"].toInt(); - y.y_form = obj["y_form"].toInt(); - y.y_min_temperature = obj["y_min_temperature"].toDouble(); - y.y_max_temperature = obj["y_max_temperature"].toDouble(); - y.y_flocculation = obj["y_flocculation"].toInt(); - y.y_attenuation = obj["y_attenuation"].toDouble(); - y.y_cells = obj["y_cells"].toDouble(); - y.y_tolerance = obj["y_tolerance"].toDouble(); - y.y_inventory = obj["y_inventory"].toDouble(); - y.y_use = obj["y_use"].toInt(); - y.y_sta1 = obj["y_sta1"].toInt() ? true:false; - y.y_bacteria = obj["y_bacteria"].toInt() ? true:false; - y.y_harvest_top = obj["y_harvest_top"].toInt() ? true:false; - y.y_harvest_time = obj["y_harvest_time"].toInt(); - y.y_pitch_temperature = obj["y_pitch_temperature"].toDouble(); - y.y_pofpos = obj["y_pofpos"].toInt() ? true:false; - y.y_zymocide = obj["y_zymocide"].toInt(); - y.y_gr_hl_lo = obj["y_gr_hl_lo"].toInt(); - y.y_sg_lo = obj["y_sg_lo"].toDouble(); - y.y_gr_hl_hi = obj["y_gr_hl_hi"].toInt(); - y.y_sg_hi = obj["y_sg_hi"].toDouble(); - y.y_cost = obj["y_cost"].toDouble(); + y.name = obj["y_name"].toString(); + y.laboratory = obj["y_laboratory"].toString(); + y.product_id = obj["y_product_id"].toString(); + y.amount = obj["y_amount"].toDouble(); + y.type = obj["y_type"].toInt(); + y.form = obj["y_form"].toInt(); + y.min_temperature = obj["y_min_temperature"].toDouble(); + y.max_temperature = obj["y_max_temperature"].toDouble(); + y.flocculation = obj["y_flocculation"].toInt(); + y.attenuation = obj["y_attenuation"].toDouble(); + y.cells = obj["y_cells"].toDouble(); + y.tolerance = obj["y_tolerance"].toDouble(); + y.inventory = obj["y_inventory"].toDouble(); + y.use = obj["y_use"].toInt(); + y.sta1 = obj["y_sta1"].toInt() ? true:false; + y.bacteria = obj["y_bacteria"].toInt() ? true:false; + y.harvest_top = obj["y_harvest_top"].toInt() ? true:false; + y.harvest_time = obj["y_harvest_time"].toInt(); + y.pitch_temperature = obj["y_pitch_temperature"].toDouble(); + y.pofpos = obj["y_pofpos"].toInt() ? true:false; + y.zymocide = obj["y_zymocide"].toInt(); + y.gr_hl_lo = obj["y_gr_hl_lo"].toInt(); + y.sg_lo = obj["y_sg_lo"].toDouble(); + y.gr_hl_hi = obj["y_gr_hl_hi"].toInt(); + y.sg_hi = obj["y_sg_hi"].toDouble(); + y.cost = obj["y_cost"].toDouble(); - if (y.y_tolerance == 0 || y.y_cells == 0) { // More and better tests? + if (y.tolerance == 0 || y.cells == 0) { // More and better tests? /* * Possible data upgrade needed. */ yquery.prepare("SELECT tolerance,cells,sta1,bacteria,harvest_top,harvest_time,pitch_temperature," "pofpos,zymocide,gr_hl_lo,sg_lo,gr_hl_hi,sg_hi " "FROM inventory_yeasts WHERE name=:name AND laboratory=:laboratory AND product_id=:product_id"); - yquery.bindValue(":name", y.y_name); - yquery.bindValue(":laboratory", y.y_laboratory); - yquery.bindValue(":product_id", y.y_product_id); + yquery.bindValue(":name", y.name); + yquery.bindValue(":laboratory", y.laboratory); + yquery.bindValue(":product_id", y.product_id); yquery.exec(); if (yquery.first()) { - y.y_tolerance = yquery.value(0).toDouble(); - y.y_cells = yquery.value(1).toDouble(); - y.y_sta1 = yquery.value(2).toInt() ? true:false; - y.y_bacteria = yquery.value(3).toInt() ? true:false; - y.y_harvest_top = yquery.value(4).toInt() ? true:false; - y.y_harvest_time = yquery.value(5).toInt(); - y.y_pitch_temperature = yquery.value(6).toDouble(); - y.y_pofpos = yquery.value(7).toInt() ? true:false; - y.y_zymocide = yquery.value(8).toInt(); - y.y_gr_hl_lo = yquery.value(9).toInt(); - y.y_sg_lo = yquery.value(10).toDouble(); - y.y_gr_hl_hi = yquery.value(11).toInt(); - y.y_sg_hi = yquery.value(12).toDouble(); + y.tolerance = yquery.value(0).toDouble(); + y.cells = yquery.value(1).toDouble(); + y.sta1 = yquery.value(2).toInt() ? true:false; + y.bacteria = yquery.value(3).toInt() ? true:false; + y.harvest_top = yquery.value(4).toInt() ? true:false; + y.harvest_time = yquery.value(5).toInt(); + y.pitch_temperature = yquery.value(6).toDouble(); + y.pofpos = yquery.value(7).toInt() ? true:false; + y.zymocide = yquery.value(8).toInt(); + y.gr_hl_lo = yquery.value(9).toInt(); + y.sg_lo = yquery.value(10).toDouble(); + y.gr_hl_hi = yquery.value(11).toInt(); + y.sg_hi = yquery.value(12).toDouble(); } else { - qDebug() << y.y_name << y.y_product_id << "not found for upgrade"; + qDebug() << y.name << y.product_id << "not found for upgrade"; } } reci->yeasts.append(y); @@ -569,32 +569,32 @@ QJsonArray array; for (int i = 0; i < reci->yeasts.size(); i++) { QJsonObject obj; - obj.insert("y_name", reci->yeasts.at(i).y_name); - obj.insert("y_laboratory", reci->yeasts.at(i).y_laboratory); - obj.insert("y_product_id", reci->yeasts.at(i).y_product_id); - obj.insert("y_amount", round(reci->yeasts.at(i).y_amount * 10000) / 10000); - obj.insert("y_type", reci->yeasts.at(i).y_type); - obj.insert("y_form", reci->yeasts.at(i).y_form); - obj.insert("y_min_temperature", round(reci->yeasts.at(i).y_min_temperature * 10) / 10); - obj.insert("y_max_temperature", round(reci->yeasts.at(i).y_max_temperature * 10) / 10); - obj.insert("y_flocculation", reci->yeasts.at(i).y_flocculation); - obj.insert("y_attenuation", round(reci->yeasts.at(i).y_attenuation * 10) / 10); - obj.insert("y_cells", reci->yeasts.at(i).y_cells); - obj.insert("y_tolerance", round(reci->yeasts.at(i).y_tolerance * 10) / 10); - obj.insert("y_inventory", round(reci->yeasts.at(i).y_inventory * 10000) / 10000); - obj.insert("y_use", reci->yeasts.at(i).y_use); - obj.insert("y_sta1", reci->yeasts.at(i).y_sta1 ? 1:0); - obj.insert("y_bacteria", reci->yeasts.at(i).y_bacteria ? 1:0); - obj.insert("y_harvest_top", reci->yeasts.at(i).y_harvest_top ? 1:0); - obj.insert("y_harvest_time", reci->yeasts.at(i).y_harvest_time); - obj.insert("y_pitch_temperature", round(reci->yeasts.at(i).y_pitch_temperature * 10) / 10); - obj.insert("y_pofpos", reci->yeasts.at(i).y_pofpos ? 1:0); - obj.insert("y_zymocide", reci->yeasts.at(i).y_zymocide); - obj.insert("y_gr_hl_lo", reci->yeasts.at(i).y_gr_hl_lo); - obj.insert("y_sg_lo", round(reci->yeasts.at(i).y_sg_lo * 1000) / 1000); - obj.insert("y_gr_hl_hi", reci->yeasts.at(i).y_gr_hl_hi); - obj.insert("y_sg_hi", round(reci->yeasts.at(i).y_sg_hi * 1000) / 1000); - obj.insert("y_cost", round(reci->yeasts.at(i).y_cost * 1000) / 1000); + obj.insert("y_name", reci->yeasts.at(i).name); + obj.insert("y_laboratory", reci->yeasts.at(i).laboratory); + obj.insert("y_product_id", reci->yeasts.at(i).product_id); + obj.insert("y_amount", round(reci->yeasts.at(i).amount * 10000) / 10000); + obj.insert("y_type", reci->yeasts.at(i).type); + obj.insert("y_form", reci->yeasts.at(i).form); + obj.insert("y_min_temperature", round(reci->yeasts.at(i).min_temperature * 10) / 10); + obj.insert("y_max_temperature", round(reci->yeasts.at(i).max_temperature * 10) / 10); + obj.insert("y_flocculation", reci->yeasts.at(i).flocculation); + obj.insert("y_attenuation", round(reci->yeasts.at(i).attenuation * 10) / 10); + obj.insert("y_cells", reci->yeasts.at(i).cells); + obj.insert("y_tolerance", round(reci->yeasts.at(i).tolerance * 10) / 10); + obj.insert("y_inventory", round(reci->yeasts.at(i).inventory * 10000) / 10000); + obj.insert("y_use", reci->yeasts.at(i).use); + obj.insert("y_sta1", reci->yeasts.at(i).sta1 ? 1:0); + obj.insert("y_bacteria", reci->yeasts.at(i).bacteria ? 1:0); + obj.insert("y_harvest_top", reci->yeasts.at(i).harvest_top ? 1:0); + obj.insert("y_harvest_time", reci->yeasts.at(i).harvest_time); + obj.insert("y_pitch_temperature", round(reci->yeasts.at(i).pitch_temperature * 10) / 10); + obj.insert("y_pofpos", reci->yeasts.at(i).pofpos ? 1:0); + obj.insert("y_zymocide", reci->yeasts.at(i).zymocide); + obj.insert("y_gr_hl_lo", reci->yeasts.at(i).gr_hl_lo); + obj.insert("y_sg_lo", round(reci->yeasts.at(i).sg_lo * 1000) / 1000); + obj.insert("y_gr_hl_hi", reci->yeasts.at(i).gr_hl_hi); + obj.insert("y_sg_hi", round(reci->yeasts.at(i).sg_hi * 1000) / 1000); + obj.insert("y_cost", round(reci->yeasts.at(i).cost * 1000) / 1000); array.append(obj); /* Append this object */ } QJsonDocument doc;