-- ============================================
-- PASO 1: Crear Reglas de Comisión
-- ============================================

-- Limpiar reglas existentes
DELETE FROM commission_rules;

-- Crear reglas para testing
INSERT INTO commission_rules (product_line, payment_type, percentage, active, created_at) VALUES
-- Armazón oftálmico (línea 1)
(1, 'cash', 5.00, 1, NOW()),
(1, 'card', 4.50, 1, NOW()),
(1, 'transfer', 4.50, 1, NOW()),

-- Armazón solar (línea 2)
(2, 'cash', 6.00, 1, NOW()),
(2, 'card', 5.50, 1, NOW()),

-- Micas (línea 7)
(7, 'cash', 10.00, 1, NOW()),
(7, 'card', 9.50, 1, NOW());

-- Verificar reglas creadas
SELECT
    cr.id,
    l.name as linea_producto,
    cr.payment_type as tipo_pago,
    CONCAT(cr.percentage, '%') as porcentaje,
    IF(cr.active, 'Activa', 'Inactiva') as estado
FROM commission_rules cr
JOIN lines l ON l.id = cr.product_line
ORDER BY cr.product_line, cr.payment_type;
