-- SmartPOS Cloud
-- Seed idempotente para cargar platos del menú diario como productos de servicio
-- y poblar la primera semana de menús con los afiches reales del cliente.
--
-- SECCIÓN 1: Categorías + Productos + product_warehouse
--   Funciona sobre el esquema base (sin migraciones nuevas).
--
-- SECCIÓN 2: daily_menu_versions + daily_menu_entries
--   PREREQUISITO: php artisan migrate (crea la tabla daily_menu_versions,
--   daily_menu_entries y pos_menu_groups del módulo de menú diario).
--
-- Precios base del cliente:
--   Mesa:     $18.000  (proteínas estándar)   $25.000 (pescado)  $30.000 (churrasco)
--   Llevar:   $20.000  (proteínas estándar)
--
-- Notas:
--   - is_service = sin stock, aparece siempre en POS.
--   - INSERT IGNORE permite ejecutar el script múltiples veces sin duplicar.

START TRANSACTION;

SET @PRECIO_BASE     := 18000;
SET @PRECIO_PESCADO  := 25000;
SET @PRECIO_CHURRASCO:= 30000;
SET @RECARGO_LLEVAR  :=  2000;

-- ══════════════════════════════════════════════════════════════════
-- SECCIÓN 1 – PRODUCTOS DE SERVICIO
-- ══════════════════════════════════════════════════════════════════

DROP TEMPORARY TABLE IF EXISTS tmp_menu_diario_catalogo;
CREATE TEMPORARY TABLE tmp_menu_diario_catalogo (
    category_code  VARCHAR(64)  NOT NULL,
    category_name  VARCHAR(191) NOT NULL,
    product_code   VARCHAR(96)  NOT NULL,
    product_name   VARCHAR(191) NOT NULL,
    product_price  DECIMAL(10,2) NOT NULL,
    product_note   TEXT NULL
);

INSERT INTO tmp_menu_diario_catalogo (
    category_code, category_name, product_code, product_name, product_price, product_note
) VALUES
-- ── Pollo ───────────────────────────────────────────────────────
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-AJIACO',          'Ajiaco con pollo',                               @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-PECHUGA-RELLENA', 'Pechuga rellena',                                @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-FINAS-HIERBAS',   'Pollo a las finas hierbas',                      @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-CREPES',          'Crepes de pollo',                                @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-SALSA-CHAMP',     'Pollo en salsa de champiñones',                  @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-AJONJOLI-MIEL',   'Cuadritos de pollo en salsa de ajonjolí y miel', @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-SALSA-ALEMANA',   'Pollo en salsa alemana',                         @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-ESPAGUETTI',      'Espaguetti con pollo',                           @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-ROLLITO-DURAZNO', 'Rollito de pollo en salsa de durazno',           @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-BBQ',             'Pollo BBQ',                                      @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-JARDINERA',       'Pollo a la jardinera',                           @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-SALSA-CASA',      'Pollo en salsa de la casa',                      @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-PECHUGA-CHAMP',   'Pechuga en salsa de champiñones',                @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-TOCINETA',        'Pollo en salsa de tocineta',                     @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-PECHUGA-DURAZNO', 'Pechuga en salsa durazno',                       @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-ARROZ-CON-POLLO', 'Arroz con pollo',                                @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-SUDADO-DORADO',   'Pollo sudado o dorado',                          @PRECIO_BASE,     'Plato base repetido en todos los afiches.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-PLANCHA',         'Pechuga a la plancha',                           @PRECIO_BASE,     'Plato base repetido en todos los afiches.'),
('CAT_MENU_POLLO','Menú diario - Pollo','MD-POL-SALSA-RANCHERA',  'Pechuga en salsa ranchera',                      @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
-- ── Res ─────────────────────────────────────────────────────────
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-GULASH',               'Gulash de carne',                           @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-BISTEC-CABALLO',       'Bistec a caballo',                          @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-SOBREBARRIGA-PLANCHA', 'Sobrebarriga (salsa o plancha)',             @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-SOBREBARRIGA-SALSA',   'Sobrebarriga en salsa',                     @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-SUDADO',               'Sudado de carne',                           @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-STEAK-PIMIENTA',       'Steak pimienta',                            @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-HIGADO-LENTEJAS',      'Hígado con lentejas',                       @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-CARNE-ASADA',          'Carne asada (res)',                         @PRECIO_BASE,     'Plato base repetido en todos los afiches.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-CHURRASCO',            'Churrasco',                                 @PRECIO_CHURRASCO,'En los afiches aparece a $30.000.'),
('CAT_MENU_RES',  'Menú diario - Res',  'MD-RES-CARNE-BBQ',            'Carne en salsa BBQ',                        @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
-- ── Cerdo ───────────────────────────────────────────────────────
('CAT_MENU_CERDO','Menú diario - Cerdo','MD-CER-COSTILLAS-BBQ',   'Costillas de cerdo BBQ',                         @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_CERDO','Menú diario - Cerdo','MD-CER-CHULETA-VALLUNA', 'Chuleta valluna',                                @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_CERDO','Menú diario - Cerdo','MD-CER-BBQ',             'Cerdo en salsa BBQ',                             @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_CERDO','Menú diario - Cerdo','MD-CER-CHULETA-PLANCHA', 'Chuleta a la plancha (cerdo)',                   @PRECIO_BASE,     'Plato base repetido en todos los afiches.'),
('CAT_MENU_CERDO','Menú diario - Cerdo','MD-CER-LOMO-HAWAIANO',   'Lomo de cerdo hawaiano o a la plancha',          @PRECIO_BASE,     'Plato base repetido en todos los afiches.'),
-- ── Pescado ─────────────────────────────────────────────────────
('CAT_MENU_PESCADO','Menú diario - Pescado','MD-PES-MOJARRA',     'Mojarra frita',                                  @PRECIO_PESCADO,  'En los afiches aparece a $25.000.'),
('CAT_MENU_PESCADO','Menú diario - Pescado','MD-PES-TRUCHA',      'Trucha a la plancha',                            @PRECIO_PESCADO,  'En los afiches aparece a $25.000.'),
-- ── Especiales ──────────────────────────────────────────────────
('CAT_MENU_ESPECIAL','Menú diario - Especiales','MD-ESP-ARROZ-ATOLLADO',   'Arroz atollado',                        @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_ESPECIAL','Menú diario - Especiales','MD-ESP-ARROZ-CUBANO',     'Arroz cubano',                          @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_ESPECIAL','Menú diario - Especiales','MD-ESP-ARROZ-PAISA',      'Arroz paisa',                           @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_ESPECIAL','Menú diario - Especiales','MD-ESP-BANDEJA-PAISA',    'Bandeja paisa',                         @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
('CAT_MENU_ESPECIAL','Menú diario - Especiales','MD-ESP-CALLOS',           'Callos a la madrileña',                 @PRECIO_BASE,     'Cazuela: callo, chorizo, cerdo, garbanzos, papa, arroz y plátano.'),
('CAT_MENU_ESPECIAL','Menú diario - Especiales','MD-ESP-ESPAGUETIS-QUESO', 'Espaguetis en salsa de queso',          @PRECIO_BASE,     'Transcrito de afiches del menú diario.'),
-- ── Recargos ────────────────────────────────────────────────────
('CAT_MENU_RECARGO','Menú diario - Recargos','MD-REC-LLEVAR',     'Recargo para llevar - menú diario',              @RECARGO_LLEVAR,  'Mesa $18.000 -> Llevar $20.000.'),
('CAT_MENU_RECARGO','Menú diario - Recargos','MD-REC-DOMICILIO',  'Recargo domicilio - menú diario',                @RECARGO_LLEVAR,  'Ajustar si el domicilio tiene otro recargo.');

-- Crear categorías si no existen
INSERT INTO categories (code, name, created_at, updated_at)
SELECT DISTINCT t.category_code, t.category_name, NOW(), NOW()
FROM tmp_menu_diario_catalogo t
LEFT JOIN categories c ON c.code = t.category_code AND c.deleted_at IS NULL
WHERE c.id IS NULL;

-- Crear productos de servicio (sin stock) si no existen
INSERT INTO products (
    code, Type_barcode, name, cost, price,
    category_id, brand_id, unit_id, unit_sale_id, unit_purchase_id,
    TaxNet, tax_code, tax_method, image, note,
    stock_alert, is_variant, is_active, is_imei, not_selling, type,
    requires_lot_tracking, requires_expiration_date, requires_regulatory_record,
    created_at, updated_at
)
SELECT
    t.product_code, 'CODE128', t.product_name, 0, t.product_price,
    c.id, NULL, NULL, NULL, NULL,
    0, '01', '1', 'no-image.png', t.product_note,
    0, 0, 1, 0, 0, 'is_service',
    0, 0, 0, NOW(), NOW()
FROM tmp_menu_diario_catalogo t
INNER JOIN categories c ON c.code = t.category_code AND c.deleted_at IS NULL
LEFT JOIN products p ON p.code = t.product_code AND p.deleted_at IS NULL
WHERE p.id IS NULL;

-- Registrar en todas las bodegas activas (manage_stock=0 para servicios)
INSERT INTO product_warehouse (
    product_id, warehouse_id, product_variant_id, qte, manage_stock, created_at, updated_at
)
SELECT p.id, w.id, NULL, 0, 0, NOW(), NOW()
FROM products p
INNER JOIN tmp_menu_diario_catalogo t ON t.product_code = p.code
INNER JOIN warehouses w ON w.deleted_at IS NULL
LEFT JOIN product_warehouse pw
    ON pw.product_id = p.id AND pw.warehouse_id = w.id
    AND pw.product_variant_id IS NULL AND pw.deleted_at IS NULL
WHERE p.deleted_at IS NULL AND pw.id IS NULL;

DROP TEMPORARY TABLE IF EXISTS tmp_menu_diario_catalogo;

COMMIT;


-- ══════════════════════════════════════════════════════════════════
-- SECCIÓN 2 – MENÚS DE LA SEMANA (requiere: php artisan migrate)
-- ══════════════════════════════════════════════════════════════════
-- Ejecutar esta sección solo después de confirmar que las tablas
-- daily_menu_versions, daily_menu_entries y pos_menu_groups existen.
--
-- Semana de ejemplo: Lunes 13 → Domingo 19 de abril de 2026.
-- Basado en los 7 afiches del cliente.
--
-- Para usar en semanas futuras: cambia las fechas en menu_date.
-- ══════════════════════════════════════════════════════════════════

START TRANSACTION;

-- ── Versiones de menú (una por día) ──────────────────────────────
-- INSERT IGNORE porque menu_date tiene índice UNIQUE.
INSERT IGNORE INTO daily_menu_versions
    (menu_date, title, soup_of_day, juice_note, fruit_note, dessert_note, general_note, is_active, created_at, updated_at)
VALUES
    ('2026-04-13', 'Menú Lunes 13 de abril',    'Cebada perlada o salpicón',  'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW()),
    ('2026-04-14', 'Menú Martes 14 de abril',   'Cebada perlada o salpicón',  'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW()),
    ('2026-04-15', 'Menú Miércoles 15 de abril','Sancocho o salpicón',         'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW()),
    ('2026-04-16', 'Menú Jueves 16 de abril',   'Arroz o salpicón',            'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW()),
    ('2026-04-17', 'Menú Viernes 17 de abril',  'Campesina o salpicón',        'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW()),
    ('2026-04-18', 'Menú Sábado 18 de abril',   'Campesina o salpicón',        'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW()),
    ('2026-04-19', 'Menú Domingo 19 de abril',  'Arroz o salpicón',            'Natural del día', 'Fruta del día', 'Postre del día', 'Todos los almuerzos acompañados de sopa, jugo, fruta y postre. Proteína + Arroz + Ensalada + Papa. Domicilios: 3212071401 - 2672039', 1, NOW(), NOW());


-- ── Macro: insertar una entrada del menú ─────────────────────────
-- Patrón reutilizable:
--   INSERT IGNORE INTO daily_menu_entries (...)
--   SELECT v.id, g.id, p.id, <sort>, <featured>, 1, <dine_in>, <takeaway>, NULL, NOW(), NOW()
--   FROM daily_menu_versions v
--   JOIN products p ON p.code = '<code>' AND p.deleted_at IS NULL
--   JOIN pos_menu_groups g ON g.slug = '<slug>' AND g.deleted_at IS NULL
--   WHERE v.menu_date = '<fecha>';


-- ═══════════════════════════════════════════════════════
-- LUNES 13 DE ABRIL 2026
-- Especiales: Crepes de pollo, Sobrebarriga en salsa,
--             Arroz paisa, Pollo BBQ
-- ═══════════════════════════════════════════════════════
-- Especiales del día (featured=1, precio mesa $18k/llevar $20k)
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-CREPES' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-SOBREBARRIGA-SALSA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-ESP-ARROZ-PAISA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='especiales' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-BBQ' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
-- Base siempre presente (featured=0)
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
-- Precio especial (sin override de precio, usan precio base del producto)
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,60,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-13';


-- ═══════════════════════════════════════════════════════
-- MARTES 14 DE ABRIL 2026
-- Especiales: Chuleta valluna, Sudado de carne,
--             Arroz con pollo, Pollo a la jardinera
-- ═══════════════════════════════════════════════════════
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-VALLUNA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-SUDADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-ARROZ-CON-POLLO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-JARDINERA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
-- Base
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
-- Precio especial
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,60,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-14';


-- ═══════════════════════════════════════════════════════
-- MIÉRCOLES 15 DE ABRIL 2026
-- Especiales: Bandeja paisa, Pollo en salsa de la casa,
--             Gulash de carne, Pechuga en salsa de champiñones
-- ═══════════════════════════════════════════════════════
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-ESP-BANDEJA-PAISA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='especiales' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SALSA-CASA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-GULASH' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PECHUGA-CHAMP' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
-- Base
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
-- Precio especial
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,60,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-15';


-- ═══════════════════════════════════════════════════════
-- JUEVES 16 DE ABRIL 2026
-- Especiales: Callos a la madrileña, Espaguetis en salsa de queso,
--             Pollo en salsa de tocineta, Steak pimienta,
--             Pechuga en salsa durazno
-- ═══════════════════════════════════════════════════════
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-ESP-CALLOS' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='especiales' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-ESP-ESPAGUETIS-QUESO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='especiales' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-TOCINETA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-STEAK-PIMIENTA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,5,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PECHUGA-DURAZNO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
-- Base
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
-- Precio especial
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,60,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-16';


-- ═══════════════════════════════════════════════════════
-- VIERNES 17 DE ABRIL 2026
-- Especiales: Arroz atollado, Bistec a caballo,
--             Pollo en salsa de champiñones, Cerdo en salsa BBQ,
--             Pechuga en salsa ranchera
-- ═══════════════════════════════════════════════════════
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-ESP-ARROZ-ATOLLADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='especiales' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-BISTEC-CABALLO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SALSA-CHAMP' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-BBQ' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,5,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SALSA-RANCHERA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
-- Base
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
-- Precio especial
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,60,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-17';


-- ═══════════════════════════════════════════════════════
-- SÁBADO 18 DE ABRIL 2026
-- Especiales: Spaghetti con pollo, Pollo en salsa tocineta,
--             Costillas de cerdo BBQ, Gulash de carne
-- ═══════════════════════════════════════════════════════
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-ESPAGUETTI' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-TOCINETA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-COSTILLAS-BBQ' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-GULASH' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
-- Base
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
-- Precio especial
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,60,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-18';


-- ═══════════════════════════════════════════════════════
-- DOMINGO 19 DE ABRIL 2026
-- Especiales: Mojarra frita (precio menú $18k ese día),
--             Arroz paisa, Pechuga ranchera,
--             Pollo en salsa de la casa, Carne en salsa BBQ
-- ═══════════════════════════════════════════════════════
-- Mojarra destacada a precio de menú ese día (override precio)
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,1,1,1,18000,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-MOJARRA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,2,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-ESP-ARROZ-PAISA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='especiales' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,3,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SALSA-RANCHERA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,4,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SALSA-CASA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,5,1,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-BBQ' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
-- Base
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,50,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-SUDADO-DORADO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,51,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-POL-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pollo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,52,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-CHULETA-PLANCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,53,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CARNE-ASADA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,54,0,1,NULL,20000,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-CER-LOMO-HAWAIANO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='cerdo' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
-- Trucha y churrasco sin override (mojarra ya está arriba con override)
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,61,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-PES-TRUCHA' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='pescado' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';
INSERT IGNORE INTO daily_menu_entries (daily_menu_version_id,pos_menu_group_id,product_id,sort_order,is_featured,is_available,dine_in_price,takeaway_price,delivery_price,created_at,updated_at) SELECT v.id,g.id,p.id,62,0,1,NULL,NULL,NULL,NOW(),NOW() FROM daily_menu_versions v JOIN products p ON p.code='MD-RES-CHURRASCO' AND p.deleted_at IS NULL JOIN pos_menu_groups g ON g.slug='res' AND g.deleted_at IS NULL WHERE v.menu_date='2026-04-19';

COMMIT;


START TRANSACTION;

SET @PRECIO_MENU_BASE := 18000;
SET @RECARGO_LLEVAR := 2000;
SET @RECARGO_DOMICILIO := 2000;

DROP TEMPORARY TABLE IF EXISTS tmp_menu_diario_catalogo;
CREATE TEMPORARY TABLE tmp_menu_diario_catalogo (
    category_code VARCHAR(64) NOT NULL,
    category_name VARCHAR(191) NOT NULL,
    product_code VARCHAR(96) NOT NULL,
    product_name VARCHAR(191) NOT NULL,
    product_price DECIMAL(10,2) NOT NULL,
    product_note TEXT NULL
);

INSERT INTO tmp_menu_diario_catalogo (
    category_code, category_name, product_code, product_name, product_price, product_note
) VALUES
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-AJIACO',               'Ajiaco con pollo',                                  @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-GULASH',               'Gulash de carne',                                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_ESPECIAL','Menu diario - Especiales', 'MD-ESP-ARROZ-ATOLLADO',       'Arroz atollado',                                    @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-PECHUGA-RELLENA',      'Pechuga rellena',                                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-FINAS-HIERBAS',        'Pollo a las finas hierbas',                         @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-CREPES',               'Crepes de pollo',                                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-BISTEC-CABALLO',       'Bistec a caballo',                                  @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-SALSA-CHAMP',          'Pollo en salsa de champiñones',                     @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_ESPECIAL','Menu diario - Especiales', 'MD-ESP-ARROZ-CUBANO',         'Arroz cubano',                                      @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-AJONJOLI-MIEL',        'Cuadritos de pollo en salsa de ajonjolí y miel',    @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-SOBREBARRIGA-PLANCHA', 'Sobrebarriga (salsa o plancha)',                    @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-SALSA-ALEMANA',        'Pollo en salsa alemana',                            @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-ESPAGUETTI',           'Espaguetti con pollo',                              @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_CERDO',   'Menu diario - Cerdo',      'MD-CER-COSTILLAS-BBQ',        'Costillas de cerdo BBQ',                            @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-ROLLITO-DURAZNO',      'Rollito de pollo en salsa de durazno',              @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-SOBREBARRIGA-SALSA',   'Sobrebarriga en salsa',                             @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_ESPECIAL','Menu diario - Especiales', 'MD-ESP-ARROZ-PAISA',          'Arroz paisa',                                       @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-BBQ',                  'Pollo BBQ',                                         @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_CERDO',   'Menu diario - Cerdo',      'MD-CER-CHULETA-VALLUNA',      'Chuleta valluna',                                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-SUDADO',               'Sudado de carne',                                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-ARROZ-CON-POLLO',      'Arroz con pollo',                                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-JARDINERA',            'Pollo a la jardinera',                              @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_ESPECIAL','Menu diario - Especiales', 'MD-ESP-BANDEJA-PAISA',        'Bandeja paisa',                                     @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-SALSA-CASA',           'Pollo en salsa de la casa',                         @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-PECHUGA-CHAMP',        'Pechuga en salsa de champiñones',                   @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_ESPECIAL','Menu diario - Especiales', 'MD-ESP-CALLOS',               'Callos a la madrileña',                             @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_ESPECIAL','Menu diario - Especiales', 'MD-ESP-ESPAGUETIS-QUESO',     'Espaguetis en salsa de queso',                      @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-TOCINETA',             'Pollo en salsa de tocineta',                        @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-STEAK-PIMIENTA',       'Steak pimienta',                                    @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-PECHUGA-DURAZNO',      'Pechuga en salsa durazno',                          @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-HIGADO-LENTEJAS',      'Higado con lentejas',                               @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),
    ('CAT_MENU_CERDO',   'Menu diario - Cerdo',      'MD-CER-BBQ',                  'Cerdo BBQ',                                         @PRECIO_MENU_BASE, 'Transcrito de afiches del menu diario.'),

    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-SUDADO-DORADO',        'Pollo sudado o dorado',                             @PRECIO_MENU_BASE, 'Plato base repetido en varios afiches.'),
    ('CAT_MENU_POLLO',   'Menu diario - Pollo',      'MD-POL-PLANCHA',              'Pechuga a la plancha',                              @PRECIO_MENU_BASE, 'Plato base repetido en varios afiches.'),
    ('CAT_MENU_CERDO',   'Menu diario - Cerdo',      'MD-CER-CHULETA-PLANCHA',      'Chuleta a la plancha (cerdo)',                      @PRECIO_MENU_BASE, 'Plato base repetido en varios afiches.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-CARNE-ASADA',          'Carne asada (res)',                                 @PRECIO_MENU_BASE, 'Plato base repetido en varios afiches.'),
    ('CAT_MENU_CERDO',   'Menu diario - Cerdo',      'MD-CER-LOMO-HAWAIANO',        'Lomo de cerdo hawaiano o a la plancha',            @PRECIO_MENU_BASE, 'Plato base repetido en varios afiches.'),
    ('CAT_MENU_PESCADO', 'Menu diario - Pescado',    'MD-PES-MOJARRA',              'Mojarra frita',                                     25000,             'En los afiches aparece a $25.000.'),
    ('CAT_MENU_PESCADO', 'Menu diario - Pescado',    'MD-PES-TRUCHA',               'Trucha a la plancha',                               25000,             'En los afiches aparece a $25.000.'),
    ('CAT_MENU_RES',     'Menu diario - Res',        'MD-RES-CHURRASCO',            'Churrasco',                                         30000,             'En los afiches aparece a $30.000.'),

    ('CAT_MENU_RECARGO', 'Menu diario - Recargos',   'MD-REC-LLEVAR',               'Recargo para llevar - menu diario',                 @RECARGO_LLEVAR,   'Basado en afiches: menu base 18.000 y llevar 20.000.'),
    ('CAT_MENU_RECARGO', 'Menu diario - Recargos',   'MD-REC-DOMICILIO',            'Recargo domicilio - menu diario',                   @RECARGO_DOMICILIO,'Ajustar este valor si tu domicilio no usa el mismo recargo que llevar.');

-- Crear categorias si no existen
INSERT INTO categories (code, name, created_at, updated_at)
SELECT DISTINCT
    t.category_code,
    t.category_name,
    NOW(),
    NOW()
FROM tmp_menu_diario_catalogo t
LEFT JOIN categories c
    ON c.code = t.category_code
   AND c.deleted_at IS NULL
WHERE c.id IS NULL;

-- Crear productos como servicios
INSERT INTO products (
    code,
    Type_barcode,
    name,
    cost,
    price,
    category_id,
    brand_id,
    unit_id,
    unit_sale_id,
    unit_purchase_id,
    TaxNet,
    tax_code,
    tax_method,
    image,
    note,
    stock_alert,
    is_variant,
    is_active,
    is_imei,
    not_selling,
    type,
    requires_lot_tracking,
    requires_expiration_date,
    requires_regulatory_record,
    created_at,
    updated_at
)
SELECT
    t.product_code,
    'CODE128',
    t.product_name,
    0,
    t.product_price,
    c.id,
    NULL,
    NULL,
    NULL,
    NULL,
    0,
    '01',
    '1',
    'no-image.png',
    t.product_note,
    0,
    0,
    1,
    0,
    0,
    'is_service',
    0,
    0,
    0,
    NOW(),
    NOW()
FROM tmp_menu_diario_catalogo t
INNER JOIN categories c
    ON c.code = t.category_code
   AND c.deleted_at IS NULL
LEFT JOIN products p
    ON p.code = t.product_code
   AND p.deleted_at IS NULL
WHERE p.id IS NULL;

-- Asegurar presencia en todas las bodegas activas para que aparezcan en POS
INSERT INTO product_warehouse (
    product_id,
    warehouse_id,
    product_variant_id,
    qte,
    manage_stock,
    created_at,
    updated_at
)
SELECT
    p.id,
    w.id,
    NULL,
    0,
    0,
    NOW(),
    NOW()
FROM products p
INNER JOIN tmp_menu_diario_catalogo t
    ON t.product_code = p.code
INNER JOIN warehouses w
    ON w.deleted_at IS NULL
LEFT JOIN product_warehouse pw
    ON pw.product_id = p.id
   AND pw.warehouse_id = w.id
   AND pw.product_variant_id IS NULL
   AND pw.deleted_at IS NULL
WHERE p.deleted_at IS NULL
  AND pw.id IS NULL;

DROP TEMPORARY TABLE IF EXISTS tmp_menu_diario_catalogo;

-- Activar menú diario en POS (si las columnas existen)
UPDATE pos_settings
   SET pos_daily_menu = 1,
       pos_fast_checkout = 1
 WHERE deleted_at IS NULL
 LIMIT 1;

COMMIT;
