Collection archetypes

Collection archetypes

Stocke les archétypes qui classifient les articles du catalogue. Un archétype représente une famille de pièces (ex. "filtre à huile", "plaquettes de frein"). Il peut être global ou surchargé par tenant via ArchetypeOverride.

Métadonnées

Service propriétaire

backend

Tenant scope

Partiel (champ company optionnel)

Soft delete

Oui (champ is_active)

Index principaux

domain + archetype_id (unique), name, is_active + created_at, company + is_active + created_at

Schéma

interface Archetype {
  _id: ObjectId;

  company?: ObjectId;           // absent = archétype global
  domain: string;               // domaine fonctionnel (ex. "auto")
  archetype_id: string;         // identifiant métier

  // Références croisées
  tecdoc_id?: string;
  vanheck_id?: string;
  etai_id?: string;
  aces_id?: string;
  unspsc_code?: string;

  name: string;
  synonyms?: string[];
  description: string;
  required_specs?: string[];    // spécifications obligatoires pour cet archétype
  uom_default?: string;         // unité de mesure par défaut
  hs_code?: string;             // code douanier
  hazard_class?: string;
  vat_rate?: number;

  is_active: boolean;           // défaut : true
  badges?: string[];

  created_by?: ObjectId;
  updated_by?: ObjectId;
  created_at: Date;
  updated_at: Date;

  // Virtuel populé
  overrides?: ArchetypeOverride[];
}

Collection archetype_overrides

Surcharge par tenant d’un archétype global (libellé personnalisé).

Schéma

interface ArchetypeOverride {
  _id: ObjectId;
  archetype: ObjectId;
  company: ObjectId;
  custom_label: string;
  is_active: boolean;
  created_by?: ObjectId;
  updated_by?: ObjectId;
  created_at: Date;
  updated_at: Date;
}

Règles d’intégrité

  1. domain + archetype_id est unique.

  2. is_active: false désactive l’archétype sans le supprimer.

  3. ArchetypeOverride permet à un tenant de renommer un archétype global sans modifier l’original.

Endpoints qui manipulent ces collections

Features qui consomment ces collections

  • Catalogue articles (CAT)

  • Conditions tarifaires (prix publics, ristournes)

  • Règles de marque (BrandRule)