Collection brands

Collection brands

Stocke les marques disponibles dans le catalogue. Une marque peut être globale (sans company) ou propre à un tenant.

Métadonnées

Service propriétaire

backend

Tenant scope

Partiel (champ company optionnel)

Soft delete

Oui (champ is_active)

Index principaux

company + normalized_name (unique), name, is_active + created_at, company + is_active + created_at

Schéma

interface IBrandAsset {
  asset_type: "logo" | "banner" | "brochure";
  url: string;
  language?: string;
  is_primary: boolean;
}

interface Brand {
  _id: ObjectId;

  company: ObjectId;            // tenant propriétaire
  name: string;
  normalized_name: string;      // généré automatiquement (sans accents, minuscules)
  description?: string;
  brand_type?: string;

  // Références externes
  tecdoc_id?: string;
  tecdoc_mfr_id?: string;
  country?: ObjectId;           // ref: Country
  website?: string;

  is_active: boolean;           // défaut : true
  assets?: IBrandAsset[];
  warranty_document_url?: string;

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

  // Virtuels populés
  aliases?: BrandAlias[];
  archetypes?: BrandArchetype[];
  rules?: BrandRule[];
  metrics?: BrandMetric[];
}

Collection brand_aliases

Alias d’une marque (noms alternatifs).

Schéma

interface BrandAlias {
  _id: ObjectId;
  brand: ObjectId;
  company: ObjectId;
  supplier: ObjectId;
  alias: string;
  normalized_alias: string;
  created_by?: ObjectId;
  updated_by?: ObjectId;
  created_at: Date;
  updated_at: Date;
}

Collection brand_archetypes

Lien entre une marque et un archétype pour un tenant.

Schéma

interface BrandArchetype {
  _id: ObjectId;
  brand: ObjectId;
  company: ObjectId;
  archetype: ObjectId;
  is_active: boolean;
  created_by?: ObjectId;
  updated_by?: ObjectId;
  created_at: Date;
  updated_at: Date;
}

Collection brand_rules

Règles de gestion associées à une marque (priorité fournisseur, visibilité, conditions tarifaires).

Schéma

interface BrandRule {
  _id: ObjectId;
  company: ObjectId;
  brand: ObjectId;
  archetype?: ObjectId;
  supplier?: ObjectId;
  type: "config" | "priority" | "supplier_priority";
  is_active: boolean;
  price_rule?: {
    markup?: number;
    rounding?: number;
    discount?: number;
    is_active: boolean;
  };
  restricted_archetypes?: ObjectId[];
  restricted_companies?: ObjectId[];
  restricted_suppliers?: ObjectId[];
  visibility: "public" | "private";
  priority: number;
  score: number;
  created_by?: ObjectId;
  updated_at: Date;
}

Collection brand_metrics

Indicateurs de performance par marque, archétype et période.

Schéma

interface BrandMetric {
  _id: ObjectId;
  brand: ObjectId;
  company: ObjectId;
  archetype?: ObjectId;
  period: "daily" | "weekly" | "monthly" | "yearly" | "lifetime";
  date: Date;
  sales_volume: number;
  revenue: number;
  avg_basket_value: number;
  return_rate: number;
  avg_delivery_time: number;
  quality_score: number;
  created_by?: ObjectId;
  updated_by?: ObjectId;
  created_at: Date;
  updated_at: Date;
}

Règles d’intégrité

  1. company + normalized_name est unique dans brands.

  2. is_active: false désactive la marque sans la supprimer.

  3. Les BrandArchetype relient une marque à ses archétypes par tenant.

Endpoints qui manipulent ces collections

Features qui consomment ces collections

  • Catalogue articles (CAT)

  • Tarification (prix publics, conditions)

  • Recherche TecDoc (tecdoc_id / tecdoc_mfr_id)