diff --git a/cookbook/helper/unit_conversion_helper.py b/cookbook/helper/unit_conversion_helper.py
index 0f78d0f72..92006e1db 100644
--- a/cookbook/helper/unit_conversion_helper.py
+++ b/cookbook/helper/unit_conversion_helper.py
@@ -135,8 +135,9 @@ class UnitConversionHelper:
:param food: base food
:return: converted ingredient object from base amount/unit/food
"""
- if uc.food is None or uc.food == food:
+ if (uc.food is None or uc.food == food) and uc.converted_amount > 0 and uc.base_amount > 0:
if unit == uc.base_unit:
return Ingredient(amount=amount * (uc.converted_amount / uc.base_amount), unit=uc.converted_unit, food=food, space=self.space)
else:
return Ingredient(amount=amount * (uc.base_amount / uc.converted_amount), unit=uc.base_unit, food=food, space=self.space)
+ return None
diff --git a/cookbook/tests/other/test_unit_conversion.py b/cookbook/tests/other/test_unit_conversion.py
index a66eaf6ba..b9df7427d 100644
--- a/cookbook/tests/other/test_unit_conversion.py
+++ b/cookbook/tests/other/test_unit_conversion.py
@@ -185,3 +185,32 @@ def test_unit_conversions(space_1, space_2, u1_s1):
assert next(x for x in conversions if x.unit == unit_kg_space_2) is not None
assert abs(next(x for x in conversions if x.unit == unit_kg_space_2).amount - Decimal(0.1)) < 0.0001
print(conversions)
+
+def test_conversion_with_zero(space_1, space_2, u1_s1):
+ with scopes_disabled():
+ uch = UnitConversionHelper(space_1)
+
+ unit_gram = Unit.objects.create(name='gram', base_unit='g', space=space_1)
+ unit_fantasy = Unit.objects.create(name='Fantasy Unit', base_unit=None, space=space_1)
+
+ food_1 = Food.objects.create(name='Test Food 1', space=space_1)
+
+ ingredient_food_1_gram = Ingredient.objects.create(
+ food=food_1,
+ unit=unit_gram,
+ amount=100,
+ space=space_1,
+ )
+
+ print('\n----------- TEST BASE CUSTOM CONVERSION - TO CUSTOM CONVERSION ---------------')
+ UnitConversion.objects.create(
+ base_amount=0,
+ base_unit=unit_gram,
+ converted_amount=0,
+ converted_unit=unit_fantasy,
+ space=space_1,
+ created_by=auth.get_user(u1_s1),
+ )
+ conversions = uch.get_conversions(ingredient_food_1_gram)
+
+ assert len(conversions) == 1 # conversion always includes the ingredient, if count is 1 no other conversion was found
diff --git a/vue3/src/components/model_editors/UnitConversionEditor.vue b/vue3/src/components/model_editors/UnitConversionEditor.vue
index 1b76a4054..cf97790b6 100644
--- a/vue3/src/components/model_editors/UnitConversionEditor.vue
+++ b/vue3/src/components/model_editors/UnitConversionEditor.vue
@@ -19,11 +19,11 @@
-
+
-
+
@@ -33,11 +33,11 @@
-
+
-
+
diff --git a/vue3/src/locales/ar.json b/vue3/src/locales/ar.json
index ea7f6d8cd..d11ab57f8 100644
--- a/vue3/src/locales/ar.json
+++ b/vue3/src/locales/ar.json
@@ -115,6 +115,7 @@
"Fats": "",
"File": "",
"Files": "",
+ "Finish": "",
"Food": "",
"FoodInherit": "",
"FoodNotOnHand": "",
diff --git a/vue3/src/locales/bg.json b/vue3/src/locales/bg.json
index 174a83ab4..7c442543e 100644
--- a/vue3/src/locales/bg.json
+++ b/vue3/src/locales/bg.json
@@ -112,6 +112,7 @@
"Fats": "Мазнини",
"File": "Файл",
"Files": "Файлове",
+ "Finish": "",
"Food": "Храна",
"FoodInherit": "Хранителни наследствени полета",
"FoodNotOnHand": "Нямате {храна} под ръка.",
diff --git a/vue3/src/locales/ca.json b/vue3/src/locales/ca.json
index 5b3bfc302..6b16bd207 100644
--- a/vue3/src/locales/ca.json
+++ b/vue3/src/locales/ca.json
@@ -154,6 +154,7 @@
"Fats": "Greixos",
"File": "Arxiu",
"Files": "Arxius",
+ "Finish": "",
"First_name": "Nom",
"Food": "Aliment",
"FoodInherit": "Camps Heretats",
diff --git a/vue3/src/locales/cs.json b/vue3/src/locales/cs.json
index 318e80750..207b6cb92 100644
--- a/vue3/src/locales/cs.json
+++ b/vue3/src/locales/cs.json
@@ -153,6 +153,7 @@
"Fats": "Tuky",
"File": "Soubor",
"Files": "Soubory",
+ "Finish": "",
"First_name": "Jméno",
"Food": "Potravina",
"FoodInherit": "Propisovatelná pole potraviny",
diff --git a/vue3/src/locales/da.json b/vue3/src/locales/da.json
index bea126381..0089a6d12 100644
--- a/vue3/src/locales/da.json
+++ b/vue3/src/locales/da.json
@@ -154,6 +154,7 @@
"Fats": "Fedtstoffer",
"File": "Fil",
"Files": "Filer",
+ "Finish": "",
"First_name": "Fornavn",
"Food": "Mad",
"FoodInherit": "Nedarvelige mad felter",
diff --git a/vue3/src/locales/de.json b/vue3/src/locales/de.json
index bbcebf78e..5820f8592 100644
--- a/vue3/src/locales/de.json
+++ b/vue3/src/locales/de.json
@@ -212,6 +212,7 @@
"Fats": "Fette",
"File": "Datei",
"Files": "Dateien",
+ "Finish": "Fertigstellen",
"FinishedAt": "Fertig um",
"First": "Erstes",
"First_name": "Vorname",
diff --git a/vue3/src/locales/el.json b/vue3/src/locales/el.json
index b208ed6fe..6ad633905 100644
--- a/vue3/src/locales/el.json
+++ b/vue3/src/locales/el.json
@@ -154,6 +154,7 @@
"Fats": "Λιπαρά",
"File": "Αρχείο",
"Files": "Αρχεία",
+ "Finish": "",
"First_name": "Όνομα",
"Food": "Φαγητό",
"FoodInherit": "Πεδία φαγητών που κληρονομούνται",
diff --git a/vue3/src/locales/en.json b/vue3/src/locales/en.json
index 085f4ec18..c4eb31346 100644
--- a/vue3/src/locales/en.json
+++ b/vue3/src/locales/en.json
@@ -210,6 +210,7 @@
"Fats": "Fats",
"File": "File",
"Files": "Files",
+ "Finish": "Finish",
"FinishedAt": "Finished at",
"First": "First",
"First_name": "First Name",
diff --git a/vue3/src/locales/es.json b/vue3/src/locales/es.json
index 88e580204..7da2874fa 100644
--- a/vue3/src/locales/es.json
+++ b/vue3/src/locales/es.json
@@ -207,6 +207,7 @@
"Fats": "Grasas",
"File": "Archivo",
"Files": "Archivos",
+ "Finish": "",
"FinishedAt": "Finaliza a las",
"First": "Primero",
"First_name": "Nombre",
diff --git a/vue3/src/locales/fi.json b/vue3/src/locales/fi.json
index c9b648886..d2890b42f 100644
--- a/vue3/src/locales/fi.json
+++ b/vue3/src/locales/fi.json
@@ -151,6 +151,7 @@
"Fats": "Rasvat",
"File": "Tiedosto",
"Files": "Tiedostot",
+ "Finish": "",
"First_name": "Etunimi",
"Food": "Ruoka",
"FoodInherit": "Ruoan perinnölliset kentät",
diff --git a/vue3/src/locales/fr.json b/vue3/src/locales/fr.json
index c967725a5..83f8e9a9c 100644
--- a/vue3/src/locales/fr.json
+++ b/vue3/src/locales/fr.json
@@ -210,6 +210,7 @@
"Fats": "Matières grasses",
"File": "Fichier",
"Files": "Fichiers",
+ "Finish": "",
"FinishedAt": "Terminé à",
"First": "Premier",
"First_name": "Prénom",
diff --git a/vue3/src/locales/he.json b/vue3/src/locales/he.json
index c8869a293..84a7a0e6e 100644
--- a/vue3/src/locales/he.json
+++ b/vue3/src/locales/he.json
@@ -154,6 +154,7 @@
"Fats": "שומנים",
"File": "קובץ",
"Files": "קבצים",
+ "Finish": "",
"First_name": "שם פרטי",
"Food": "אוכל",
"FoodInherit": "ערכי מזון",
diff --git a/vue3/src/locales/hr.json b/vue3/src/locales/hr.json
index 9f6feb3d7..229351d2f 100644
--- a/vue3/src/locales/hr.json
+++ b/vue3/src/locales/hr.json
@@ -154,6 +154,7 @@
"Fats": "Masti",
"File": "Datoteka",
"Files": "Datoteke",
+ "Finish": "",
"First_name": "Ime",
"Food": "Namirnica",
"FoodInherit": "Nasljedna polja namirnice",
diff --git a/vue3/src/locales/hu.json b/vue3/src/locales/hu.json
index 6ef2fec0d..9c4efc5d0 100644
--- a/vue3/src/locales/hu.json
+++ b/vue3/src/locales/hu.json
@@ -137,6 +137,7 @@
"Fats": "Zsírok",
"File": "Fájl",
"Files": "Fájlok",
+ "Finish": "",
"First_name": "Keresztnév",
"Food": "Alapanyag",
"FoodInherit": "",
diff --git a/vue3/src/locales/hy.json b/vue3/src/locales/hy.json
index f87090a0a..a8571b64e 100644
--- a/vue3/src/locales/hy.json
+++ b/vue3/src/locales/hy.json
@@ -69,6 +69,7 @@
"Fats": "",
"File": "",
"Files": "",
+ "Finish": "",
"Food": "Սննդամթերք",
"FromBalance": "",
"Fulltext": "",
diff --git a/vue3/src/locales/id.json b/vue3/src/locales/id.json
index 983a95ff1..cb14f4d98 100644
--- a/vue3/src/locales/id.json
+++ b/vue3/src/locales/id.json
@@ -126,6 +126,7 @@
"Fats": "Lemak",
"File": "Berkas",
"Files": "File",
+ "Finish": "",
"First_name": "",
"Food": "",
"FoodInherit": "",
diff --git a/vue3/src/locales/is.json b/vue3/src/locales/is.json
index f1c0149fa..a11241f45 100644
--- a/vue3/src/locales/is.json
+++ b/vue3/src/locales/is.json
@@ -153,6 +153,7 @@
"Fats": "",
"File": "",
"Files": "",
+ "Finish": "",
"First_name": "",
"Food": "",
"FoodInherit": "",
diff --git a/vue3/src/locales/it.json b/vue3/src/locales/it.json
index 300fb1be4..c13aa1746 100644
--- a/vue3/src/locales/it.json
+++ b/vue3/src/locales/it.json
@@ -211,6 +211,7 @@
"Fats": "Grassi",
"File": "File",
"Files": "File",
+ "Finish": "",
"FinishedAt": "Finito alle",
"First": "Primo",
"First_name": "Nome",
diff --git a/vue3/src/locales/lt.json b/vue3/src/locales/lt.json
index e0bab211b..6cea93143 100644
--- a/vue3/src/locales/lt.json
+++ b/vue3/src/locales/lt.json
@@ -139,6 +139,7 @@
"Fats": "",
"File": "",
"Files": "",
+ "Finish": "",
"First_name": "",
"Food": "",
"FoodInherit": "",
diff --git a/vue3/src/locales/lv.json b/vue3/src/locales/lv.json
index bc5ffffc5..7b1425dda 100644
--- a/vue3/src/locales/lv.json
+++ b/vue3/src/locales/lv.json
@@ -154,6 +154,7 @@
"Fats": "",
"File": "",
"Files": "",
+ "Finish": "",
"First_name": "",
"Food": "",
"FoodInherit": "",
diff --git a/vue3/src/locales/nb_NO.json b/vue3/src/locales/nb_NO.json
index c6066283d..b2f0554be 100644
--- a/vue3/src/locales/nb_NO.json
+++ b/vue3/src/locales/nb_NO.json
@@ -146,6 +146,7 @@
"Fats": "Fett",
"File": "Fil",
"Files": "Filer",
+ "Finish": "",
"First_name": "Fornavn",
"Food": "Matretter",
"FoodInherit": "Arvbare felt for matvarer",
diff --git a/vue3/src/locales/nl.json b/vue3/src/locales/nl.json
index cd150fb83..40975c11d 100644
--- a/vue3/src/locales/nl.json
+++ b/vue3/src/locales/nl.json
@@ -211,6 +211,7 @@
"Fats": "Vetten",
"File": "Bestand",
"Files": "Bestanden",
+ "Finish": "",
"FinishedAt": "Afgerond op",
"First": "Eerste",
"First_name": "Voornaam",
diff --git a/vue3/src/locales/pl.json b/vue3/src/locales/pl.json
index b1c8cb735..2025c70ed 100644
--- a/vue3/src/locales/pl.json
+++ b/vue3/src/locales/pl.json
@@ -180,6 +180,7 @@
"Fats": "Tłuszcze",
"File": "Plik",
"Files": "Pliki",
+ "Finish": "",
"First_name": "Imię",
"Food": "Żywność",
"FoodInherit": "Pola dziedziczone w żywności",
diff --git a/vue3/src/locales/pt.json b/vue3/src/locales/pt.json
index 74f8ddb9b..36d20eda6 100644
--- a/vue3/src/locales/pt.json
+++ b/vue3/src/locales/pt.json
@@ -103,6 +103,7 @@
"Fats": "Gorduras",
"File": "Ficheiro",
"Files": "Ficheiros",
+ "Finish": "",
"Food": "Comida",
"FoodInherit": "Campos herdados por comida",
"FoodNotOnHand": "Não têm {food} disponível.",
diff --git a/vue3/src/locales/pt_BR.json b/vue3/src/locales/pt_BR.json
index 3627d14a2..8d3088082 100644
--- a/vue3/src/locales/pt_BR.json
+++ b/vue3/src/locales/pt_BR.json
@@ -209,6 +209,7 @@
"Fats": "Gorduras",
"File": "Arquivo",
"Files": "Arquivos",
+ "Finish": "",
"FinishedAt": "Finalizado em",
"First": "Primeiro",
"First_name": "Primeiro Nome",
diff --git a/vue3/src/locales/ro.json b/vue3/src/locales/ro.json
index 0d239ed3a..ca80b1134 100644
--- a/vue3/src/locales/ro.json
+++ b/vue3/src/locales/ro.json
@@ -133,6 +133,7 @@
"Fats": "Grăsimi",
"File": "Fișier",
"Files": "Fișiere",
+ "Finish": "",
"First_name": "Prenume",
"Food": "Mâncare",
"FoodInherit": "Câmpuri moștenite de alimente",
diff --git a/vue3/src/locales/ru.json b/vue3/src/locales/ru.json
index bece78624..905b53747 100644
--- a/vue3/src/locales/ru.json
+++ b/vue3/src/locales/ru.json
@@ -210,6 +210,7 @@
"Fats": "Жиры",
"File": "Файл",
"Files": "Файлы",
+ "Finish": "",
"FinishedAt": "Завершено в",
"First": "Первый",
"First_name": "Имя",
diff --git a/vue3/src/locales/sl.json b/vue3/src/locales/sl.json
index 6d9e1ada8..3fac2f5cd 100644
--- a/vue3/src/locales/sl.json
+++ b/vue3/src/locales/sl.json
@@ -210,6 +210,7 @@
"Fats": "Maščobe",
"File": "Datoteka",
"Files": "Datoteke",
+ "Finish": "",
"FinishedAt": "Končano ob",
"First": "Prvi",
"First_name": "Ime",
diff --git a/vue3/src/locales/sv.json b/vue3/src/locales/sv.json
index 88b8f6afd..d37ecca2f 100644
--- a/vue3/src/locales/sv.json
+++ b/vue3/src/locales/sv.json
@@ -191,6 +191,7 @@
"Fats": "Fett",
"File": "Fil",
"Files": "Filer",
+ "Finish": "",
"First_name": "Förnamn",
"Food": "Livsmedel",
"FoodInherit": "Ärftliga livsmedels fält",
diff --git a/vue3/src/locales/tr.json b/vue3/src/locales/tr.json
index 0af83184c..0ce39c37b 100644
--- a/vue3/src/locales/tr.json
+++ b/vue3/src/locales/tr.json
@@ -154,6 +154,7 @@
"Fats": "Yağlar",
"File": "Dosya",
"Files": "Dosyalar",
+ "Finish": "",
"First_name": "İsim",
"Food": "Yiyecek",
"FoodInherit": "Yiyeceğin Devralınabileceği Alanlar",
diff --git a/vue3/src/locales/uk.json b/vue3/src/locales/uk.json
index f29a44dff..60a264a05 100644
--- a/vue3/src/locales/uk.json
+++ b/vue3/src/locales/uk.json
@@ -137,6 +137,7 @@
"Fats": "Жири",
"File": "Файл",
"Files": "Файли",
+ "Finish": "",
"Food": "Їжа",
"FoodInherit": "Пола Успадкованої Їжі",
"FoodNotOnHand": "У вас немає {food} на руках.",
diff --git a/vue3/src/locales/zh_Hans.json b/vue3/src/locales/zh_Hans.json
index 5cd63fc21..46b3f00c5 100644
--- a/vue3/src/locales/zh_Hans.json
+++ b/vue3/src/locales/zh_Hans.json
@@ -154,6 +154,7 @@
"Fats": "脂肪",
"File": "文件",
"Files": "文件",
+ "Finish": "",
"First_name": "名",
"Food": "食物",
"FoodInherit": "食物可继承的字段",
diff --git a/vue3/src/locales/zh_Hant.json b/vue3/src/locales/zh_Hant.json
index 5cbf2e15d..7e4b7dfe4 100644
--- a/vue3/src/locales/zh_Hant.json
+++ b/vue3/src/locales/zh_Hant.json
@@ -209,6 +209,7 @@
"Fats": "脂肪",
"File": "檔案",
"Files": "檔案",
+ "Finish": "",
"FinishedAt": "完成於",
"First": "第一個",
"First_name": "名字",