INSERT INTO tenants (id, name, slug, status, timezone, currency, created_at, updated_at)
VALUES (1, 'Acme Industries Ltd.', 'acme-industries', 'active', 'Asia/Dhaka', 'BDT', NOW(), NOW());

INSERT INTO modules (code, name, is_enabled) VALUES
('payroll', 'Payroll', 1),
('attendance', 'Attendance', 1),
('leave', 'Leave', 1),
('loan', 'Loan', 1),
('advance_salary', 'Advance Salary', 1),
('task_management', 'Task Management', 1),
('contract_management', 'Contract Management', 1),
('finance', 'Finance', 1),
('mobile_app_access', 'Mobile App Access', 1),
('api_access', 'API Access', 1),
('face_recognition', 'Face Recognition', 1),
('gps_attendance', 'GPS Attendance', 1),
('holiday_ot', 'Holiday OT', 1),
('multi_branch', 'Multi Branch', 1),
('shift_management', 'Shift Management', 1);

INSERT INTO packages (id, name, monthly_price, yearly_price, branch_limit, employee_limit, device_limit, is_trial, features, created_at, updated_at)
VALUES (1, 'Enterprise', 25000, 250000, 25, 5000, 150, 0, JSON_ARRAY('payroll','attendance','leave','finance','multi_branch','api_access'), NOW(), NOW());

INSERT INTO subscriptions (tenant_id, package_id, status, starts_at, expires_at, billing_cycle)
VALUES (1, 1, 'active', CURRENT_DATE(), DATE_ADD(CURRENT_DATE(), INTERVAL 1 YEAR), 'yearly');

INSERT INTO branches (id, tenant_id, name, code, address, timezone, status) VALUES
(1, 1, 'Head Office', 'HQ', 'Dhaka', 'Asia/Dhaka', 'active'),
(2, 1, 'Gazipur Plant', 'GZP', 'Gazipur', 'Asia/Dhaka', 'active'),
(3, 1, 'Chattogram Depot', 'CTG', 'Chattogram', 'Asia/Dhaka', 'active');

INSERT INTO departments (id, tenant_id, name, code) VALUES
(1, 1, 'Human Resources', 'HR'),
(2, 1, 'Production', 'PROD'),
(3, 1, 'Accounts & Finance', 'FIN');

INSERT INTO designations (id, tenant_id, name, grade) VALUES
(1, 1, 'HR Manager', 'M2'),
(2, 1, 'Line Manager', 'M1'),
(3, 1, 'Machine Operator', 'G4');

INSERT INTO employees (tenant_id, branch_id, department_id, designation_id, employee_code, rfid_card_no, fingerprint_id, face_id, name, email, phone, salary_type, basic_salary, status, joined_at)
VALUES
(1, 1, 1, 1, 'EMP-1001', 'RF-889120', 'FP-1001', 'FC-1001', 'Nusrat Jahan', 'nusrat@acme.test', '+880170000001', 'monthly', 65000, 'active', '2021-01-05'),
(1, 2, 2, 2, 'EMP-1007', 'RF-889146', 'FP-1007', 'FC-1007', 'Rafiq Hasan', 'rafiq@acme.test', '+880170000007', 'monthly', 52000, 'active', '2020-09-12');

INSERT INTO devices (tenant_id, branch_id, serial_no, model, ip_address, port, status, last_seen_at, capabilities)
VALUES
(1, 1, 'F22-HQ-01', 'F22', '10.10.1.20', 4370, 'online', NOW(), JSON_ARRAY('fingerprint','rfid','pin')),
(1, 2, 'UFACE-GZ-02', 'UFace', '10.10.2.22', 4370, 'online', NOW(), JSON_ARRAY('face','fingerprint','rfid','pin'));

INSERT INTO shifts (tenant_id, name, type, start_time, end_time, grace_minutes, weekly_off)
VALUES (1, 'General Shift', 'fixed', '09:00:00', '18:00:00', 10, JSON_ARRAY('friday'));

INSERT INTO rules (tenant_id, name, module, priority, conditions, actions, is_active)
VALUES
(1, 'Late after 10 minutes warning', 'attendance', 10, JSON_OBJECT('late_minutes', JSON_OBJECT('operator', '>=', 'value', 10)), JSON_OBJECT('type', 'warning'), 1),
(1, 'Late after 30 minutes half day', 'attendance', 20, JSON_OBJECT('late_minutes', JSON_OBJECT('operator', '>=', 'value', 30)), JSON_OBJECT('type', 'half_day'), 1),
(1, 'Holiday overtime multiplier', 'payroll', 30, JSON_OBJECT('is_holiday', JSON_OBJECT('operator', '=', 'value', true)), JSON_OBJECT('type', 'ot_multiplier', 'value', 2), 1);
