Skip to content

Seeded reports/cost.md.jinja fails on the seeded Easy Pancakes recipe #851

Open

Description

@dubadub

The cost template that cook seed installs fails on the seeded Easy Pancakes recipe, and the example in docs/report.md doesn't run as written.

Reproduce (CookCLI 0.41.1)

$ cook seed demo && cd demo
$ cook report -t reports/cost.md.jinja -d db "Breakfast/Easy Pancakes.cook"
Error: invalid float literal
   5 > {%- set price = db(ingredient.name ~ '.shopping.price_per_unit') * (ingredient.quantity.value | float) %}
    ingredient: pinch sea salt,

What goes wrong:

  1. Text quantities fail. @sea salt{pinch} and @butter{knob} have text quantities, so | float fails.
  2. Missing price data fails. With numeric quantities only (@eggs{2}, @butter{10%g}), the report still fails, because db/butter doesn't exist: Error: Invalid number:. The seeded db/ has prices for only eggs, flour, milk, olive oil and sea salt, so any recipe that uses another ingredient aborts.
  3. Units aren't converted. price_per_unit is per g or ml, but the template multiplies it by the raw value whatever the unit. @sea salt{1%tbsp} is costed as 1 g.
  4. The docs example can't find the recipe. The example in docs/report.md, cook report -t reports/cost.md.jinja "Easy Pancakes:2" -d ./db …, fails with Recipe not found: Easy Pancakes, because the recipe is in Breakfast/.

Expected

The seeded template runs on every seeded recipe. Ingredients without a price or a numeric quantity are skipped or flagged in the output instead of aborting the report. The docs example should also use a path that exists.

The fix probably needs a default on the db() lookup and a check like ingredient.quantity.value is number, or a numeric-style filter. Unit conversion can come later, but the template should at least say what it assumes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions