-- Seed data for Landvex AB
-- BOC Business Operations Center

BEGIN;

-- Tenant: Landvex AB
INSERT INTO boc_tenants (id, name, slug, domain, settings, status)
VALUES (
    '550e8400-e29b-41d4-a716-446655440000',
    'Landvex AB',
    'landvex',
    'landvex.com',
    '{"currency": "USD", "timezone": "Europe/Stockholm", "language": "sv", "fiscal_year_start": "01-01"}',
    'active'
)
ON CONFLICT (id) DO NOTHING;

-- Users
INSERT INTO boc_users (id, tenant_id, email, name, role, status)
VALUES
    ('550e8400-e29b-41d4-a716-446655440001', '550e8400-e29b-41d4-a716-446655440000', 'erik@landvex.com', 'Erik Svensson', 'admin', 'active'),
    ('550e8400-e29b-41d4-a716-446655440002', '550e8400-e29b-41d4-a716-446655440000', 'johan@landvex.com', 'Johan Berglund', 'cto', 'active')
ON CONFLICT (tenant_id, email) DO NOTHING;

-- Customers
INSERT INTO boc_customers (id, tenant_id, name, email, phone, company, org_number, status, source, tags, assigned_to)
VALUES
    ('550e8400-e29b-41d4-a716-446655440010', '550e8400-e29b-41d4-a716-446655440000', 'Acme Corp', 'contact@acme.com', '+1-555-0101', 'Acme Corporation', '123456-7890', 'customer', 'referral', '{"enterprise", "us"}', '550e8400-e29b-41d4-a716-446655440001'),
    ('550e8400-e29b-41d4-a716-446655440011', '550e8400-e29b-41d4-a716-446655440000', 'Nordic Tech', 'info@nordictech.se', '+46-70-123-4567', 'Nordic Tech AB', '556677-8899', 'prospect', 'web', '{"nordic", "tech"}', '550e8400-e29b-41d4-a716-446655440001'),
    ('550e8400-e29b-41d4-a716-446655440012', '550e8400-e29b-41d4-a716-446655440000', 'Global Finance', 'hello@globalfinance.com', '+44-20-7946-0958', 'Global Finance Ltd', '987654-3210', 'lead', 'campaign', '{"finance", "uk"}', '550e8400-e29b-41d4-a716-446655440002'),
    ('550e8400-e29b-41d4-a716-446655440013', '550e8400-e29b-41d4-a716-446655440000', 'Svenska Bygg', 'kontakt@svenskabygg.se', '+46-8-555-1234', 'Svenska Bygg AB', '551234-5678', 'customer', 'partner', '{"construction", "sweden"}', '550e8400-e29b-41d4-a716-446655440001'),
    ('550e8400-e29b-41d4-a716-446655440014', '550e8400-e29b-41d4-a716-446655440000', 'HealthTech Inc', 'sales@healthtech.io', '+1-555-0202', 'HealthTech Inc', '112233-4455', 'prospect', 'conference', '{"health", "us"}', '550e8400-e29b-41d4-a716-446655440002')
ON CONFLICT (id) DO NOTHING;

-- Contacts
INSERT INTO boc_contacts (id, tenant_id, customer_id, name, email, phone, title, is_primary)
VALUES
    ('550e8400-e29b-41d4-a716-446655440020', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440010', 'John Doe', 'john@acme.com', '+1-555-0102', 'CEO', true),
    ('550e8400-e29b-41d4-a716-446655440021', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440011', 'Anna Svensson', 'anna@nordictech.se', '+46-70-987-6543', 'CTO', true),
    ('550e8400-e29b-41d4-a716-446655440022', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440012', 'James Smith', 'james@globalfinance.com', '+44-20-7946-0959', 'CFO', true)
ON CONFLICT (id) DO NOTHING;

-- Deals
INSERT INTO boc_deals (id, tenant_id, customer_id, name, description, value, currency, status, stage, probability, expected_close, assigned_to)
VALUES
    ('550e8400-e29b-41d4-a716-446655440030', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440010', 'Acme Enterprise License', 'Full AMOS suite for Acme', 150000, 'USD', 'open', 'negotiation', 75, '2026-09-15', '550e8400-e29b-41d4-a716-446655440001'),
    ('550e8400-e29b-41d4-a716-446655440031', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440011', 'Nordic Tech Pilot', 'Pilot project for Nordic market', 45000, 'USD', 'open', 'proposal', 60, '2026-08-30', '550e8400-e29b-41d4-a716-446655440001'),
    ('550e8400-e29b-41d4-a716-446655440032', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440014', 'HealthTech Integration', 'AMOS Vision for medical imaging', 220000, 'USD', 'open', 'discovery', 40, '2026-10-01', '550e8400-e29b-41d4-a716-446655440002')
ON CONFLICT (id) DO NOTHING;

-- Products
INSERT INTO boc_products (id, tenant_id, name, description, price, currency, sku, status)
VALUES
    ('550e8400-e29b-41d4-a716-446655440040', '550e8400-e29b-41d4-a716-446655440000', 'quiXzoom Auth Core', 'Authentication platform with KYZ', 99, 'USD', 'QZ-AUTH-001', 'active'),
    ('550e8400-e29b-41d4-a716-446655440041', '550e8400-e29b-41d4-a716-446655440000', 'AMOS Vision', 'AI object detection and analysis', 299, 'USD', 'AMOS-VISION-001', 'active'),
    ('550e8400-e29b-41d4-a716-446655440042', '550e8400-e29b-41d4-a716-446655440000', 'AMOS Fraud', 'Fraud detection engine', 199, 'USD', 'AMOS-FRAUD-001', 'active'),
    ('550e8400-e29b-41d4-a716-446655440043', '550e8400-e29b-41d4-a716-446655440000', 'AMOS Infrastructure', 'Infrastructure monitoring AI', 149, 'USD', 'AMOS-INFRA-001', 'active')
ON CONFLICT (id) DO NOTHING;

-- Employees
INSERT INTO boc_employees (id, tenant_id, name, email, phone, department, position, start_date, status)
VALUES
    ('550e8400-e29b-41d4-a716-446655440050', '550e8400-e29b-41d4-a716-446655440000', 'Erik Svensson', 'erik@landvex.com', '+46-70-123-4567', 'Executive', 'Group CEO', '2020-01-01', 'active'),
    ('550e8400-e29b-41d4-a716-446655440051', '550e8400-e29b-41d4-a716-446655440000', 'Johan Berglund', 'johan@landvex.com', '+46-70-987-6543', 'Technology', 'Group CTO', '2021-03-15', 'active')
ON CONFLICT (id) DO NOTHING;

-- Invoices
INSERT INTO boc_invoices (id, tenant_id, customer_id, amount, currency, status, due_date)
VALUES
    ('550e8400-e29b-41d4-a716-446655440060', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440010', 75000, 'USD', 'paid', '2026-06-30'),
    ('550e8400-e29b-41d4-a716-446655440061', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440013', 25000, 'USD', 'pending', '2026-08-15'),
    ('550e8400-e29b-41d4-a716-446655440062', '550e8400-e29b-41d4-a716-446655440000', '550e8400-e29b-41d4-a716-446655440011', 15000, 'USD', 'overdue', '2026-07-01')
ON CONFLICT (id) DO NOTHING;

-- Expenses
INSERT INTO boc_expenses (id, tenant_id, category, description, amount, currency, date, status)
VALUES
    ('550e8400-e29b-41d4-a716-446655440070', '550e8400-e29b-41d4-a716-446655440000', 'Infrastructure', 'AWS EC2 instances', 8500, 'USD', '2026-07-01', 'approved'),
    ('550e8400-e29b-41d4-a716-446655440071', '550e8400-e29b-41d4-a716-446655440000', 'Software', 'GitHub Enterprise', 4200, 'USD', '2026-07-05', 'approved'),
    ('550e8400-e29b-41d4-a716-446655440072', '550e8400-e29b-41d4-a716-446655440000', 'Travel', 'Conference trip San Francisco', 3200, 'USD', '2026-07-10', 'pending')
ON CONFLICT (id) DO NOTHING;

-- Contracts
INSERT INTO boc_contracts (id, tenant_id, title, type, customer_id, value, currency, start_date, end_date, status)
VALUES
    ('550e8400-e29b-41d4-a716-446655440080', '550e8400-e29b-41d4-a716-446655440000', 'Acme Enterprise Agreement', 'license', '550e8400-e29b-41d4-a716-446655440010', 150000, 'USD', '2026-01-01', '2027-01-01', 'active'),
    ('550e8400-e29b-41d4-a716-446655440081', '550e8400-e29b-41d4-a716-446655440000', 'Nordic Tech Pilot Agreement', 'pilot', '550e8400-e29b-41d4-a716-446655440011', 45000, 'USD', '2026-07-01', '2026-09-30', 'active')
ON CONFLICT (id) DO NOTHING;

-- Support Tickets
INSERT INTO boc_tickets (id, tenant_id, title, description, status, priority, customer_id, assigned_to)
VALUES
    ('550e8400-e29b-41d4-a716-446655440090', '550e8400-e29b-41d4-a716-446655440000', 'API latency issue', 'Reports of slow response times', 'open', 'high', '550e8400-e29b-41d4-a716-446655440010', '550e8400-e29b-41d4-a716-446655440002'),
    ('550e8400-e29b-41d4-a716-446655440091', '550e8400-e29b-41d4-a716-446655440000', 'Feature request: SSO', 'Customer wants SAML integration', 'open', 'medium', NULL, '550e8400-e29b-41d4-a716-446655440002')
ON CONFLICT (id) DO NOTHING;

COMMIT;
