<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Isaac Mwendwa Muthui</title>
    <description>The latest articles on DEV Community by Isaac Mwendwa Muthui (@yit2022).</description>
    <link>https://dev.to/yit2022</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4175357%2Fb991557f-5312-494d-9c6e-ada13e38c838.jpeg</url>
      <title>DEV Community: Isaac Mwendwa Muthui</title>
      <link>https://dev.to/yit2022</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yit2022"/>
    <language>en</language>
    <item>
      <title>Modelling eTIMS Reverse Invoicing for Agro Processors: Supplier Identity, Consent and Immutable Invoices</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Fri, 20 Nov 2026 04:36:13 +0000</pubDate>
      <link>https://dev.to/yit2022/modelling-etims-reverse-invoicing-for-agro-processors-supplier-identity-consent-and-immutable-2nn7</link>
      <guid>https://dev.to/yit2022/modelling-etims-reverse-invoicing-for-agro-processors-supplier-identity-consent-and-immutable-2nn7</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/etims-reverse-invoicing-checklist-agro-processors-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you build or integrate procurement systems for agro processors in Kenya, eTIMS reverse invoicing is a data-modelling problem before it is an API problem. A dairy, tea factory or grain miller pays hundreds or thousands of smallholder farmers per cycle. Under Kenyan tax law, those expenses need eTIMS invoices to be deductible, and KRA's answer is to let the buyer generate the invoice on the farmer's behalf.&lt;/p&gt;

&lt;p&gt;KRA documents two routes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reverse invoicing (system-to-system):&lt;/strong&gt; the buyer's own billing system integrates with eTIMS through OSCU or VSCU, after KRA KYC approval. The system creates a secondary device per seller and notifies the seller by SMS. eTIMS validates seller PIN, onboarding status and VAT status, and runs PIN validation, rate validation and duplicate detection. (&lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/reverse-invoicing" rel="noopener noreferrer"&gt;KRA&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Buyer Initiated Invoicing (BII):&lt;/strong&gt; invoices raised through the KRA profile on eCitizen, *222# or a .csv upload. eTIMS blocks invoices for VAT-registered sellers, and the seller has 30 days to accept or reject via SMS/USSD before automatic rejection. (&lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/buyer-initiated-invoicing" rel="noopener noreferrer"&gt;KRA&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Either way, the integration only works if the records underneath are clean. Five design decisions matter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Supplier master as the single source of identity.&lt;/strong&gt; One &lt;code&gt;supplier&lt;/code&gt; row per farmer with &lt;code&gt;kra_pin&lt;/code&gt;, &lt;code&gt;etims_phone&lt;/code&gt;, &lt;code&gt;vat_registered&lt;/code&gt; (boolean, with a &lt;code&gt;checked_at&lt;/code&gt; date) and &lt;code&gt;consent_id&lt;/code&gt;. Grower numbers become aliases, not keys. A PIN that fails validation should block invoice generation, not be silently skipped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consent as a first-class record.&lt;/strong&gt; KRA requires formal seller consent and a buyer-seller agreement. Store &lt;code&gt;consent&lt;/code&gt; with supplier, date, channel, agreement version and the phone number used. No consent row, no invoice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invoice lines derived from intake, never typed.&lt;/strong&gt; Each invoice line should reference one or more &lt;code&gt;goods_receipt&lt;/code&gt; rows (supplier, date, item, grade, quantity). Price comes from a versioned &lt;code&gt;price_rule&lt;/code&gt; effective for that payment cycle, so rate validation failures can be explained.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutable invoices, corrections as credit notes.&lt;/strong&gt; KRA's guidance is to correct errors with a credit note against the original. Model &lt;code&gt;credit_note&lt;/code&gt; with a foreign key to the invoice and a reason code (quality deduction, weighing error, price revision). Never update a transmitted invoice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explicit invoice state for BII.&lt;/strong&gt; &lt;code&gt;draft → submitted → pending_seller → accepted | rejected | expired&lt;/code&gt; (30 days). Only &lt;code&gt;accepted&lt;/code&gt; invoices support the expense. Reconcile intake quantity, invoiced quantity and paid amount per supplier per cycle, and surface &lt;code&gt;pending_seller&lt;/code&gt; and &lt;code&gt;expired&lt;/code&gt; as exceptions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Records must be kept for at least five years with an audit trail, so append-only event logs on invoice state are worth the storage.&lt;/p&gt;

&lt;p&gt;Below is the full operations checklist I wrote for processors, including the legal basis and an FAQ.&lt;/p&gt;




&lt;p&gt;If your factory buys milk, tea leaf, coffee cherry, grain or fruit from smallholder farmers, you probably pay hundreds or thousands of suppliers who will never run an invoicing system of their own. Under Kenyan tax law, that is your problem as much as theirs: expenses must be backed by eTIMS invoices to be allowed as deductions.&lt;/p&gt;

&lt;p&gt;This week the Kenya Revenue Authority (KRA) again urged farmers who supply factories to use &lt;strong&gt;eTIMS reverse invoicing&lt;/strong&gt;, where the buyer generates the invoice on the farmer's behalf. Speaking at a KRA Citizen Assembly at Murang'a University, the Commissioner for Micro and Small Taxpayers, George Obell, said that a factory buying agricultural produce "can generate an invoice on behalf of the farmer, thereby documenting the transaction in eTIMS", which "enables the purchasing business to support its expense claims with the requisite documentation" (&lt;a href="https://www.tuko.co.ke/business-economy/money/647264-kra-introduces-reverse-invoicing-farmers-meet-etims-requirements/" rel="noopener noreferrer"&gt;Tuko&lt;/a&gt;, &lt;a href="https://www.pulse.co.ke/story/kra-etims-reverse-invoicing-explained-what-farmers-need-to-know-2026111807021331084" rel="noopener noreferrer"&gt;Pulse Kenya&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;This eTIMS reverse invoicing checklist is for dairies, tea and coffee factories, grain millers, fruit and vegetable processors and other agro processors in Kenya that buy produce from many small suppliers. It is a practical operations guide, not tax or legal advice. It reflects KRA's public guidance at the time of writing; confirm the details with KRA or your tax adviser before you change anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  What KRA actually offers: two routes
&lt;/h2&gt;

&lt;p&gt;KRA describes two ways for a buyer to issue an invoice on a seller's behalf.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Reverse invoicing (system-to-system).&lt;/strong&gt; According to &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/reverse-invoicing" rel="noopener noreferrer"&gt;KRA's reverse invoicing page&lt;/a&gt;, large buyers generate invoices for small-scale sellers through their own existing billing system, integrated with eTIMS through OSCU or VSCU. KRA says it is best suited to structured supply chains "such as tea, coffee and similar" ecosystems, and gives the example of a dairy processor generating an eTIMS invoice for each farmer, reflecting the quantity and price of milk delivered. Key conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The buyer must be &lt;strong&gt;approved by KRA through a Know Your Customer (KYC) process&lt;/strong&gt; before implementation.&lt;/li&gt;
&lt;li&gt;The buyer needs a trusted Trader Invoicing System capable of system-to-system integration with eTIMS.&lt;/li&gt;
&lt;li&gt;Seller consent must be &lt;strong&gt;formally obtained&lt;/strong&gt;, and buyer-seller agreements must set out each party's roles. KRA also mentions a Service Level Agreement and a Declaration of Compliance.&lt;/li&gt;
&lt;li&gt;The system creates a &lt;strong&gt;secondary device for each seller&lt;/strong&gt;, and the seller is notified by SMS. Sellers can monitor and validate invoices issued in their name.&lt;/li&gt;
&lt;li&gt;eTIMS validates the seller's PIN, eTIMS onboarding status and VAT registration status. KRA lists PIN validation, rate validation and duplicate detection as controls.&lt;/li&gt;
&lt;li&gt;Errors are corrected with a &lt;strong&gt;credit note&lt;/strong&gt;, not by editing the original invoice.&lt;/li&gt;
&lt;li&gt;The buyer keeps invoice records for &lt;strong&gt;at least five years&lt;/strong&gt;, with an audit trail.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Buyer Initiated Invoicing (BII).&lt;/strong&gt; &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/buyer-initiated-invoicing" rel="noopener noreferrer"&gt;KRA's BII guide&lt;/a&gt; describes a lighter route: the buyer logs into the KRA profile on eCitizen (or &lt;em&gt;222#), selects "Initiate Buyer Invoice" and enters the seller's ID or PIN, date, description, unit price, quantity and amount, or uploads a .csv file. eTIMS checks the seller's PIN and onboarding status and **blocks invoices for VAT-registered sellers&lt;/em&gt;&lt;em&gt;. The seller gets an SMS or USSD prompt and has **30 days to accept or reject&lt;/em&gt;*; after that the invoice is automatically rejected. KRA warns that misuse can lead to immediate deactivation of the buyer's eTIMS.&lt;/p&gt;

&lt;p&gt;The legal basis, as the BII guide sets out, is Section 16(1)(c) of the Income Tax Act (eTIMS invoices as a condition for deducting expenditure) and Section 23A(3A) of the Tax Procedures Act (a purchaser may issue an electronic invoice on behalf of a small-scale seller).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why now.&lt;/strong&gt; Tuko reports that KRA first introduced reverse invoicing on 27 December 2024, and that a KRA public notice of 10 November 2025 confirmed that, from 1 January 2026, income and expenses declared in tax returns would be validated against eTIMS records. That is what turns a missing farmer invoice into a disallowed expense.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 12-point eTIMS reverse invoicing checklist
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Decide and prepare
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Count what you are not invoicing today.&lt;/strong&gt; Pull last month's produce payments and split them into: suppliers who issued their own eTIMS invoice, suppliers covered by a buyer-generated invoice, and the rest. The last group is your exposure. Do it by value as well as by headcount.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Choose the route that fits your volume.&lt;/strong&gt; BII through eCitizen or .csv upload can work for a few dozen occasional sellers. If you pay hundreds of farmers every cycle from a milk, leaf or cherry payroll, KRA designed system-to-system reverse invoicing for you. Write down the decision and the reason.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Name one owner.&lt;/strong&gt; Reverse invoicing touches intake, procurement, finance, IT and the field team who talk to farmers. Give one person responsibility for KYC approval, supplier onboarding, the payment-to-invoice match and exceptions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Start the KRA approval early.&lt;/strong&gt; For the system route, KRA requires KYC approval before implementation and publishes a KYC questionnaire and OSCU/VSCU technical specifications on its reverse invoicing page. Integration and sandbox testing take time; do not plan to go live on the same week you apply.&lt;/p&gt;

&lt;h3&gt;
  
  
  Clean the supplier data
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;5. One supplier record per farmer, with a valid KRA PIN.&lt;/strong&gt; eTIMS validates the seller's PIN and onboarding status. Duplicate grower numbers, names spelt three ways and missing PINs will fail validation or, worse, put a delivery on the wrong person's invoice. Fix the supplier master before you connect anything. Our &lt;a href="https://factoraerp.com/en/blog/item-master-data-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;item master data checklist&lt;/a&gt; covers the same discipline for items.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Flag VAT-registered sellers.&lt;/strong&gt; Under BII, eTIMS blocks buyer-initiated invoices for VAT-registered sellers. Larger growers, transporters and aggregators who are VAT-registered must issue their own invoices. Keep a status field on the supplier record and review it regularly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Record consent and the agreement.&lt;/strong&gt; KRA requires formal seller consent and a buyer-seller agreement. Keep a signed or digitally recorded consent per supplier, dated, with the phone number registered on eTIMS, because that is where notifications go. Explain to farmers in plain language what they will receive and why. Tuko reports that KRA expects buyers, not farmers, to carry the operational cost of the reverse invoicing functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make every invoice match a delivery
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;8. Invoice from intake records, not from the payment list.&lt;/strong&gt; The invoice should reflect what was actually received: supplier, date, product, quantity and price. That means weighbridge or milk-collection records must be complete and tied to the supplier ID at intake. See our &lt;a href="https://factoraerp.com/en/blog/dairy-milk-intake-checklist-kenya" rel="noopener noreferrer"&gt;dairy milk intake checklist&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/supplier-intake-checklist-food-manufacturers-kenya" rel="noopener noreferrer"&gt;supplier intake checklist&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Classify products and prices consistently.&lt;/strong&gt; KRA's conditions require products to be "clearly specified and accurately classified", and the system runs rate validation. Use one item code per produce type and grade, and keep the price list or price-per-kilogram rule that applied to each payment cycle on file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Correct with credit notes, never by editing.&lt;/strong&gt; Rejected deliveries, quality deductions, weighing errors and price revisions happen. KRA's guidance is to generate a credit note against the original invoice. Agree in advance who can raise one and how it is approved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reconcile and prove it
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;11. Reconcile three numbers every cycle.&lt;/strong&gt; Intake quantity, invoiced quantity and paid amount per supplier should agree. Under BII, track pending and rejected invoices: an invoice the farmer has not accepted within 30 days is automatically rejected and does not support your expense. Make this part of your &lt;a href="https://factoraerp.com/en/blog/month-end-close-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;month-end close&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. Keep five years of records and test a sample.&lt;/strong&gt; KRA requires buyers to keep invoice records for at least five years with an audit trail. Each quarter, pick ten random farmer payments and trace each one back to the intake slip, the eTIMS invoice and the consent record. If any link is missing, fix the process, not just the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple test
&lt;/h2&gt;

&lt;p&gt;Pick any farmer payment from last month. Can you show, within ten minutes, the delivery it paid for, the eTIMS invoice issued for it, the farmer's consent and any credit note? If yes, your reverse invoicing is ready to scale. If not, the gap is in your intake and supplier records, and that is where to start.&lt;/p&gt;

&lt;h2&gt;
  
  
  How FactoraERP helps
&lt;/h2&gt;

&lt;p&gt;FactoraERP records goods receipts by supplier, item, lot and date as produce arrives, keeps one supplier and item master, and links receipts to supplier bills and payments, so each payment can be traced to the delivery behind it. See &lt;a href="https://factoraerp.com" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Free download: eTIMS readiness checklist for factories
&lt;/h2&gt;

&lt;p&gt;If you want a free &lt;strong&gt;eTIMS readiness checklist for factories&lt;/strong&gt;, sign up for the FactoraERP Insights newsletter at &lt;a href="https://isaacmuthui.substack.com" rel="noopener noreferrer"&gt;https://isaacmuthui.substack.com&lt;/a&gt;. You will get practical operations notes for food and agro manufacturers. No spam; unsubscribe anytime. For background, read our guide to &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS for food and agro manufacturers in Kenya&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is eTIMS reverse invoicing?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A KRA arrangement in which a registered buyer generates eTIMS tax invoices on behalf of sellers for goods or services it receives. It is designed for sectors with many small-scale suppliers, such as farmers supplying processors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between reverse invoicing and Buyer Initiated Invoicing?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Reverse invoicing runs through the buyer's own billing system integrated with eTIMS (OSCU or VSCU) and requires KRA KYC approval. Buyer Initiated Invoicing is done through the KRA profile on eCitizen, *222# or a .csv upload, and each invoice must be accepted by the seller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does the farmer have to approve each invoice?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Under BII, yes: the seller accepts or rejects through SMS/USSD within 30 days, otherwise the invoice is automatically rejected. Under system-to-system reverse invoicing, the seller gives formal consent to onboarding and is notified of each invoice, and can monitor and validate them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I issue a buyer-initiated invoice for a VAT-registered supplier?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
No. KRA says eTIMS blocks buyer-initiated invoices for VAT-registered sellers. They must issue their own eTIMS invoices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does this matter for my tax return?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Section 16(1)(c) of the Income Tax Act links the deduction of expenses to eTIMS invoices, and Tuko reports that from 1 January 2026 KRA validates expenses declared in returns against eTIMS records. Produce purchases without a valid invoice risk being disallowed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I fix a wrong quantity or price?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Issue a credit note against the original invoice, as KRA's guidance describes, then issue the correct invoice if needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long must records be kept?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KRA's reverse invoicing guidance says at least five years, with an audit trail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who pays for the system?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Tuko reports that KRA stipulates buyers must absorb the operational costs of reverse invoicing rather than passing them on to farmers.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Isaac Muthui, CEO, Tamalaki Business Network Ltd&lt;/em&gt;&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>api</category>
      <category>fintech</category>
    </item>
    <item>
      <title>Modelling EUDR Lot-to-Plot Traceability for Coffee: Plots, Lot Edges and GeoJSON Exports</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Mon, 16 Nov 2026 04:38:18 +0000</pubDate>
      <link>https://dev.to/yit2022/modelling-eudr-lot-to-plot-traceability-for-coffee-plots-lot-edges-and-geojson-exports-5e1i</link>
      <guid>https://dev.to/yit2022/modelling-eudr-lot-to-plot-traceability-for-coffee-plots-lot-edges-and-geojson-exports-5e1i</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/eudr-traceability-checklist-coffee-processors-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you build or integrate systems for coffee processors in Kenya, the EU Deforestation Regulation (EUDR) is a lineage problem. From 30 December 2026, the EU operator that first places coffee on the EU market (usually the importer) must file a due diligence statement that includes the geolocation of &lt;strong&gt;every plot&lt;/strong&gt; the coffee came from, plus the production period and supplier details. Micro and small operators follow on 30 June 2027.&lt;/p&gt;

&lt;p&gt;The field data (plot points and polygons) is increasingly there. What usually breaks is the join between that data and the lots a factory, mill and warehouse actually move. Four design decisions matter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Plots as first-class entities, not grower attributes.&lt;/strong&gt; A grower can farm more than one plot. Store &lt;code&gt;plot&lt;/code&gt; with its own ID, a foreign key to &lt;code&gt;grower&lt;/code&gt;, a geometry, area in hectares and a mapping date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Geometry rules enforced at write time.&lt;/strong&gt; The guidance summarised by the European Coffee Federation: a GPS point with six decimal places is enough for plots up to 4 ha; plots above 4 ha need a polygon. Data must be exportable as GeoJSON.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lot composition as a recorded edge, not a reconstruction.&lt;/strong&gt; When deliveries are pooled into a factory lot, or lots are bulked into a grade, write the edges (input, output, weight) at that moment. Lineage becomes a graph walk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production period on the lot.&lt;/strong&gt; The statement needs a date or time range of production (for coffee, the harvest season). Derive it from the min and max delivery dates and store it with the lot.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  A minimal schema
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;grower&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;grower_id&lt;/span&gt;     &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;-- same ID used in delivery, payment and mapping systems&lt;/span&gt;
  &lt;span class="n"&gt;coop_id&lt;/span&gt;       &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;          &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;plot&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;plot_id&lt;/span&gt;       &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;grower_id&lt;/span&gt;     &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;grower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grower_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;area_ha&lt;/span&gt;       &lt;span class="kt"&gt;NUMERIC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;geom_geojson&lt;/span&gt;  &lt;span class="kt"&gt;JSONB&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;-- Point or Polygon, WGS84&lt;/span&gt;
  &lt;span class="n"&gt;mapped_on&lt;/span&gt;     &lt;span class="kt"&gt;DATE&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;mapped_by&lt;/span&gt;     &lt;span class="kt"&gt;TEXT&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;delivery&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;delivery_id&lt;/span&gt;   &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;grower_id&lt;/span&gt;     &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;grower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grower_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;plot_id&lt;/span&gt;       &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plot_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;-- NULL = unknown plot: treat as a gap&lt;/span&gt;
  &lt;span class="n"&gt;delivered_on&lt;/span&gt;  &lt;span class="kt"&gt;DATE&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;kg_cherry&lt;/span&gt;     &lt;span class="kt"&gt;NUMERIC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;lot&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;lot_id&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;stage&lt;/span&gt;         &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;-- 'factory', 'milled', 'grade', 'bulk'&lt;/span&gt;
  &lt;span class="n"&gt;season&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;produced_from&lt;/span&gt; &lt;span class="kt"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;produced_to&lt;/span&gt;   &lt;span class="kt"&gt;DATE&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Edges: deliveries into factory lots, and lots into downstream lots&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;lot_input&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;lot_id&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;lot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;delivery_id&lt;/span&gt;   &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;delivery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delivery_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;input_lot_id&lt;/span&gt;  &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;lot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;kg&lt;/span&gt;            &lt;span class="kt"&gt;NUMERIC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;CHECK&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delivery_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_lot_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Validating plot geometry
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;validate_plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;geom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;area_ha&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;errs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;geom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;six_dp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;repr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;area_ha&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"Polygon"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;errs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"plot &amp;gt; 4 ha must be a Polygon"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"Point"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;lon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;geom&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"coordinates"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;six_dp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;six_dp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;errs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"point needs 6 decimal places"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"Polygon"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ring&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;geom&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"coordinates"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ring&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;ring&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;ring&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;errs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"polygon ring must be closed with &amp;gt;= 4 positions"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;errs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"unsupported geometry {t}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;errs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add overlap checks between plots (in PostGIS, &lt;code&gt;ST_Overlaps&lt;/code&gt; on a geometry column) and flag implausible areas against the recorded &lt;code&gt;area_ha&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Walking the lineage
&lt;/h2&gt;

&lt;p&gt;Given a bag's grade lot, a recursive query collects every delivery, and so every plot, upstream:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="no"&gt;RECURSIVE&lt;/span&gt; &lt;span class="nf"&gt;up&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="s1"&gt;'GRADE-AB-2026-0141'&lt;/span&gt;
  &lt;span class="k"&gt;UNION&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input_lot_id&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;lot_input&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input_lot_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delivery_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;grower_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delivered_on&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kg&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;lot_input&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;up&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lot_id&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delivery_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;delivery&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delivery_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delivery_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any row with &lt;code&gt;plot_id IS NULL&lt;/code&gt; is a traceability gap you must resolve before the lot goes into an EU contract. Turn the distinct plots into a GeoJSON &lt;code&gt;FeatureCollection&lt;/code&gt; for the buyer, with &lt;code&gt;MIN(delivered_on)&lt;/code&gt; and &lt;code&gt;MAX(delivered_on)&lt;/code&gt; as the production period.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that bite in practice
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ID mismatch.&lt;/strong&gt; Cooperative grower numbers, payment IDs and mapping-tool IDs often differ. Build the crosswalk once and enforce one ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-plot growers.&lt;/strong&gt; If the delivery only records the grower, all of that grower's plots end up in the lot's plot list. Capture plot at intake where you can.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mixed lots.&lt;/strong&gt; Decide whether unmapped deliveries are excluded from EU-bound lots, or tracked as a share. A lot with unknown inputs is hard to sell into the EU after the application date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bulking and blending at the mill.&lt;/strong&gt; New references must keep their input edges. This is where most paper systems lose lineage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retention.&lt;/strong&gt; Keep what you sent, when and to whom, and the buyer's statement reference, for at least five years.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Context and sources
&lt;/h2&gt;

&lt;p&gt;Kenya is classified as low risk under the EU country benchmarking, which allows the operator simplified due diligence (no risk assessment or mitigation unless there are signals of risk). It does not remove the need for plot geolocation. In July 2026, the Kenya Coffee Platform told the EUDR Learning Community for Africa that about 90 percent of active coffee farmers had been mapped, and that the main remaining gap is traceability from cooperative level down to individual plots. That gap is a data model.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;European Commission, EUDR overview and application dates: &lt;a href="https://environment.ec.europa.eu/topics/forests/deforestation/eu-deforestation-regulation-eudr_en" rel="noopener noreferrer"&gt;https://environment.ec.europa.eu/topics/forests/deforestation/eu-deforestation-regulation-eudr_en&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;European Coffee Federation, EUDR Due Diligence guidance (October 2026): &lt;a href="https://www.ecf-coffee.org/wp-content/uploads/2025/05/ECF_EUDR_Due_Diligence_Guidance_Oct2026_FINAL.pdf" rel="noopener noreferrer"&gt;https://www.ecf-coffee.org/wp-content/uploads/2025/05/ECF_EUDR_Due_Diligence_Guidance_Oct2026_FINAL.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;EUDR Learning Community for Africa, Session 1 minutes: &lt;a href="https://eudrafrica.thecosa.org/wp-content/uploads/2026/08/EUDR-Learning-Community-for-Africa_Session-1-Meeting-Minutes-and-QA.pdf" rel="noopener noreferrer"&gt;https://eudrafrica.thecosa.org/wp-content/uploads/2026/08/EUDR-Learning-Community-for-Africa_Session-1-Meeting-Minutes-and-QA.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full 12-point operations checklist for cooperatives, mills and exporters, with an FAQ, is on the FactoraERP blog: &lt;a href="https://factoraerp.com/en/blog/eudr-traceability-checklist-coffee-processors-kenya" rel="noopener noreferrer"&gt;https://factoraerp.com/en/blog/eudr-traceability-checklist-coffee-processors-kenya&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>gis</category>
      <category>compliance</category>
    </item>
    <item>
      <title>Modelling KEBS S-Mark Permits in an ERP: Product-Brand-Site Scope, Expiry Alerts and Label Validation</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Sat, 14 Nov 2026 04:29:54 +0000</pubDate>
      <link>https://dev.to/yit2022/modelling-kebs-s-mark-permits-in-an-erp-product-brand-site-scope-expiry-alerts-and-label-523k</link>
      <guid>https://dev.to/yit2022/modelling-kebs-s-mark-permits-in-an-erp-product-brand-site-scope-expiry-alerts-and-label-523k</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/kebs-standardization-mark-permit-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you build or integrate an ERP for a food factory in Kenya, product certification is a data model problem hiding behind a certificate on the wall. The KEBS Standardization Mark (S-Mark) permit has a scope, a validity window and a label obligation, and most systems model none of them. Four design decisions matter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Scope as a composite key.&lt;/strong&gt; KEBS issues permits per &lt;strong&gt;product, brand and production site&lt;/strong&gt;, and they are not transferable. Model a &lt;code&gt;certification_permit&lt;/code&gt; with &lt;code&gt;(permit_type, permit_number)&lt;/code&gt; as identity and &lt;code&gt;(product, brand, site)&lt;/code&gt; as its scope, then a many-to-many &lt;code&gt;permit_sku&lt;/code&gt; table linking every finished SKU that prints that permit number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validity as a date range with lead-time alerts.&lt;/strong&gt; An S-Mark permit is valid for two years from issue. KEBS says acquisition can take about eight weeks when the manufacturer is ready. Store &lt;code&gt;issued_on&lt;/code&gt;, &lt;code&gt;expires_on&lt;/code&gt; and a &lt;code&gt;renewal_due_on&lt;/code&gt; you compute with your own lead time, and surface the queue to the QA owner.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Label artwork as a validated reference.&lt;/strong&gt; KEBS requires the S-Mark logo and the permit number on the label. Make &lt;code&gt;permit_number&lt;/code&gt; on artwork a foreign key, and validate on approval that the artwork's SKU, brand and site sit inside that permit's scope.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies between permits.&lt;/strong&gt; For wheat flour, dry milled maize products and edible fats and oils, the mandatory Fortification Mark requires an S-Mark or Diamond Mark first. That is a &lt;code&gt;requires_permit_id&lt;/code&gt; relationship, not a note in a spreadsheet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Everything below is the operational checklist those structures support.&lt;/p&gt;

&lt;p&gt;Most food factories treat the KEBS Standardization Mark as a project. You apply, prepare for the inspection, pass, frame the permit and move on. Two years later someone notices the expiry date, or a new brand has been on the shelf for six months using a permit number that was never issued for it.&lt;/p&gt;

&lt;p&gt;The S-Mark does not work like that. KEBS issues a permit &lt;strong&gt;per product, per brand and per production site&lt;/strong&gt;. It is valid for two years. During that time KEBS carries out surveillance inspections in the factory and in the market. And the mark on your label is a statement that every batch carrying it complies with the relevant Kenya Standard, not only the batch that was sampled for the application.&lt;/p&gt;

&lt;p&gt;It is also a live topic. In a public notice dated 16 October 2026, KEBS said it had revoked the certification permits of manufacturers found using permits issued for ordinary juices and drinks to market khat-infused beverages. On 12 November 2026, The Standard reported that KEBS is pushing for stronger regulation of imported and locally made products as Parliament reviews draft rules. KEBS consulted the public earlier this year on draft Standards (Product Certification) Regulations, 2026, which are intended to replace the 1977 permit regulations.&lt;/p&gt;

&lt;p&gt;This KEBS Standardization Mark permit checklist is written for dairies, millers, juice and water bottlers, bakeries, edible oil refiners, snack makers and other Kenyan and East African food and agro processors. It is not a guide to filling in the KIMS application form. KEBS publishes a user manual for that. It is about the operational side: how to know at any moment which permits you hold, what each one covers, when it expires, and whether the batches leaving your gate today could stand up to a surveillance visit.&lt;/p&gt;

&lt;p&gt;It does not replace KEBS guidance, your QA consultant or your legal adviser. Fees, categories and procedures below are as KEBS publishes them at the time of writing; confirm the current position with KEBS before you act.&lt;/p&gt;

&lt;h2&gt;
  
  
  What KEBS and the law actually say
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Standardization Mark scheme.&lt;/strong&gt; KEBS describes the &lt;a href="https://qualityassurance.kebs.go.ke/standardization-mark/" rel="noopener noreferrer"&gt;Standardization Mark&lt;/a&gt; as a mandatory product certification scheme for locally manufactured products under section 10 of the Standards Act (Cap. 496). A permit certifies that a particular product conforms to an approved Kenya Standard or specification. Applications are made on the KIMS portal. KEBS officers inspect the production process, draw samples for analysis at KEBS or accredited/designated laboratories, and agree a scheme of supervision and control with the manufacturer. Once all requirements are met, a permit is issued with a unique permit number. The manufacturer must display the S-Mark logo and the permit number on the product label. The permit is valid for two years, and KEBS carries out surveillance in the factory and the market during that time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Per product, brand and site.&lt;/strong&gt; KEBS's &lt;a href="https://qualityassurance.kebs.go.ke/faqs/" rel="noopener noreferrer"&gt;quality assurance FAQ&lt;/a&gt; states that all permits (Standardization Mark, Fortification Mark and Diamond Mark) are issued per product, brand and manufacturing site, and are not transferable to other sites, branches or firms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fees and categories.&lt;/strong&gt; KEBS's published fee schedule (two years, exclusive of VAT) charges an inspection fee per production site (KSh 40,000 for large, KSh 20,000 for medium and KSh 10,000 for small manufacturing enterprises) plus permit fees. Large enterprises pay KSh 15,000 per product, brand and site; medium and small enterprises' permit fees cover up to three products per site, with KSh 10,000 for each additional product. KEBS places alcoholic beverage manufacturers, animal feed millers, fortified maize and wheat millers, milk pasteurisers and bottlers, and containerised drinking water bottlers in the large category. A change request on a permit costs KSh 1,000 once evaluated and granted. KEBS says all its payments are now made through eCitizen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fortification Mark.&lt;/strong&gt; For wheat flour, dry milled maize products and edible fats and oils, KEBS runs a mandatory fortification logo scheme on behalf of the Ministry of Health. The FAQ says a manufacturer must already hold the S-Mark or Diamond Mark before applying, and lists the fee as KSh 20,000 plus VAT per product, brand and site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test reports.&lt;/strong&gt; KEBS accepts test reports from laboratories accredited to ISO/IEC 17025 (for example by KENAS), after evaluating them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Renewal.&lt;/strong&gt; The &lt;a href="https://kebs.org/wp-content/uploads/2024/10/20230405KIMS-Manufacturer_User_Interface_Manual-QualityAssurance.pdf" rel="noopener noreferrer"&gt;KIMS manufacturer user manual&lt;/a&gt; describes renewal from the "Awarded permits" view: open the permit, choose Renew, update the STA 10 details, submit and pay.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The law.&lt;/strong&gt; Under section 10 of the &lt;a href="https://new.kenyalaw.org/akn/ke/act/1973/17/eng@2024-12-27" rel="noopener noreferrer"&gt;Standards Act (Cap. 496)&lt;/a&gt;, no person may apply a standardization mark to a commodity except under a permit issued by KEBS, and only if that commodity complies with the relevant Kenya Standard or approved specification. The &lt;a href="https://new.kenyalaw.org/akn/ke/act/ln/1977/154/eng@2022-12-31" rel="noopener noreferrer"&gt;Standardization Marks (Permits and Fees) Regulations&lt;/a&gt; say permits are not transferable, that the permit-holder must apply the mark to all commodities that comply, and that KEBS may carry out periodic tests and inspections and may suspend or revoke a permit, for example where the mark is used on commodities that do not comply or fees have not been paid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is changing.&lt;/strong&gt; A &lt;a href="https://aowangaadvocates.com/overview-of-the-draft-standards-product-certification-regulations-2026-kenya/" rel="noopener noreferrer"&gt;summary of the draft Standards (Product Certification) Regulations, 2026&lt;/a&gt; by AO Wanga Advocates describes proposals for a public register of certified products, permit-holder obligations to keep production and quality records, cooperate with inspections, provide samples and report production stoppages, and wider KEBS powers to stop sales, order recalls and suspend or cancel permits. These are drafts. Track the final text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this is an operations problem, not a certificate problem
&lt;/h2&gt;

&lt;p&gt;A permit is a promise about every batch. The places where that promise usually breaks are not the inspection day. They are the ordinary decisions in between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A new flavour or pack is launched under an existing brand and printed with the existing permit number.&lt;/li&gt;
&lt;li&gt;Production moves a product to a second site for a few weeks to meet demand.&lt;/li&gt;
&lt;li&gt;A contract packer runs your brand on their line.&lt;/li&gt;
&lt;li&gt;The label artwork is redrawn and the permit number is dropped or mistyped.&lt;/li&gt;
&lt;li&gt;The sample retention, lab results and release records that a surveillance officer might ask for exist only in a few notebooks.&lt;/li&gt;
&lt;li&gt;Nobody owns the expiry dates, so renewal starts late.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these is a data question: which product, which brand, which site, which permit, which standard, which batch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 12-point KEBS Standardization Mark permit checklist
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Keep one permit register, owned by one person
&lt;/h3&gt;

&lt;p&gt;List every S-Mark, Fortification Mark and Diamond Mark permit in one register: permit number, product, brand, site, Kenya Standard, issue date, expiry date and status. Name one owner, usually the QA manager, with finance as backup. If the only copy of your permits is the framed certificates in reception, you do not have a register.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Map every finished SKU to a permit, or to "no permit needed"
&lt;/h3&gt;

&lt;p&gt;Go through your finished-goods list and link each SKU to the permit that covers it. Where a product is not covered by a mandatory standard, record that decision and its basis. Any SKU with neither a permit nor a recorded decision is a gap. Our &lt;a href="https://factoraerp.com/en/blog/item-master-data-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;item master data checklist&lt;/a&gt; explains why that list must be clean first.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Treat product, brand and site as the permit's scope
&lt;/h3&gt;

&lt;p&gt;Because permits are issued per product, brand and site and are not transferable, any change to one of the three triggers a question before production, not after: does this need a new permit or a change request? Put that question into your new product and new brand approval steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Put expiry dates on a calendar with lead time
&lt;/h3&gt;

&lt;p&gt;Permits run for two years. KEBS says acquisition can take about eight weeks from application when the manufacturer is ready. Set reminders well ahead of each expiry, assign the renewal owner, and check the STA 10 details you will need to update in KIMS. Budget the inspection and permit fees in the year they fall due.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Control the label: mark and permit number
&lt;/h3&gt;

&lt;p&gt;KEBS requires the S-Mark logo and the permit number on the product label. Make the permit number a controlled field in label artwork approval, checked against the register for that exact product, brand and site. Our &lt;a href="https://factoraerp.com/en/blog/label-control-checklist-food-manufacturers-kenya" rel="noopener noreferrer"&gt;label control checklist&lt;/a&gt; covers artwork approval and line checks.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Keep the standard you are certified against on file
&lt;/h3&gt;

&lt;p&gt;Hold a current copy of each Kenya Standard and code of practice your permits refer to (KEBS sells them through its webstore). Note the edition. When a standard is revised, review your specification, tests and labels against it.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Run the tests the standard calls for, at a defined frequency
&lt;/h3&gt;

&lt;p&gt;Write down which parameters you test in-house, which go to an external ISO/IEC 17025 accredited lab, and how often. Keep the reports linked to batch numbers. A permit is easier to defend when you can show results across many batches, not only the application sample. Our &lt;a href="https://factoraerp.com/en/blog/calibration-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;calibration checklist&lt;/a&gt; covers the instruments behind in-house results.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Follow the scheme of supervision and control you signed
&lt;/h3&gt;

&lt;p&gt;The scheme agreed with KEBS sets out your obligations. Keep a copy with the register, list the controls it commits you to, and check them in your &lt;a href="https://factoraerp.com/en/blog/internal-audit-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;internal audits&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Be surveillance-ready on any working day
&lt;/h3&gt;

&lt;p&gt;KEBS surveillance can happen in the factory and in the market. Keep batch production records, QA release decisions, test results and retained samples where they can be produced quickly. Our &lt;a href="https://factoraerp.com/en/blog/food-safety-records-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;food safety records checklist&lt;/a&gt; sets out which records to keep and how.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Add the Fortification Mark where it applies
&lt;/h3&gt;

&lt;p&gt;If you mill maize or wheat flour or refine edible fats and oils, the fortification logo is a separate mandatory scheme that requires an S-Mark or Diamond Mark first. Track it in the same register, with premix purchases, dosing records and fortificant test results linked to batches.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Connect complaints and failures to the permit
&lt;/h3&gt;

&lt;p&gt;A failed test, a customer complaint about quality, or a market sample that fails should be logged against the product, brand, site and permit, with corrective action and evidence. KEBS expects manufacturers to correct nonconformities and confirm the action taken. See our &lt;a href="https://factoraerp.com/en/blog/customer-complaint-handling-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;customer complaint handling checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Review the register every quarter and watch the new regulations
&lt;/h3&gt;

&lt;p&gt;Once a quarter, check the register against live SKUs, labels, sites and brands, and close any gaps. Keep an eye on the draft Standards (Product Certification) Regulations, 2026: if they are finalised, update the register for any new fees, forms and record-keeping obligations.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple permit register template
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;What to record&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Permit type&lt;/td&gt;
&lt;td&gt;S-Mark / Fortification Mark / Diamond Mark&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Permit number&lt;/td&gt;
&lt;td&gt;As issued by KEBS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Product&lt;/td&gt;
&lt;td&gt;Description as on the permit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Brand&lt;/td&gt;
&lt;td&gt;Brand name as on the permit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Production site&lt;/td&gt;
&lt;td&gt;Physical site the permit covers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kenya Standard&lt;/td&gt;
&lt;td&gt;Standard number and edition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linked SKUs&lt;/td&gt;
&lt;td&gt;Every finished SKU printed with this permit number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Issue / expiry&lt;/td&gt;
&lt;td&gt;Dates; renewal reminder date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Owner&lt;/td&gt;
&lt;td&gt;Named person and backup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scheme of supervision&lt;/td&gt;
&lt;td&gt;Location of the signed copy; key obligations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test plan&lt;/td&gt;
&lt;td&gt;Parameters, frequency, in-house or accredited lab&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Surveillance log&lt;/td&gt;
&lt;td&gt;Visit dates, findings, corrective actions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change requests&lt;/td&gt;
&lt;td&gt;Date, change, KEBS decision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Status&lt;/td&gt;
&lt;td&gt;Active / renewal in progress / expired / withdrawn&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you cannot say in one minute which permit covers the product on the pallet in front of you, a surveillance officer cannot either.&lt;/p&gt;

&lt;h2&gt;
  
  
  An illustration
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This is an illustrative example, not a real case.&lt;/em&gt; A juice and water bottler holds S-Mark permits for its mango juice and its bottled water, both made at its main site. Over a year it adds a passion-fruit variant under the same juice brand, launches a second water brand for a supermarket, and moves part of the water production to a newer site to cope with demand. The labels for all three new lines are copied from existing artwork, so each carries an existing permit number.&lt;/p&gt;

&lt;p&gt;On paper the business is "certified". In practice, three lines are carrying a permit number issued for a different product, brand or site. Nobody has broken a rule on purpose. The problem is that the permit register, the SKU list and the label artwork were never linked. Checks 2, 3, 5 and 12 would have raised the question before the first bottle was printed.&lt;/p&gt;

&lt;h2&gt;
  
  
  A minimal schema sketch
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;certification_permit&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;            &lt;span class="kt"&gt;BIGSERIAL&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;permit_type&lt;/span&gt;   &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;CHECK&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;permit_type&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'S_MARK'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'FORTIFICATION'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'DIAMOND'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;permit_number&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;product_desc&lt;/span&gt;  &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;brand_id&lt;/span&gt;      &lt;span class="kt"&gt;BIGINT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;site_id&lt;/span&gt;       &lt;span class="kt"&gt;BIGINT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;site&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;standard_ref&lt;/span&gt;  &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="c1"&gt;-- Kenya Standard number + edition&lt;/span&gt;
  &lt;span class="n"&gt;issued_on&lt;/span&gt;     &lt;span class="kt"&gt;DATE&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;expires_on&lt;/span&gt;    &lt;span class="kt"&gt;DATE&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;requires_permit_id&lt;/span&gt; &lt;span class="kt"&gt;BIGINT&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;certification_permit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;-- e.g. fortification needs S-Mark/D-Mark&lt;/span&gt;
  &lt;span class="n"&gt;status&lt;/span&gt;        &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="s1"&gt;'ACTIVE'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;UNIQUE&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;permit_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;permit_number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;permit_sku&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;permit_id&lt;/span&gt; &lt;span class="kt"&gt;BIGINT&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;certification_permit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;sku_id&lt;/span&gt;    &lt;span class="kt"&gt;BIGINT&lt;/span&gt; &lt;span class="k"&gt;REFERENCES&lt;/span&gt; &lt;span class="nf"&gt;item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;permit_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sku_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- Gap report: finished SKUs with no permit and no recorded exemption decision&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;permit_sku&lt;/span&gt; &lt;span class="n"&gt;ps&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;ps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sku_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;item_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'FINISHED'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sku_id&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;certification_decision&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gap query is the one worth scheduling. It catches the new flavour printed with an old permit number before a surveillance officer does. Pair it with a check that every batch released under a permit was produced at the permit's site.&lt;/p&gt;

&lt;h2&gt;
  
  
  How FactoraERP helps
&lt;/h2&gt;

&lt;p&gt;FactoraERP keeps one item master for purchasing, stores, production, QA and sales, with lot and expiry control on each item. Quality checks, non-conformances and batches sit in the same system, so a test result is recorded against the batch it belongs to and a deviation can be followed from the record to the product. Because production, stock and dispatch are in the same system, tracing a lot backwards and forwards does not mean pulling files from different shelves when a surveillance officer or a renewal asks for evidence. See &lt;a href="https://factoraerp.com" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Free download: eTIMS readiness checklist for factories
&lt;/h2&gt;

&lt;p&gt;Kenyan manufacturers increasingly need their records to tell one consistent story, for KEBS and for KRA. If you want a free &lt;strong&gt;eTIMS readiness checklist for factories&lt;/strong&gt;, sign up for the FactoraERP Insights newsletter at &lt;a href="https://isaacmuthui.substack.com" rel="noopener noreferrer"&gt;https://isaacmuthui.substack.com&lt;/a&gt;. You will get practical operations notes for food and agro manufacturers. No spam; unsubscribe anytime. For background, see our &lt;a href="https://factoraerp.com/en/blog/haccp-ccp-monitoring-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;HACCP CCP monitoring checklist&lt;/a&gt; and our guide to &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS for food and agro manufacturers&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is the KEBS Standardization Mark?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It is a product certification mark issued by KEBS under the Standards Act for products made in Kenya that conform to the relevant Kenya Standard or approved specification. KEBS describes it as mandatory for locally manufactured products covered by the scheme. It is also called the S-Mark or SM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long is a KEBS S-Mark permit valid?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Two years from the date of issue, and it is renewable. KEBS carries out surveillance in the factory and the market during that period.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does one permit cover all my products?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
No. KEBS issues permits per product, brand and manufacturing site, and they are not transferable to other sites, branches or firms. For medium and small enterprises, one permit fee covers up to three products per site, with a fee for each additional product.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How much does the S-Mark cost?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KEBS publishes a two-year fee schedule, exclusive of VAT: an inspection fee per production site of KSh 40,000, KSh 20,000 or KSh 10,000 depending on firm category, plus permit fees (KSh 15,000 per product, brand and site for large enterprises). Check KEBS's current schedule before budgeting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What must appear on the label?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KEBS requires the Standardization Mark logo and the permit number on the product label.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can KEBS withdraw a permit?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Yes. The 1977 regulations allow KEBS to suspend or revoke a permit, for example where the mark is used on products that do not comply or fees are unpaid. In October 2026 KEBS publicly said it had revoked permits it found being misused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do fortified flour and oil need a separate mark?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Yes. KEBS runs a mandatory fortification logo scheme for wheat flour, dry milled maize products and edible fats and oils, and requires an S-Mark or Diamond Mark first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can a buyer check a permit?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KEBS lists several ways: its website, the KEBS mobile app, an SMS of SM#permit number to 20023, or the toll-free number 1545.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Isaac Muthui, CEO, Tamalaki Business Network Ltd&lt;/em&gt;&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>compliance</category>
    </item>
    <item>
      <title>Designing an Item Master for eTIMS: Item Codes, Product Types, Unit Conversions and Stock Movement Types</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Sun, 08 Nov 2026 04:27:29 +0000</pubDate>
      <link>https://dev.to/yit2022/designing-an-item-master-for-etims-item-codes-product-types-unit-conversions-and-stock-movement-45oa</link>
      <guid>https://dev.to/yit2022/designing-an-item-master-for-etims-item-codes-product-types-unit-conversions-and-stock-movement-45oa</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/item-master-data-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you are building or integrating an ERP for a food factory in Kenya, the item master is the schema everything else joins to — and with eTIMS stock tracking it becomes an external contract, not just an internal table. Five design decisions matter most:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identity&lt;/strong&gt; — one internal item key per physical SKU, never reused, plus a separate mapped eTIMS item code (&lt;code&gt;itemCd&lt;/code&gt;, unique, up to 20 characters in KRA's OSCU spec v2.0) and classification code (&lt;code&gt;itemClsCd&lt;/code&gt;, up to 10 characters).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type&lt;/strong&gt; — an enum that maps cleanly to eTIMS product type (&lt;code&gt;itemTyCd&lt;/code&gt;: 1 raw material, 2 finished product, 3 service without stock), with your own sub-types (packaging, intermediate, by-product) layered on top.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Units&lt;/strong&gt; — a base unit per item and explicit conversion rows for purchase, issue and sales units, mapped to eTIMS packaging unit (&lt;code&gt;pkgUnitCd&lt;/code&gt;) and quantity unit (&lt;code&gt;qtyUnitCd&lt;/code&gt;) codes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tax&lt;/strong&gt; — a locked, audited &lt;code&gt;taxTyCd&lt;/code&gt; per item (A exempt, B 16%, C 0%, D non-VAT, E 8% in the spec's code list), set with a tax adviser, never inherited by copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Movements&lt;/strong&gt; — stock in/out events typed to the spec's movement codes (import, purchase, return, stock movement, processing, adjustment in; sale, return, stock movement, processing, discarding, adjustment out), with recipes referencing the same item keys so processing out and processing in reconcile.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simplified item save payload in KRA's &lt;a href="https://www.kra.go.ke/images/publications/OSCU_Specification_Document_v2.0.pdf" rel="noopener noreferrer"&gt;OSCU requirements and communication protocols&lt;/a&gt; looks like this (fields and sample values abridged from the spec's own item save example; PIN, branch and user fields omitted):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"itemCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"KE1NTXU0000006"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"itemClsCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"5059690800"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"itemTyCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"itemNm"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"test material item 3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"orgnNatCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"KE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"pkgUnitCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"NT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"qtyUnitCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"U"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"taxTyCd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"btchNo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"bcd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"dftPrc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"useYn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Y"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The spec also explains the item code structure — country of origin, product type, packaging unit, quantity unit, then an incrementing sequence — and gives an optional batch number field of only up to 10 characters, which is worth knowing before you design lot codes.&lt;/p&gt;

&lt;p&gt;Below is the 12-point operational checklist I recommend for Kenyan food and agro processors, with an item master template and FAQ. Full references on the canonical post.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the guidance and the specification actually say
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;KRA stock management for electronic invoicing.&lt;/strong&gt; On its &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/stock-management-functionality-for-electronic-invoicing" rel="noopener noreferrer"&gt;stock management functionality page&lt;/a&gt;, KRA informs taxpayers that they must maintain accurate and up-to-date stock records while invoicing through TIMS/eTIMS, in accordance with section 23A(2)(b) of the Tax Procedures Act, 2015. The records should cover stock received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, and should align with the transactions invoiced through TIMS/eTIMS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System-to-system integration.&lt;/strong&gt; KRA's &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/etims-system-to-system-integration" rel="noopener noreferrer"&gt;eTIMS system-to-system integration page&lt;/a&gt; describes two options for connecting an invoicing or ERP system: the Online Sales Control Unit (OSCU), for taxpayers whose invoicing is always online, and the Virtual Sales Control Unit (VSCU), suited to bulk invoicing where the system is not always online.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What an item looks like to eTIMS.&lt;/strong&gt; KRA's published &lt;a href="https://www.kra.go.ke/images/publications/OSCU_Specification_Document_v2.0.pdf" rel="noopener noreferrer"&gt;OSCU requirements and communication protocols (version 2.0)&lt;/a&gt; define the item record an integrated system saves. Required fields include an item classification code, a unique item code, an item type, the item name, the country of origin, a packaging unit code, a quantity unit code, a taxation type and a default unit price. Optional fields include a barcode and a batch number. The specification says the item code is mandatory and must be unique, and shows how it is built — for example, &lt;code&gt;KE2NTBA0000012&lt;/code&gt; is country of origin (KE), product type (2, finished product), packaging unit (NT), quantity unit (BA) and an incrementing sequence. The product type code list has three values: 1 raw material, 2 finished product, 3 service without stock. The taxation type list in the same document runs A (exempt), B (16%), C (0%), D (non-VAT) and E (8%).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stock movements have types too.&lt;/strong&gt; The same specification lists stock in/out types, including incoming import, purchase, return, stock movement, processing and adjustment, and outgoing sale, return, stock movement, processing, discarding and adjustment. For a food processor, "processing" in and out is where raw materials become finished goods — which is why the recipe and the item master have to agree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manufacturers' open questions.&lt;/strong&gt; &lt;a href="https://www.the-star.co.ke/business/markets/2026-10-02-manufacturers-seek-clarity-as-kra-plans-etims-stock-tracking-rollout" rel="noopener noreferrer"&gt;The Star (2 October 2026)&lt;/a&gt; reported that the Kenya Association of Manufacturers has asked for clarity on how stock functionality will sit beside existing ERP systems and how the conversion of raw materials into finished goods — including wastage, by-products, damaged goods and samples — will be captured. &lt;a href="https://peopledaily.digital/insights/beyond-etims-invoices-why-kenyan-businesses-must-account-for-every-unit-of-stock" rel="noopener noreferrer"&gt;People Daily (10 October 2026)&lt;/a&gt; added a point that is really about master data: multi-branch businesses need consistent product codes and transfer records so goods do not appear twice or vanish.&lt;/p&gt;

&lt;p&gt;Treat the specification as KRA's technical reference for integrators, not as tax advice. Which tax type applies to which product is a question for your tax adviser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why item masters go wrong in food plants
&lt;/h2&gt;

&lt;p&gt;Item masters rarely fail on day one. They decay.&lt;/p&gt;

&lt;p&gt;A new supplier arrives and stores creates a new item instead of linking the existing one. A pack size changes and someone edits the old item's description rather than creating a new SKU, so last year's sales and this year's sales now share a name but not a weight. Promotional bundles are sold under the single-unit code. Units of measure are implied ("bags") rather than defined. By-products such as bran, whey or pulp are not items at all, so they are sold off-system. Tax types are copied from the last item created. Nobody owns the list, so everybody edits it.&lt;/p&gt;

&lt;p&gt;None of that is visible on a normal day. It all becomes visible when stock movements and invoices are expected to tell one story.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 12-point item master data checklist for food processors
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Govern the list
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Name one owner and one change process.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Decide who can create, change and retire items — typically one person in finance or supply chain, with a named backup. Requests come from stores, production, QA or sales with a reason. No one creates items "just for today". A shared spreadsheet that anyone can edit is not an item master.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Write a naming convention and apply it to every item.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
For example: product or material, variant, net quantity, pack format — "Maize flour, sifted, 2 kg, packet". Names must be readable on a pick list and on an invoice. Keep a separate field for the supplier's name for the same material, rather than renaming your item to match each supplier. The KRA specification provides for a supplier item code and name on purchase records for exactly that reason.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Clean duplicates before you integrate.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Export the item list, sort by name and by barcode, and look for the same physical item under two or more codes. Merge or block the duplicates, move their history to the surviving code where your system allows, and record what you merged. Integrating a duplicate-ridden list simply sends the duplicates to eTIMS faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Define what each item is
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;4. Classify every item by type: raw material, finished product, or service.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Ingredients, packaging, consumables you track, semi-finished goods, finished goods and by-products all need a type decided on purpose. The eTIMS product type list distinguishes raw material, finished product and service without stock. Decide internally how you treat packaging, intermediates and by-products, and document the rule so it is applied the same way every time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Map each item to the right classification code.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
eTIMS integrations retrieve standard item classification codes from KRA's system, and each saved item carries one. Map your items to codes deliberately with your integrator — not by picking the first match. Record the mapping in the item master so a new joiner can see why sugar, maize, milk powder and PET preforms sit where they do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Define units of measure and conversions explicitly.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
For every item, record the base unit (kg, litre, piece), the purchase unit, the issue unit, the sales unit, and the conversion factors between them. Map your units to the eTIMS packaging unit and quantity unit codes — the specification's lists include, for instance, bag, carton, kilogram and litre. "Bag" without a weight is not a unit. Unit confusion is one of the commonest causes of variances that disappear on recount, as in our &lt;a href="https://factoraerp.com/en/blog/stock-count-reconciliation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;stock count reconciliation checklist&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Give every pack size and bundle its own SKU.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A 500 g and a 1 kg packet are different items. A 12-pack shrink-wrapped tray is a different item from the single unit, unless your system handles it as a defined packaging level with a fixed conversion. If you change the net quantity of a product, create a new item rather than editing the old one. Our &lt;a href="https://factoraerp.com/en/blog/net-quantity-pack-weight-checks-food-factories-kenya" rel="noopener noreferrer"&gt;net quantity and pack weight checks&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/label-control-checklist-food-manufacturers-kenya" rel="noopener noreferrer"&gt;label control checklist&lt;/a&gt; depend on the SKU meaning one declared quantity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect the item to tax, recipes and lots
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;8. Set the tax type per item with your tax adviser — and lock the field.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The eTIMS item record carries a taxation type. Decide each item's type with your tax adviser, record the basis, and restrict who can change it. Copying the tax type from "the last item we created" is how a zero-rated or exempt product ends up invoiced at the wrong rate, or the reverse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Make recipes use the same item codes as stores and purchasing.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Every ingredient and packaging line on a bill of materials should point to the item that stores actually receive and issue — not a recipe-only description. Declare by-products, co-products and waste as items where they have value or must be disposed of, so processing out (raw materials consumed) and processing in (finished goods and by-products made) can be reconciled. This is the conversion question KAM has raised. See our &lt;a href="https://factoraerp.com/en/blog/batch-costing-yield-tracking-agro-processors-kenya" rel="noopener noreferrer"&gt;batch costing and yield tracking guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Decide which items are lot-controlled, and with which dates.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Food-contact ingredients, packaging and finished goods usually need lot or batch tracking for traceability and recall; some consumables do not. Record per item whether lots, expiry or best-before dates and shelf-life rules apply, and keep lot codes consistent with what you print. Note that the specification's batch number field on the item record is short (up to 10 characters in version 2.0), so agree your lot code format with your integrator early. See &lt;a href="https://factoraerp.com/en/blog/reduce-expiry-spoilage-losses-fefo-batch-expiry-tracking" rel="noopener noreferrer"&gt;FEFO and batch expiry tracking&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/how-to-run-a-mock-recall-food-traceability-kenya" rel="noopener noreferrer"&gt;how to run a mock recall&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep it true over time
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;11. Use consistent codes across every branch, depot and warehouse.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
One item, one code, everywhere. Depots must not create local versions of central items. Transfers between sites should move stock of the same item code out of one location and into another. People Daily's warning on multi-branch businesses is, in practice, a master data rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. Retire, don't delete — and review the list every month.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Items you stop buying or selling should be blocked or marked unused, not deleted, so history, stock and invoices still resolve. The eTIMS item record includes a used/unused flag for the same reason. Once a month, review new items created, items changed, items with stock but no movement, items with movement but no recipe or price, and any item whose tax type or units changed. Keep the change log: master data changes are part of the records behind your stock and invoices, and section 23 of the &lt;a href="https://new.kenyalaw.org/akn/ke/act/2015/29" rel="noopener noreferrer"&gt;Tax Procedures Act, 2015&lt;/a&gt; sets a general five-year retention period for documents required under a tax law.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple item master template
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;What to record&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Internal item code&lt;/td&gt;
&lt;td&gt;Unique, never reused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Item name&lt;/td&gt;
&lt;td&gt;Per naming convention (product, variant, net quantity, pack)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Item type&lt;/td&gt;
&lt;td&gt;Raw material / finished product / service; internal sub-type (packaging, intermediate, by-product)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eTIMS classification code&lt;/td&gt;
&lt;td&gt;Mapped with integrator; basis noted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eTIMS item code&lt;/td&gt;
&lt;td&gt;As generated for your integration; unique&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Origin&lt;/td&gt;
&lt;td&gt;Country of origin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Units&lt;/td&gt;
&lt;td&gt;Base, purchase, issue and sales units; conversion factors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eTIMS units&lt;/td&gt;
&lt;td&gt;Packaging unit code; quantity unit code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tax type&lt;/td&gt;
&lt;td&gt;Agreed with tax adviser; field locked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Barcode&lt;/td&gt;
&lt;td&gt;Where used; one barcode per SKU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lot control&lt;/td&gt;
&lt;td&gt;Yes/no; expiry or best-before; shelf-life rule&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recipe links&lt;/td&gt;
&lt;td&gt;BOMs using the item; by-product / waste declared&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supplier links&lt;/td&gt;
&lt;td&gt;Supplier item codes and names&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Status&lt;/td&gt;
&lt;td&gt;Active / blocked / unused; date and approver&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change log&lt;/td&gt;
&lt;td&gt;Who changed what, when and why&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If two people in your plant would give the same product two different item codes, your eTIMS stock record will too.&lt;/p&gt;

&lt;h2&gt;
  
  
  An illustration
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This is an illustrative example, not a real case.&lt;/em&gt; A maize miller buys grain in tonnes, issues it to the mill in kilograms and sells flour in 1 kg and 2 kg packets and 24 kg bales. Over three years the item list grows to four codes for the same 2 kg packet — one per depot and one from a promotion. Bran is sold for cash at the gate but is not an item. Two packets are set up with a different tax type from the others because they were copied from an old item. The 24 kg bale has no item of its own, so each bale is invoiced as twelve 2 kg packets.&lt;/p&gt;

&lt;p&gt;Every month the stock report shows large swings: depots appear short of the 2 kg packet while head office is long, flour output never reconciles to grain consumed, and nobody can tell bale stock or bale sales apart from loose packets. A recount changes nothing. Under KRA's stock-management expectation — stock received, processed, sold, transferred and adjusted, aligned with invoices — that business would struggle to explain any single month. The fix is not another count. It is checks 2, 3, 6, 7, 8, 9 and 11.&lt;/p&gt;

&lt;h2&gt;
  
  
  How FactoraERP helps
&lt;/h2&gt;

&lt;p&gt;FactoraERP keeps one item master for purchasing, stores, production, QA and sales, with item types, units of measure and conversions, lot and expiry control, and status (active or blocked) on each item. Recipes reference the same items stores receive and issue, and can declare primary product, co-product, by-product or waste, so material consumed and output produced can be reconciled. Stock is held by item, lot, location and status, and receipts, issues, output, transfers and dispatches are recorded as they happen. See &lt;a href="https://factoraerp.com" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Free download: eTIMS readiness checklist for factories
&lt;/h2&gt;

&lt;p&gt;Kenyan manufacturers increasingly need their item lists, stock records and invoices to tell one consistent story. If you want a free &lt;strong&gt;eTIMS readiness checklist for factories&lt;/strong&gt;, sign up for the FactoraERP Insights newsletter at &lt;a href="https://isaacmuthui.substack.com" rel="noopener noreferrer"&gt;https://isaacmuthui.substack.com&lt;/a&gt;. You will get practical operations notes for food and agro manufacturers. No spam; unsubscribe anytime. For background, see our guide to &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS for food and agro manufacturers&lt;/a&gt; and our &lt;a href="https://factoraerp.com/en/blog/month-end-close-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;month-end close checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is item master data in a food factory?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It is the controlled list of every material, packaging item, intermediate, finished product and by-product you buy, make, hold or sell, with its code, name, type, units and conversions, tax type, lot rules, recipe and supplier links and status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does item master data matter for eTIMS?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KRA expects stock records to align with TIMS/eTIMS invoices. In KRA's OSCU specification, each item saved by an integrated system carries a classification code, a unique item code, a product type, packaging and quantity unit codes and a taxation type. Duplicate, mis-typed or badly measured items make that alignment hard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What product types does eTIMS use?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The OSCU specification (version 2.0) lists three product types: raw material, finished product, and service without stock. Agree with your integrator and adviser how packaging, intermediates and by-products are treated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should a new pack size get a new item code?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Yes. A different net quantity or pack format is a different item. Editing an existing item's size mixes history and breaks stock and sales comparisons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do by-products like bran or whey fit in?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Where they have value or must be disposed of, set them up as items and declare them on the recipe, so production output and stock movements account for them. KAM has asked KRA for clarity on how wastage and by-products will be captured; confirm current guidance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who should own the item master?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
One named owner, usually in finance or supply chain, with a documented request and approval process. Stores, production, QA and sales request changes; they do not create items freely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can a small plant manage its item master in a spreadsheet?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It can start there if one person owns it, codes are unique, units and conversions are written down, duplicates are removed and changes are logged. Once you have several sites, many SKUs, lot control or an eTIMS integration, a system with controlled fields and history is safer.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Isaac Muthui, CEO, Tamalaki Business Network Ltd&lt;/em&gt;&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>api</category>
    </item>
    <item>
      <title>Modelling a Year-End Inventory Snapshot: Cut-Off Events, Lot Status, Variance Audit Trails and Opening Balances</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Sat, 07 Nov 2026 04:25:40 +0000</pubDate>
      <link>https://dev.to/yit2022/modelling-a-year-end-inventory-snapshot-cut-off-events-lot-status-variance-audit-trails-and-19hh</link>
      <guid>https://dev.to/yit2022/modelling-a-year-end-inventory-snapshot-cut-off-events-lot-status-variance-audit-trails-and-19hh</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/year-end-stock-take-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you model a food factory's year-end inventory snapshot as a set of events, five objects matter more than the trial balance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cut-off / freeze events&lt;/strong&gt; — a timestamp (and production stop rules) after which receipts, issues, outputs and dispatches belong to the next year.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lot-status inventory snapshots&lt;/strong&gt; — counts of raw materials, WIP and finished goods by lot, location and status (including QA hold / quarantine / rework), plus third-party and in-transit lines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variance audit trail&lt;/strong&gt; — every difference with reason code, value and named approver, linked back to a count and an observer note.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;eTIMS stock alignment&lt;/strong&gt; — invoice and credit-note quantities that reconcile to the same year-boundary movements, supporting opening and closing stock by item.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Opening-balance lock&lt;/strong&gt; — January's opening stock loaded only from the signed closing pack, not from a parallel spreadsheet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Kenya Revenue Authority's &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/stock-management-functionality-for-electronic-invoicing" rel="noopener noreferrer"&gt;stock management functionality notice&lt;/a&gt; cites section 23A(2)(b) of the Tax Procedures Act, 2015 and expects records of stock received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, aligned with TIMS/eTIMS invoices. &lt;a href="https://www.the-star.co.ke/business/markets/2026-10-02-manufacturers-seek-clarity-as-kra-plans-etims-stock-tracking-rollout" rel="noopener noreferrer"&gt;The Star (2 Oct 2026)&lt;/a&gt; reported manufacturers preparing for a January 2027 rollout; &lt;a href="https://peopledaily.digital/insights/beyond-etims-invoices-why-kenyan-businesses-must-account-for-every-unit-of-stock" rel="noopener noreferrer"&gt;People Daily&lt;/a&gt; framed the operational test as reconciling transactions with goods actually held and moved.&lt;/p&gt;

&lt;p&gt;Below is the 12-point year-end stocktake I recommend for Kenyan food and agro processors — different from a routine count or a full month-end close — with a year-end file template and FAQ. Full references on the canonical post.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the guidance and the law actually say
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;KRA stock management for electronic invoicing.&lt;/strong&gt; On its &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/stock-management-functionality-for-electronic-invoicing" rel="noopener noreferrer"&gt;stock management functionality page&lt;/a&gt;, KRA informs taxpayers that they must maintain accurate and up-to-date stock records while invoicing through TIMS/eTIMS, in accordance with section 23A(2)(b) of the Tax Procedures Act, 2015. The records should cover stock that is received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, and they should align with the transactions invoiced through TIMS/eTIMS. KRA links this to correct tax reporting, accurate business records and compliance, and has been running consultative forums with businesses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manufacturers and the January 2027 prep window.&lt;/strong&gt; &lt;a href="https://www.the-star.co.ke/business/markets/2026-10-02-manufacturers-seek-clarity-as-kra-plans-etims-stock-tracking-rollout" rel="noopener noreferrer"&gt;The Star (2 October 2026)&lt;/a&gt; reported that KRA issued a public notice on 7 September 2026 requiring accurate stock records through TIMS/eTIMS, and that preparations point toward a January 2027 rollout. The Kenya Association of Manufacturers has asked for clarity on how the functionality will sit beside existing ERP systems, how conversion of raw materials into finished goods (including wastage, by-products, damaged goods and samples) will be captured, how imports and inter-warehouse transfers will be treated, and what happens during system downtime. KRA's George Obell was quoted saying the initiative targets missing-trader fraud and unfair competition. The same piece notes that eTIMS architecture already includes stock inventory, stock by item, imported items, stock-in and stock-out histories, movements and opening and closing stock — exactly the ledger your year-end snapshot should be able to support.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accounting for every unit.&lt;/strong&gt; &lt;a href="https://peopledaily.digital/insights/beyond-etims-invoices-why-kenyan-businesses-must-account-for-every-unit-of-stock" rel="noopener noreferrer"&gt;People Daily (10 October 2026)&lt;/a&gt; walks through the basic equation: opening stock plus what came in, minus what went out, should equal what remains. A physical shortfall needs investigation with supporting documents — purchase invoices, sales records, transfer notes, adjustment records and physical counts — not a silent journal. Multi-branch businesses need consistent product codes and transfer records. Electronic invoicing improves visibility; it does not replace physical controls for damage, theft, returns, internal use or transfers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Five-year retention.&lt;/strong&gt; Section 23 of Kenya's &lt;a href="https://new.kenyalaw.org/akn/ke/act/2015/29" rel="noopener noreferrer"&gt;Tax Procedures Act, 2015&lt;/a&gt; requires a person to keep documents required under a tax law so that tax liability can be readily ascertained, and to retain them for five years from the end of the reporting period they relate to (subject to the exceptions in the Act). Your year-end stocktake pack belongs in that set. East African Standard EAS 39 (Hygiene in the food and drink manufacturing industry — Code of practice) clause 14 also expects records of actions taken to assure food safety to be indexed, filed and maintained for a suitable period — so confirm with your quality lead whether food-safety retention for the same year-end evidence runs longer than the tax minimum. Our &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS guide for food and agro manufacturers&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/food-safety-records-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;food safety records checklist&lt;/a&gt; cover those two sides of the same filing cabinet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why year-end stocktakes go wrong in food plants
&lt;/h2&gt;

&lt;p&gt;Factories rarely fail the annual count because nobody showed up. They fail because year-end is treated as a finance deadline instead of an operations freeze.&lt;/p&gt;

&lt;p&gt;The patterns are familiar. Planning starts in the last week of December. Production is still issuing material while stores are counting. WIP has no status on the sheet. Held finished goods are mixed into free stock. Stock at a co-packer or third-party warehouse is guessed from last month's email. In-transit trucks are invisible to both sites. Nobody from outside the counting team observes. Variances are posted as "year-end adj" without a named approver. Opening balances for January are loaded from a spreadsheet that does not match the signed count. And when eTIMS or an auditor later asks for the year-boundary story, the pack cannot be found in under five minutes.&lt;/p&gt;

&lt;p&gt;None of that survives a world in which stock movements and electronic invoices are expected to tell one story — and in which January's opening stock is simply last year's closing stock with a signature.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 12-point year-end stock take checklist for food processors
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Plan and freeze (start in November)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Publish the year-end stocktake plan in November.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Write the freeze window, count dates by warehouse and cold room, team leads, observer or auditor attendance, cut-off rules for receipts and dispatches, and the date opening balances will be locked. Brief stores, production, QA, dispatch and finance. A plan that only exists in someone's head is how the 31st becomes a scramble.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Announce a production and movement freeze for the count window.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Decide which lines stop, which can finish work-in-progress already in process, and which receipts or dispatches are blocked until after the count. Tell suppliers and logistics partners where needed. A year-end count against a moving warehouse invents variances that January will inherit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Post every open slip before anyone counts.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
GRNs, production issues and outputs, transfers, delivery notes, credit notes and returns that belong to the closing year must be in the system before the count starts. Use the same discipline as in our &lt;a href="https://factoraerp.com/en/blog/stock-count-reconciliation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;stock count reconciliation checklist&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/supplier-intake-checklist-food-manufacturers-kenya" rel="noopener noreferrer"&gt;supplier intake checklist&lt;/a&gt;. Incomplete ledgers invent year-end "losses".&lt;/p&gt;

&lt;h3&gt;
  
  
  Count everything that is yours — and everything that affects yours
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;4. Count raw materials and packaging by lot and location.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Blind counts where practical. Partial bags, open drums, returned packaging and near-expiry lots get their own lines. Confirm units of measure before you chase a variance. FEFO and expiry write-offs at year-end belong here: see &lt;a href="https://factoraerp.com/en/blog/reduce-expiry-spoilage-losses-fefo-batch-expiry-tracking" rel="noopener noreferrer"&gt;FEFO and batch expiry tracking&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Count work-in-progress with a status, not a guess.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
List every open tank, silo, line, vat or pallet of WIP at the freeze: product, batch or order, quantity, stage and owner. Decide whether each line is finished into the closing year, carried as WIP into January, or written off with approval. WIP with no status becomes opening stock nobody can defend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Count finished goods separately from blocked stock.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Sellable FG is one figure. Stock on hold, in quarantine, in rework, in the returns bay or awaiting disposal is another. Record status on the sheet, as in our &lt;a href="https://factoraerp.com/en/blog/qa-hold-checklist-before-batch-leaves-warehouse-kenya" rel="noopener noreferrer"&gt;QA hold checklist&lt;/a&gt;. Held pallets counted as free stock are how January's available-to-promise lies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Include third-party, consignment and co-packer stock.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Stock at a co-packer, bonded store, distributor warehouse or customer site that is still yours needs a count confirmation — preferably with the third party's signed sheet or a joint count. Guessing from last month's email is not a year-end figure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Include in-transit stock with named sender and receiver.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Trucks, containers and inter-branch transfers that left before the freeze and have not yet been received need a line: document number, contents, quantity, sender, receiver and expected arrival. People Daily's multi-branch point applies at year-end too: goods that left one store must not vanish from both sites' closing and opening balances. Tie dispatch evidence to the same discipline as our &lt;a href="https://factoraerp.com/en/blog/finished-goods-dispatch-checklist-kenya" rel="noopener noreferrer"&gt;finished goods dispatch checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Observe, reconcile, align and lock
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;9. Have an auditor, external observer or independent internal observer present.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Year-end counts that only the usual store team sees are harder to defend. Note who observed, which locations they covered and any exceptions they recorded. If your statutory auditor attends, treat their presence as part of the pack, not a courtesy visit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Reconcile variances only with named approval — then lock the year-end adjustment list.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Every difference carries item, lot, location, system quantity, counted quantity, difference, value, reason code and approver. The counter does not approve their own write-off. "Year-end adj" is not a reason. KRA's stock-management notice expects returns, adjustments and disposals to be recorded. Run the recount and investigation steps from the &lt;a href="https://factoraerp.com/en/blog/stock-count-reconciliation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;stock count reconciliation checklist&lt;/a&gt; before anyone posts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. Align year-end stock with eTIMS invoices and stock records.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Confirm that invoices and credit notes for the closing year were transmitted as required, that quantities match what left the warehouse, and that your inventory ledger can support opening and closing stock by item — the same objects The Star noted already exist in eTIMS architecture. Document any legitimate year-end variances (wastage, by-products, samples, damage) with the same reason codes KAM has been asking KRA to clarify. See our &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. Assemble the year-end pack, lock opening balances for the new year, and retain the file.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
File the November plan, freeze notice, posted-transaction list, count and recount sheets, WIP and hold registers, third-party confirmations, in-transit register, observer notes, approved adjustment list, eTIMS/invoice match summary, and a sign-off page from operations and finance. Load January opening balances only from that signed closing stock — not from a parallel spreadsheet. Plan to keep the pack at least five years under section 23 of the Tax Procedures Act, and confirm longer food-safety retention with your quality lead (EAS 39 clause 14: records of actions to assure safety kept for a suitable period).&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple year-end stocktake file
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th&gt;What to record&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;November plan&lt;/td&gt;
&lt;td&gt;Freeze window, count dates, teams, observer, lock date for opening balances&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Freeze notice&lt;/td&gt;
&lt;td&gt;Lines stopped / WIP finish rules; receipt and dispatch cut-off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Posting completeness&lt;/td&gt;
&lt;td&gt;Open GRNs, issues, outputs, transfers, dispatches posted before count&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RM &amp;amp; packaging&lt;/td&gt;
&lt;td&gt;Blind sheets, lots, locations, UoM, near-expiry, recounts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WIP register&lt;/td&gt;
&lt;td&gt;Order/batch, stage, quantity, owner; finish / carry / write-off decision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FG &amp;amp; blocked stock&lt;/td&gt;
&lt;td&gt;Sellable vs hold / quarantine / rework / returns / disposal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Third-party / co-packer&lt;/td&gt;
&lt;td&gt;Location, confirmation or joint count, signed sheet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In-transit&lt;/td&gt;
&lt;td&gt;Document no., qty, sender, receiver, expected arrival&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observer&lt;/td&gt;
&lt;td&gt;Name, locations covered, exceptions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Adjustments&lt;/td&gt;
&lt;td&gt;Variance, reason code, value, named approver&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eTIMS / invoice alignment&lt;/td&gt;
&lt;td&gt;Invoice &amp;amp; credit-note match; opening/closing by item support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Opening balances&lt;/td&gt;
&lt;td&gt;Loaded from signed closing stock only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retention&lt;/td&gt;
&lt;td&gt;Pack filed; tax min. five years; food-safety period confirmed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign-off&lt;/td&gt;
&lt;td&gt;Operations + finance names, dates&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you cannot point to last year's year-end pack in under five minutes, January's opening stock is not under control.&lt;/p&gt;

&lt;h2&gt;
  
  
  An illustration
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This is an illustrative example, not a real case.&lt;/em&gt; A mid-sized dairy plans its year-end count for 30 December. Production runs until midday. Three silos of WIP have no stage written on the sheet. Twelve pallets of flavoured yoghurt on QA hold are counted into free stock. Stock at a co-packer is taken from a November email. Two trucks that left for Mombasa on the 29th appear on neither the dairy's nor the depot's count. Finance posts a balancing adjustment labelled "year-end" so the trial balance closes, then loads January opening balances from a spreadsheet that was edited after the count.&lt;/p&gt;

&lt;p&gt;By mid-January the co-packer returns a lower figure, the held yoghurt is released and sold, the trucks arrive with shortages, and the WIP is finished with scrap that was never recorded. Opening stock nobody trusts is now the base for every variance report of the new year. Under KRA's stock-management expectation — records of what was received, sold, adjusted and disposed of, aligned with eTIMS invoices — that tidy December close is exactly the kind of story that does not hold. The fix is not a better journal in January. It is checks 1–3, 5–8 and 10–12 done before anyone signs in December.&lt;/p&gt;

&lt;h2&gt;
  
  
  How FactoraERP helps
&lt;/h2&gt;

&lt;p&gt;FactoraERP keeps stock by item, lot, location and status, and records receipts, production issues, output and dispatch as they happen, so a year-end freeze starts from a live ledger rather than a pile of slips. Blind count sheets, recounts, variance reason codes and approved adjustments link each write-off to a count and a named approver. QC results and holds sit on the same stock: a batch on hold is not available for picking until QA releases it. Recipes can declare primary product, co-product, by-product or waste, which supports the conversion and wastage explanations manufacturers need when stock records and invoices must align. See &lt;a href="https://factoraerp.com" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Free download: eTIMS readiness checklist for factories
&lt;/h2&gt;

&lt;p&gt;Kenyan manufacturers increasingly need their operational records, stock records and invoices to tell one consistent story — especially at the year boundary. If you want a free &lt;strong&gt;eTIMS readiness checklist for factories&lt;/strong&gt;, sign up for the FactoraERP Insights newsletter at &lt;a href="https://isaacmuthui.substack.com" rel="noopener noreferrer"&gt;https://isaacmuthui.substack.com&lt;/a&gt;. You will get practical operations notes for food and agro manufacturers. No spam; unsubscribe anytime. For background, see our guide to &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS for food and agro manufacturers&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is a year-end stocktake in a food factory?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It is the annual physical and documentary count that locks closing stock for the year and opening stock for the next: freeze, counts of raw materials, WIP and finished goods, third-party and in-transit stock, observer presence, approved variances, eTIMS/invoice alignment and a signed pack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How is this different from a routine stock count or month-end close?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A routine stock count compares physical quantities with the system and posts approved variances. Month-end close covers the full period (cut-off, production, yields, purchases, sales, accruals). Year-end stocktake focuses on the annual freeze, complete coverage (including third-party and in-transit), observer presence and locking opening balances you will defend for the next year.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When should we start planning the year-end stocktake?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
In November. Publish the freeze window, count dates, teams and observer arrangements early enough that production, stores and logistics can prepare — not in the last days of December.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does KRA expect on stock records for eTIMS?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KRA's stock-management notice, citing section 23A(2)(b) of the Tax Procedures Act, 2015, expects accurate records of stock received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, aligned with TIMS/eTIMS invoices. Consult your tax adviser for how that applies to your registration and timeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is the eTIMS stock-tracking rollout expected?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Reporting in The Star on 2 October 2026 described preparations for a January 2027 rollout, following a 7 September 2026 public notice and ongoing consultations with manufacturers. Treat dates as reported and confirm current guidance with KRA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long should we keep the year-end stocktake pack?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Section 23 of the Tax Procedures Act, 2015 sets a general five-year retention period for documents required under a tax law, with exceptions. EAS 39 clause 14 expects food-safety records to be kept for a suitable period. Confirm both with your accountant and quality lead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can a small plant run year-end stocktake on paper?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Yes, if the November plan and freeze are written, slips are posted before counting, WIP and holds have registers, third-party and in-transit lines exist, adjustments have reason codes and named approvers, opening balances come only from the signed close, and the pack is filed together. Software helps when lots, locations, holds and third-party sites outgrow paper.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Isaac Muthui, CEO, Tamalaki Business Network Ltd&lt;/em&gt;&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>inventory</category>
    </item>
    <item>
      <title>Modelling Month-End Close: Cut-Off Events, Inventory Snapshots, Adjustment Audit Trails and eTIMS Stock Alignment</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Fri, 06 Nov 2026 04:36:51 +0000</pubDate>
      <link>https://dev.to/yit2022/modelling-month-end-close-cut-off-events-inventory-snapshots-adjustment-audit-trails-and-etims-l95</link>
      <guid>https://dev.to/yit2022/modelling-month-end-close-cut-off-events-inventory-snapshots-adjustment-audit-trails-and-etims-l95</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/month-end-close-checklist-food-processors-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you model a food factory's month-end close as a set of events, four objects matter more than the trial balance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cut-off events&lt;/strong&gt; — a timestamp after which receipts, issues, outputs and dispatches belong to the next period.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inventory snapshots&lt;/strong&gt; — counts of raw materials, WIP and finished goods by lot, location and status (including QA hold / quarantine / rework).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adjustment audit trail&lt;/strong&gt; — every variance with reason code, value and named approver, linked back to a count.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;eTIMS stock alignment&lt;/strong&gt; — invoice and credit-note quantities that reconcile to the same movements.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Kenya Revenue Authority's &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/stock-management-functionality-for-electronic-invoicing" rel="noopener noreferrer"&gt;stock management functionality notice&lt;/a&gt; cites section 23A(2)(b) of the Tax Procedures Act, 2015 and expects records of stock received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, aligned with TIMS/eTIMS invoices. &lt;a href="https://www.the-star.co.ke/business/markets/2026-10-02-manufacturers-seek-clarity-as-kra-plans-etims-stock-tracking-rollout" rel="noopener noreferrer"&gt;The Star (2 Oct 2026)&lt;/a&gt; reported manufacturers preparing for a January 2027 rollout; &lt;a href="https://peopledaily.digital/insights/beyond-etims-invoices-why-kenyan-businesses-must-account-for-every-unit-of-stock" rel="noopener noreferrer"&gt;People Daily&lt;/a&gt; framed the operational test as reconciling transactions with goods actually held and moved.&lt;/p&gt;

&lt;p&gt;Below is the 15-point close I recommend for Kenyan food and agro processors — broader than a stock count — with a close-file template and FAQ. Full references on the canonical post.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the guidance and the law actually say
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;KRA stock management for electronic invoicing.&lt;/strong&gt; On its &lt;a href="https://www.kra.go.ke/business/etims-electronic-tax-invoice-management-system/learn-about-etims/stock-management-functionality-for-electronic-invoicing" rel="noopener noreferrer"&gt;stock management functionality page&lt;/a&gt;, KRA informs taxpayers that they must maintain accurate and up-to-date stock records while invoicing through TIMS/eTIMS, in accordance with section 23A(2)(b) of the Tax Procedures Act, 2015. The records should cover stock that is received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, and they should align with the transactions invoiced through TIMS/eTIMS. KRA links this to correct tax reporting, accurate business records and compliance, and has been running consultative forums with businesses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manufacturers and the January 2027 prep window.&lt;/strong&gt; &lt;a href="https://www.the-star.co.ke/business/markets/2026-10-02-manufacturers-seek-clarity-as-kra-plans-etims-stock-tracking-rollout" rel="noopener noreferrer"&gt;The Star (2 October 2026)&lt;/a&gt; reported that KRA issued a public notice on 7 September 2026 requiring accurate stock records through TIMS/eTIMS, and that preparations point toward a January 2027 rollout. The Kenya Association of Manufacturers has asked for clarity on how the functionality will sit beside existing ERP systems, how conversion of raw materials into finished goods (including wastage, by-products, damaged goods and samples) will be captured, how imports and inter-warehouse transfers will be treated, and what happens during system downtime. KRA's George Obell was quoted saying the initiative targets missing-trader fraud and unfair competition. The same piece notes that eTIMS architecture already includes stock inventory, stock by item, imported items, stock-in and stock-out histories, movements and opening and closing stock.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accounting for every unit.&lt;/strong&gt; &lt;a href="https://peopledaily.digital/insights/beyond-etims-invoices-why-kenyan-businesses-must-account-for-every-unit-of-stock" rel="noopener noreferrer"&gt;People Daily (10 October 2026)&lt;/a&gt; walks through the basic equation: opening stock plus what came in, minus what went out, should equal what remains. A physical shortfall needs investigation with supporting documents — purchase invoices, sales records, transfer notes, adjustment records and physical counts — not a silent journal. Multi-branch businesses need consistent product codes and transfer records. Electronic invoicing improves visibility; it does not replace physical controls for damage, theft, returns, internal use or transfers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Five-year retention.&lt;/strong&gt; Section 23 of Kenya's &lt;a href="https://new.kenyalaw.org/akn/ke/act/2015/29" rel="noopener noreferrer"&gt;Tax Procedures Act, 2015&lt;/a&gt; requires a person to keep documents required under a tax law so that tax liability can be readily ascertained, and to retain them for five years from the end of the reporting period they relate to (subject to the exceptions in the Act). KRA's eTIMS FAQ points taxpayers back to that rule. Your month-end close pack belongs in that set. Our &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS guide for food and agro manufacturers&lt;/a&gt; covers the invoicing side of the same story.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why month-end close goes wrong in food plants
&lt;/h2&gt;

&lt;p&gt;Factories rarely fail the close because nobody counted anything. They fail because the close is treated as a finance ritual after the fact.&lt;/p&gt;

&lt;p&gt;The patterns are familiar. Cut-off was never announced, so GRNs and dispatch notes from the last day of the month land in the next period. Production orders stay open with material issued and nothing received. WIP sits on the floor with no status. Finished goods on QA hold are counted as free stock. Yields are estimated at month-end instead of recorded per batch. Returns and scrap are written off without a named approver. Accruals for power, transport or lab tests are guessed. And when the stock figure still looks wrong, someone posts a balancing adjustment with the reason "month-end".&lt;/p&gt;

&lt;p&gt;None of that survives a world in which stock movements and eTIMS invoices are expected to tell one story.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 15-point month-end close checklist for food processors
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Cut-off and freeze
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Announce a hard cut-off date and time.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Write it down: last receipt, last issue, last production booking and last dispatch that belong to this period. Tell stores, production, QA and dispatch. Anything after the cut-off belongs to next month, even if someone "was in a hurry".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Post every open slip before anyone counts.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
GRNs, production issues and outputs, transfers, delivery notes and credit notes that belong to the period must be in the system before the count starts. A count against an incomplete ledger invents variances. Use the same discipline as in our &lt;a href="https://factoraerp.com/en/blog/stock-count-reconciliation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;stock count reconciliation checklist&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/supplier-intake-checklist-food-manufacturers-kenya" rel="noopener noreferrer"&gt;supplier intake checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stock, WIP and finished goods
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;3. Count raw materials and packaging by lot and location.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Blind counts where practical. Partial bags, open drums and returned packaging get their own lines. Confirm units of measure before you chase a variance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Count work-in-progress with a status, not a guess.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
List every open tank, silo, line, vat or pallet of WIP: product, batch or order, quantity, stage and owner. WIP that has no status is stock that will not survive an audit question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Count finished goods separately from free stock that is blocked.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Sellable FG in the warehouse is one figure. Stock on hold, in quarantine, in rework, in the returns bay or awaiting disposal is another. Record status on the sheet, as in our &lt;a href="https://factoraerp.com/en/blog/qa-hold-checklist-before-batch-leaves-warehouse-kenya" rel="noopener noreferrer"&gt;QA hold checklist&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/rework-control-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;rework control checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quality and production close
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;6. Clear or formally carry open QA holds.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Every held batch at month-end needs a decision: release, rework, reject or keep on hold with a named owner and a next review date. Held stock must not be counted as available for sale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Close or park every production order.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Orders with material issued and no output, or output with no issues, must be finished, cancelled or explicitly carried with a reason. Open orders are where yields disappear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Reconcile yields and batch costing for the period.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Compare expected recipe yields with actual output, scrap and by-products for closed batches. Investigate outliers before you accept a period cost. See &lt;a href="https://factoraerp.com/en/blog/batch-costing-yield-tracking-agro-processors-kenya" rel="noopener noreferrer"&gt;batch costing and yield tracking for agro processors&lt;/a&gt;. FEFO and expiry write-offs belong here too: &lt;a href="https://factoraerp.com/en/blog/reduce-expiry-spoilage-losses-fefo-batch-expiry-tracking" rel="noopener noreferrer"&gt;FEFO and batch expiry tracking&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Purchases, sales and eTIMS alignment
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;9. Match purchases and GRNs to the period.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Every supplier invoice in the period should have a corresponding receipt (or a documented accrual). Every GRN should have a matching invoice or a clear "goods received, invoice pending" line. Quantity and unit mismatches are closed here, not left for next month.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Reconcile sales invoices and credit notes with eTIMS.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Confirm that invoices issued for the period were transmitted through TIMS/eTIMS as required, that credit notes are paired, and that quantities on invoices match what left the warehouse. Our &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS guide&lt;/a&gt; and &lt;a href="https://factoraerp.com/en/blog/finished-goods-dispatch-checklist-kenya" rel="noopener noreferrer"&gt;finished goods dispatch checklist&lt;/a&gt; cover the floor side of that match.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. Close inter-warehouse and inter-branch transfers.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
In-transit stock at month-end needs a named sender, receiver and expected arrival. People Daily's multi-branch point applies: goods that left one store must not vanish from both.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adjustments, accruals and the pack
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;12. Post returns, scrap and stock adjustments only with named approval.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Every adjustment carries item, lot, location, system quantity, counted quantity, difference, value, reason code and approver. The counter does not approve their own write-off. "Month-end adj" is not a reason. KRA's stock-management notice expects returns, adjustments and disposals to be recorded, not absorbed into silence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. Document accruals and period expenses.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Power, water, transport, laboratory tests, casual labour, packaging on order and similar costs that belong to the period get a schedule: amount, basis, owner and supporting document. Guessed accruals become next month's surprise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. Assemble the month-end close pack and retain it.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
File cut-off notice, posted transaction list, count and recount sheets, WIP and hold registers, production-order close list, yield summary, purchase/GRN match, invoice/eTIMS match, transfer register, approved adjustments, accrual schedule and sign-off page together. Plan to keep them at least five years under section 23 of the Tax Procedures Act, and confirm longer food-safety retention with your quality lead using your &lt;a href="https://factoraerp.com/en/blog/food-safety-records-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;food safety records checklist&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. Get a named sign-off that the period is closed.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Operations and finance both sign that cut-off was observed, counts and holds were reviewed, production was closed or parked, invoices align with movements, and adjustments have approvers. Without that page, the close is a conversation, not a record.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple month-end close file
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th&gt;What to record&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cut-off&lt;/td&gt;
&lt;td&gt;Date/time announced; what belongs in / out of the period&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Posting completeness&lt;/td&gt;
&lt;td&gt;Open GRNs, issues, outputs, transfers, dispatches posted before count&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RM &amp;amp; packaging count&lt;/td&gt;
&lt;td&gt;Blind sheets, lots, locations, UoM, recounts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WIP register&lt;/td&gt;
&lt;td&gt;Order/batch, stage, quantity, owner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FG &amp;amp; blocked stock&lt;/td&gt;
&lt;td&gt;Sellable vs hold / quarantine / rework / returns / disposal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;QA holds&lt;/td&gt;
&lt;td&gt;Decision, owner, next review date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Production orders&lt;/td&gt;
&lt;td&gt;Closed, cancelled or carried with reason&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Yields &amp;amp; costing&lt;/td&gt;
&lt;td&gt;Expected vs actual, scrap, by-products, outliers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Purchases / GRNs&lt;/td&gt;
&lt;td&gt;Match or documented accrual&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sales / eTIMS&lt;/td&gt;
&lt;td&gt;Invoice list, credit notes, transmission status, qty match to dispatch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transfers&lt;/td&gt;
&lt;td&gt;In-transit, sender, receiver, expected arrival&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Adjustments&lt;/td&gt;
&lt;td&gt;Variance, reason code, value, named approver&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accruals&lt;/td&gt;
&lt;td&gt;Amount, basis, owner, support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retention&lt;/td&gt;
&lt;td&gt;Pack filed; retention date (min. five years for tax docs)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign-off&lt;/td&gt;
&lt;td&gt;Operations + finance names, dates&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you cannot point to the pack for last month in under five minutes, the close is not under control.&lt;/p&gt;

&lt;h2&gt;
  
  
  An illustration
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This is an illustrative example, not a real case.&lt;/em&gt; A mid-sized juice plant closes October. The accountant's stock report looks tidy. On the floor, three production orders still have concentrate issued and no finished output booked, twelve pallets of a new SKU sit on QA hold but were counted as free stock, and a GRN for sugar delivered on the afternoon of the 31st was left on a clipboard. Finance posts a balancing stock adjustment so the trial balance closes.&lt;/p&gt;

&lt;p&gt;Two weeks later the same sugar appears again when the GRN is posted, the held SKU is released and sold, and the open production orders are closed with scrap that was never recorded. November opens with a stock figure nobody trusts. Under KRA's stock-management expectation — records of what was received, sold, adjusted and disposed of, aligned with eTIMS invoices — that tidy October close is exactly the kind of story that does not hold. The fix is not a better journal. It is checks 1–2, 5–7 and 12 done before anyone signs.&lt;/p&gt;

&lt;h2&gt;
  
  
  How FactoraERP helps
&lt;/h2&gt;

&lt;p&gt;FactoraERP keeps stock by item, lot, location and status, and records receipts, production issues, output and dispatch as they happen, so month-end starts from a live ledger rather than a pile of slips. Blind count sheets, recounts, variance reason codes and approved adjustments link each write-off to a count and a named approver. QC results and holds sit on the same stock: a batch on hold is not available for picking or delivery notes until QA releases it with user, time and results. Recipes can declare primary product, co-product, by-product or waste, and waste quantities can be recorded against production runs, which supports yield and scrap review at period close. See &lt;a href="https://factoraerp.com" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Free download: eTIMS readiness checklist for factories
&lt;/h2&gt;

&lt;p&gt;Kenyan manufacturers increasingly need their operational records, stock records and invoices to tell one consistent story. If you want a free &lt;strong&gt;eTIMS readiness checklist for factories&lt;/strong&gt;, sign up for the FactoraERP Insights newsletter at &lt;a href="https://isaacmuthui.substack.com" rel="noopener noreferrer"&gt;https://isaacmuthui.substack.com&lt;/a&gt;. You will get practical operations notes for food and agro manufacturers. No spam; unsubscribe anytime. For background, see our guide to &lt;a href="https://factoraerp.com/en/blog/etims-for-food-agro-manufacturers-kenya" rel="noopener noreferrer"&gt;eTIMS for food and agro manufacturers&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is a month-end close in a food factory?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
It is the set of steps that lock a period: cut-off, posting completeness, counts of raw materials, WIP and finished goods, clearance of QA holds and production orders, yield and cost review, purchase and sales/eTIMS matching, approved adjustments, accruals and a signed close pack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How is this different from a stock count?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A stock count compares physical quantities with the system and posts approved variances. Month-end close includes that work and also closes production, quality holds, purchases, sales/eTIMS alignment, transfers, accruals and retention of the pack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does KRA expect on stock records for eTIMS?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KRA's stock-management notice, citing section 23A(2)(b) of the Tax Procedures Act, 2015, expects accurate records of stock received, purchased, sold, transferred, returned, adjusted or otherwise disposed of, aligned with TIMS/eTIMS invoices. Consult your tax adviser for how that applies to your registration and timeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is the eTIMS stock-tracking rollout expected?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Reporting in The Star on 2 October 2026 described preparations for a January 2027 rollout, following a 7 September 2026 public notice and ongoing consultations with manufacturers. Treat dates as reported and confirm current guidance with KRA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How long should we keep the month-end close pack?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Section 23 of the Tax Procedures Act, 2015 sets a general five-year retention period for documents required under a tax law, with exceptions. Food-safety records may need longer. Confirm with your accountant and quality lead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can a small plant run this close on paper?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Yes, if cut-off is written, slips are posted before counting, WIP and holds have registers, adjustments have reason codes and named approvers, and the pack is filed together. Software helps when lots, locations, holds and invoice volumes outgrow paper.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Isaac Muthui, CEO, Tamalaki Business Network Ltd&lt;/em&gt;&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>accounting</category>
    </item>
    <item>
      <title>Ancient Egypt set taxes by a gauge on the Nile. What is the one reading your system depends on?</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Wed, 04 Nov 2026 04:27:45 +0000</pubDate>
      <link>https://dev.to/yit2022/ancient-egypt-set-taxes-by-a-gauge-on-the-nile-what-is-the-one-reading-your-system-depends-on-2oj</link>
      <guid>https://dev.to/yit2022/ancient-egypt-set-taxes-by-a-gauge-on-the-nile-what-is-the-one-reading-your-system-depends-on-2oj</guid>
      <description>&lt;p&gt;For thousands of years Egypt's harvest depended on the annual Nile flood, so Egyptians built nilometers: stone columns, staircases and river-fed wells marked in cubits. The staircase on Elephantine Island at Aswan saw the flood first, so readings could be sent downstream ahead of the water. The flood height was used to set the year's taxes. The Roda Island nilometer in Cairo (first built 715, rebuilt 861) still stands, and records for 622–999 suggest about one flood in four fell short.&lt;/p&gt;

&lt;h3&gt;
  
  
  For builders: design around the reading that decides
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Identify the one measurement that drives every downstream decision, and instrument that first.&lt;/li&gt;
&lt;li&gt;Capture upstream (intake, first process step), not in the end-of-month report.&lt;/li&gt;
&lt;li&gt;Bind plans and thresholds to measured values, not to last period's budget.&lt;/li&gt;
&lt;li&gt;Keep long, honest history; "one bad year in four" only appears in long series.&lt;/li&gt;
&lt;li&gt;Give the people doing the work the same view as the people judging it.&lt;/li&gt;
&lt;li&gt;When the system changes (the Aswan High Dam ended the flood in 1970), revisit what you measure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full story (with sources): &lt;a href="https://isaacmuthui.com/stories/roda-nilometer-flood/" rel="noopener noreferrer"&gt;https://isaacmuthui.com/stories/roda-nilometer-flood/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Isaac Mwendwa Muthui is Founder &amp;amp; CEO of Tamalaki Business Network.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>history</category>
      <category>data</category>
      <category>manufacturing</category>
      <category>iot</category>
    </item>
    <item>
      <title>The golden rhino of Mapungubwe was wood inside. What is your dashboard fastened to?</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Tue, 03 Nov 2026 05:00:22 +0000</pubDate>
      <link>https://dev.to/yit2022/the-golden-rhino-of-mapungubwe-was-wood-inside-what-is-your-dashboard-fastened-to-8dl</link>
      <guid>https://dev.to/yit2022/the-golden-rhino-of-mapungubwe-was-wood-inside-what-is-your-dashboard-fastened-to-8dl</guid>
      <description>&lt;p&gt;In the early 1930s archaeologists found a small golden rhinoceros on a royal grave on Mapungubwe Hill, at the Shashe–Limpopo confluence in southern Africa. It is a carved wooden figure covered in thin sheets of gold. The shine was a skin.&lt;/p&gt;

&lt;p&gt;Mapungubwe grew rich from a trade network (interior gold and ivory out to the Swahili coast, beads and cloth back), not from one mine. When the excavations came, the findings were largely kept within academia for decades and rarely reached the public.&lt;/p&gt;

&lt;h3&gt;
  
  
  For builders: check what the gold is fastened to
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A dashboard is a finish. Trace each headline number back to the records it is built from.&lt;/li&gt;
&lt;li&gt;Value lives in connections: link intake, quality, production and dispatch, not just one module.&lt;/li&gt;
&lt;li&gt;Keep history. Drift (supplier quality, demand, conditions) only shows over time.&lt;/li&gt;
&lt;li&gt;Data nobody can see is still underground. Put the record where decisions are made.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full story (with sources): &lt;a href="https://isaacmuthui.com/stories/mapungubwe-golden-rhino/" rel="noopener noreferrer"&gt;https://isaacmuthui.com/stories/mapungubwe-golden-rhino/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Isaac Mwendwa Muthui is Founder &amp;amp; CEO of Tamalaki Business Network.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>history</category>
      <category>data</category>
      <category>manufacturing</category>
      <category>leadership</category>
    </item>
    <item>
      <title>The Akan calibrated their money by hand. Do you calibrate your data?</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Sun, 01 Nov 2026 06:14:21 +0000</pubDate>
      <link>https://dev.to/yit2022/the-akan-calibrated-their-money-by-hand-do-you-calibrate-your-data-4fih</link>
      <guid>https://dev.to/yit2022/the-akan-calibrated-their-money-by-hand-do-you-calibrate-your-data-4fih</guid>
      <description>&lt;p&gt;&lt;em&gt;First published on &lt;a href="https://isaacmuthui.com/stories/akan-gold-weights/" rel="noopener noreferrer"&gt;isaacmuthui.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Pick one up in a museum case and it fits in the palm of your hand. A tiny brass leopard. A shield. A double-edged sword. A neat little block cut with lines, like a seal. Most weigh less than about two and a half ounces. Visitors lean in and see miniature sculpture.&lt;/p&gt;

&lt;p&gt;The people who made them saw money. Or, more exactly, they saw the thing that made money trustworthy.&lt;/p&gt;

&lt;p&gt;These are Akan goldweights, called &lt;em&gt;mrammou&lt;/em&gt; or &lt;em&gt;abrammuo&lt;/em&gt;, from the forest country of what is now Ghana and Côte d'Ivoire. For centuries the Akan, and later the Asante kingdom, traded in gold dust. Gold dust was the main currency of Asante, and from the early eighteenth century it was its legal tender. You did not count gold dust. You weighed it. And to weigh it, you needed a scale and a set of weights that both sides of a deal could believe.&lt;/p&gt;

&lt;h2&gt;
  
  
  A currency you had to measure
&lt;/h2&gt;

&lt;p&gt;Imagine buying cloth, salt or a gun with a pinch of powder. The value of the deal depends entirely on how much powder is in the pan. Lean on the scale, and you cheat. Use a weight that is a little light, and you cheat quietly, every day, for years.&lt;/p&gt;

&lt;p&gt;The Akan answer was to make the standard itself an object of skill and pride. Goldsmiths cast the weights in brass using the lost-wax method: model the form in wax, cover it in clay, melt the wax out, and pour in the metal. Then came the part that mattered most. Each weight was checked. If a casting came out too heavy, the smith would file it down, and even a beautiful figure might lose a horn or a limb to meet its value. If it was too light, the smith added small lead rings or glass beads until it reached the standard.&lt;/p&gt;

&lt;p&gt;Researchers who have measured surviving weights report that most fall within about 3% of their intended value, a range they compare with European nested weights of the same era. That is a remarkable result for objects that were also works of art. Beauty came second. Accuracy came first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Every trader carried the standard
&lt;/h2&gt;

&lt;p&gt;There was no single central weights office stamping each piece. Weights belonged to people. A merchant kept his own scale and his own set of weights. A complete set raised a man's standing, and small complete sets were given to newly married men so that they could enter trade respectably.&lt;/p&gt;

&lt;p&gt;The system was large. Scholars have recorded more than sixty weight values in a full Akan series, with names that differed from place to place; the historian Timothy Garrard documented twelve separate name lists across Ghana and Côte d'Ivoire. Estimates of how many weights were cast between about 1400 and 1900 run into the millions, though nobody can count them exactly.&lt;/p&gt;

&lt;p&gt;The oldest weights are geometric. Figures of people, animals, tools and buildings appear from around 1600. And many of those figures meant something. A weight could stand for a proverb, a story or a rule of conduct. Equality and justice sit at the heart of Akan thinking, and the weights carried those ideas into the market. The writer Kwame Anthony Appiah has described how his mother, who collected goldweights, heard the proverbs that each figure called up, and the Anansi stories behind them.&lt;/p&gt;

&lt;p&gt;Think about that. The tool that kept the deal honest also reminded you, while you used it, why honesty mattered.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the standard fell away
&lt;/h2&gt;

&lt;p&gt;By the late nineteenth century, the quality of the weights, both their design and their metal, had declined. As coin and paper replaced gold dust as money, the weights lost their daily use and were abandoned. Today many are sold to tourists as mass-produced copies that look like the old ones but carry neither the accuracy nor the proverbs.&lt;/p&gt;

&lt;p&gt;The objects survived. The system around them did not.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the goldweights teach a business today
&lt;/h2&gt;

&lt;p&gt;Every business runs on measurement it rarely thinks about. How much did we receive? How much did we use? How much did we ship? How long did the line run? Most arguments between departments, and between companies, are really arguments about whose scale to believe.&lt;/p&gt;

&lt;p&gt;The Akan goldweights point to four lessons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trust is a standard both sides can check.&lt;/strong&gt; A deal is only as fair as the measurement underneath it. When a supplier, a customer and your own team each keep a different number for the same delivery, you do not have a trust problem. You have a measurement problem. Agree on one record and make it easy for everyone to check.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calibrate, then keep calibrating.&lt;/strong&gt; The goldsmith did not assume the casting was right. He weighed it, and filed or added until it was. Scales drift, sensors drift, and spreadsheets drift fastest of all. Build the check into the work: weigh, compare, correct, and note who did it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Put the standard where the work happens.&lt;/strong&gt; Akan traders carried their weights with them. The measurement was present at the moment of the deal, not in an office days later. In a factory or a warehouse, that means recording quantities and conditions at intake, on the line and at dispatch, not at the end of the week from memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let your measures carry your values.&lt;/strong&gt; The weights were proverbs as well as tools. What you choose to measure tells your people what you care about. If you only measure output, you will get output. If you also measure quality, waste and safety, and name who is responsible, your numbers start to teach.&lt;/p&gt;

&lt;p&gt;This is the work I care about most at Tamalaki. When we build systems such as FactoraERP, the hardest part is rarely the software screen. It is agreeing on the standard: what a lot is, when it is weighed, who confirms it, and how the record follows it from intake to dispatch. Get that right and the rest of the system has something honest to stand on.&lt;/p&gt;

&lt;p&gt;The Akan goldweights lost their purpose when the money changed. The lesson did not. Whatever your currency, someone has to hold the standard.&lt;/p&gt;

&lt;p&gt;So here is my question for you this week: if your biggest customer asked tomorrow how you measured their last order, could you show them, and would they believe your scale?&lt;/p&gt;

&lt;h2&gt;
  
  
  For builders: your system is a set of goldweights
&lt;/h2&gt;

&lt;p&gt;Every system you build rests on measurements someone has to trust: a stock count, a sensor reading, a latency number, a row count after a migration. The Akan goldsmith's habit translates directly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One standard, checkable by both sides.&lt;/strong&gt; If two services compute "available stock" differently, they will disagree in production. Define the measure once and expose it so others can verify it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calibrate in the loop.&lt;/strong&gt; Reconcile counts, compare sensor readings against a reference, and alert on drift. Don't assume the casting came out right.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure at the point of work.&lt;/strong&gt; Capture data where the event happens (intake, the line, dispatch), with who and when, not in a batch job reconstructing it days later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record the adjustment.&lt;/strong&gt; The smith's lead rings and filed edges are visible. Your corrections should be too: an audit trail, not a silent overwrite.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Wikipedia, "Akan goldweights" (names mrammou/abrammuo; status of complete sets and gift sets for newly married men; Early c.1400–1720 and Late c.1700–1900 periods; geometric weights oldest, figurative from c.1600; estimate of around 4 million cast, described as supposition; more than sixty values and Garrard's twelve name lists; lost-wax casting, filing, lead rings and glass beads; most weights under 2½ oz and within 3% of theoretical value, compared with European nest weights; decline by the 1890s; Appiah quotation context): &lt;a href="https://en.wikipedia.org/wiki/Akan_goldweights" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Akan_goldweights&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Wikipedia, "Economy of the Ashanti Empire" (gold dust as main currency and legal tender from the early 18th century, under Osei Kofi Tutu I): &lt;a href="https://en.wikipedia.org/wiki/Economy_of_the_Ashanti_Empire" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Economy_of_the_Ashanti_Empire&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kwame Anthony Appiah, &lt;em&gt;In My Father's House&lt;/em&gt; (1992), on his mother's goldweight collection, as quoted in the Wikipedia article.&lt;/li&gt;
&lt;li&gt;Timothy F. Garrard, &lt;em&gt;Akan Weights and the Gold Trade&lt;/em&gt; (Longman, 1980).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>history</category>
      <category>data</category>
      <category>architecture</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Shelf-Life Is Versioned Config, Expiry Is a Derived Field: Modelling Shelf-Life Studies, Lot Expiry and FEFO in a Food ERP</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Sun, 01 Nov 2026 04:35:41 +0000</pubDate>
      <link>https://dev.to/yit2022/shelf-life-is-versioned-config-expiry-is-a-derived-field-modelling-shelf-life-studies-lot-expiry-1d0</link>
      <guid>https://dev.to/yit2022/shelf-life-is-versioned-config-expiry-is-a-derived-field-modelling-shelf-life-studies-lot-expiry-1d0</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/shelf-life-validation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In most food ERPs, an expiry date is a column on a lot. Someone types it at packing, or the system adds a fixed number of days to the production date, and that's the end of it. But the number of days is not a constant. It is the output of a shelf-life study, it is only valid for a particular recipe, pack and storage condition, and it should change when any of those change. If the data model can't express that, the date printed on the pack quietly drifts away from the evidence behind it.&lt;/p&gt;

&lt;p&gt;This post walks through how we think about modelling shelf-life and expiry in an ERP for food and agro manufacturers in East Africa. The operational checklist behind it is in the &lt;a href="https://factoraerp.com/en/blog/shelf-life-validation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;original article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the domain rules say
&lt;/h2&gt;

&lt;p&gt;The requirements read like a spec:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Kenya's Food Hygiene Regulations (Cap. 254), regulation 14&lt;/strong&gt;: each container marked "to identify the producing factory and the lot", and specified products carrying a date marking. &lt;a href="https://faolex.fao.org/docs/pdf/ken106527.pdf" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Codex CODEX STAN 1-1985, 4.7&lt;/strong&gt;: day and month for products lasting up to three months, month and year beyond that, and storage conditions on the label "if the validity of the date depends thereon". &lt;a href="https://www.fao.org/input/download/standards/32/CXS_001e.pdf" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Codex CXC 1-1969, 13.4&lt;/strong&gt;: records retained "for a period that exceeds the shelf-life of the product". &lt;a href="https://doi.org/10.4060/cc6125en" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FSAI Guidance Note 18&lt;/strong&gt; (an Irish benchmark, not Kenyan law): set shelf-life before launch, redo it on "modification or reformulation", test at least three replicates from three batches per interval where no plan is specified, apply and document a margin of safety, and verify periodically. &lt;a href="https://www.fsai.ie/publications/guidance-note-18-validation-of-product-shelf-life" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Translated into engineering terms: shelf-life is &lt;em&gt;versioned configuration with provenance&lt;/em&gt;, expiry is a &lt;em&gt;derived field&lt;/em&gt; on a lot, and changes to recipe or packaging are &lt;em&gt;invalidation events&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shelf-life belongs to a product version, not a product
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ShelfLifeSpec (id, item_id, recipe_version_id, pack_spec_id, storage_condition,
               date_type, days, margin_days, study_id, approved_by, valid_from, valid_to)
               date_type IN ('use_by','best_before')
ShelfLifeStudy (id, item_id, recipe_version_id, design_json, lab_id, decision_note, closed_at)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The spec points at the recipe version and the pack specification it was proven for, and at the study that justifies it. &lt;code&gt;days&lt;/code&gt; is what goes on the label; &lt;code&gt;margin_days&lt;/code&gt; is how much was taken off the study result and why lives in &lt;code&gt;decision_note&lt;/code&gt;. When either the recipe or the pack spec gets a new version, the old spec doesn't silently carry over. It needs a review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Expiry is derived at the moment the lot is made
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expiry_date = production_date(lot, factory_timezone) + spec.days
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details matter. First, compute it from the production date in the factory's time zone, not the server's, or a lot packed at 1 a.m. in Nairobi gets the wrong date. Second, store the derived date &lt;em&gt;and&lt;/em&gt; the spec id on the lot, so that a later change to the spec doesn't rewrite history on lots already in the market.&lt;/p&gt;

&lt;p&gt;In FactoraERP today, stock items have a &lt;code&gt;trackExpiry&lt;/code&gt; flag and a &lt;code&gt;shelfLifeDays&lt;/code&gt; value, and finished-goods lots get an expiry date calculated from their production date in the factory's time zone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Invalidation: changes that should trigger a review
&lt;/h2&gt;

&lt;p&gt;FSAI lists the triggers in plain language: no evidence for an existing date, and modification or reformulation of the food or its production. That's an event rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;on RecipeVersionPublished(item_id)  -&amp;gt; flag ShelfLifeSpec(item_id) as 'review_required'
on PackSpecChanged(item_id)          -&amp;gt; flag ...
on SupplierApproved(key_ingredient)  -&amp;gt; flag ...
on ComplaintLogged(type='spoilage', lot.expiry_date &amp;gt; complaint_date) -&amp;gt; attach to ShelfLifeSpec as evidence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last rule is the one most systems miss. A spoilage complaint before the printed date is shelf-life evidence, and it should land on the spec, not only in the complaint log.&lt;/p&gt;

&lt;h2&gt;
  
  
  FEFO is where the date earns its keep
&lt;/h2&gt;

&lt;p&gt;An expiry date nobody uses for stock rotation is just ink. Dispatch should pick first-expired, first-out, and any exception should be a recorded decision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- lots skipped in a dispatch that expire earlier than the lot picked&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lot_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expiry_date&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;lot&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;item_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;item_id&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'sellable'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qty_available&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expiry_date&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;picked_lot_expiry&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In FactoraERP, dispatching out of first-expiry order needs an operations manager or admin and a written reason, and the override is stored on the sale with who and when.&lt;/p&gt;

&lt;h2&gt;
  
  
  Study results are measurements, not a PDF
&lt;/h2&gt;

&lt;p&gt;A durability study is a grid: batch × replicate × interval × test. FSAI recommends reading it at a high percentile (90th or 95th) rather than the mean, which needs at least three replicates per time point. That's a query, not an opinion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;interval_day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;percentile_cont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;WITHIN&lt;/span&gt; &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;p95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="k"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;shelf_life_result&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;study_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;study_id&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;interval_day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;span class="k"&gt;HAVING&lt;/span&gt; &lt;span class="k"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;interval_day&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Version shelf-life by recipe, pack spec and storage condition, and link it to the study that proves it.&lt;/li&gt;
&lt;li&gt;Derive expiry at lot creation in the factory's time zone, and store the spec id with it.&lt;/li&gt;
&lt;li&gt;Treat recipe, packaging and supplier changes as invalidation events.&lt;/li&gt;
&lt;li&gt;Route early spoilage complaints to the shelf-life spec as evidence.&lt;/li&gt;
&lt;li&gt;Enforce FEFO and record every override with who, when and why.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full 10-step operational checklist, with references to Kenya's food hygiene regulations, Codex CXS 1, CXC 1 and CXG 61 and FSAI Guidance Note 18, is on the &lt;a href="https://factoraerp.com/en/blog/shelf-life-validation-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;FactoraERP blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>foodsafety</category>
    </item>
    <item>
      <title>Modelling Environmental Monitoring in a Food ERP: Sampling Sites, Swab Results and the Workflow a Positive Should Trigger</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Sat, 31 Oct 2026 04:34:08 +0000</pubDate>
      <link>https://dev.to/yit2022/modelling-environmental-monitoring-in-a-food-erp-sampling-sites-swab-results-and-the-workflow-a-2kfm</link>
      <guid>https://dev.to/yit2022/modelling-environmental-monitoring-in-a-food-erp-sampling-sites-swab-results-and-the-workflow-a-2kfm</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/environmental-monitoring-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A swab result looks like the simplest record in a food factory: a site, a date, a pass or a fail. In practice it is one of the hardest to model well. The same "fail" can mean "re-clean the bench" or "hold three days of product", depending on where the sample was taken, what it was tested for, when it was taken relative to cleaning, and what has been produced since the last clear result. If the data model can't express that, the result ends up in a PDF from the lab and nobody can trend it.&lt;/p&gt;

&lt;p&gt;This post walks through how we think about modelling environmental monitoring in an ERP for food and agro manufacturers in East Africa. The operational checklist behind it is in the &lt;a href="https://factoraerp.com/en/blog/environmental-monitoring-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;original article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the domain rules say
&lt;/h2&gt;

&lt;p&gt;The requirements read like a spec:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Codex CXG 61-2007&lt;/strong&gt; (Annex I) lists what a Listeria environmental monitoring programme must define: type of samples (food contact and non-food contact), target organisms, sampling locations and number of samples, frequency, tools, analytical methods, "a system to record the data and their evaluation, e.g. performing trend analyses", and actions on positive results. &lt;a href="https://www.fao.org/input/download/standards/10740/CXG_061e.pdf" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EAS 39:2001&lt;/strong&gt;: environmental sampling "at a level commensurate with identifying the risk" (4.3.4), timely action when results exceed action limits (4.3.7), a per-line tracking system "to track the location of possible sources of contamination" (4.6.2), and "records of environmental tests" (14.3.4). &lt;a href="https://law.resource.org/pub/eac/ibr/eas.39.2001.pdf" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;21 CFR 117.165(b)(3)&lt;/strong&gt; (a US benchmark, not Kenyan law): the written procedure must identify the test microorganisms, "the locations from which samples will be collected and the number of sites", the timing and frequency, the tests and methods, the laboratory, and the corrective action procedures. &lt;a href="https://www.ecfr.gov/current/title-21/chapter-I/subchapter-B/part-117/subpart-C/section-117.165" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Translated into engineering terms: a sampling &lt;em&gt;plan&lt;/em&gt; is configuration, a &lt;em&gt;sample&lt;/em&gt; is an event against a site, a &lt;em&gt;result&lt;/em&gt; is a measurement against a limit, and a &lt;em&gt;positive&lt;/em&gt; is the start of a workflow, not the end of a record.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sites are first-class entities
&lt;/h2&gt;

&lt;p&gt;The most common mistake is storing the location as free text on the sample. "Filler", "filler area", "near filler" and "Filler 2" become four sites and the trend disappears.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EmSite      (id, code, area_id, zone, surface_type, food_contact bool, active_from, active_to)
            zone IN (1,2,3,4)
EmPlanItem  (id, site_id, target, method, frequency, timing, action_limit, owner_id)
            timing IN ('in_production','pre_startup','post_clean')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sites get stable codes that match the plant map (&lt;code&gt;RTE-Z1-03&lt;/code&gt;), a zone, and validity dates so the history survives a layout change. The plan item says what to test at that site, how often and when relative to cleaning. Timing matters: a post-clean swab verifies the sanitiser, a mid-shift swab looks for harbourage. Mixing them in one trend hides both signals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Samples and results
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EmSample (id, site_id, plan_item_id, collected_at, collected_by, timing, pooled_group_id, lab_id, received_at)
EmResult (id, sample_id, target, method, value, unit, result_text, status, tested_at)
         status IN ('pass','fail','pending')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details come straight from the guidance. First, pooling: Codex allows compositing samples where sensitivity allows, but "in the case of positive findings additional testing will be necessary to determine the location". A &lt;code&gt;pooled_group_id&lt;/code&gt; lets a positive pool fan out into follow-up samples for each member site. Second, &lt;code&gt;received_at&lt;/code&gt;: if the lab can't show when a sample arrived, a transport problem looks like a clean result.&lt;/p&gt;

&lt;p&gt;In FactoraERP today, the laboratory module stores samples with a type (including &lt;code&gt;environmental&lt;/code&gt; and &lt;code&gt;water&lt;/code&gt;), a collection point, date, time and collector, and test results with spec min/max and a pass/fail status. Non-conformances with root cause and CAPA live in the same quality module.&lt;/p&gt;

&lt;h2&gt;
  
  
  A positive opens a workflow
&lt;/h2&gt;

&lt;p&gt;The response is where most systems stop. Codex describes a range: "no action (no risk of recontamination), to intensified cleaning, to source tracing (increased environmental testing), to review of hygienic practices up to holding and testing of product". That's a rule table keyed on zone and target:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EmResponseRule (zone, target, actions[])
  (1, 'Listeria spp.') -&amp;gt; [hold_product_since_last_negative, intensified_clean, vector_sampling, ncr]
  (3, 'Listeria spp.') -&amp;gt; [intensified_clean, vector_sampling, increase_frequency]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Hold product since last negative" is the expensive one, and it is only possible if the system can answer a query like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- batches produced on lines served by a site since its last clear result&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;batch_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;produced_at&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;em_site&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;area_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;area_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;site_code&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;produced_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;collected_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;em_sample&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;
    &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;em_result&lt;/span&gt; &lt;span class="n"&gt;er&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;er&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
    &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;site_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;er&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'pass'&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Vector sampling" means automatically creating follow-up samples at the positive site and its neighbours. Neighbours can be modelled as an adjacency list on the site map, so the plan grows around a problem and shrinks back when it's fixed, which is what EAS 39 4.6.2 asks for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trending is the point
&lt;/h2&gt;

&lt;p&gt;CXG 61 says long-term review "can also reveal low level, intermittent contamination that may otherwise go unnoticed". The useful view isn't a pass rate; it is positives per site over time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;date_trunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'month'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;collected_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="k"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;FILTER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;er&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'fail'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;positives&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="k"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;samples&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;em_sample&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;em_site&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;site_id&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;em_result&lt;/span&gt; &lt;span class="n"&gt;er&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;er&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;es&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'in_production'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;positives&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One positive is an event. The same drain showing up three months in a row is a harbourage site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Make sampling sites first-class entities with stable codes and zones.&lt;/li&gt;
&lt;li&gt;Record timing relative to cleaning, and don't trend post-clean and mid-shift swabs together.&lt;/li&gt;
&lt;li&gt;Support pooled samples with fan-out on positives.&lt;/li&gt;
&lt;li&gt;Treat a positive as the start of a workflow keyed on zone and target.&lt;/li&gt;
&lt;li&gt;Be able to query the product made since a site's last clear result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full 10-step operational checklist, with references to Codex CXC 1 and CXG 61, EAS 39 and Kenya's food hygiene regulations, is on the &lt;a href="https://factoraerp.com/en/blog/environmental-monitoring-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;FactoraERP blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>foodsafety</category>
    </item>
    <item>
      <title>Waste Is an Output, Not a Subtraction: Modelling By-Products, Waste Streams and Licensed Collections in a Food ERP</title>
      <dc:creator>Isaac Mwendwa Muthui</dc:creator>
      <pubDate>Fri, 30 Oct 2026 04:32:32 +0000</pubDate>
      <link>https://dev.to/yit2022/waste-is-an-output-not-a-subtraction-modelling-by-products-waste-streams-and-licensed-44b</link>
      <guid>https://dev.to/yit2022/waste-is-an-output-not-a-subtraction-modelling-by-products-waste-streams-and-licensed-44b</guid>
      <description>&lt;p&gt;&lt;em&gt;By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at &lt;a href="https://factoraerp.com/en/blog/waste-management-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;factoraerp.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most production software models a batch as inputs in, one product out. Whatever doesn't make it into the finished-goods line is "loss", a single number that nobody can explain. In a food factory that number is made of very different things: rejects, line purges, bran, whey, pomace, film offcuts, chemical containers and effluent. Some of it is sold as feed, some goes to a licensed collector, some is hazardous. If the system can't tell them apart, nobody can manage them.&lt;/p&gt;

&lt;p&gt;This post walks through how we think about modelling waste and by-product streams in an ERP for food and agro manufacturers in East Africa. The operational checklist behind it is in the &lt;a href="https://factoraerp.com/en/blog/waste-management-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;original article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the domain rules say
&lt;/h2&gt;

&lt;p&gt;The requirements read like a spec:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Codex CXC 1-1969&lt;/strong&gt; (9.2.1): waste "should be collected, disposed of by trained personnel and, where appropriate, disposal records maintained"; containers "for waste, by-products and inedible or hazardous substances should be specifically identifiable". &lt;a href="https://doi.org/10.4060/cc6125en" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EAS 39:2001&lt;/strong&gt; (10.8): skips emptied "at least once per week", factory waste containers "emptied daily" and not mistakable for food containers. &lt;a href="https://law.resource.org/pub/eac/ibr/eas.39.2001.pdf" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kenya's Sustainable Waste Management Act, 2022&lt;/strong&gt;: segregate "non-hazardous waste into organic and non-organic fractions" (s.12); a private sector entity's annual monitoring report specifies "the actual quantities of waste generated by the entity" (s.19); waste goes to "a person who is licensed to transport and dispose of the waste". &lt;a href="https://new.kenyalaw.org/akn/ke/act/2022/31/eng@2022-12-31" rel="noopener noreferrer"&gt;Source&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Translated into engineering terms: every production output has a type, every waste movement has a stream, a quantity and a destination, and every collection points at a counterparty whose licence has an expiry date.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outputs are typed, not leftover
&lt;/h2&gt;

&lt;p&gt;The first design choice is to stop calculating waste as &lt;code&gt;input - output&lt;/code&gt;. Declare it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RecipeOutput     (id, recipe_id, item_id, output_type, expected_pct)
                 output_type IN ('primary','co_product','byproduct','waste')
ProductionOutput (id, run_id, recipe_output_id, qty_kg, recorded_at, recorded_by)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A recipe that turns 1,000 kg of maize into flour, bran and screenings says so up front. When the run closes, each output is weighed and recorded against the run. "Unexplained loss" becomes the residual after declared outputs, which is the number you actually want to drive towards zero.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By-products are items.&lt;/strong&gt; Bran or whey that leaves the gate as feed gets an item code, a lot, a stock location and a dispatch record, exactly like finished goods. If a raw-material lot is later found to have a problem, the by-product lot is in the same trace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Waste never enters saleable stock.&lt;/strong&gt; A waste output posts to a waste location (or no stock at all), so it can't be picked, sold or counted as inventory value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Streams, movements and collections
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WasteStream      (id, name, category, hazardous, container_spec, removal_frequency, owner_id)
                 category IN ('organic','plastic','general_dry','hazardous','effluent')
WasteMovement    (id, stream_id, source_run_id NULL, source_area, qty_kg, moved_at, moved_by)
WasteCollection  (id, stream_id, collector_id, qty_kg, collected_at, destination, document_ref)
Collector        (id, name, licence_no, licence_expires_on)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few rules make this useful:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Category is fixed on the stream.&lt;/strong&gt; Segregation at source maps one-to-one to streams. If organic and plastic are mixed in one stream, the report can't separate them later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block expired collectors.&lt;/strong&gt; A collection against a collector whose &lt;code&gt;licence_expires_on&lt;/code&gt; is in the past should fail validation, or at least raise an exception for the EHS lead. That turns a filing-cabinet check into a system rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Schedules generate tasks.&lt;/strong&gt; &lt;code&gt;removal_frequency&lt;/code&gt; on the stream creates cleaning-schedule tasks (empty line bins every shift, skip weekly). A missed task is a hygiene finding, not a surprise at audit.&lt;/p&gt;

&lt;h2&gt;
  
  
  The queries that matter
&lt;/h2&gt;

&lt;p&gt;Monthly totals by category, which is close to what an annual monitoring report asks for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;date_trunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'month'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;collected_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qty_kg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;kg&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;waste_collection&lt;/span&gt; &lt;span class="n"&gt;wc&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;waste_stream&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stream_id&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the one production managers care about, waste as a share of output per product and shift:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
       &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;po&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qty_kg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;FILTER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;ro&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'waste'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;
       &lt;span class="k"&gt;NULLIF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;po&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qty_kg&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;waste_share&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;production_output&lt;/span&gt; &lt;span class="n"&gt;po&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;recipe_output&lt;/span&gt; &lt;span class="n"&gt;ro&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;ro&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;po&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;recipe_output_id&lt;/span&gt;
&lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;production_run&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;po&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run_id&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;started_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="s1"&gt;'30 days'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;product_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shift&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;waste_share&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When waste share on one shift starts climbing, it's usually a yield, equipment or training problem showing up early, long before it shows up in the month-end cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Declare outputs on the recipe: primary, co-product, by-product, waste.&lt;/li&gt;
&lt;li&gt;Treat by-products as stock items with lots, not as negative waste.&lt;/li&gt;
&lt;li&gt;Model waste streams with a fixed category so segregation is reportable.&lt;/li&gt;
&lt;li&gt;Put licence expiry on collectors and validate against it.&lt;/li&gt;
&lt;li&gt;Measure waste where it is made, per run, not by subtraction at month end.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full 10-step operational checklist, with references to Codex, EAS 39, Kenya's food hygiene regulations and the Sustainable Waste Management Act, is on the &lt;a href="https://factoraerp.com/en/blog/waste-management-checklist-food-factories-kenya" rel="noopener noreferrer"&gt;FactoraERP blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>erp</category>
      <category>database</category>
      <category>architecture</category>
      <category>sustainability</category>
    </item>
  </channel>
</rss>
