-- ============================================
-- Setup Commission Rules for Testing
-- ============================================

-- Limpiar reglas existentes
TRUNCATE TABLE commission_rules;

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

-- Reglas para Armazón solar (línea 2)
INSERT INTO commission_rules (product_line, payment_type, percentage, active, created_at) VALUES
(2, 'cash', 6.00, 1, NOW()),
(2, 'card', 5.50, 1, NOW()),
(2, 'transfer', 5.50, 1, NOW());

-- Reglas para Lente de Contacto (línea 3)
INSERT INTO commission_rules (product_line, payment_type, percentage, active, created_at) VALUES
(3, 'cash', 8.00, 1, NOW()),
(3, 'card', 7.50, 1, NOW()),
(3, 'transfer', 7.50, 1, NOW());

-- Reglas para Micas (línea 7)
INSERT INTO commission_rules (product_line, payment_type, percentage, active, created_at) VALUES
(7, 'cash', 10.00, 1, NOW()),
(7, 'card', 9.50, 1, NOW()),
(7, 'transfer', 9.50, 1, NOW());

-- Reglas generales para otros productos (4-6, 8-10)
INSERT INTO commission_rules (product_line, payment_type, percentage, active, created_at) VALUES
(4, 'cash', 3.00, 1, NOW()),
(4, 'card', 2.50, 1, NOW()),
(5, 'cash', 3.00, 1, NOW()),
(5, 'card', 2.50, 1, NOW()),
(6, 'cash', 3.00, 1, NOW()),
(6, 'card', 2.50, 1, NOW());

-- Verificar reglas creadas
SELECT
    cr.id,
    l.name as product_line,
    cr.payment_type,
    cr.percentage,
    cr.active
FROM commission_rules cr
JOIN lines l ON l.id = cr.product_line
ORDER BY cr.product_line, cr.payment_type;
