export enum CategorieStock {
    MATERIAUX_CONSTRUCTION = 'MATERIAUX_CONSTRUCTION',
    OUTILLAGE = 'OUTILLAGE',
    QUINCAILLERIE = 'QUINCAILLERIE',
    EQUIPEMENTS_SECURITE = 'EQUIPEMENTS_SECURITE',
    EQUIPEMENTS_TECHNIQUES = 'EQUIPEMENTS_TECHNIQUES',
    CONSOMMABLES = 'CONSOMMABLES',
    VEHICULES_ENGINS = 'VEHICULES_ENGINS',
    FOURNITURES_BUREAU = 'FOURNITURES_BUREAU',
    PRODUITS_CHIMIQUES = 'PRODUITS_CHIMIQUES',
    PIECES_DETACHEES = 'PIECES_DETACHEES',
    EQUIPEMENTS_MESURE = 'EQUIPEMENTS_MESURE',
    MOBILIER = 'MOBILIER',
    AUTRE = 'AUTRE'
}

export enum UniteMesure {
    UNITE = 'UNITE',
    PAIRE = 'PAIRE',
    LOT = 'LOT',
    JEU = 'JEU',
    KIT = 'KIT',
    ENSEMBLE = 'ENSEMBLE',
    GRAMME = 'GRAMME',
    KILOGRAMME = 'KILOGRAMME',
    TONNE = 'TONNE',
    MILLIMETRE = 'MILLIMETRE',
    CENTIMETRE = 'CENTIMETRE',
    METRE = 'METRE',
    METRE_LINEAIRE = 'METRE_LINEAIRE',
    KILOMETRE = 'KILOMETRE',
    CENTIMETRE_CARRE = 'CENTIMETRE_CARRE',
    METRE_CARRE = 'METRE_CARRE',
    HECTARE = 'HECTARE',
    CENTIMETRE_CUBE = 'CENTIMETRE_CUBE',
    DECIMETRE_CUBE = 'DECIMETRE_CUBE',
    METRE_CUBE = 'METRE_CUBE',
    LITRE = 'LITRE',
    MILLILITRE = 'MILLILITRE',
    HEURE = 'HEURE',
    JOUR = 'JOUR',
    SEMAINE = 'SEMAINE',
    MOIS = 'MOIS',
    SAC = 'SAC',
    PALETTE = 'PALETTE',
    ROULEAU = 'ROULEAU',
    PLAQUE = 'PLAQUE',
    BARRE = 'BARRE',
    TUBE = 'TUBE',
    PROFILE = 'PROFILE',
    PANNEAU = 'PANNEAU',
    BIDON = 'BIDON',
    CARTOUCHE = 'CARTOUCHE',
    METRE_CABLE = 'METRE_CABLE',
    BOBINE = 'BOBINE',
    AUTRE = 'AUTRE'
}

export enum StatutStock {
    ACTIF = 'ACTIF',
    INACTIF = 'INACTIF',
    OBSOLETE = 'OBSOLETE',
    SUPPRIME = 'SUPPRIME',
    EN_COMMANDE = 'EN_COMMANDE',
    EN_TRANSIT = 'EN_TRANSIT',
    EN_CONTROLE = 'EN_CONTROLE',
    QUARANTAINE = 'QUARANTAINE',
    DEFECTUEUX = 'DEFECTUEUX',
    PERDU = 'PERDU',
    RESERVE = 'RESERVE',
    EN_REPARATION = 'EN_REPARATION'
}

export interface Stock {
    id?: string;
    reference: string;
    designation: string;
    description?: string;
    categorie: CategorieStock;
    sousCategorie?: string;
    uniteMesure: UniteMesure;
    quantiteStock: number;
    quantiteMinimum?: number;
    quantiteMaximum?: number;
    quantiteSecurite?: number;
    quantiteReservee?: number;
    quantiteEnCommande?: number;
    prixUnitaireHT?: number;
    coutMoyenPondere?: number;
    coutDerniereEntree?: number;
    tauxTVA?: number;
    emplacementStockage?: string;
    codeZone?: string;
    codeAllee?: string;
    codeEtagere?: string;
    fournisseurPrincipal?: {
        id: string;
        nom: string;
    };
    chantier?: {
        id: string;
        nom: string;
    };
    marque?: string;
    modele?: string;
    referenceFournisseur?: string;
    codeBarre?: string;
    codeEAN?: string;
    poidsUnitaire?: number;
    longueur?: number;
    largeur?: number;
    hauteur?: number;
    volume?: number;
    dateDerniereEntree?: string;
    dateDerniereSortie?: string;
    datePeremption?: string;
    dateDerniereInventaire?: string;
    statut: StatutStock;
    gestionParLot?: boolean;
    traçabiliteRequise?: boolean;
    articlePerissable?: boolean;
    controleQualiteRequis?: boolean;
    articleDangereux?: boolean;
    classeDanger?: string;
    commentaires?: string;
    notesStockage?: string;
    conditionsStockage?: string;
    temperatureStockageMin?: number;
    temperatureStockageMax?: number;
    humiditeMax?: number;
    dateCreation?: string;
    dateModification?: string;
    creePar?: string;
    modifiePar?: string;
    
    // Propriétés calculées
    quantiteDisponible?: number;
    valeurStock?: number;
    enRupture?: boolean;
    sousQuantiteMinimum?: boolean;
    sousQuantiteSecurite?: boolean;
    perime?: boolean;
}

export interface MouvementStock {
    stockId: string;
    quantite: number;
    coutUnitaire?: number;
    motif?: string;
    chantierId?: string;
    reference?: string;
}

export interface StockStatistiques {
    total: number;
    parCategorie: Record<CategorieStock, number>;
    parStatut: Record<StatutStock, number>;
    articlesEnRupture: number;
    articlesSousMinimum: number;
    articlesPerimes: number;
    valeurTotaleStock: number;
}