ERP by industry

Food-distribution ERP: manage batches, expiry and traceability

The short answer

A food distribution inventory workflow records each batch and its expiry date when stock arrives, sends out the batch that expires first, and keeps the batch number on every delivery and return. That lets you answer two questions fast: what is about to expire, and which customers received a given batch. ERPNext covers this with standard batch, expiry, unit and return features. Van sales, route planning and cold-chain monitoring need separately agreed scope.

What a food distribution inventory workflow must do

Our interest

StarterKit sells ERPNext services, so we have a commercial interest in this topic. The workflow below uses standard ERPNext features and a fictional company.

A food distributor runs the same chain as any trading company: purchase order, receipt, sales order, delivery, invoice and payment. Our trading-company guide walks through it. Food adds batches, expiry dates and the need to trace stock both ways.

A batch is a group of units made or packed together, sharing one batch number and one expiry date. Track batches from the day stock arrives, and the system can answer these questions without a paper search.

Questions a food distributor needs to answer
QuestionWhere the answer comes from
Which batch did this supplier deliver, and when?The purchase receipt, with the batch on each line.
What expires in the next 30 days?A batch expiry report.
Which batch should go out first?Picking based on expiry date.
Which customers received batch X?Stock reports filtered by batch, linked to each delivery note.
Where did this returned stock come from?The return, created against the original delivery.

New to ERPNext? Start with what ERPNext is.

What UAE food rules ask of a distributor

Federal Law No. 10 of 2015 on food safety says a food business must trace the food it handles, know where it was stored and distributed, and keep the records. It must also withdraw and recall unsafe food and tell the authorities (Article 9, items 8 and 10). The law applies across the UAE, including free zones (Article 19).

Government source: Federal Law No. 10 of 2015 on food safety, Arabic text published by Dubai Municipality, Articles 9 and 19.

Its executive regulations, Cabinet Resolution No. 26 of 2017, list the records (Article 18):

  • Supplier records: supplier name and address, date received, type and quantity of food, and batch number.
  • Customer records: customer name and address, date supplied, type and quantity of food, and batch number. Businesses that sell directly to consumers are excluded from this part.
  • How long to keep them (minimum periods): at least 180 days from supply for perishable food with a use-by date, food with a shelf life under three months, and food sold directly to consumers. At least 180 days after expiry for food with a shelf life over five years. At least five years in all other cases.
  • Other duties: give copies to the authority on request, and review your traceability procedures regularly.

The same regulations ban handling expired food without written permission from the competent authority, which is the local food safety authority in each emirate (Articles 1 and 9(2)(b)). Disposal must be safe and needs that authority to be informed first (Article 11).

Government source: Cabinet Resolution No. 26 of 2017, Arabic text published by Dubai Municipality, Articles 1, 9, 11 and 18.

This is our English summary of the Arabic texts, not legal advice. Your emirate’s authority may set further rules, so confirm your duties with it.

Set up items for batch and expiry tracking

Batch tracking is switched on per item, using these settings:

  • Has Batch No. Every stock transaction for the item must then carry a batch.
  • Automatically Create New Batch and Batch Number Series. ERPNext names new batches for you, or you type the supplier’s batch number.
  • Has Expiry Date. Each batch then holds an expiry date.
  • Shelf Life In Days. The number of days after which a batch is unusable.

Source: ERPNext documentation: Item, sections 3.3 and 3.7.

Decide these settings before your first transaction. The documentation says you cannot switch on batch tracking for an item that already has transactions.

One detail matters for distributors. If a batch has no expiry date, ERPNext calculates it from the item’s shelf life, counted from the manufacturing date. With no manufacturing date, the code uses the date of the document that created the batch, or today’s date. If your stock arrives some time after production, that date will be later than the real expiry. Enter the expiry printed on the carton.

Source: ERPNext source code (version 16): Batch, expiry date calculation.

By default, batch items cannot go below zero, even where negative stock is allowed. The documentation says this applies from version 15. Version 16 adds a separate batch setting, off by default.

Source: ERPNext documentation: Batch.

Cartons, packs and pieces

A distributor may buy in cartons and sell both cartons and single pieces. ERPNext handles this with one stock unit and a list of other units, each with a conversion factor. Set the stock unit to the smallest unit you count, then add the larger ones.

Fictional example: date syrup, 400 g bottle
UnitConversion to stock unitUsed for
Piece (stock unit)1Stock counts and small orders.
Carton12Buying from the supplier and most sales.

The item can carry a default purchase unit and a default sales unit, so the right unit appears on each document. A price is always tied to one unit, so you can keep a carton price and a piece price for the same item. If a unit should never be split, tick “Must be whole number” on that unit, and ERPNext rejects fractions.

Source: ERPNext documentation: Item Price, section 2.1.

Source: ERPNext documentation: UOM.

Clean units also help with e-invoicing. Each line of a UAE e-invoice carries the invoiced quantity and a unit of measure code.

Government source: MoF: UAE electronic invoice mandatory fields v1.1, fields 40 and 41.

Receive stock: the batch starts here

The batch record starts at the purchase receipt, so this step needs the most care. The documentation describes creating the batch first, with the supplier’s batch number and printed expiry date, then selecting it on the receipt. If ERPNext creates batches automatically on submit, check each new batch’s expiry, for the reason above.

Source: ERPNext documentation: Batch, transacting items with batches.

Source: ERPNext documentation: Serial and Batch Bundle.

Three controls help at this point:

  • Rejected warehouse. Damaged or below-standard goods go to a separate warehouse, not into sellable stock.
  • Quality inspection. If the item requires one, ERPNext will not submit the receipt until the inspection is recorded.
  • Return to supplier. A purchase return created from the original receipt sends goods back and keeps the link.

Source: ERPNext documentation: Purchase Receipt.

Source: ERPNext documentation: Purchase Return.

In the current code, ERPNext also refuses a receipt or delivery of a batch whose expiry date has passed. We cover the exceptions in the returns section below.

Source: ERPNext source code (version 16): stock ledger entry, batch expiry check.

Sell and deliver: earliest expiry first

Food stock should leave in order of expiry, not in order of arrival. This is called first expired, first out. In ERPNext, the setting “Pick Serial / Batch Based On” in Stock Settings offers FIFO, LIFO and Expiry. The default in the code is FIFO (first in, first out), so change it to Expiry.

Source: ERPNext documentation: Serial and Batch Bundle, outward entries.

Source: ERPNext source code (version 16): Stock Settings defaults.

The usual chain is sales order, pick list, delivery note and sales invoice. For batched items, the documentation says the pick list selects the warehouse where the batch is nearest to expiry. When you choose a batch on a transaction, ERPNext filters the list by expiry date against the posting date.

Source: ERPNext documentation: Pick List.

Source: ERPNext documentation: Batch, transacting items with batches.

One order can mix units. A fictional grocery orders 10 cartons and 6 pieces of the same item. The order has two lines, and stock falls by 126 pieces in total.

One gap to plan for: a customer may only accept stock with a minimum number of days left. We found no standard field for a customer’s minimum remaining shelf life in the version 16 code. Treat that as configured or custom work. For the invoice step, see the sales invoice tutorial.

Returns, damaged stock and expired stock

Create a customer return from the original delivery note. ERPNext copies the items and rates, keeps the link to the sale, and asks for the returned batch. Return quantities show as negative numbers.

  • Return delivery note. Brings the goods back into a warehouse you choose. It does not credit the customer.
  • Credit note. A return sales invoice reduces what the customer owes. Tick “Update Stock” only if no return delivery note has already received the goods, or stock is counted twice.

Source: ERPNext documentation: Sales Return.

Send returns to a holding warehouse first. Good stock moves back to sellable stock; damaged or expired stock moves to a write-off warehouse. A stock entry does both: “Material Transfer” moves stock between warehouses, and “Material Issue” takes it out.

Source: ERPNext documentation: Stock Entry.

The expiry check does not block these steps. In the code, returns and stock entries that issue or transfer stock skip it, so you can take back an expired batch and move it out. Disposal itself is regulated, as explained above.

If your business is in scope for UAE e-invoicing, a tax credit note must be issued as an electronic credit note. Read the UAE e-invoicing guide and how ERPNext e-invoicing works.

Government source: MoF: UAE Electronic Invoicing Guidelines v2.0, section 6.2.

Trace a batch to customers and back to the supplier

Tracing works because every receipt, delivery, return and transfer stores the batch. Four standard reports do the work:

  • Stock Ledger. Filter by batch number. Each row is one movement with its document number, so you can open each delivery note and see the customer and address.
  • Serial and Batch Summary. Lists the documents that moved a batch, with dates, warehouses and quantities.
  • Batch-wise Balance History. Shows opening, in, out and balance quantities for each batch by warehouse.
  • Batch Item Expiry Status. Shows each batch with its expiry date and days left.

Source: ERPNext documentation: Stock Ledger report.

Source: ERPNext documentation: managing batch-wise inventory.

Source: ERPNext source code (version 16): stock report filters and columns.

Where ERPNext keeps the records the regulations list
RecordWhere it lives in ERPNext
Supplier name and addressThe supplier record and its linked address, selected on the purchase receipt.
Date received, type, quantity and batchThe purchase receipt date and its item lines.
Customer name and addressThe customer and the shipping address on the delivery note.
Date supplied, type, quantity and batchThe delivery note date and its item lines.

Run a practice recall every few months. Pick a batch, list every customer who received it, and time it. That shows your traceability procedure works, which the regulations ask you to review.

What is standard and what needs separate scope

Not everything a distributor wants is a standard ERPNext feature. Label each need before you agree a price.

Food distribution needs and how ERPNext covers them
NeedStatusNotes
Batch and expiry trackingStandard, configuredItem settings decided before go-live.
Earliest expiry picked firstStandard settingChange Pick Serial / Batch Based On to Expiry.
Cartons and piecesStandard, configuredUnits, conversion factors and prices per unit.
Returns and credit notesStandardHolding and write-off warehouses are configured.
Batch trace reportsStandardTest them on your own data.
Customer minimum shelf lifeConfigured or customNo standard field found.
Van salesSeparate scopeAgree it in writing.
Route planningSeparate scopeERPNext has a Delivery Trip record that can use Google Maps to estimate arrival times and order stops. Setup is agreed separately.
Cold-chain temperature monitoringSeparate scopeNot covered in this guide.
UAE e-invoice exchangeNeeds an accredited providerERPNext is not an accredited provider.

Source: ERPNext documentation: Delivery Trip.

StarterKit includes access to all ERPNext modules, but access does not mean every module is configured for your business. Setup, data work and any custom work are agreed in a written quote.

Test it before you commit: three tasks

Ask any supplier, including us, to run these three tasks on a test system with your own items.

  1. Receive a batchPost a purchase receipt for a fictional supplier with a batch number and expiry date. Check that the batch shows the expiry you typed, not a calculated date.
  2. Sell mixed unitsCreate one sales order with cartons and pieces of the same item. Check that the pick list chooses the earliest expiry and that stock falls by the right number of pieces.
  3. Trace a returnReturn part of the delivery, then filter the Stock Ledger by the batch. Check that you can see the receipt, the delivery and the return, with the supplier and customer on each document.

Then try to deliver a batch after its expiry date, and note what happens.

We have not run these three tasks for this guide. What we describe above comes from the ERPNext documentation and the version 16 source code, read on 17 November 2026. Behaviour can differ by version and by setup, so run the tasks yourself before you rely on them.

Our ERPNext trial checklist lists more checks to run before you sign.

Prepared by the StarterKit team. Regulatory statements link to UAE government sources. Examples and suggested work plans are labelled separately; they do not determine your business’s legal or tax position. Check the linked decisions for the full conditions and later changes.