Only evaluate serving name in summary when serving is used

This commit is contained in:
Christopher C. Wells 2021-03-02 20:02:20 -08:00
parent 73022ac167
commit 905635c022
1 changed files with 7 additions and 5 deletions

View File

@ -187,6 +187,7 @@ class JournalEntryController extends Controller
// Update summary
$unit = $ingredient['unit'];
if ($item instanceof Food) {
if ($unit === 'serving') {
if (empty($item->serving_unit) && empty($item->serving_unit_name)) {
$unit = null;
}
@ -194,6 +195,7 @@ class JournalEntryController extends Controller
$unit = $item->serving_unit_formatted;
}
}
}
$entries[$entry_key]->summary .= (!empty($entries[$entry_key]->summary) ? ', ' : null);
$entries[$entry_key]->summary .= "{$ingredient['amount']} {$unit} {$item->name}";
}