-- Script de vérification du stock central
SELECT 
    'RÉSUMÉ DU STOCK CENTRAL' as info,
    COUNT(*) as total_articles,
    SUM(quantity) as quantite_totale
FROM stock 
WHERE store_id = 1 AND stock_type = 'admin';

-- Vérification par catégorie
SELECT 
    c.name as categorie,
    COUNT(s.id) as nombre_articles,
    SUM(s.quantity) as quantite_totale
FROM stock s
JOIN products p ON s.product_id = p.id
JOIN categories c ON p.category_id = c.id
WHERE s.store_id = 1 AND s.stock_type = 'admin'
GROUP BY c.name
ORDER BY c.name;

-- Détail complet du stock central
SELECT 
    c.name as categorie,
    p.name as produit,
    col.name as couleur,
    sz.name as taille,
    s.quantity as quantite,
    p.price as prix_detail
FROM stock s
JOIN products p ON s.product_id = p.id
JOIN categories c ON p.category_id = c.id
JOIN colors col ON s.color_id = col.id
JOIN sizes sz ON s.size_id = sz.id
WHERE s.store_id = 1 AND s.stock_type = 'admin'
ORDER BY c.name, p.name, col.name, sz.name;

-- Vérification des totaux
SELECT 
    'Vérification totaux' as verification,
    (SELECT COUNT(*) FROM stock WHERE store_id = 1 AND stock_type = 'admin') as articles_stock,
    (SELECT SUM(quantity) FROM stock WHERE store_id = 1 AND stock_type = 'admin') as quantite_totale,
    '51 articles attendus' as attendu;
