SET @company_id = 1;

INSERT IGNORE INTO accounts (company_id, code, name_en, name_ar, type, parent_id, is_posting, currency_code) VALUES
(@company_id, '1000', 'Assets', 'الأصول', 'asset', NULL, 0, 'SAR'),
(@company_id, '2000', 'Liabilities', 'الالتزامات', 'liability', NULL, 0, 'SAR'),
(@company_id, '4000', 'Revenue', 'الإيرادات', 'revenue', NULL, 0, 'SAR'),
(@company_id, '5000', 'Expenses', 'المصروفات', 'expense', NULL, 0, 'SAR');

INSERT IGNORE INTO accounts (company_id, code, name_en, name_ar, type, parent_id, is_posting, currency_code) VALUES
(@company_id, '1010', 'Cash', 'الصندوق', 'asset', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '1000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '1100', 'Accounts Receivable', 'الذمم المدينة', 'asset', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '1000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '1200', 'Inventory', 'المخزون', 'asset', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '1000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '2100', 'Accounts Payable', 'الذمم الدائنة', 'liability', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '2000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '2110', 'VAT Output', 'ضريبة المخرجات', 'liability', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '2000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '2120', 'VAT Input', 'ضريبة المدخلات', 'asset', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '1000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '4010', 'Sales', 'المبيعات', 'revenue', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '4000' LIMIT 1) AS a), 1, 'SAR'),
(@company_id, '5010', 'Cost of Sales', 'تكلفة المبيعات', 'expense', (SELECT id FROM (SELECT id FROM accounts WHERE company_id = @company_id AND code = '5000' LIMIT 1) AS a), 1, 'SAR');
