src/EditProductTab6.cpp

changeset 200
bbab7d37d12f
parent 199
59b0bdbb2f9f
child 201
b8232133a12d
--- a/src/EditProductTab6.cpp	Wed May 11 11:33:29 2022 +0200
+++ b/src/EditProductTab6.cpp	Wed May 11 21:04:08 2022 +0200
@@ -181,9 +181,6 @@
 	volume = product->batch_size - product->eq_trub_chiller_loss;
     }
 
-    // Also in calcFermentables()
-   //$('#yeast_cells').val(initcells);
-
     if (product->yeasts.size() == 0)
 	return;		// No yeast in product.
 
@@ -206,11 +203,15 @@
 		double f2 = round(f1 / 5 * 1000000.0) / 1000000.0;
      		double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008);
 		qDebug() << "  sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier;
-     		double yeast_grams = round(volume * multiplier * 100.0) / 100.0; // * (100 / dataRecord.starter_viability), 2);
+     		double yeast_grams = round(volume * multiplier * 100.0) / product->starter_viability;
      		double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0;
-		ui->need_grEdit->setValue(yeast_grams);
-		ui->pitch_grEdit->setValue(yeast_gr_hl);
-     		qDebug() << "  need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl;
+		double pitch_gr_hl = round(((product->yeasts.at(i).y_amount * 1000.0) / (volume * 0.01)) * 100.0) / 100.0;
+		ui->dry_needShow->setValue(yeast_grams);
+		ui->dry_pitchrateShow->setValue(yeast_gr_hl);
+		ui->pitch_grShow->setValue(pitch_gr_hl);
+		ui->pitch_grShow->setStyleSheet((pitch_gr_hl < yeast_gr_hl) ? "background-color: red":"");
+
+     		qDebug() << "  need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl << "pitch:" << pitch_gr_hl;
 		return;
 	    } else {
 		/*
@@ -506,18 +507,18 @@
     double max = 100;
 
     for (int i = 0; i < product->yeasts.size(); i++) {
-	if (product->yeasts.at(i).y_use == 0) {
-	    if (product->yeasts.at(i).y_form == 0) {	// Liquid
+	if (product->yeasts.at(i).y_use == YEAST_USE_PRIMARY) {
+	    if (product->yeasts.at(i).y_form == YEAST_FORMS_LIQUID) {
 		vpm = 0.80;
 		max = 97;
-		if (product->yeasts.at(i).y_laboratory == "White Labs") { // PurePitch
+		if (product->yeasts.at(i).y_laboratory == "White Labs") {	// PurePitch
 		    vpm = 0.95;
 		    max = 100;
 		}
-	    } else if (product->yeasts.at(i).y_form == 1) {	// dry
+	    } else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRY) {
 		vpm = 0.998;
 		max = 100;
-	    } else if (product->yeasts.at(i).y_form == 6) {	// dried kveik
+	    } else if (product->yeasts.at(i).y_form == YEAST_FORMS_DRIED) {	// dried kveik
 		vpm = 0.92;
 		max = 100;
 	    } else {	// Slant, Culture, Frozen, Bottle
@@ -676,8 +677,8 @@
     newy.y_laboratory = "";
     newy.y_product_id = "";
     newy.y_amount = 0;
-    newy.y_type = 0;
-    newy.y_form = 0;
+    newy.y_type = YEAST_TYPES_ALE;
+    newy.y_form = YEAST_FORMS_LIQUID;
     newy.y_min_temperature = 0;
     newy.y_max_temperature = 0;
     newy.y_flocculation = 0;
@@ -685,7 +686,7 @@
     newy.y_cells = 0;
     newy.y_tolerance = 0;
     newy.y_inventory = 0;
-    newy.y_use = 0;
+    newy.y_use = YEAST_USE_PRIMARY;
     newy.y_sta1 = false;
     newy.y_bacteria = false;
     newy.y_harvest_top = false;
@@ -730,10 +731,11 @@
 
     qDebug() << "yeast_amount_changed()" << product->yeasts_row << val;
 
-    if (product->yeasts.at(product->yeasts_row).y_form == 0) {
+    if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) {
 	product->yeasts[product->yeasts_row].y_amount = val;
         item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0'));
-    } else if (product->yeasts.at(product->yeasts_row).y_form == 1) {
+    } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) ||
+	       (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) {
 	product->yeasts[product->yeasts_row].y_amount = val / 1000.0;
         item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0'));
     } else {
@@ -810,11 +812,11 @@
     ynameEdit->setText(product->yeasts.at(product->yeasts_row).y_name);
     ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).y_laboratory);
     yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).y_product_id);
-    if (product->yeasts.at(product->yeasts_row).y_form == 0) {
+    if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) {
 	yamountEdit->setDecimals(0);
 	yamountEdit->setSingleStep(1.0);
 	yamountLabel->setText(tr("Total packs:"));
-    } else if (product->yeasts.at(product->yeasts_row).y_form == 1) {
+    } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) {
 	yamountEdit->setDecimals(1);
     	yamountEdit->setSingleStep(0.5);
 	yamountLabel->setText(tr("Amount in gr:"));
@@ -939,9 +941,9 @@
     instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     yamountLabel = new QLabel(dialog);
     yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
-    if (product->yeasts.at(product->yeasts_row).y_form == 0)
+    if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID)
 	yamountLabel->setText(tr("Total packs:"));
-    else if (product->yeasts.at(product->yeasts_row).y_form == 1)
+    else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED))
 	yamountLabel->setText(tr("Amount in gr:"));
     else
 	yamountLabel->setText(tr("Amount in ml:"));
@@ -980,11 +982,11 @@
     yamountEdit->setGeometry(QRect(160, 130, 121, 24));
     yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     yamountEdit->setAccelerated(true);
-    if (product->yeasts.at(product->yeasts_row).y_form == 0) {
+    if (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_LIQUID) {
 	yamountEdit->setDecimals(0);
         yamountEdit->setSingleStep(1.0);
 	yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount);
-    } else if (product->yeasts.at(product->yeasts_row).y_form == 1) {
+    } else if ((product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).y_form == YEAST_FORMS_DRIED)) {
     	yamountEdit->setDecimals(1);
     	yamountEdit->setSingleStep(0.5);
 	yamountEdit->setValue(product->yeasts.at(product->yeasts_row).y_amount * 1000.0);

mercurial