HOCO B2B
Team tasksAnis

SRV-27 — Data imports — products, resellers, users, stock

Excel/CSV import jobs with templates, dry-run validation report, idempotent apply and error rows export.

FieldDetails
Task codeSRV-27
PhaseP1 — V1 build & integration
Product scopeV1
StatusDone (Mon 19 Oct 2026)
StartMon 19 Oct 2026
DueMon 19 Oct 2026
ResponsibleAnis — Full-stack developer
Co-responsible—
Effort0.5 person-day(s) planned · 3 from scratch · size XS
Area · appServer · server
Depends onSRV-11, SRV-14
UnblocksDSH-12, SRV-41
Milestones—

Summary

Excel/CSV import jobs with templates, dry-run validation report, idempotent apply and error rows export.

Description

Go-live needs HOCO's existing products, resellers, users and stock loaded without hand entry (cahier §13.2; ADM-06, CAT-06), and catalog maintenance needs Excel imports afterwards. This task implements ImportJob for four types — products (with variants, the three customer-type prices, VAT, attributes and image URLs), resellers (with customer type, normalised phone and duplicate detection), users (staff and delegates with roles and zones) and stock (initial levels per warehouse posted as movements) — with downloadable XLSX templates, an upload through files (IMPORT_FILE), a dry-run validation report per row (errors and warnings), an idempotent apply keyed on natural keys (product reference + variant SKU, reseller phone, user phone or email, SKU + warehouse), and an error-rows export. Endpoints are admin.imports.create/get and admin.products.import. Out of scope: the import UI (BO-32 in DSH-04, BO-67 in DSH-12) and API sync with HOCO's stock system (V2).

Subtasks

#SubtaskOwner
1Import framework: ImportJob lifecycle (QUEUED, RUNNING, SUCCEEDED, FAILED), worker processor, progress, IMPORT audit entryAnis
2XLSX templates per type with data-validation lists (brands, categories, customer types, wilayas, roles) and an instructions sheetAnis
3Row parser and validator per type reusing module Zod schemas; dry-run report with error and warning per row and columnAnis
4Products import: create/update by reference + SKU, three prices with PriceChange entries, VAT, attributes validated against AttributeDefinition, image URLs fetched into storageAnis
5Resellers import: phone normalisation, duplicate detection against existing records, customer type, wilaya/commune codes, delegate assignment, source IMPORTAnis
6Users import: staff and delegates with roles and zones, password-setup link sent by SMS or emailAnis
7Stock import: initial levels per SKU and warehouse posted as RECEIPT or ADJUSTMENT movements with reason « Import initial »Anis
8Idempotent apply (same file twice = no change) and error-rows XLSX exportAnis

Deliverables

  • apps/server/src/modules/integrations/imports/{framework.ts,templates/,products.ts,resellers.ts,users.ts,stock.ts,router.ts}
  • packages/contracts/src/admin/imports.ts
  • Template files served from /admin/imports/templates/{type}.xlsx

Acceptance criteria

  • A dry run never writes business data and reports every invalid row with its column and message (ADM-06)
  • Applying the same products file twice leaves the database unchanged the second time (CAT-06)
  • A reseller row whose phone already exists is reported as a duplicate and updates nothing unless the update mode is chosen (CRM-03)
  • A stock import creates one movement per row and the levels match the file (STK-04)
  • A 5 000-row products file completes in under 5 minutes on staging

Requirements covered

RequirementTitleRelease
ADM-06Initial imports: products, resellers, user accounts, stockV1
CAT-06Product import/export (Excel/CSV) with a validation reportV1

Screens

ScreenNameApp
BO-32Product import wizardBO
BO-67Data importsBO

API surface

Test measures

  • Fixture files with valid, invalid and duplicate rows per type; assertions on the report and on data
  • Idempotency test applying the same file twice
  • Dry run with a real HOCO export during LCH-01 preparation

Risks

  • HOCO's spreadsheets do not match the templates — a mapping step in the wizard and an early sample file request after PRJ-03

KPI

  • Delivered by Mon 19 Oct 2026 within 0.5 person-day(s).
  • Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
  • Zero open critical defects, permission gaps or data-integrity regressions at sign-off.

Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.

On this page