# A lot record that traces one step back and one step forward

A green coffee lot opens as a record titled by its origin, with the sack's tag and its codes at the top. Beside it stand where the lot came from and its EUDR state, and under it every batch roasted from the lot and every customer who got the coffee, so tracing a lot takes one page, even after it is used up.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/screens/lot-traceability/

*Lot GL-2618 of the demo's roastery, rendered when the site was built from the kit's own components, with the demo's data.*

A live screen, rendered from the kit's components on the page: https://meadowstack.com/screens/lot-traceability/

Open it in the live demo: https://meadowstack.com/demo/?lang=en#/fernhill/zelena-kava/zk-2618

From the example app [An app for a roastery with an online shop](https://meadowstack.com/examples/coffee-roastery-production/).

## One step back, one step forward

The EU's General Food Law asks a food business to name who supplied it and the businesses it supplied (Regulation 178/2002, Article 18). The lot record holds both ends on one page:

- **Back**: the producer (Mutovu washing station), the region and country, the variety, altitude, process and harvest, the importer and the day the sacks arrived.
- **Forward**: every batch roasted from the lot, green kilos into roasted kilos (15 kg into 12.9 kg for RB-1300), and every customer who got the coffee with their order numbers. The demo lists the online shop's customers as well as the businesses the law asks about.
- **What is left**: 46 kg on rack A3, a meter that says it lasts 10 days of a target 21, and the 12 kg the [roast plan](https://meadowstack.com/screens/roast-plan/) takes on Monday 7 December.

A lot with nothing left keeps its page and says why: it stays for tracing its batches and its customers.

## The sack's tag and the EUDR facts

The tag leads the record. It is the kit's `Paper` with `variant="label"`: the same facts as the properties beside it, the lot number in a QR code and a barcode drawn as SVG from the number, and a PDF for a sack whose tag has torn off. Because the tag is drawn from the lot's data, the tag and the record cannot disagree.

Under the EU deforestation regulation (Regulation 2023/1115), coffee is a relevant commodity, the due diligence statement gives the geolocation of all plots of land where it grew, and the EU's information system returns a reference number for each statement. The record keeps who placed the coffee on the market, the reference and verification numbers, and the plots: 168 plots on 52 ha for this lot, whose reference the importer has not sent yet.

## The next step is what this person can do

`NextStep` heads the side column, and it names one thing: receive a delivery that is on its way, request more when the stock runs low, add a missing EUDR reference, record the arrival cupping, or a quiet line with a check when nothing waits. Each case asks the permission table first. Only the owner and the accountant write EUDR references (`green.eudr`), so the owner sees "Add the reference" on this lot, and the roaster sees "The stock lasts 10 days, nothing is waiting."

It is a record screen ([the record pattern](https://meadowstack.com/patterns/record/)): titled by what people call the lot, the lot number a small eyebrow, the stock state a glyph with its word. Under 1024px the next step and the facts come first, then the tag, the batches and the customers.

## What AI coding tools get wrong here

- **A table of lot numbers**: an id, a quantity and a date, with no way to see where the coffee went. Here the trace both ways is part of the record: a roasted batch links to its own page, a customer to their order.
- **A tag pasted in as an image**: a picture of a label that drifts from the data the first time a field changes. `Paper` draws the label from the same fields as the properties, and the PDF prints from them too.
- **Every action for everyone**: an "Add the reference" button the roaster can press and the save then refuses. In Meadowstack a component asks `<Can>` or `useCan`, which read the module's `permissions.ts`; the api asks the same table, and the next step skips what the person may not do ([permissions](https://meadowstack.com/patterns/permissions/)).

## The sack's tag, drawn from the lot

*The demo hands the lot's facts to the kit's Paper label, which draws the QR code and the barcode from the lot number and prints the same tag as a PDF.*

From `apps/demo/src/modules/green/components/lot-record.tsx` in the Meadowstack repository:

```tsx
const labelFields: PaperField[] = [
  { id: "origin", label: tx("Původ", "Origin"), value: `${lot.region}, ${lot.country}` },
  { id: "variety", label: tx("Odrůda", "Variety"), value: lot.variety },
  { id: "process", label: tx("Zpracování", "Process"), value: lot.process },
  { id: "harvest", label: tx("Sklizeň", "Harvest"), value: lot.harvest },
  { id: "sacks", label: tx("Pytle", "Sacks"), value: `${bagsLabel(lot.bags)} × ${kg(lot.bagKg)}` },
  { id: "received", label: tx("Přijato", "Received"), value: formatDate(lot.receivedAt) },
];
const sackTag = (
  <div className="flex max-w-sm flex-col gap-3">
    <Paper
      variant="label"
      title={lot.name}
      number={lot.code}
      issuer={tx(`${lot.producer}, dovozce ${lot.supplier}`, `${lot.producer}, imported by ${lot.supplier}`)}
      fields={labelFields}
      pdf={{
        name: tx(`Štítek dávky ${lot.code}`, `Lot label ${lot.code}`),
        markdown: () =>
          [
            `# ${lot.name} ${lot.code}`,
            "",
            tx(`${lot.producer}, dovozce ${lot.supplier}`, `${lot.producer}, imported by ${lot.supplier}`),
            "",
            ...labelFields.map((field) => `**${String(field.label)}:** ${String(field.value)}  `),
          ].join("\n"),
      }}
    />
```

## A next step only for those who may take it

*The missing EUDR reference becomes the lot's next step only for people the permission table lets write it: the owner and the accountant.*

From `apps/demo/src/modules/green/components/lot-record.tsx` in the Meadowstack repository:

```tsx
if (lot.kgLeft > 0 && lot.eudr.state === "missing" && can("green.eudr"))
  return (
    <NextStep
      action={
        <Button variant="primary" className="w-fit" onClick={() => open("eudr", lot)}>
          {tx("Doplnit referenci", "Add the reference")}
        </Button>
      }
    >
      {tx(
        `${lot.eudr.operator} ještě neposlal referenční číslo prohlášení o náležité péči. Vyžádejte si ho a zapište.`,
        `${lot.eudr.operator} has not sent the due diligence statement's reference number yet. Ask for it and write it down.`,
      )}
    </NextStep>
```

## Questions

### What does one step back, one step forward mean for a roastery?

The EU's General Food Law asks a food business to name who supplied it and which businesses it supplied. For a lot of green coffee that is the producer and the importer on one side, and on the other the batches roasted from the lot and the cafés and shops that got them.

### Can a used-up lot still be traced?

Yes. A lot with nothing left keeps its page and says so: it stays for tracing its batches and its customers.

### Who can write the EUDR reference number?

In the demo, the owner and the accountant. The roaster sees the same lot without the button, and the api refuses the change for anyone the permission table leaves out.

### What is on the sack's tag?

The coffee, the lot number, the producer and the importer, the origin, variety, process and harvest, the sacks and the day they arrived, with the lot number in a QR code and a barcode. It downloads as a PDF for a sack whose tag has torn off.

### Does the lot record work on a phone?

Yes. Under 1024px it is one column: the next step and the facts first, then the tag, the batches and the customers.

## Sources

- [Regulation (EC) No 178/2002, the General Food Law, Article 18 on traceability (EUR-Lex)](https://eur-lex.europa.eu/eli/reg/2002/178/oj), checked 2 December 2026
- [Regulation (EU) 2023/1115 on deforestation-free products, Articles 2, 9 and 33 (EUR-Lex)](https://eur-lex.europa.eu/eli/reg/2023/1115/oj), checked 2 December 2026

## Related

- [An app for a roastery with an online shop](https://meadowstack.com/examples/coffee-roastery-production/) (Example app)
- [A driver record that says what expires next](https://meadowstack.com/screens/driver-record/) (Screens)
- [A site diary day, prefilled and signed by the right person](https://meadowstack.com/screens/site-diary/) (Screens)
- [A workflow canvas where a test run walks the steps](https://meadowstack.com/screens/workflow-canvas/) (Screens)
- [A month close that knows what each step waits for](https://meadowstack.com/screens/month-end-close/) (Screens)
- [A time-off request waiting for a decision](https://meadowstack.com/screens/time-off-approval/) (Screens)
