82 lines
4.6 KiB
SQL
82 lines
4.6 KiB
SQL
-- ============================================================================
|
|
-- ERP GENERIC - SEED DATA: CATALOGS (Development)
|
|
-- ============================================================================
|
|
-- Description: Base catalogs needed before other seeds (currencies, countries, UOMs)
|
|
-- Order: Must be loaded FIRST (before tenants, companies, etc.)
|
|
-- ============================================================================
|
|
|
|
-- ===========================================
|
|
-- CURRENCIES (ISO 4217)
|
|
-- ===========================================
|
|
|
|
INSERT INTO core.currencies (id, code, name, symbol, decimals, rounding, active)
|
|
VALUES
|
|
('00000000-0000-0000-0000-000000000001', 'MXN', 'Peso Mexicano', '$', 2, 0.01, true),
|
|
('00000000-0000-0000-0000-000000000002', 'USD', 'US Dollar', '$', 2, 0.01, true),
|
|
('00000000-0000-0000-0000-000000000003', 'EUR', 'Euro', '€', 2, 0.01, true)
|
|
ON CONFLICT (code) DO NOTHING;
|
|
|
|
-- ===========================================
|
|
-- COUNTRIES (ISO 3166-1 alpha-2)
|
|
-- ===========================================
|
|
|
|
INSERT INTO core.countries (id, code, name, phone_code, currency_code)
|
|
VALUES
|
|
('00000000-0000-0000-0001-000000000001', 'MX', 'México', '+52', 'MXN'),
|
|
('00000000-0000-0000-0001-000000000002', 'US', 'United States', '+1', 'USD'),
|
|
('00000000-0000-0000-0001-000000000003', 'CA', 'Canada', '+1', 'CAD'),
|
|
('00000000-0000-0000-0001-000000000004', 'ES', 'España', '+34', 'EUR'),
|
|
('00000000-0000-0000-0001-000000000005', 'DE', 'Alemania', '+49', 'EUR')
|
|
ON CONFLICT (code) DO NOTHING;
|
|
|
|
-- ===========================================
|
|
-- UOM CATEGORIES
|
|
-- ===========================================
|
|
|
|
INSERT INTO core.uom_categories (id, name, description)
|
|
VALUES
|
|
('00000000-0000-0000-0002-000000000001', 'Unit', 'Unidades individuales'),
|
|
('00000000-0000-0000-0002-000000000002', 'Weight', 'Unidades de peso'),
|
|
('00000000-0000-0000-0002-000000000003', 'Volume', 'Unidades de volumen'),
|
|
('00000000-0000-0000-0002-000000000004', 'Length', 'Unidades de longitud'),
|
|
('00000000-0000-0000-0002-000000000005', 'Time', 'Unidades de tiempo')
|
|
ON CONFLICT (name) DO NOTHING;
|
|
|
|
-- ===========================================
|
|
-- UNITS OF MEASURE
|
|
-- ===========================================
|
|
|
|
INSERT INTO core.uom (id, category_id, name, code, uom_type, factor, rounding, active)
|
|
VALUES
|
|
-- Units
|
|
('00000000-0000-0000-0003-000000000001', '00000000-0000-0000-0002-000000000001', 'Unit', 'UNIT', 'reference', 1.0, 1, true),
|
|
('00000000-0000-0000-0003-000000000002', '00000000-0000-0000-0002-000000000001', 'Dozen', 'DOZ', 'bigger', 12.0, 1, true),
|
|
('00000000-0000-0000-0003-000000000003', '00000000-0000-0000-0002-000000000001', 'Sheet', 'SHEET', 'reference', 1.0, 1, true),
|
|
-- Weight
|
|
('00000000-0000-0000-0003-000000000010', '00000000-0000-0000-0002-000000000002', 'Kilogram', 'KG', 'reference', 1.0, 0.001, true),
|
|
('00000000-0000-0000-0003-000000000011', '00000000-0000-0000-0002-000000000002', 'Gram', 'G', 'smaller', 0.001, 0.01, true),
|
|
('00000000-0000-0000-0003-000000000012', '00000000-0000-0000-0002-000000000002', 'Pound', 'LB', 'bigger', 0.453592, 0.01, true),
|
|
-- Volume
|
|
('00000000-0000-0000-0003-000000000020', '00000000-0000-0000-0002-000000000003', 'Liter', 'L', 'reference', 1.0, 0.001, true),
|
|
('00000000-0000-0000-0003-000000000021', '00000000-0000-0000-0002-000000000003', 'Milliliter', 'ML', 'smaller', 0.001, 1, true),
|
|
('00000000-0000-0000-0003-000000000022', '00000000-0000-0000-0002-000000000003', 'Gallon', 'GAL', 'bigger', 3.78541, 0.01, true),
|
|
-- Length
|
|
('00000000-0000-0000-0003-000000000030', '00000000-0000-0000-0002-000000000004', 'Meter', 'M', 'reference', 1.0, 0.001, true),
|
|
('00000000-0000-0000-0003-000000000031', '00000000-0000-0000-0002-000000000004', 'Centimeter', 'CM', 'smaller', 0.01, 0.1, true),
|
|
('00000000-0000-0000-0003-000000000032', '00000000-0000-0000-0002-000000000004', 'Inch', 'IN', 'smaller', 0.0254, 0.1, true),
|
|
-- Time
|
|
('00000000-0000-0000-0003-000000000040', '00000000-0000-0000-0002-000000000005', 'Hour', 'HOUR', 'reference', 1.0, 0.01, true),
|
|
('00000000-0000-0000-0003-000000000041', '00000000-0000-0000-0002-000000000005', 'Day', 'DAY', 'bigger', 8.0, 0.01, true),
|
|
('00000000-0000-0000-0003-000000000042', '00000000-0000-0000-0002-000000000005', 'Minute', 'MIN', 'smaller', 0.016667, 1, true)
|
|
ON CONFLICT (id) DO NOTHING;
|
|
|
|
-- Output confirmation
|
|
DO $$
|
|
BEGIN
|
|
RAISE NOTICE 'Catalogs seed data loaded:';
|
|
RAISE NOTICE ' - 3 currencies (MXN, USD, EUR)';
|
|
RAISE NOTICE ' - 5 countries';
|
|
RAISE NOTICE ' - 5 UOM categories';
|
|
RAISE NOTICE ' - 15 units of measure';
|
|
END $$;
|