CSV templates and bulk import

Supported data types

Warehouses, locations, products, categories, brands, units of measure, packaging & unit conversions, alternate barcodes, pick faces (min/max), suppliers, customers, transporters, vehicles, reason codes, opening stock and outbound orders.

Each type has a downloadable template (header plus example row) and a column guide (Masters → Import / Export). Column definitions come from app/Masters/definitions.php, so templates always match the current fields, including custom fields (cf_<key> columns).

Engine (app/Services/ImportService.php)

  1. Upload: size limit (import.max_mb, default 10 MB), row limit (import.max_rows, default 20,000). The MIME type is sniffed; the filename/extension is not trusted. Required columns are checked. The file is stored in storage/temporary under a random name.
  2. Parse: UTF-8 (BOM removed), UTF-16 and Windows-1252 converted; , ; or TAB delimiter detected; headers normalised to lowercase. Apostrophes added by formula protection on export are stripped.
  3. Validate (dry run): for every row: required fields, types, ranges, dates, select values, foreign keys by code, barcode uniqueness across all barcode tables, duplicates within the file (by unique key), existing-record behaviour per mode, warehouse access, plus entity rules (locations holding stock cannot be deactivated, base unit fixed while stock exists, etc.). Results: counts, preview of the first 20 rows, and up to 2,000 row-level errors (line, column, message) stored with the job and downloadable as CSV.
  4. Commit: refused while errors exist unless "Import valid rows only" is explicitly chosen. Processed in chunks of 500 rows per request, each chunk in a transaction, with rows re-validated at commit time. Progress is stored (processed_rows), so an interrupted import can be resumed without duplicating rows. Inserted, updated and skipped counts are recorded and shown in the import history. Audit entries are written for upload and commit.

Modes

ModeExisting recordNew record
inserterrorinserted
upsertupdated (blank cells keep values)inserted
updateupdated (blank cells keep values)error
skipskipped (counted)inserted

Special importers

  • opening_stock: warehouse, location, sku, batch_no, mfg_date, expiry_date, qty, uom, status. Creates batches (refusing conflicting expiry dates) and OPENING_STOCK ledger movements directly into the bins. Requires adjustments.approve.
  • orders: order_ref, warehouse, customer, sku, qty, uom, required_date, priority, ship_to. Rows with the same reference + warehouse + customer form one draft order.

Export

Each master list has Export CSV (permission <module>.export). Exports stream row by row (low memory), include a UTF-8 BOM for Excel, are audited, and neutralise formula injection.