-- ============================================================
--  BharatERP - Seed Data (Demo)
--  Inserted by installer after schema creation
-- ============================================================


-- Company (populated by installer, this is fallback)
INSERT IGNORE INTO `companies` (`id`,`name`,`legal_name`,`gstin`,`email`,`phone`,`city`,`state`,`business_type`) VALUES
(1, 'BharatERP Demo Store', 'BharatERP Demo Pvt Ltd', '27AABCS1429B1ZB', 'admin@bharaterp.in', '9876543210', 'Mumbai', 'Maharashtra', 'retail');

-- Admin user password = 'admin123' (bcrypt)
-- Real password set by installer; this is a safe default
INSERT IGNORE INTO `users` (`id`,`company_id`,`name`,`email`,`password`,`role`,`is_active`) VALUES
(1, 1, 'Super Admin', 'admin@bharaterp.in', '$2y$12$LiEsKiWr8/gPqbA/9p4tO.z9cJxQZ7K2mHwT1AJvnF5D1EeWUj3Oy', 'super_admin', 1);

-- Warehouses
INSERT IGNORE INTO `warehouses` (`id`,`company_id`,`name`,`code`,`city`,`is_default`,`is_active`) VALUES
(1, 1, 'Main Warehouse', 'WH-MAIN', 'Mumbai', 1, 1),
(2, 1, 'Branch Store', 'WH-BRANCH', 'Mumbai', 0, 1);

-- Units
INSERT IGNORE INTO `units` (`id`,`company_id`,`name`,`abbreviation`) VALUES
(1, 1, 'Pieces', 'Pcs'),
(2, 1, 'Kilograms', 'Kg'),
(3, 1, 'Grams', 'Gm'),
(4, 1, 'Liters', 'Ltr'),
(5, 1, 'Milliliters', 'Ml'),
(6, 1, 'Box', 'Box'),
(7, 1, 'Dozen', 'Doz'),
(8, 1, 'Meters', 'Mtr');

-- Categories
INSERT IGNORE INTO `categories` (`id`,`company_id`,`name`,`sort_order`) VALUES
(1, 1, 'Electronics', 1),
(2, 1, 'Groceries', 2),
(3, 1, 'Clothing', 3),
(4, 1, 'Home & Kitchen', 4),
(5, 1, 'Health & Beauty', 5),
(6, 1, 'Stationery', 6),
(7, 1, 'Beverages', 7),
(8, 1, 'Dairy', 8);

-- Sample Products
INSERT IGNORE INTO `products` (`id`,`company_id`,`name`,`sku`,`barcode`,`category_id`,`unit_id`,`purchase_price`,`selling_price`,`mrp`,`gst_rate`,`hsn_code`,`min_stock`,`is_active`) VALUES
(1, 1, 'Basmati Rice (1 Kg)', 'RICE-001', '8901234567890', 2, 2, 55.00, 75.00, 80.00, 5.00, '1006', 10, 1),
(2, 1, 'Tata Salt (1 Kg)', 'SALT-001', '8902345678901', 2, 2, 18.00, 22.00, 25.00, 5.00, '2501', 20, 1),
(3, 1, 'Amul Milk 500ml', 'MILK-001', '8903456789012', 8, 4, 26.00, 30.00, 30.00, 5.00, '0401', 30, 1),
(4, 1, 'Parle-G Biscuit 100g', 'BISC-001', '8904567890123', 2, 1, 8.00, 12.00, 12.00, 12.00, '1905', 50, 1),
(5, 1, 'Sunflower Oil 1L', 'OIL-001', '8905678901234', 2, 4, 110.00, 140.00, 150.00, 5.00, '1512', 15, 1),
(6, 1, 'Rin Detergent 500g', 'DET-001', '8906789012345', 4, 1, 40.00, 55.00, 60.00, 18.00, '3402', 25, 1),
(7, 1, 'Colgate Toothpaste', 'PASTE-001', '8907890123456', 5, 1, 52.00, 68.00, 75.00, 12.00, '3306', 20, 1),
(8, 1, 'A4 Paper (500 Sheets)', 'PAPER-001', '8908901234567', 6, 1, 200.00, 260.00, 280.00, 12.00, '4802', 10, 1),
(9, 1, 'Lay''s Chips Classic', 'CHIPS-001', '8909012345678', 2, 1, 18.00, 25.00, 25.00, 12.00, '2106', 40, 1),
(10, 1, 'Lifebuoy Soap 100g', 'SOAP-001', '8900123456789', 5, 1, 22.00, 30.00, 35.00, 18.00, '3401', 30, 1);

-- Inventory (stock for warehouse 1)
INSERT IGNORE INTO `inventory` (`company_id`,`product_id`,`warehouse_id`,`quantity`,`min_quantity`) VALUES
(1, 1, 1, 85.000, 10),
(1, 2, 1, 120.000, 20),
(1, 3, 1, 65.000, 30),
(1, 4, 1, 200.000, 50),
(1, 5, 1, 45.000, 15),
(1, 6, 1, 80.000, 25),
(1, 7, 1, 55.000, 20),
(1, 8, 1, 30.000, 10),
(1, 9, 1, 150.000, 40),
(1, 10, 1, 90.000, 30);

-- Sample Customers
INSERT IGNORE INTO `customers` (`id`,`company_id`,`name`,`phone`,`email`,`gstin`,`city`,`customer_type`,`credit_limit`) VALUES
(1, 1, 'Ramesh Sharma', '9876543210', 'ramesh@example.com', '', 'Mumbai', 'retail', 5000),
(2, 1, 'Priya Traders', '9765432109', 'priya@priyatraders.com', '27AAPCT1234A1Z5', 'Pune', 'wholesale', 50000),
(3, 1, 'Suresh Kumar', '9654321098', '', '', 'Nashik', 'retail', 2000),
(4, 1, 'M/s Kapoor Enterprises', '9543210987', 'kapoor@kapoorent.in', '27ABCPK5678B1Z3', 'Mumbai', 'corporate', 100000),
(5, 1, 'Walk-in Customer', '0000000000', '', '', 'Mumbai', 'retail', 0);

-- Sample Vendors
INSERT IGNORE INTO `vendors` (`id`,`company_id`,`name`,`phone`,`email`,`gstin`,`city`,`payment_terms`) VALUES
(1, 1, 'M/s Sharma Distributors', '9123456780', 'sharma@dist.com', '27ABCPS9876B1Z1', 'Mumbai', 30),
(2, 1, 'Patel Wholesale Suppliers', '9012345679', 'patel@wholesale.com', '24ABCPP1234C1Z2', 'Surat', 15),
(3, 1, 'National Food Traders', '8901234568', 'info@nft.com', '27AAACN5678A1Z5', 'Mumbai', 30);

-- Chart of Accounts
INSERT IGNORE INTO `accounts` (`company_id`,`code`,`name`,`type`,`is_system`) VALUES
(1, '1000', 'Cash in Hand', 'asset', 1),
(1, '1010', 'Bank Account', 'asset', 1),
(1, '1100', 'Accounts Receivable', 'asset', 1),
(1, '1200', 'Inventory', 'asset', 1),
(1, '1300', 'Other Current Assets', 'asset', 0),
(1, '2000', 'Accounts Payable', 'liability', 1),
(1, '2100', 'GST Payable', 'liability', 1),
(1, '2200', 'GST Input Credit', 'asset', 1),
(1, '2300', 'Short-term Loans', 'liability', 0),
(1, '3000', 'Owner''s Capital', 'equity', 1),
(1, '3100', 'Retained Earnings', 'equity', 1),
(1, '4000', 'Sales Revenue', 'income', 1),
(1, '4100', 'Other Income', 'income', 0),
(1, '5000', 'Cost of Goods Sold', 'expense', 1),
(1, '5100', 'Rent Expense', 'expense', 0),
(1, '5200', 'Salary Expense', 'expense', 0),
(1, '5300', 'Utilities', 'expense', 0),
(1, '5400', 'Marketing', 'expense', 0),
(1, '5500', 'Misc Expense', 'expense', 0);

-- Settings
INSERT IGNORE INTO `settings` (`company_id`,`key`,`value`) VALUES
(1, 'invoice_terms', 'Thank you for your business!'),
(1, 'invoice_footer', 'GST Compliant Invoice | BharatERP'),
(1, 'currency_symbol', '₹'),
(1, 'date_format', 'd-m-Y'),
(1, 'low_stock_threshold', '10'),
(1, 'auto_backup', '1');

