-- =============================================================================
-- Dwapa POS — Tenant database seed data
-- Run against a tenant database after schema creation.
-- Uses UUID v7-style IDs matching the frontend mock data where possible.
-- =============================================================================

-- ── Categories ───────────────────────────────────────────────────────────────

INSERT INTO categories (id, name, slug, created_at, updated_at) VALUES
  ('01900000-0000-7000-8000-000000000001', 'Beverages',   'beverages',   NOW(), NOW()),
  ('01900000-0000-7000-8000-000000000002', 'Food',        'food',        NOW(), NOW()),
  ('01900000-0000-7000-8000-000000000003', 'Electronics', 'electronics', NOW(), NOW()),
  ('01900000-0000-7000-8000-000000000004', 'Clothing',    'clothing',    NOW(), NOW()),
  ('01900000-0000-7000-8000-000000000005', 'Household',   'household',   NOW(), NOW()),
  ('01900000-0000-7000-8000-000000000006', 'Beauty',      'beauty',      NOW(), NOW());

-- ── Products ─────────────────────────────────────────────────────────────────
-- added_by_id references an existing user row — use a placeholder user ID.
-- Replace with real user IDs after the tenant has actual staff accounts.

SET @owner_id = '00000000-0000-0000-0000-000000000001';

INSERT INTO products (id, name, sku, category_id, price, cost, stock, status, image_url, added_by_id, created_at, updated_at) VALUES
  ('prd_0001-0000-7000-8000-000000000001', 'Coca-Cola 500ml',           'BEV-0001', '01900000-0000-7000-8000-000000000001',  1.50, 0.90, 240, 'active',       'https://images.unsplash.com/photo-1554866585-cd94860890b7?auto=format&fit=crop&w=400&q=80', @owner_id, '2025-11-04 09:00:00', NOW()),
  ('prd_0002-0000-7000-8000-000000000002', 'Voltic Mineral Water 750ml','BEV-0002', '01900000-0000-7000-8000-000000000001',  1.00, 0.55,  18, 'low_stock',    'https://images.unsplash.com/photo-1548839140-29a749e1cf4b?auto=format&fit=crop&w=400&q=80', @owner_id, '2025-11-12 10:30:00', NOW()),
  ('prd_0003-0000-7000-8000-000000000003', 'Golden Tree Chocolate Bar', 'FOO-0001', '01900000-0000-7000-8000-000000000002',  3.20, 2.10,  96, 'active',       'https://images.unsplash.com/photo-1481391319762-47dff72954b9?auto=format&fit=crop&w=400&q=80', @owner_id, '2025-12-01 08:15:00', NOW()),
  ('prd_0004-0000-7000-8000-000000000004', 'Jollof Rice Spice Mix',    'FOO-0002', '01900000-0000-7000-8000-000000000002',  4.50, 2.80,   0, 'out_of_stock', 'https://images.unsplash.com/photo-1586201375761-83865001e31c?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-01-08 11:45:00', NOW()),
  ('prd_0005-0000-7000-8000-000000000005', 'Samsung Galaxy Buds',      'ELE-0001', '01900000-0000-7000-8000-000000000003', 89.00,64.00,  32, 'active',       'https://images.unsplash.com/photo-1590658268037-6bf12165a8df?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-01-22 14:00:00', NOW()),
  ('prd_0006-0000-7000-8000-000000000006', 'USB-C Fast Charger 25W',   'ELE-0002', '01900000-0000-7000-8000-000000000003', 18.50,11.00,  12, 'low_stock',    'https://images.unsplash.com/photo-1615526675657-139752bd3065?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-02-03 09:20:00', NOW()),
  ('prd_0007-0000-7000-8000-000000000007', 'Ankara Print Shirt',       'CLO-0001', '01900000-0000-7000-8000-000000000004', 25.00,14.50,  58, 'active',       'https://images.unsplash.com/photo-1596755094514-f87e34085b2c?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-02-18 13:10:00', NOW()),
  ('prd_0008-0000-7000-8000-000000000008', 'Kente Scarf',              'CLO-0002', '01900000-0000-7000-8000-000000000004', 15.00, 8.00,  74, 'active',       'https://images.unsplash.com/photo-1520903920243-00d872a2d1c9?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-03-05 15:40:00', NOW()),
  ('prd_0009-0000-7000-8000-000000000009', 'Sunlight Detergent 1kg',   'HOU-0001', '01900000-0000-7000-8000-000000000005',  5.80, 3.90, 130, 'active',       'https://images.unsplash.com/photo-1585421514738-01798e343b17?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-03-21 10:05:00', NOW()),
  ('prd_0010-0000-7000-8000-000000000010', 'Kitchen Towel 6-Pack',     'HOU-0002', '01900000-0000-7000-8000-000000000005',  7.20, 4.40,   0, 'out_of_stock', 'https://images.unsplash.com/photo-1584556363007-1b16b6311b44?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-04-11 12:30:00', NOW()),
  ('prd_0011-0000-7000-8000-000000000011', 'Shea Butter Body Cream',   'BEA-0001', '01900000-0000-7000-8000-000000000006',  9.90, 5.60,  85, 'active',       'https://images.unsplash.com/photo-1556228720-195a672e8a03?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-05-02 09:50:00', NOW()),
  ('prd_0012-0000-7000-8000-000000000012', 'Coconut Oil Hair Serum',   'BEA-0002', '01900000-0000-7000-8000-000000000006', 12.50, 7.30,  44, 'archived',     'https://images.unsplash.com/photo-1608248543803-ba4f8c7041b9?auto=format&fit=crop&w=400&q=80', @owner_id, '2026-05-27 16:25:00', NOW());

-- ── Customers ────────────────────────────────────────────────────────────────

INSERT INTO customers (id, name, email, phone, total_orders, total_spent, loyalty_points, status, created_at, updated_at) VALUES
  ('cus_0001-0000-7000-8000-000000000001', 'Ama Serwaa',          'ama.serwaa@gmail.com',    '+233 24 111 2233', 34, 1240.50, 620,  'active',   '2025-09-14 10:00:00', NOW()),
  ('cus_0002-0000-7000-8000-000000000002', 'Kojo Antwi',          'kojo.antwi@yahoo.com',    '+233 20 445 6677', 21,  890.00, 445,  'active',   '2025-10-02 12:30:00', NOW()),
  ('cus_0003-0000-7000-8000-000000000003', 'Abena Konadu',        'abena.k@outlook.com',     '+233 26 778 8990', 18,  640.80, 320,  'active',   '2025-11-19 09:15:00', NOW()),
  ('cus_0004-0000-7000-8000-000000000004', 'Kofi Adjei',          'kofi.adjei@gmail.com',    '+233 54 223 3445',  9,  210.40, 105,  'inactive', '2025-12-05 14:50:00', NOW()),
  ('cus_0005-0000-7000-8000-000000000005', 'Esi Prah',            'esi.prah@gmail.com',      '+233 27 556 6778', 27, 1105.20, 552,  'active',   '2026-01-11 11:05:00', NOW()),
  ('cus_0006-0000-7000-8000-000000000006', 'Nana Yaa Asantewaa',  'nanayaa@icloud.com',      '+233 55 889 9001', 42, 2310.70, 1155, 'active',   '2026-02-08 16:20:00', NOW()),
  ('cus_0007-0000-7000-8000-000000000007', 'Kweku Frimpong',      'kweku.f@gmail.com',       '+233 24 990 0112',  5,   98.50,  49,  'inactive', '2026-03-16 13:35:00', NOW()),
  ('cus_0008-0000-7000-8000-000000000008', 'Adwoa Mansa',         'adwoa.mansa@yahoo.com',   '+233 20 112 2334', 15,  530.90, 265,  'active',   '2026-04-22 10:45:00', NOW()),
  ('cus_0009-0000-7000-8000-000000000009', 'Yaw Darko',           'yaw.darko@gmail.com',     '+233 26 334 4556', 11,  342.60, 171,  'active',   '2026-05-30 15:10:00', NOW()),
  ('cus_0010-0000-7000-8000-000000000010', 'Akua Afriyie',        'akua.afriyie@outlook.com','+233 54 667 7889',  7,  156.30,  78,  'active',   '2026-06-25 09:30:00', NOW());

-- ── Sales ────────────────────────────────────────────────────────────────────
-- attendant_id and branch_id reference the tenant's users/branches tables.
-- Use placeholder IDs; replace after real staff accounts exist.

SET @attendant1 = '00000000-0000-0000-0000-000000000010';  -- Efua Owusu
SET @attendant2 = '00000000-0000-0000-0000-000000000011';  -- Kwame Boateng
SET @attendant3 = '00000000-0000-0000-0000-000000000012';  -- Yaw Mensah
SET @attendant4 = '00000000-0000-0000-0000-000000000013';  -- Akosua Asante
SET @branch1    = '00000000-0000-0000-0000-000000000020';  -- Accra Mall
SET @branch2    = '00000000-0000-0000-0000-000000000021';  -- Osu Branch
SET @branch3    = '00000000-0000-0000-0000-000000000022';  -- Kumasi City

INSERT INTO sales (id, customer_id, customer_name, attendant_id, attendant_name, branch_id, branch_name, items_count, subtotal, discount_amount, tax_amount, total, payment_method, status, created_at, updated_at) VALUES
  ('sal_0001-0000-7000-8000-000000000001', NULL,                                       'Ama Serwaa',          @attendant2, 'Kwame Boateng', @branch1, 'Accra Mall',   4, 31.91, 0, 4.79,  36.70, 'momo', 'completed', DATE_SUB(NOW(), INTERVAL 1 HOUR),  NOW()),
  ('sal_0002-0000-7000-8000-000000000002', 'cus_0002-0000-7000-8000-000000000002',     'Kojo Antwi',          @attendant1, 'Efua Owusu',    @branch1, 'Accra Mall',   1, 77.39, 0, 11.61, 89.00, 'card', 'completed', DATE_SUB(NOW(), INTERVAL 2 HOUR),  NOW()),
  ('sal_0003-0000-7000-8000-000000000003', NULL,                                       'Walk-in customer',    @attendant3, 'Yaw Mensah',    @branch2, 'Osu Branch',   6, 19.48, 0, 2.92,  22.40, 'cash', 'pending',   DATE_SUB(NOW(), INTERVAL 3 HOUR),  NOW()),
  ('sal_0004-0000-7000-8000-000000000004', 'cus_0003-0000-7000-8000-000000000003',     'Abena Konadu',        @attendant4, 'Akosua Asante', @branch3, 'Kumasi City',  2, 34.78, 0, 5.22,  40.00, 'momo', 'completed', DATE_SUB(NOW(), INTERVAL 7 HOUR),  NOW()),
  ('sal_0005-0000-7000-8000-000000000005', 'cus_0004-0000-7000-8000-000000000004',     'Kofi Adjei',          @attendant3, 'Yaw Mensah',    @branch2, 'Osu Branch',   3, 16.17, 0, 2.43,  18.60, 'cash', 'refunded',  DATE_SUB(NOW(), INTERVAL 26 HOUR), NOW()),
  ('sal_0006-0000-7000-8000-000000000006', 'cus_0005-0000-7000-8000-000000000005',     'Esi Prah',            @attendant2, 'Kwame Boateng', @branch1, 'Accra Mall',   5, 55.22, 0, 8.28,  63.50, 'card', 'completed', DATE_SUB(NOW(), INTERVAL 49 HOUR), NOW()),
  ('sal_0007-0000-7000-8000-000000000007', NULL,                                       'Walk-in customer',    @attendant4, 'Akosua Asante', @branch3, 'Kumasi City',  2,  7.30, 0, 1.10,   8.40, 'cash', 'completed', DATE_SUB(NOW(), INTERVAL 72 HOUR), NOW()),
  ('sal_0008-0000-7000-8000-000000000008', 'cus_0006-0000-7000-8000-000000000006',     'Nana Yaa Asantewaa',  @attendant1, 'Efua Owusu',    @branch1, 'Accra Mall',   7, 97.65, 0, 14.65,112.30, 'momo', 'completed', DATE_SUB(NOW(), INTERVAL 120 HOUR),NOW()),
  ('sal_0009-0000-7000-8000-000000000009', 'cus_0007-0000-7000-8000-000000000007',     'Kweku Frimpong',      @attendant3, 'Yaw Mensah',    @branch2, 'Osu Branch',   1, 21.74, 0, 3.26,  25.00, 'card', 'cancelled', DATE_SUB(NOW(), INTERVAL 216 HOUR),NOW()),
  ('sal_0010-0000-7000-8000-000000000010', 'cus_0008-0000-7000-8000-000000000008',     'Adwoa Mansa',         @attendant4, 'Akosua Asante', @branch3, 'Kumasi City',  4, 41.65, 0, 6.25,  47.90, 'momo', 'completed', DATE_SUB(NOW(), INTERVAL 288 HOUR),NOW()),
  ('sal_0011-0000-7000-8000-000000000011', 'cus_0009-0000-7000-8000-000000000009',     'Yaw Darko',           @attendant2, 'Kwame Boateng', @branch1, 'Accra Mall',   3, 27.13, 0, 4.07,  31.20, 'cash', 'pending',   DATE_SUB(NOW(), INTERVAL 384 HOUR),NOW()),
  ('sal_0012-0000-7000-8000-000000000012', 'cus_0010-0000-7000-8000-000000000010',     'Akua Afriyie',        @attendant3, 'Yaw Mensah',    @branch2, 'Osu Branch',   2, 17.22, 0, 2.58,  19.80, 'momo', 'completed', DATE_SUB(NOW(), INTERVAL 504 HOUR),NOW());

-- ── Sale Items (representative lines for the first few sales) ────────────────

INSERT INTO sale_items (id, sale_id, product_id, product_name, quantity, unit_price, line_total, created_at, updated_at) VALUES
  ('sli_0001-0000-7000-8000-000000000001', 'sal_0001-0000-7000-8000-000000000001', 'prd_0001-0000-7000-8000-000000000001', 'Coca-Cola 500ml',           2,  1.50,  3.00, NOW(), NOW()),
  ('sli_0002-0000-7000-8000-000000000002', 'sal_0001-0000-7000-8000-000000000001', 'prd_0003-0000-7000-8000-000000000003', 'Golden Tree Chocolate Bar',  1,  3.20,  3.20, NOW(), NOW()),
  ('sli_0003-0000-7000-8000-000000000003', 'sal_0001-0000-7000-8000-000000000001', 'prd_0007-0000-7000-8000-000000000007', 'Ankara Print Shirt',         1, 25.00, 25.00, NOW(), NOW()),
  ('sli_0004-0000-7000-8000-000000000004', 'sal_0002-0000-7000-8000-000000000002', 'prd_0005-0000-7000-8000-000000000005', 'Samsung Galaxy Buds',        1, 89.00, 89.00, NOW(), NOW()),
  ('sli_0005-0000-7000-8000-000000000005', 'sal_0003-0000-7000-8000-000000000003', 'prd_0001-0000-7000-8000-000000000001', 'Coca-Cola 500ml',            4,  1.50,  6.00, NOW(), NOW()),
  ('sli_0006-0000-7000-8000-000000000006', 'sal_0003-0000-7000-8000-000000000003', 'prd_0009-0000-7000-8000-000000000009', 'Sunlight Detergent 1kg',     2,  5.80, 11.60, NOW(), NOW()),
  ('sli_0007-0000-7000-8000-000000000007', 'sal_0004-0000-7000-8000-000000000004', 'prd_0008-0000-7000-8000-000000000008', 'Kente Scarf',                1, 15.00, 15.00, NOW(), NOW()),
  ('sli_0008-0000-7000-8000-000000000008', 'sal_0004-0000-7000-8000-000000000004', 'prd_0006-0000-7000-8000-000000000006', 'USB-C Fast Charger 25W',     1, 18.50, 18.50, NOW(), NOW()),
  ('sli_0009-0000-7000-8000-000000000009', 'sal_0005-0000-7000-8000-000000000005', 'prd_0001-0000-7000-8000-000000000001', 'Coca-Cola 500ml',            3,  1.50,  4.50, NOW(), NOW()),
  ('sli_0010-0000-7000-8000-000000000010', 'sal_0005-0000-7000-8000-000000000005', 'prd_0011-0000-7000-8000-000000000011', 'Shea Butter Body Cream',     1,  9.90,  9.90, NOW(), NOW()),
  ('sli_0011-0000-7000-8000-000000000011', 'sal_0006-0000-7000-8000-000000000006', 'prd_0005-0000-7000-8000-000000000005', 'Samsung Galaxy Buds',        1, 89.00, 89.00, NOW(), NOW());
