src/database/db_product.cpp

changeset 373
b02aca4e926c
parent 294
afc763d9fd89
child 384
d68826df8b63
equal deleted inserted replaced
372:d9c78eb19728 373:b02aca4e926c
362 h.humulene = obj["h_humulene"].toDouble(); 362 h.humulene = obj["h_humulene"].toDouble();
363 h.caryophyllene = obj["h_caryophyllene"].toDouble(); 363 h.caryophyllene = obj["h_caryophyllene"].toDouble();
364 h.cohumulone = obj["h_cohumulone"].toDouble(); 364 h.cohumulone = obj["h_cohumulone"].toDouble();
365 h.myrcene = obj["h_myrcene"].toDouble(); 365 h.myrcene = obj["h_myrcene"].toDouble();
366 h.total_oil = obj["h_total_oil"].toDouble(); 366 h.total_oil = obj["h_total_oil"].toDouble();
367 h.utilisation = obj["h_utilisation"].toDouble();
368 h.bu_factor = obj["h_bu_factor"].toDouble();
367 /* Check and update inventory */ 369 /* Check and update inventory */
368 yquery.prepare("SELECT inventory FROM inventory_hops WHERE name=:name AND origin=:origin"); 370 yquery.prepare("SELECT inventory,utilisation,bu_factor FROM inventory_hops WHERE name=:name AND origin=:origin");
369 yquery.bindValue(":name", h.name); 371 yquery.bindValue(":name", h.name);
370 yquery.bindValue(":origin", h.origin); 372 yquery.bindValue(":origin", h.origin);
371 yquery.exec(); 373 yquery.exec();
372 if (yquery.first()) { 374 if (yquery.first()) {
373 h.avail = true; 375 h.avail = true;
374 h.inventory = yquery.value(0).toDouble(); 376 h.inventory = yquery.value("inventory").toDouble();
377 if (h.utilisation == 0)
378 h.utilisation = yquery.value("utilisation").toDouble();
379 if (h.bu_factor == 0)
380 h.bu_factor = yquery.value("bu_factor").toDouble();
375 } 381 }
376 prod->hops.append(h); 382 prod->hops.append(h);
377 } 383 }
378 qDebug() << "hops" << prod->hops.size(); 384 qDebug() << "hops" << prod->hops.size();
379 } 385 }
889 obj.insert("h_humulene", round(prod->hops.at(i).humulene * 100) / 100); 895 obj.insert("h_humulene", round(prod->hops.at(i).humulene * 100) / 100);
890 obj.insert("h_caryophyllene", round(prod->hops.at(i).caryophyllene * 100) / 100); 896 obj.insert("h_caryophyllene", round(prod->hops.at(i).caryophyllene * 100) / 100);
891 obj.insert("h_cohumulone", round(prod->hops.at(i).cohumulone * 100) / 100); 897 obj.insert("h_cohumulone", round(prod->hops.at(i).cohumulone * 100) / 100);
892 obj.insert("h_myrcene", round(prod->hops.at(i).myrcene * 100) / 100); 898 obj.insert("h_myrcene", round(prod->hops.at(i).myrcene * 100) / 100);
893 obj.insert("h_total_oil", round(prod->hops.at(i).total_oil * 100) / 100); 899 obj.insert("h_total_oil", round(prod->hops.at(i).total_oil * 100) / 100);
900 obj.insert("h_utilisation", round(prod->hops.at(i).utilisation * 100) / 100);
901 obj.insert("h_bu_factor", round(prod->hops.at(i).bu_factor * 100) / 100);
894 // qDebug() << "hops_Json" << i << obj; 902 // qDebug() << "hops_Json" << i << obj;
895 array.append(obj); /* Append this object */ 903 array.append(obj); /* Append this object */
896 } 904 }
897 QJsonDocument doc; 905 QJsonDocument doc;
898 doc.setArray(array); 906 doc.setArray(array);

mercurial