-- ═══════════════════════════════════════════════════════════════════════════════ -- SEED 01: CATÁLOGOS BASE -- ═══════════════════════════════════════════════════════════════════════════════ -- Proyecto: ERP Construcción -- Autor: Claude Opus 4.5 -- Fecha: 2026-02-03 -- Descripción: Catálogos fundamentales del sistema (sin dependencias) -- ═══════════════════════════════════════════════════════════════════════════════ -- Usar UUIDs determinísticos para reproducibilidad -- Prefijo: 00000000-0000-0000-0001-XXXXXXXXXXXX para catálogos BEGIN; -- ───────────────────────────────────────────────────────────────────────────────── -- 1. UNIDADES DE MEDIDA -- ───────────────────────────────────────────────────────────────────────────────── INSERT INTO core.units (id, code, name, symbol, category, is_active, created_at) VALUES -- Longitud ('00000000-0000-0000-0001-000000000001', 'M', 'Metro', 'm', 'longitud', true, NOW()), ('00000000-0000-0000-0001-000000000002', 'ML', 'Metro lineal', 'ml', 'longitud', true, NOW()), ('00000000-0000-0000-0001-000000000003', 'KM', 'Kilómetro', 'km', 'longitud', true, NOW()), ('00000000-0000-0000-0001-000000000004', 'CM', 'Centímetro', 'cm', 'longitud', true, NOW()), ('00000000-0000-0000-0001-000000000005', 'MM', 'Milímetro', 'mm', 'longitud', true, NOW()), ('00000000-0000-0000-0001-000000000006', 'PLG', 'Pulgada', 'in', 'longitud', true, NOW()), ('00000000-0000-0000-0001-000000000007', 'PIE', 'Pie', 'ft', 'longitud', true, NOW()), -- Área ('00000000-0000-0000-0001-000000000010', 'M2', 'Metro cuadrado', 'm²', 'area', true, NOW()), ('00000000-0000-0000-0001-000000000011', 'HA', 'Hectárea', 'ha', 'area', true, NOW()), ('00000000-0000-0000-0001-000000000012', 'CM2', 'Centímetro cuadrado', 'cm²', 'area', true, NOW()), -- Volumen ('00000000-0000-0000-0001-000000000020', 'M3', 'Metro cúbico', 'm³', 'volumen', true, NOW()), ('00000000-0000-0000-0001-000000000021', 'LT', 'Litro', 'L', 'volumen', true, NOW()), ('00000000-0000-0000-0001-000000000022', 'GL', 'Galón', 'gal', 'volumen', true, NOW()), -- Peso ('00000000-0000-0000-0001-000000000030', 'KG', 'Kilogramo', 'kg', 'peso', true, NOW()), ('00000000-0000-0000-0001-000000000031', 'TON', 'Tonelada', 'ton', 'peso', true, NOW()), ('00000000-0000-0000-0001-000000000032', 'GR', 'Gramo', 'g', 'peso', true, NOW()), ('00000000-0000-0000-0001-000000000033', 'LB', 'Libra', 'lb', 'peso', true, NOW()), -- Cantidad ('00000000-0000-0000-0001-000000000040', 'PZA', 'Pieza', 'pza', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000041', 'JGO', 'Juego', 'jgo', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000042', 'PAR', 'Par', 'par', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000043', 'LOTE', 'Lote', 'lote', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000044', 'ROLLO', 'Rollo', 'rollo', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000045', 'BOLSA', 'Bolsa', 'bolsa', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000046', 'CAJA', 'Caja', 'caja', 'cantidad', true, NOW()), ('00000000-0000-0000-0001-000000000047', 'CUBETA', 'Cubeta', 'cubeta', 'cantidad', true, NOW()), -- Tiempo ('00000000-0000-0000-0001-000000000050', 'HR', 'Hora', 'hr', 'tiempo', true, NOW()), ('00000000-0000-0000-0001-000000000051', 'DIA', 'Día', 'día', 'tiempo', true, NOW()), ('00000000-0000-0000-0001-000000000052', 'SEM', 'Semana', 'sem', 'tiempo', true, NOW()), ('00000000-0000-0000-0001-000000000053', 'MES', 'Mes', 'mes', 'tiempo', true, NOW()), -- Global ('00000000-0000-0000-0001-000000000060', 'GLOBAL', 'Global', 'gbl', 'global', true, NOW()), ('00000000-0000-0000-0001-000000000061', 'SALIDA', 'Salida', 'sal', 'global', true, NOW()) ON CONFLICT (id) DO NOTHING; -- ───────────────────────────────────────────────────────────────────────────────── -- 2. MONEDAS -- ───────────────────────────────────────────────────────────────────────────────── INSERT INTO core.currencies (id, code, name, symbol, decimal_places, is_active, is_default, created_at) VALUES ('00000000-0000-0000-0001-000000000101', 'MXN', 'Peso Mexicano', '$', 2, true, true, NOW()), ('00000000-0000-0000-0001-000000000102', 'USD', 'Dólar Americano', 'US$', 2, true, false, NOW()), ('00000000-0000-0000-0001-000000000103', 'EUR', 'Euro', '€', 2, true, false, NOW()), ('00000000-0000-0000-0001-000000000104', 'CAD', 'Dólar Canadiense', 'CA$', 2, true, false, NOW()), ('00000000-0000-0000-0001-000000000105', 'GBP', 'Libra Esterlina', '£', 2, true, false, NOW()) ON CONFLICT (id) DO NOTHING; -- ───────────────────────────────────────────────────────────────────────────────── -- 3. IMPUESTOS (México SAT) -- ───────────────────────────────────────────────────────────────────────────────── INSERT INTO core.taxes (id, code, name, rate, tax_type, is_retention, is_active, created_at) VALUES -- IVA ('00000000-0000-0000-0001-000000000201', 'IVA16', 'IVA 16%', 0.16, 'iva', false, true, NOW()), ('00000000-0000-0000-0001-000000000202', 'IVA8', 'IVA 8% (Frontera)', 0.08, 'iva', false, true, NOW()), ('00000000-0000-0000-0001-000000000203', 'IVA0', 'IVA 0%', 0.00, 'iva', false, true, NOW()), ('00000000-0000-0000-0001-000000000204', 'EXENTO', 'Exento de IVA', 0.00, 'exento', false, true, NOW()), -- ISR Retención ('00000000-0000-0000-0001-000000000210', 'ISR10', 'Retención ISR 10%', 0.10, 'isr', true, true, NOW()), ('00000000-0000-0000-0001-000000000211', 'ISR1.25', 'Retención ISR 1.25%', 0.0125, 'isr', true, true, NOW()), -- IVA Retención ('00000000-0000-0000-0001-000000000220', 'RIVA', 'Retención IVA 2/3', 0.106667, 'iva_retenido', true, true, NOW()), ('00000000-0000-0000-0001-000000000221', 'RIVA4', 'Retención IVA 4%', 0.04, 'iva_retenido', true, true, NOW()), -- IEPS (si aplica) ('00000000-0000-0000-0001-000000000230', 'IEPS', 'IEPS Variable', 0.00, 'ieps', false, false, NOW()), -- Sin impuesto ('00000000-0000-0000-0001-000000000240', 'SIN', 'Sin impuesto', 0.00, 'ninguno', false, true, NOW()) ON CONFLICT (id) DO NOTHING; -- ───────────────────────────────────────────────────────────────────────────────── -- 4. BANCOS (México) -- ───────────────────────────────────────────────────────────────────────────────── INSERT INTO core.banks (id, code, name, short_name, swift_code, is_active, created_at) VALUES ('00000000-0000-0000-0001-000000000301', '002', 'BANAMEX', 'Banamex', 'BNMXMXMM', true, NOW()), ('00000000-0000-0000-0001-000000000302', '012', 'BBVA MEXICO', 'BBVA', 'BCMRMXMM', true, NOW()), ('00000000-0000-0000-0001-000000000303', '014', 'SANTANDER', 'Santander', 'BMSXMXMM', true, NOW()), ('00000000-0000-0000-0001-000000000304', '021', 'HSBC', 'HSBC', 'BABORUMM', true, NOW()), ('00000000-0000-0000-0001-000000000305', '030', 'BAJIO', 'Bajío', 'BABORUMM', true, NOW()), ('00000000-0000-0000-0001-000000000306', '036', 'INBURSA', 'Inbursa', 'INBUMXMM', true, NOW()), ('00000000-0000-0000-0001-000000000307', '044', 'SCOTIABANK', 'Scotia', 'MBCOMXMM', true, NOW()), ('00000000-0000-0000-0001-000000000308', '058', 'BANREGIO', 'Banregio', 'BANOMXMM', true, NOW()), ('00000000-0000-0000-0001-000000000309', '072', 'BANORTE', 'Banorte', 'MENOMXMT', true, NOW()), ('00000000-0000-0000-0001-000000000310', '106', 'BANK OF AMERICA', 'BofA', 'BABORUMM', true, NOW()), ('00000000-0000-0000-0001-000000000311', '127', 'AZTECA', 'Azteca', 'BABORUMM', true, NOW()), ('00000000-0000-0000-0001-000000000312', '128', 'AUTOFIN', 'Autofin', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000313', '130', 'COMPARTAMOS', 'Compartamos', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000314', '137', 'BANCOPPEL', 'Coppel', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000315', '138', 'ABC CAPITAL', 'ABC', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000316', '145', 'BBASE', 'BBase', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000317', '646', 'BANSEFI', 'Bansefi', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000318', '659', 'ASP INTEGRA', 'ASP', NULL, true, NOW()), ('00000000-0000-0000-0001-000000000319', '901', 'CLS', 'CLS', NULL, false, NOW()), ('00000000-0000-0000-0001-000000000320', '999', 'OTRO', 'Otro', NULL, true, NOW()) ON CONFLICT (id) DO NOTHING; -- ───────────────────────────────────────────────────────────────────────────────── -- 5. ESTADOS DE MÉXICO -- ───────────────────────────────────────────────────────────────────────────────── INSERT INTO core.states (id, code, name, abbreviation, country_code, is_active, created_at) VALUES ('00000000-0000-0000-0001-000000000401', 'AGS', 'Aguascalientes', 'Ags.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000402', 'BC', 'Baja California', 'B.C.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000403', 'BCS', 'Baja California Sur', 'B.C.S.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000404', 'CAM', 'Campeche', 'Camp.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000405', 'COAH', 'Coahuila', 'Coah.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000406', 'COL', 'Colima', 'Col.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000407', 'CHIS', 'Chiapas', 'Chis.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000408', 'CHIH', 'Chihuahua', 'Chih.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000409', 'CDMX', 'Ciudad de México', 'CDMX', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000410', 'DGO', 'Durango', 'Dgo.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000411', 'GTO', 'Guanajuato', 'Gto.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000412', 'GRO', 'Guerrero', 'Gro.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000413', 'HGO', 'Hidalgo', 'Hgo.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000414', 'JAL', 'Jalisco', 'Jal.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000415', 'MEX', 'Estado de México', 'Méx.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000416', 'MICH', 'Michoacán', 'Mich.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000417', 'MOR', 'Morelos', 'Mor.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000418', 'NAY', 'Nayarit', 'Nay.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000419', 'NL', 'Nuevo León', 'N.L.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000420', 'OAX', 'Oaxaca', 'Oax.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000421', 'PUE', 'Puebla', 'Pue.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000422', 'QRO', 'Querétaro', 'Qro.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000423', 'QROO', 'Quintana Roo', 'Q.R.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000424', 'SLP', 'San Luis Potosí', 'S.L.P.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000425', 'SIN', 'Sinaloa', 'Sin.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000426', 'SON', 'Sonora', 'Son.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000427', 'TAB', 'Tabasco', 'Tab.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000428', 'TAM', 'Tamaulipas', 'Tamps.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000429', 'TLAX', 'Tlaxcala', 'Tlax.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000430', 'VER', 'Veracruz', 'Ver.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000431', 'YUC', 'Yucatán', 'Yuc.', 'MX', true, NOW()), ('00000000-0000-0000-0001-000000000432', 'ZAC', 'Zacatecas', 'Zac.', 'MX', true, NOW()) ON CONFLICT (id) DO NOTHING; -- ───────────────────────────────────────────────────────────────────────────────── -- 6. MUNICIPIOS (Solo Aguascalientes como ejemplo para demo) -- ───────────────────────────────────────────────────────────────────────────────── INSERT INTO core.municipalities (id, state_id, code, name, is_active, created_at) VALUES -- Aguascalientes ('00000000-0000-0000-0001-000000000501', '00000000-0000-0000-0001-000000000401', '001', 'Aguascalientes', true, NOW()), ('00000000-0000-0000-0001-000000000502', '00000000-0000-0000-0001-000000000401', '002', 'Asientos', true, NOW()), ('00000000-0000-0000-0001-000000000503', '00000000-0000-0000-0001-000000000401', '003', 'Calvillo', true, NOW()), ('00000000-0000-0000-0001-000000000504', '00000000-0000-0000-0001-000000000401', '004', 'Cosío', true, NOW()), ('00000000-0000-0000-0001-000000000505', '00000000-0000-0000-0001-000000000401', '005', 'Jesús María', true, NOW()), ('00000000-0000-0000-0001-000000000506', '00000000-0000-0000-0001-000000000401', '006', 'Pabellón de Arteaga', true, NOW()), ('00000000-0000-0000-0001-000000000507', '00000000-0000-0000-0001-000000000401', '007', 'Rincón de Romos', true, NOW()), ('00000000-0000-0000-0001-000000000508', '00000000-0000-0000-0001-000000000401', '008', 'San José de Gracia', true, NOW()), ('00000000-0000-0000-0001-000000000509', '00000000-0000-0000-0001-000000000401', '009', 'Tepezalá', true, NOW()), ('00000000-0000-0000-0001-000000000510', '00000000-0000-0000-0001-000000000401', '010', 'El Llano', true, NOW()), ('00000000-0000-0000-0001-000000000511', '00000000-0000-0000-0001-000000000401', '011', 'San Francisco de los Romo', true, NOW()) ON CONFLICT (id) DO NOTHING; -- ───────────────────────────────────────────────────────────────────────────────── -- VERIFICACIÓN -- ───────────────────────────────────────────────────────────────────────────────── DO $$ DECLARE v_units INTEGER; v_currencies INTEGER; v_taxes INTEGER; v_banks INTEGER; v_states INTEGER; BEGIN SELECT COUNT(*) INTO v_units FROM core.units; SELECT COUNT(*) INTO v_currencies FROM core.currencies; SELECT COUNT(*) INTO v_taxes FROM core.taxes; SELECT COUNT(*) INTO v_banks FROM core.banks; SELECT COUNT(*) INTO v_states FROM core.states; RAISE NOTICE '══════════════════════════════════════════════════════════════'; RAISE NOTICE 'SEED 01 - CATÁLOGOS BASE - COMPLETADO'; RAISE NOTICE '══════════════════════════════════════════════════════════════'; RAISE NOTICE 'Unidades de medida: %', v_units; RAISE NOTICE 'Monedas: %', v_currencies; RAISE NOTICE 'Impuestos: %', v_taxes; RAISE NOTICE 'Bancos: %', v_banks; RAISE NOTICE 'Estados: %', v_states; RAISE NOTICE '══════════════════════════════════════════════════════════════'; END $$; COMMIT; -- ═══════════════════════════════════════════════════════════════════════════════ -- FIN SEED 01 -- ═══════════════════════════════════════════════════════════════════════════════