-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `prolex`
--

-- --------------------------------------------------------

--
-- Table structure for table `account_types`
--

CREATE TABLE IF NOT EXISTS `account_types` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `account_types_code_unique` (`code`),
  KEY `account_types_created_by_foreign` (`created_by`),
  KEY `account_types_updated_by_foreign` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `account_types`
--

INSERT INTO `account_types` (`id`, `name`, `code`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Asset', 'ASSET', 'Resources owned by the business', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(2, 'Liability', 'LIABILITY', 'Obligations owed to others', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(3, 'Equity', 'EQUITY', 'Owner residual interest in the business', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(4, 'Revenue', 'REVENUE', 'Income earned from primary operations', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(5, 'Expense', 'EXPENSE', 'Operational costs incurred', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(6, 'Cost of Goods Sold', 'COGS', 'Direct costs tied to revenue generation', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(7, 'Other Income', 'OTHER_INCOME', 'Non-operating income sources', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(8, 'Other Expense', 'OTHER_EXPENSE', 'Non-operating expenses', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(9, 'Current Asset', 'CURRENT_ASSET', 'Accounts that offset asset balances', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(10, 'Current Liability', 'CURRENT_LIABILITY', 'Accounts that offset liability balances', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(12, 'Cash & Cash Equivalent', 'CASH_EQUIVALENT', 'Cash & Cash Equivalent', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(13, 'Accounts Receivable', 'ACCOUNTS_RECEIVABLE', 'Accounts Receivable', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(14, 'Accounts Payable', 'ACCOUNTS_PAYABLE', 'Accounts Payable', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(15, 'Fixed Assets', 'FIXED_ASSETS', 'Fixed Assets', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(16, 'Long-Term Liabilities', 'LONG_TERM_LIABILITIES', 'Long-Term Liabilities', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(17, 'Trust Account - Current Asset', 'TRUST_CURRENT_ASSET', 'Trust Account - Current Asset', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(18, 'Trust Account - Current Liability', 'TRUST_CURRENT_LIABILITY', 'Trust Account - Current Liability', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(19, 'Trust Account - Expense', 'TRUST_EXPENSE', 'Trust Account - Expense', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(20, 'Trust Account - Accounts Payable', 'TRUST_AP', 'Trust Account - Accounts Payable', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(21, 'Trust Account - Accounts Receivable', 'TRUST_AR', 'Trust Account - Accounts Receivable', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(22, 'Trust Account - Income', 'TRUST_INCOME', 'Trust Account - Income', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(23, 'Trust Account - Cash & Cash Equivalent', 'TRUST_CASH_EQUIVALENT', 'Trust Account - Cash & Cash Equivalent', 1, 1, '2026-03-31 08:38:19', '2026-03-31 08:38:19', NULL),
(24, 'SHELBY', 'TOMM', 'ACC FOR ME', 1, 1, '2026-04-01 13:45:26', '2026-04-01 13:46:12', '2026-04-01 13:46:12');

-- --------------------------------------------------------

--
-- Table structure for table `billing_audit_log`
--

CREATE TABLE IF NOT EXISTS `billing_audit_log` (
  `log_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `table_name` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `record_id` bigint UNSIGNED NOT NULL,
  `action` enum('INSERT','UPDATE','DELETE') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `changed_field` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `old_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `new_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `changed_by` bigint UNSIGNED NOT NULL,
  `changed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `session_token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`log_id`),
  KEY `idx_bal_table` (`table_name`,`record_id`),
  KEY `idx_bal_user` (`changed_by`),
  KEY `idx_bal_at` (`changed_at`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Append-only billing audit trail. Every INSERT/UPDATE/DELETE on any billing table is written here. Required for regulatory compliance.';

--
-- Dumping data for table `billing_audit_log`
--

INSERT INTO `billing_audit_log` (`log_id`, `table_name`, `record_id`, `action`, `changed_field`, `old_value`, `new_value`, `changed_by`, `changed_at`, `ip_address`, `session_token`) VALUES
(1, 'client_invoices', 1, 'UPDATE', 'status', 'sent', 'partial', 1, '2026-03-27 06:19:38', NULL, NULL),
(2, 'tariff_time_logs', 1, 'UPDATE', 'status', 'approved', 'billed', 1, '2026-03-27 06:19:38', NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `cache_store`
--

CREATE TABLE IF NOT EXISTS `cache_store` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `cache_key` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `cache_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `expires_at` timestamp NULL DEFAULT NULL,
  `is_locked` tinyint(1) DEFAULT '0',
  `locked_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lock_expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `cache_key` (`cache_key`),
  KEY `idx_cache_expires` (`expires_at`),
  KEY `idx_cache_locked` (`is_locked`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `cases`
--

CREATE TABLE IF NOT EXISTS `cases` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `matter_id` bigint UNSIGNED DEFAULT NULL,
  `court_id` bigint UNSIGNED DEFAULT NULL,
  `court_case_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `filing_date` date DEFAULT NULL,
  `incident_date` date DEFAULT NULL,
  `litigation_stage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `next_hearing_date` date DEFAULT NULL,
  `case_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `case_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `category_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `type_id` int DEFAULT NULL,
  `status_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reason_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `outcome_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `priority_id` int DEFAULT NULL,
  `role_id` int DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_by` int DEFAULT NULL,
  `updated_by` int DEFAULT NULL,
  `date_of_incident` date DEFAULT NULL,
  `court_appearance_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `case_id` (`case_id`),
  KEY `cases_matter_id_index` (`matter_id`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cases`
--

INSERT INTO `cases` (`id`, `matter_id`, `court_id`, `court_case_number`, `filing_date`, `incident_date`, `litigation_stage`, `next_hearing_date`, `case_id`, `case_name`, `category_code`, `type_id`, `status_code`, `reason_code`, `outcome_code`, `priority_id`, `role_id`, `notes`, `created_by`, `updated_by`, `date_of_incident`, `court_appearance_date`, `created_at`, `updated_at`) VALUES
(1, 1, NULL, NULL, NULL, NULL, NULL, NULL, 'case1001', 'Breach of Contract – Vendor', 'CIV', 2, 'open', NULL, NULL, 3, 10, 'Dispute over delayed vendor deliverables.', 1, 1, '2024-01-12', '2024-03-20', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(2, 2, NULL, NULL, NULL, NULL, NULL, NULL, 'case1002', 'Assault Investigation', 'CRM', 4, 'pend', NULL, NULL, 5, 11, 'Investigation pending witness statements.', 1, 1, '2023-11-03', '2024-02-15', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(3, 3, NULL, NULL, NULL, NULL, NULL, NULL, 'case1003', 'Patent Infringement Claim', 'IP', 5, 'open', NULL, NULL, 6, 12, 'Alleged infringement of registered process patent.', 1, 1, '2024-02-01', '2024-04-10', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(4, 4, NULL, NULL, NULL, NULL, NULL, NULL, 'case1004', 'Employment Termination Dispute', 'CIV', 2, 'open', NULL, NULL, 4, 10, 'Client contesting wrongful dismissal.', 1, 1, '2024-01-20', '2024-03-15', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(5, 5, NULL, NULL, NULL, NULL, NULL, NULL, 'case1005', 'Trademark Opposition', 'IP', 3, 'open', NULL, NULL, 2, 11, 'Opposition filed against trademark registration.', 1, 1, '2024-02-05', '2024-04-01', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(6, 6, NULL, NULL, NULL, NULL, NULL, NULL, 'case1006', 'Landlord-Tenant Dispute', 'CIV', 2, 'open', NULL, NULL, 3, 12, 'Tenant refusing to vacate property.', 1, 1, '2024-01-18', '2024-03-10', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(7, 7, NULL, NULL, NULL, NULL, NULL, NULL, 'case1007', 'Product Liability Claim', 'CIV', 5, 'open', NULL, NULL, 4, 10, 'Injury caused by defective product.', 1, 1, '2024-01-22', '2024-03-18', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(8, 8, NULL, NULL, NULL, NULL, NULL, NULL, 'case1008', 'Fraud Investigation', 'CRM', 4, 'pend', NULL, NULL, 5, 11, 'Financial irregularities under review.', 1, 1, '2024-02-01', '2024-04-05', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(9, 9, NULL, NULL, NULL, NULL, NULL, NULL, 'case1009', 'Copyright Infringement', 'IP', 5, 'open', NULL, NULL, 6, 12, 'Unauthorized use of copyrighted material.', 1, 1, '2024-01-25', '2024-03-25', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(10, 10, NULL, NULL, NULL, NULL, NULL, NULL, 'case1010', 'Medical Malpractice', 'CIV', 3, 'open', NULL, NULL, 4, 10, 'Negligence claim against hospital staff.', 1, 1, '2024-02-10', '2024-04-15', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(11, 11, NULL, NULL, NULL, NULL, NULL, NULL, 'case1011', 'Insurance Dispute', 'CIV', 2, 'open', NULL, NULL, 3, 11, 'Claim denied by insurance provider.', 1, 1, '2024-01-30', '2024-03-28', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(12, 12, NULL, NULL, NULL, NULL, NULL, NULL, 'case1012', 'Environmental Regulation Violation', 'CIV', 4, 'pend', NULL, NULL, 5, 12, 'Pollution incident under investigation.', 1, 1, '2024-02-15', '2024-04-20', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(13, 13, NULL, NULL, NULL, NULL, NULL, NULL, 'case1013', 'Cybercrime Investigation', 'CRM', 5, 'pend', NULL, NULL, 6, 10, 'Hacking incident affecting multiple clients.', 1, 1, '2024-01-10', '2024-03-12', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(14, 14, NULL, NULL, NULL, NULL, NULL, NULL, 'case1014', 'Construction Dispute', 'CIV', 2, 'open', NULL, NULL, 4, 11, 'Contractor failing to meet specifications.', 1, 1, '2024-01-15', '2024-03-10', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(15, 15, NULL, NULL, NULL, NULL, NULL, NULL, 'case1015', 'Vehicle Accident Claim', 'CIV', 3, 'open', NULL, NULL, 3, 12, 'Road accident, multiple parties involved.', 1, 1, '2024-02-05', '2024-03-30', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(16, 16, NULL, NULL, NULL, NULL, NULL, NULL, 'case1016', 'Tax Evasion Investigation', 'CRM', 4, 'pend', NULL, NULL, 5, 10, 'Audit for undeclared income.', 1, 1, '2024-01-28', '2024-03-22', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(17, 17, NULL, NULL, NULL, NULL, NULL, NULL, 'case1017', 'Intellectual Property Licensing Dispute', 'IP', 5, 'open', NULL, NULL, 6, 11, 'Breach of licensing agreement.', 1, 1, '2024-02-12', '2024-04-10', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(18, 18, NULL, NULL, NULL, NULL, NULL, NULL, 'case1018', 'Debt Recovery', 'CIV', 2, 'open', NULL, NULL, 3, 12, 'Client seeking recovery of unpaid invoices.', 1, 1, '2024-01-18', '2024-03-15', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(19, 19, NULL, NULL, NULL, NULL, NULL, NULL, 'case1019', 'Bankruptcy Proceedings', 'CIV', 3, 'pend', NULL, NULL, 4, 10, 'Liquidation process initiated.', 1, 1, '2024-02-01', '2024-04-05', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(20, 20, NULL, NULL, NULL, NULL, NULL, NULL, 'case1020', 'Criminal Theft Case', 'CRM', 4, 'pend', NULL, NULL, 5, 11, 'Investigation ongoing.', 1, 1, '2024-01-12', '2024-03-10', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(21, 21, NULL, NULL, NULL, NULL, NULL, NULL, 'case1021', 'Consumer Rights Violation', 'CIV', 2, 'open', NULL, NULL, 3, 12, 'Complaint against retailer.', 1, 1, '2024-01-20', '2024-03-15', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(22, 22, NULL, NULL, NULL, NULL, NULL, NULL, 'case1022', 'Antitrust Investigation', 'CIV', 3, 'pend', NULL, NULL, 4, 10, 'Market manipulation under review.', 1, 1, '2024-02-01', '2024-04-01', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(23, 23, NULL, NULL, NULL, NULL, NULL, NULL, 'case1023', 'Harassment Complaint', 'CRM', 4, 'pend', NULL, NULL, 5, 11, 'Investigation into workplace harassment.', 1, 1, '2024-01-25', '2024-03-25', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(24, 24, NULL, NULL, NULL, NULL, NULL, NULL, 'case1024', 'Fraudulent Contract', 'CIV', 2, 'open', NULL, NULL, 3, 12, 'Alleged fraudulent business contract.', 1, 1, '2024-01-28', '2024-03-20', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(25, 25, NULL, NULL, NULL, NULL, NULL, NULL, 'case1025', 'Sample Case 25', 'CIV', 3, 'open', NULL, NULL, 4, 10, 'Placeholder case for testing.', 1, 1, '2024-02-05', '2024-04-01', '2026-03-13 11:22:12', '2026-03-18 13:51:59'),
(26, 1, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0001', 'Case for Breach of Contract – Vendor', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(27, 2, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0002', 'Case for Assault Investigation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(28, 3, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0003', 'Case for Patent Infringement Claim', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(29, 4, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0004', 'Case for Employment Termination Dispute', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(30, 5, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0005', 'Case for Trademark Opposition', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(31, 6, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0006', 'Case for Landlord-Tenant Dispute', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(32, 7, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0007', 'Case for Product Liability Claim', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(33, 8, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0008', 'Case for Fraud Investigation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(34, 9, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0009', 'Case for Copyright Infringement', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(35, 10, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0010', 'Case for Medical Malpractice', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(36, 11, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0011', 'Case for Insurance Dispute', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(37, 12, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0012', 'Case for Environmental Regulation Violation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(38, 13, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0013', 'Case for Cybercrime Investigation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(39, 14, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0014', 'Case for Construction Dispute', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(40, 15, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0015', 'Case for Vehicle Accident Claim', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(41, 16, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0016', 'Case for Tax Evasion Investigation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(42, 17, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0017', 'Case for Intellectual Property Licensing Dispute', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(43, 18, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0018', 'Case for Debt Recovery', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(44, 19, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0019', 'Case for Bankruptcy Proceedings', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(45, 20, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0020', 'Case for Criminal Theft Case', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(46, 21, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0021', 'Case for Consumer Rights Violation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(47, 22, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0022', 'Case for Antitrust Investigation', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(48, 23, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0023', 'Case for Harassment Complaint', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(49, 24, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0024', 'Case for Fraudulent Contract', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(50, 25, NULL, NULL, NULL, NULL, NULL, NULL, 'CASE-0025', 'Case for Sample Case 25', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Seeded case linked to matter', 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
-- Table structure for table `case_categories`
--

CREATE TABLE IF NOT EXISTS `case_categories` (
  `category_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `category_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`category_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_categories`
--

INSERT INTO `case_categories` (`category_code`, `category_description`, `created_at`, `updated_at`) VALUES
('ADM', 'Administrative Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('BNK', 'Bankruptcy & Insolvency', '2026-01-22 14:06:22', '2026-01-23 11:27:59'),
('BOLO', 'DSDSSS', '2026-01-23 08:54:10', '2026-01-23 11:24:48'),
('CIV', 'Civil Litigation', '2026-01-16 10:44:09', '2026-01-16 10:44:09'),
('CON', 'Construction Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('COR', 'Corporate & Commercial', '2026-01-16 10:44:09', '2026-01-16 10:44:09'),
('CRM', 'Criminal Defense', '2026-01-16 10:44:09', '2026-01-16 10:44:09'),
('EMP', 'Employment & Labor Law', '2026-01-16 10:44:09', '2026-01-16 10:44:09'),
('ENV', 'Environmental Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('EST', 'Estate Planning & Probate', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('FAM', 'Family Law', '2026-01-16 10:44:09', '2026-01-16 10:44:09'),
('IMM', 'Immigration Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('INS', 'Insurance Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('INT', 'International Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('IP', 'Intellectual Property', '2026-01-16 10:44:09', '2026-01-16 10:44:09'),
('MED', 'Medical Malpractice', '2026-01-22 14:06:22', '2026-01-22 14:06:22'),
('TAX', 'Taxation Law', '2026-01-22 14:06:22', '2026-01-22 14:06:22');

-- --------------------------------------------------------

--
-- Table structure for table `case_clients`
--

CREATE TABLE IF NOT EXISTS `case_clients` (
  `id` int NOT NULL AUTO_INCREMENT,
  `case_id` int NOT NULL,
  `client_id` int NOT NULL,
  `role_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `case_id` (`case_id`,`client_id`),
  KEY `fk_case_clients_client` (`client_id`),
  KEY `fk_case_clients_role` (`role_code`)
) ENGINE=InnoDB AUTO_INCREMENT=151 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_clients`
--

INSERT INTO `case_clients` (`id`, `case_id`, `client_id`, `role_code`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(121, 1, 1, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(122, 2, 2, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(123, 2, 3, 'Co-Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(124, 3, 4, 'Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(125, 3, 5, 'Co-Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(126, 4, 6, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(127, 4, 7, 'Co-Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(128, 4, 8, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(129, 5, 9, 'Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(130, 6, 10, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(131, 6, 11, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(132, 7, 12, 'Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(133, 7, 13, 'Co-Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(134, 7, 14, 'Applicant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(135, 8, 15, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(136, 8, 16, 'Co-Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(137, 8, 17, 'Applicant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(138, 8, 18, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(139, 9, 19, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(140, 10, 20, 'Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(141, 10, 21, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(142, 11, 22, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(143, 11, 23, 'Applicant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(144, 11, 24, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(145, 12, 25, 'Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(146, 12, 26, 'Co-Defendant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(147, 12, 27, 'Applicant', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(148, 12, 28, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(149, 13, 29, 'Plaintiff', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(150, 13, 30, 'Respondent', 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18');

-- --------------------------------------------------------

--
-- Table structure for table `case_lawyers`
--

CREATE TABLE IF NOT EXISTS `case_lawyers` (
  `case_lawyer_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `case_id` bigint UNSIGNED NOT NULL,
  `lawyer_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `lawyer_role_id` int UNSIGNED NOT NULL,
  `tier_id` bigint UNSIGNED DEFAULT NULL,
  `tariff_id` bigint UNSIGNED DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`case_lawyer_id`),
  UNIQUE KEY `unique_case_lawyer` (`case_id`,`lawyer_id`),
  KEY `lawyer_id` (`lawyer_id`),
  KEY `tier_id` (`tier_id`),
  KEY `tariff_id` (`tariff_id`),
  KEY `fk_case_lawyer_role` (`lawyer_role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `case_outcomes`
--

CREATE TABLE IF NOT EXISTS `case_outcomes` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_outcomes`
--

INSERT INTO `case_outcomes` (`id`, `code`, `name`, `description`, `updated_at`, `created_at`) VALUES
(1, 'WON', 'Won', 'Case resolved in favor of the client', NULL, NULL),
(2, 'LOST', 'Lost', 'Case resolved against the client', NULL, NULL),
(3, 'SETTLED', 'Settled', 'Case resolved via settlement agreement', NULL, NULL),
(4, 'DISMISSED', 'Dismissed', 'Case dismissed by the court', '2026-01-19 06:05:49', NULL),
(5, 'WITHDRAWN', 'Withdrawn', 'Case withdrawn by the client or attorney', NULL, NULL),
(6, 'PENDING', 'Pending', 'Case still ongoing, no final outcome yet', NULL, NULL),
(7, 'APPEALED', 'Appealed', 'Case outcome is under appeal', NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `case_parties`
--

CREATE TABLE IF NOT EXISTS `case_parties` (
  `case_party_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `case_id` bigint UNSIGNED NOT NULL,
  `client_id` bigint UNSIGNED NOT NULL,
  `role_id` int NOT NULL,
  `party_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED NOT NULL,
  PRIMARY KEY (`case_party_id`),
  KEY `fk_case_parties_case` (`case_id`),
  KEY `fk_case_parties_client` (`client_id`),
  KEY `fk_case_parties_role` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_parties`
--

INSERT INTO `case_parties` (`case_party_id`, `case_id`, `client_id`, `role_id`, `party_name`, `notes`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES
(1, 1, 31, 5, 'John Doe', 'Witness for the case', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(2, 2, 32, 5, 'Jane Smith', 'Testifying witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(3, 2, 33, 6, 'Acme Corp', 'Third party involved', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(4, 3, 34, 5, 'Robert Brown', 'Expert witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(5, 3, 35, 6, 'Linda White', 'Third party consultant', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(6, 3, 36, 6, 'Global LLC', 'Corporate third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(7, 4, 37, 5, 'Peter Davis', 'Supporting witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(8, 4, 38, 5, 'Susan Miller', 'Witness providing testimony', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(9, 4, 39, 6, 'Michael Wilson', 'Third party consultant', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(10, 4, 40, 6, 'Emily Clark', 'Corporate third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(11, 5, 41, 5, 'David Thompson', 'Expert witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(12, 6, 42, 5, 'Laura Adams', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(13, 6, 43, 6, 'Smith & Co', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(14, 7, 44, 5, 'Nancy Lee', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(15, 7, 45, 5, 'Oliver King', 'Expert witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(16, 7, 46, 6, 'Global Solutions', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(17, 8, 47, 5, 'Victor Green', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(18, 8, 48, 5, 'Rachel Hall', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(19, 8, 49, 6, 'Steven Young', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(20, 8, 50, 6, 'Monica Scott', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(21, 9, 51, 5, 'Philip Allen', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(22, 10, 52, 5, 'Angela Baker', 'Expert witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(23, 10, 53, 6, 'TechCorp Ltd', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(24, 11, 54, 5, 'Brenda Foster', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(25, 11, 55, 5, 'Jason Hall', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(26, 11, 56, 6, 'Global Ventures', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(27, 12, 57, 5, 'Olivia Perez', 'Witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(28, 12, 58, 5, 'Kevin Morgan', 'Expert witness', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(29, 12, 59, 6, 'Daniel Reed', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1),
(30, 12, 60, 6, 'Samantha Cox', 'Third party', '2026-03-13 11:56:24', '2026-03-13 11:56:24', 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `case_priorities`
--

CREATE TABLE IF NOT EXISTS `case_priorities` (
  `priority_id` int NOT NULL AUTO_INCREMENT,
  `priority_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `severity_rank` int NOT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`priority_id`),
  UNIQUE KEY `priority_name` (`priority_name`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_priorities`
--

INSERT INTO `case_priorities` (`priority_id`, `priority_name`, `severity_rank`, `description`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Low', 1, 'No immediate action required', 1, '2026-01-26 15:29:42', '2026-01-26 15:29:42'),
(2, 'Normal', 2, 'Standard case priority', 1, '2026-01-26 15:29:42', '2026-01-26 15:29:42'),
(3, 'Medium', 3, 'Requires attention but not urgent', 1, '2026-01-26 15:29:42', '2026-01-26 15:29:42'),
(4, 'High', 4, 'Time-sensitive case', 1, '2026-01-26 15:29:42', '2026-01-26 15:29:42'),
(5, 'Urgent', 5, 'Immediate action required', 1, '2026-01-26 15:29:42', '2026-01-26 15:29:42'),
(6, 'Critical', 6, 'Court-mandated or high-risk matter', 1, '2026-01-26 15:29:42', '2026-01-26 15:29:42');

-- --------------------------------------------------------

--
-- Table structure for table `case_reasons`
--

CREATE TABLE IF NOT EXISTS `case_reasons` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `reason_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `reason_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `created_by` bigint NOT NULL,
  `updated_by` bigint NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `fk_case_reasons_created_by` (`created_by`),
  KEY `fk_case_reasons_updated_by` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_reasons`
--

INSERT INTO `case_reasons` (`id`, `reason_code`, `reason_name`, `reason_description`, `created_at`, `updated_at`, `created_by`, `updated_by`, `status`) VALUES
(1, 'CANCEL_DUP', 'Duplicate Case', 'The case was identified as a duplicate of an existing case and was therefore cancelled.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 0),
(2, 'CANCEL_REQ', 'Cancelled by Request', 'The case was cancelled following a formal request by the reporting party.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 0),
(3, 'CANCEL_INV', 'Invalid Case', 'The case did not meet the minimum criteria required for processing.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1),
(4, 'CANCEL_ERR', 'Created in Error', 'The case was created due to a system or user error and has been cancelled.', '2026-01-15 09:22:28', '2026-01-19 11:44:25', 1, 1, 0),
(5, 'CANCEL_NOJ', 'No Jurisdiction', 'The case falls outside the organisation’s legal or operational jurisdiction.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1),
(6, 'CANCEL_NEV', 'Insufficient Evidence', 'The case was cancelled due to a lack of supporting evidence.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1),
(7, 'CANCEL_RES', 'Resolved Externally', 'The matter was resolved outside the system prior to case processing.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1),
(8, 'CANCEL_NON', 'Non-Responsive Party', 'The involved party failed to respond within the required timeframe.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1),
(9, 'CANCEL_WDR', 'Withdrawn by Initiator', 'The case was formally withdrawn by the individual who initiated it.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1),
(10, 'CANCEL_POL', 'Policy Violation', 'The case conflicted with organisational policy and could not proceed.', '2026-01-15 09:22:28', '2026-01-15 09:22:28', 1, 1, 1);

-- --------------------------------------------------------

--
-- Table structure for table `case_roles`
--

CREATE TABLE IF NOT EXISTS `case_roles` (
  `role_id` int NOT NULL AUTO_INCREMENT,
  `role_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED NOT NULL,
  PRIMARY KEY (`role_id`),
  UNIQUE KEY `role_name` (`role_name`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_roles`
--

INSERT INTO `case_roles` (`role_id`, `role_name`, `description`, `is_active`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES
(1, 'Plaintiff', 'Party initiating the case', 1, '2026-01-26 15:30:52', '2026-01-26 15:30:52', 0, 0),
(2, 'Defendant', 'Party responding to the case', 1, '2026-01-26 15:30:52', '2026-01-26 15:30:52', 0, 0),
(3, 'Applicant', 'Party applying for legal relief', 1, '2026-01-26 15:30:52', '2026-01-26 15:30:52', 0, 0),
(4, 'Respondent', 'Party responding to an application', 1, '2026-01-26 15:30:52', '2026-01-26 15:30:52', 0, 0),
(5, 'Witness', 'Individual providing testimony', 1, '2026-01-26 15:30:52', '2026-03-13 11:54:08', 0, 0),
(6, 'Third Party', 'External party involved in the case', 1, '2026-01-26 15:30:52', '2026-01-26 15:30:52', 0, 0),
(8, 'Co-Plaintiff', 'Co-plaintiff on the case', 1, '2026-03-13 12:00:46', '2026-03-13 12:00:46', 0, 0),
(9, 'Co-Defendant', 'Co-defendant on the case', 1, '2026-03-13 12:00:46', '2026-03-13 12:00:46', 0, 0);

-- --------------------------------------------------------

--
-- Table structure for table `case_statuses`
--

CREATE TABLE IF NOT EXISTS `case_statuses` (
  `status_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `color_code` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `sort_order` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`status_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_statuses`
--

INSERT INTO `case_statuses` (`status_code`, `status_name`, `status_description`, `color_code`, `is_active`, `sort_order`, `created_at`, `updated_at`) VALUES
('CLOS', 'Closed', 'Case has been concluded and formally closeddd', '#6C757D', 0, 3, '2026-01-16 14:07:34', '2026-01-22 06:16:40'),
('INTVN', 'Intervened', 'government intervention', '#6b7280', 1, 0, '2026-01-17 14:23:12', '2026-01-17 14:23:12'),
('OPEN', 'Open', 'Case is active and currently being handled', '#28A745', 0, 1, '2026-01-16 14:07:34', '2026-01-16 14:07:34'),
('PEND', 'Pending', 'Case is temporarily inactive or awaiting action', '#FFC107', 0, 2, '2026-01-16 14:07:34', '2026-01-16 14:07:34'),
('TRAN', 'Transferred', 'Case has been transferred to another firm or court', '#17A2B8', 0, 5, '2026-01-16 14:07:34', '2026-01-16 14:07:34'),
('WDTH', 'Withdrawn', 'Case was withdrawn by the client or counsel', '#DC3545', 0, 4, '2026-01-16 14:07:34', '2026-01-16 14:07:34');

-- --------------------------------------------------------

--
-- Table structure for table `case_types`
--

CREATE TABLE IF NOT EXISTS `case_types` (
  `type_id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `type_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`type_id`),
  UNIQUE KEY `uq_case_types_type_name` (`type_name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `case_types`
--

INSERT INTO `case_types` (`type_id`, `type_name`, `type_description`, `created_at`, `updated_at`) VALUES
(1, 'robbery', 'Illegal possession or taking of property using force or intimidations.', '2026-01-22 11:31:43', '2026-01-22 13:59:13'),
(2, 'assault', 'Physical attack causing bodily harm or threat thereof', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(3, 'fraud', 'Deception intended to result in financial or personal gain', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(4, 'burglary', 'Unlawful entry into a structure with intent to commit a crime', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(5, 'theft', 'Unlawful taking of another person’s property without force', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(6, 'homicide', 'Unlawful killing of another human being', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(7, 'kidnapping', 'Unlawful abduction or detention of a person', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(8, 'domestic_violence', 'Abuse or violence occurring within a domestic relationship', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(9, 'drug_trafficking', 'Illegal manufacture, distribution, or sale of controlled substances', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(10, 'money_laundering', 'Concealment of the origins of illegally obtained money', '2026-01-22 11:31:43', '2026-01-22 11:31:43'),
(11, 'cybercrime', 'Criminal activities carried out using computers or digital networksss', '2026-01-22 11:31:43', '2026-01-22 13:53:16');

-- --------------------------------------------------------

--
-- Table structure for table `cashbooks`
--

CREATE TABLE IF NOT EXISTS `cashbooks` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `account_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gl_account_id` bigint UNSIGNED NOT NULL,
  `is_trust` tinyint(1) NOT NULL DEFAULT '0',
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cashbooks_created_by_foreign` (`created_by`),
  KEY `cashbooks_updated_by_foreign` (`updated_by`),
  KEY `cashbooks_gl_account_id_index` (`gl_account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `cashbooks`
--

INSERT INTO `cashbooks` (`id`, `name`, `account_number`, `gl_account_id`, `is_trust`, `currency`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Cash USD', '1001-002-847361', 18, 0, 'USD', 1, 1, '2026-04-01 08:22:05', '2026-04-01 08:22:05', NULL),
(2, 'Petty Cash USD', '1001-002-847362', 17, 0, 'USD', 1, 1, '2026-04-01 08:22:05', '2026-04-01 08:22:05', NULL),
(3, 'Trust Account - Cash USD', '1001-009-554821', 22, 1, 'CUR001', 1, 1, '2026-04-01 08:22:05', '2026-04-01 13:31:54', NULL),
(4, 'Trust Account - Petty Cash USD', '1001-009-554822', 23, 1, 'USD', 1, 1, '2026-04-01 08:22:05', '2026-04-01 08:22:05', NULL),
(5, 'Trust Account - Trade Receivable', '1001-009-554823', 24, 1, 'USD', 1, 1, '2026-04-01 08:22:05', '2026-04-01 08:22:05', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `chat_groups`
--

CREATE TABLE IF NOT EXISTS `chat_groups` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `group_description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `group_name` (`group_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `chat_messages`
--

CREATE TABLE IF NOT EXISTS `chat_messages` (
  `message_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `chat_id` bigint UNSIGNED NOT NULL,
  `sender_id` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `message_type` enum('text','file','audio','video','call','notification') COLLATE utf8mb4_unicode_ci DEFAULT 'text',
  `message` text COLLATE utf8mb4_unicode_ci,
  `file_id` bigint UNSIGNED DEFAULT NULL,
  `call_type` enum('audio','video') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `call_status` enum('missed','answered','declined') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_read` tinyint(1) DEFAULT '0',
  `is_deleted` tinyint(1) DEFAULT '0',
  `sent_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `read_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`message_id`),
  KEY `chat_id` (`chat_id`),
  KEY `sender_id` (`sender_id`),
  KEY `file_id` (`file_id`),
  KEY `chat_messages_updated_by_index` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `chat_messages`
--

INSERT INTO `chat_messages` (`message_id`, `chat_id`, `sender_id`, `updated_by`, `message_type`, `message`, `file_id`, `call_type`, `call_status`, `is_read`, `is_deleted`, `sent_at`, `read_at`, `deleted_at`) VALUES
(1, 1, 1, NULL, 'text', 'hello', NULL, NULL, NULL, 1, 0, '2026-03-14 16:18:07', '2026-03-14 14:18:17', NULL),
(2, 1, 1, NULL, 'text', 'hello', NULL, NULL, NULL, 1, 0, '2026-03-15 09:07:11', '2026-03-15 07:08:04', NULL),
(3, 1, 1, NULL, 'text', 'hello', NULL, NULL, NULL, 1, 0, '2026-03-15 09:07:14', '2026-03-15 07:08:04', NULL),
(4, 1, 1, NULL, 'text', 'hi', NULL, NULL, NULL, 1, 0, '2026-03-15 09:20:22', '2026-03-15 07:20:28', NULL),
(5, 1, 1, NULL, 'text', 'good mornign', NULL, NULL, NULL, 1, 0, '2026-03-15 07:27:46', '2026-03-15 07:27:49', NULL),
(6, 1, 1, NULL, 'text', 'hello', NULL, NULL, NULL, 1, 0, '2026-03-15 07:48:05', '2026-03-15 07:48:20', NULL),
(7, 1, 2, NULL, 'text', 'im good', NULL, NULL, NULL, 1, 0, '2026-03-15 07:48:25', '2026-03-15 07:48:27', NULL),
(8, 1, 2, NULL, 'text', 'hi', NULL, NULL, NULL, 1, 0, '2026-03-15 08:03:23', '2026-03-15 08:14:59', NULL),
(9, 1, 1, NULL, 'text', 'hi', NULL, NULL, NULL, 1, 0, '2026-03-15 08:03:57', '2026-03-15 08:15:00', NULL),
(10, 1, 2, NULL, 'text', 'good', NULL, NULL, NULL, 1, 0, '2026-03-15 08:17:17', '2026-03-15 08:17:21', NULL),
(11, 1, 2, NULL, 'text', 'whos james', NULL, NULL, NULL, 1, 0, '2026-03-15 08:17:31', '2026-03-15 08:17:31', NULL),
(12, 1, 2, NULL, 'text', 'why is the long.', NULL, NULL, NULL, 1, 0, '2026-03-15 13:35:37', '2026-03-15 13:35:57', NULL),
(13, 1, 1, NULL, 'text', 'what 😂😂 whats a long', NULL, NULL, NULL, 1, 0, '2026-03-15 13:36:11', '2026-03-15 13:36:13', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `chat_participants`
--

CREATE TABLE IF NOT EXISTS `chat_participants` (
  `participant_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `chat_id` bigint UNSIGNED NOT NULL,
  `user_id` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `role` enum('member','admin','owner') COLLATE utf8mb4_unicode_ci DEFAULT 'member',
  `joined_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `last_seen` timestamp NULL DEFAULT NULL,
  `is_muted` tinyint(1) DEFAULT '0',
  `is_blocked` tinyint(1) DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`participant_id`),
  UNIQUE KEY `chat_participants_chat_id_user_id_unique` (`chat_id`,`user_id`),
  KEY `chat_id` (`chat_id`),
  KEY `user_id` (`user_id`),
  KEY `chat_participants_updated_by_index` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `chat_participants`
--

INSERT INTO `chat_participants` (`participant_id`, `chat_id`, `user_id`, `updated_by`, `role`, `joined_at`, `last_seen`, `is_muted`, `is_blocked`, `created_at`, `updated_at`) VALUES
(1, 1, 1, NULL, 'member', '2026-03-14 14:12:19', '2026-04-07 06:13:24', 0, 0, NULL, '2026-03-15 07:36:04'),
(2, 1, 2, NULL, 'member', '2026-03-14 14:12:19', '2026-03-15 14:36:18', 0, 0, NULL, '2026-03-15 07:36:23'),
(3, 2, 1, NULL, 'member', '2026-03-15 08:17:01', '2026-04-07 06:13:24', 0, 0, NULL, NULL),
(4, 2, 3, NULL, 'member', '2026-03-15 08:17:01', '2026-03-15 08:17:01', 0, 0, NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `chat_passcodes`
--

CREATE TABLE IF NOT EXISTS `chat_passcodes` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` bigint UNSIGNED NOT NULL,
  `passcode_hash` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_user_passcode` (`user_id`),
  KEY `idx_created_by` (`created_by`),
  KEY `idx_updated_by` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `chat_passcodes`
--

INSERT INTO `chat_passcodes` (`id`, `user_id`, `passcode_hash`, `is_active`, `created_at`, `updated_at`, `created_by`, `updated_by`) VALUES
(1, 1, '$2y$12$o5.dUYztKamaPICUqGih9.XooUXlRopUjp59Xsc9B4uDSRmUoEtgW', 1, '2026-03-07 07:38:26', '2026-03-14 14:48:56', 1, 1),
(2, 2, '$2y$12$.kgRbXABDMvcq/4Dk5DH..srnIM2AwmCNSqBc7Dk17TNJgzikPJ42', 1, '2026-03-07 07:38:26', '2026-03-07 07:38:26', 2, 2),
(3, 3, '$2y$12$zmNnoCbUr.kDXZyQaxD/Q.scDbkIjPlRnv/mw40vD3yz8hmebpW2C', 1, '2026-03-07 07:38:27', '2026-03-07 07:38:27', 3, 3),
(4, 4, '$2y$12$GPFwPttkLWF1Bn0O/FGJW.JUtB5IUmlgJwoDlVTrlQLwJz5C3kdba', 1, '2026-03-07 07:38:27', '2026-03-07 07:38:27', 4, 4),
(5, 5, '$2y$12$35Jtlz8ePuokkg0L93I0LOFCE/tlbpPpkpSWCHgbb7KYTKHzAXk2C', 1, '2026-03-07 07:38:28', '2026-03-07 07:38:28', 5, 5),
(6, 6, '$2y$12$A4v./8.iv9mfbONGbP6eBezpzVEjz1H7h9nJiJbMEBm6tAMxFRzRa', 1, '2026-03-07 07:38:28', '2026-03-07 07:38:28', 6, 6),
(7, 7, '$2y$12$NyEarXfDOVOA6xDfIZPSk.ifmdo3wYTvt4BUkmjcrK6L0K6uXUnTu', 1, '2026-03-07 07:38:29', '2026-03-07 07:38:29', 7, 7);

-- --------------------------------------------------------

--
-- Table structure for table `chat_requests`
--

CREATE TABLE IF NOT EXISTS `chat_requests` (
  `request_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `sender_id` bigint UNSIGNED NOT NULL,
  `receiver_id` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `status` enum('pending','accepted','rejected') COLLATE utf8mb4_unicode_ci DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `responded_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`request_id`),
  KEY `sender_id` (`sender_id`),
  KEY `receiver_id` (`receiver_id`),
  KEY `chat_requests_sender_id_receiver_id_index` (`sender_id`,`receiver_id`),
  KEY `chat_requests_updated_by_index` (`updated_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `chat_rooms`
--

CREATE TABLE IF NOT EXISTS `chat_rooms` (
  `chat_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `chat_type` enum('private','group') COLLATE utf8mb4_unicode_ci DEFAULT 'private',
  `group_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `group_description` text COLLATE utf8mb4_unicode_ci,
  `group_avatar_url` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `last_message_id` bigint UNSIGNED DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`chat_id`),
  KEY `created_by` (`created_by`),
  KEY `last_message_id` (`last_message_id`),
  KEY `chat_rooms_updated_by_foreign` (`updated_by`),
  KEY `chat_rooms_created_by_updated_by_index` (`created_by`,`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `chat_rooms`
--

INSERT INTO `chat_rooms` (`chat_id`, `chat_type`, `group_name`, `group_description`, `group_avatar_url`, `created_by`, `updated_by`, `created_at`, `updated_at`, `last_message_id`, `is_active`, `deleted_at`) VALUES
(1, 'private', NULL, NULL, NULL, 1, NULL, '2026-03-14 14:12:19', '2026-03-15 13:36:11', 13, 1, NULL),
(2, 'private', NULL, NULL, NULL, 1, NULL, '2026-03-15 08:17:01', '2026-03-15 08:17:01', NULL, 1, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `clients`
--

CREATE TABLE IF NOT EXISTS `clients` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `client_id` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
  `first_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `national_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_of_birth` date DEFAULT NULL,
  `gender` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone_primary` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `street_address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `city` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `state_province` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `employer_name` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `position_role` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `client_category` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_onboarded` date DEFAULT NULL,
  `assigned_lawyer` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `referred_lawyer` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `client_id` (`client_id`),
  UNIQUE KEY `national_id` (`national_id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `clients`
--

INSERT INTO `clients` (`id`, `client_id`, `first_name`, `last_name`, `national_id`, `date_of_birth`, `gender`, `phone_primary`, `email`, `street_address`, `city`, `state_province`, `country`, `employer_name`, `position_role`, `client_type`, `client_category`, `date_onboarded`, `assigned_lawyer`, `referred_lawyer`, `notes`, `created_at`, `updated_at`) VALUES
(1, 'CL-0001', 'James', 'Whitaker', 'ZW123456A', '1985-03-14', 'Male', '+263771234567', 'james.whitaker@example.com', '12 Samora Machel Ave', 'Harare', 'Harare Province', 'Zimbabwe', 'Whitaker Holdings', 'Managing Director', NULL, NULL, '2024-01-10', 'L940147', 'L200861', 'Corporate compliance advisory', '2026-01-06 10:29:08', '2026-01-06 12:44:40'),
(2, 'CL-0002', 'Emily', 'Carter', 'ZW654321B', '1990-07-22', 'Female', '+263772345678', 'emily.carter@example.com', '45 Borrowdale Road', 'Harare', 'Harare Province', 'Zimbabwe', 'Carter & Co', 'Legal Consultant', 'Individual', 'Professional', '2024-01-15', 'Adv. Ncube', NULL, 'Contract review services', '2026-01-06 10:29:08', '2026-01-06 10:29:08'),
(3, 'CL-0003', 'Michael', 'Dube', 'ZW789456C', '1978-11-05', 'Male', '+263773456789', 'michael.dube@example.com', '89 Main Street', 'Bulawayo', 'Bulawayo Province', 'Zimbabwe', 'Dube Logistics', 'Operations Manager', 'Individual', 'Commercial', '2024-02-01', 'Adv. Sibanda', 'Adv. Moyo', 'Ongoing litigation support', '2026-01-06 10:29:08', '2026-01-06 10:29:08'),
(5, 'CL-0005', 'Daniel', 'Mukasa', 'ZW456789E', '1983-09-30', 'Male', '+263775678901', 'daniel.mukasa@example.com', '101 Airport Road', 'Gweru', 'Midlands Province', 'Zimbabwe', 'Mukasa Engineering', 'Senior Engineer', NULL, NULL, '2024-02-20', 'L200861', 'L940147', 'Regulatory and safety compliance', '2026-01-06 10:29:08', '2026-01-06 12:43:58'),
(8, 'CL001', 'Tendai', 'Moyo', '63-123456-A-63', '1988-04-12', 'Male', '+263772345678', 'tendai.moyo@email.com', '12 Samora Machel Ave', 'Harare', 'Harare', 'Zimbabwe', 'Econet Wireless', 'Network Technician', 'Individual', 'Corporate', '2024-01-15', 'L940147', 'L200861', 'Corporate client onboarding', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(9, 'CL002', 'Rudo', 'Chikore', '08-654321-B-08', '1992-09-30', 'Female', '+263773456789', 'rudo.chikore@email.com', '45 Jason Moyo St', 'Bulawayo', 'Bulawayo', 'Zimbabwe', 'NSSA', 'HR Officer', 'Individual', 'Labour', '2024-01-18', 'L940147', 'L200861', 'Labour dispute consultation', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(10, 'CL003', 'Farai', 'Dube', '75-112233-C-75', '1985-06-05', 'Male', '+263774567890', 'farai.dube@email.com', '89 Herbert Chitepo Rd', 'Mutare', 'Manicaland', 'Zimbabwe', 'ZimPower', 'Electrical Engineer', 'Individual', 'Energy', '2024-01-20', 'L940147', 'L200861', 'Regulatory compliance case', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(11, 'CL004', 'Chipo', 'Sibanda', '02-998877-D-02', '1990-11-21', 'Female', '+263775678901', 'chipo.sibanda@email.com', '23 Josiah Tongogara St', 'Gweru', 'Midlands', 'Zimbabwe', 'Delta Beverages', 'Sales Manager', 'Individual', 'Commercial', '2024-01-22', 'L940147', 'L200861', 'Commercial contract review', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(12, 'CL005', 'Blessing', 'Ndlovu', '12-445566-E-12', '1983-02-14', 'Male', '+263776789012', 'blessing.ndlovu@email.com', '7 Main Street', 'Victoria Falls', 'Matabeleland North', 'Zimbabwe', 'Victoria Falls Safari Lodge', 'Operations Manager', 'Individual', 'Hospitality', '2024-01-25', 'L940147', 'L200861', 'Hospitality licensing matter', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(13, 'CL006', 'Memory', 'Zhou', '44-778899-F-44', '1995-07-19', 'Female', '+263777890123', 'memory.zhou@email.com', '101 Enterprise Rd', 'Harare', 'Harare', 'Zimbabwe', 'CBZ Bank', 'Account Analyst', 'Individual', 'Finance', '2024-01-27', 'L940147', 'L200861', 'Banking dispute advisory', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(14, 'CL007', 'Simba', 'Katsande', '19-334455-G-19', '1987-03-08', 'Male', '+263778901234', 'simba.katsande@email.com', '55 Mkoba Rd', 'Gweru', 'Midlands', 'Zimbabwe', 'Local Authority', 'Procurement Officer', 'Individual', 'Public Sector', '2024-01-29', 'L940147', 'L200861', 'Tender review assistance', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(15, 'CL008', 'Nyasha', 'Mukandi', '60-221144-H-60', '1998-12-02', 'Female', '+263779012345', 'nyasha.mukandi@email.com', '18 Chiremba Rd', 'Masvingo', 'Masvingo', 'Zimbabwe', 'Great Zimbabwe University', 'Research Assistant', 'Individual', 'Education', '2024-02-01', 'L940147', 'L200861', 'Student contract matter', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(16, 'CL009', 'Tawanda', 'Mapfumo', '71-556677-J-71', '1981-08-27', 'Male', '+263771123456', 'tawanda.mapfumo@email.com', '33 Robert Mugabe Way', 'Kadoma', 'Mashonaland West', 'Zimbabwe', 'RioZim', 'Mine Supervisor', 'Individual', 'Mining', '2024-02-03', 'L940147', 'L200861', 'Mining compliance case', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(17, 'CL010', 'Rutendo', 'Goronga', '25-889900-K-25', '1993-05-16', 'Female', '+263772234567', 'rutendo.goronga@email.com', '9 Kwekwe Rd', 'Kwekwe', 'Midlands', 'Zimbabwe', 'Private Practice', 'Consultant', 'Individual', 'Civil', '2024-02-05', 'L940147', 'L200861', 'Civil litigation support', '2026-01-31 11:13:20', '2026-01-31 11:13:20'),
(18, 'CL1870787', 'Herr', 'Gwena', 'AE224400', '1967-02-01', 'Male', '+263 889 1123 222', 'herr@wasser.com', '0910 Reichshouse street', 'Berlin', 'Berlin', 'Germany', 'Gwena AG', 'CFO', 'IND', 'HNWI', '2009-08-04', NULL, NULL, NULL, '2026-03-23 08:58:40', '2026-03-23 08:58:40'),
(19, 'CL011', 'Tatenda', 'Chirwa', '63-445566-L-63', '1991-04-18', 'Male', '+263773112233', 'tatenda.chirwa@email.com', '14 First Street', 'Harare', 'Harare', 'Zimbabwe', 'ZB Bank', 'Credit Officer', 'Individual', 'Finance', '2024-02-07', 'L940147', 'L200861', 'Loan agreement advisory', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(20, 'CL012', 'Lindiwe', 'Ncube', '08-778899-M-08', '1986-09-12', 'Female', '+263774223344', 'lindiwe.ncube@email.com', '22 Lobengula St', 'Bulawayo', 'Bulawayo', 'Zimbabwe', 'OK Zimbabwe', 'Store Manager', 'Individual', 'Retail', '2024-02-10', 'L940147', 'L200861', 'Retail lease agreement review', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(21, 'CL013', 'Kudakwashe', 'Banda', '12-334455-N-12', '1994-01-25', 'Male', '+263775334455', 'kuda.banda@email.com', '5 Chinhoyi Rd', 'Chinhoyi', 'Mashonaland West', 'Zimbabwe', 'ZESA', 'Technician', 'Individual', 'Energy', '2024-02-12', 'L940147', 'L200861', 'Employment contract dispute', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(22, 'CL014', 'Tsitsi', 'Muchengeti', '44-667788-P-44', '1989-06-30', 'Female', '+263776445566', 'tsitsi.muchengeti@email.com', '78 Sam Nujoma St', 'Harare', 'Harare', 'Zimbabwe', 'Ministry of Health', 'Nurse', 'Individual', 'Public Sector', '2024-02-14', 'L940147', 'L200861', 'Workplace grievance case', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(23, 'CL015', 'Elvis', 'Madondo', '19-998877-Q-19', '1982-11-11', 'Male', '+263777556677', 'elvis.madondo@email.com', '3 Industrial Rd', 'Kwekwe', 'Midlands', 'Zimbabwe', 'ZISCO Steel', 'Foreman', 'Individual', 'Industrial', '2024-02-16', 'L940147', 'L200861', 'Industrial safety compliance', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(24, 'CL016', 'Rumbidzai', 'Chinoda', '60-112244-R-60', '1996-03-09', 'Female', '+263778667788', 'rumbi.chinoda@email.com', '44 Mutare Rd', 'Mutare', 'Manicaland', 'Zimbabwe', 'Steward Bank', 'Customer Service Rep', 'Individual', 'Finance', '2024-02-18', 'L940147', 'L200861', 'Customer dispute resolution', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(25, 'CL017', 'Brian', 'Zhou', '71-556600-S-71', '1984-07-21', 'Male', '+263779778899', 'brian.zhou@email.com', '12 Enterprise Rd', 'Harare', 'Harare', 'Zimbabwe', 'ZimTrade', 'Export Officer', 'Individual', 'Trade', '2024-02-20', 'L940147', 'L200861', 'Export compliance advisory', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(26, 'CL018', 'Faith', 'Makoni', '25-334411-T-25', '1993-10-05', 'Female', '+263771889900', 'faith.makoni@email.com', '67 Josiah Tongogara Ave', 'Masvingo', 'Masvingo', 'Zimbabwe', 'Teacher Service Commission', 'Teacher', 'Individual', 'Education', '2024-02-22', 'L940147', 'L200861', 'Employment contract clarification', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(27, 'CL019', 'Percy', 'Ndlovu', '02-778811-U-02', '1980-05-17', 'Male', '+263772990011', 'percy.ndlovu@email.com', '88 Main Rd', 'Victoria Falls', 'Matabeleland North', 'Zimbabwe', 'Tourism Authority', 'Tour Guide', 'Individual', 'Tourism', '2024-02-24', 'L940147', 'L200861', 'Tourism licensing issue', '2026-03-27 04:54:26', '2026-03-27 04:54:26'),
(28, 'CL020', 'Shamiso', 'Gumbo', '75-223344-V-75', '1997-12-28', 'Female', '+263773001122', 'shamiso.gumbo@email.com', '29 Borrowdale Brooke', 'Harare', 'Harare', 'Zimbabwe', 'Startup Hub', 'Entrepreneur', 'Individual', 'Startup', '2024-02-26', 'L940147', 'L200861', 'Business registration advisory', '2026-03-27 04:54:26', '2026-03-27 04:54:26');

-- --------------------------------------------------------

--
-- Table structure for table `client_categories`
--

CREATE TABLE IF NOT EXISTS `client_categories` (
  `category_id` int NOT NULL AUTO_INCREMENT,
  `category_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category_description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`category_id`),
  UNIQUE KEY `category_code` (`category_code`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `client_categories`
--

INSERT INTO `client_categories` (`category_id`, `category_code`, `category_description`, `created_at`, `updated_at`) VALUES
(1, 'INDIV', 'Individual private clients seeking personal legal services', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(2, 'HNWI', 'High-net-worth individuals requiring complex legal and tax advisory services', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(3, 'SME', 'Small and medium-sized enterprises including startups and owner-managed businesses', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(4, 'CORP', 'Large corporations and multinational companies', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(5, 'FIN', 'Financial institutions such as banks, insurers, and investment firms', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(6, 'GOV', 'Government bodies, public authorities, and state-owned entities', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(7, 'NONP', 'Non-profit organizations, charities, and foundations', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(8, 'PROF', 'Professional services firms including accountants, consultants, and medical practices', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(9, 'REF', 'Referral-based clients introduced by third parties or panel arrangements', '2026-01-06 14:54:30', '2026-01-06 14:54:30'),
(10, 'PROB', 'Pro bono and strategic clients taken on for public interest or reputational purposes', '2026-01-06 14:54:30', '2026-01-06 14:54:30');

-- --------------------------------------------------------

--
-- Table structure for table `client_invoices`
--

CREATE TABLE IF NOT EXISTS `client_invoices` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `invoice_number` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `invoice_date` date NOT NULL,
  `due_date` date DEFAULT NULL,
  `client_id` bigint UNSIGNED NOT NULL COMMENT 'FK → clients.id',
  `matter_id` bigint UNSIGNED DEFAULT NULL,
  `case_id` bigint UNSIGNED DEFAULT NULL,
  `case_reference` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `responsible_lawyer` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FK → lawyers.lawyer_id',
  `quotation_id` bigint UNSIGNED DEFAULT NULL COMMENT 'FK → client_quotations.id if converted from quotation',
  `arrangement_id` bigint UNSIGNED DEFAULT NULL COMMENT 'FK → fee_arrangements.arrangement_id',
  `billing_period_from` date DEFAULT NULL,
  `billing_period_to` date DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `narration` text COLLATE utf8mb4_unicode_ci,
  `gl_account` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint UNSIGNED NOT NULL,
  `subtotal` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'Sum of invoice lines before tax and disbursements',
  `disbursement_total` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'Sum of client_invoice_disbursements',
  `discount_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  `tax_total` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'Sum of client_invoice_taxes',
  `total` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'subtotal + disbursement_total − discount_total + tax_total',
  `amount_paid` decimal(12,2) NOT NULL DEFAULT '0.00',
  `balance_due` decimal(12,2) GENERATED ALWAYS AS ((`total` - `amount_paid`)) STORED,
  `status` enum('draft','sent','partial','paid','overdue','cancelled','written_off') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `sent_at` timestamp NULL DEFAULT NULL,
  `paid_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_invoice_number` (`invoice_number`),
  KEY `idx_inv_client` (`client_id`),
  KEY `idx_inv_matter` (`matter_id`),
  KEY `idx_inv_case` (`case_id`),
  KEY `idx_inv_lawyer` (`responsible_lawyer`),
  KEY `idx_inv_status` (`status`),
  KEY `idx_inv_date` (`invoice_date`),
  KEY `idx_inv_currency` (`currency_id`),
  KEY `idx_inv_quotation` (`quotation_id`),
  KEY `idx_inv_arrangement` (`arrangement_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Client invoice header. Lines in client_invoice_lines. Tax in client_invoice_taxes. Disbursements in client_invoice_disbursements.';

--
-- Dumping data for table `client_invoices`
--

INSERT INTO `client_invoices` (`id`, `invoice_number`, `invoice_date`, `due_date`, `client_id`, `matter_id`, `case_id`, `case_reference`, `responsible_lawyer`, `quotation_id`, `arrangement_id`, `billing_period_from`, `billing_period_to`, `description`, `narration`, `gl_account`, `currency_id`, `subtotal`, `disbursement_total`, `discount_total`, `tax_total`, `total`, `amount_paid`, `status`, `sent_at`, `paid_at`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'INV-001', '2026-01-15', '2026-02-14', 1, 101, NULL, NULL, '1', NULL, 1, NULL, NULL, NULL, NULL, NULL, 1, 281.25, 0.00, 0.00, 42.19, 323.44, 150.00, 'partial', NULL, NULL, NULL, NULL, '2026-03-27 06:17:34', '2026-03-27 06:17:34'),
(2, 'INV-002', '2026-01-16', '2026-01-30', 2, 102, NULL, NULL, '2', 1, 2, NULL, NULL, NULL, NULL, NULL, 1, 1200.00, 0.00, 0.00, 180.00, 1380.00, 0.00, 'sent', NULL, NULL, NULL, NULL, '2026-03-27 06:18:40', '2026-03-27 06:18:40');

-- --------------------------------------------------------

--
-- Table structure for table `client_invoice_disbursements`
--

CREATE TABLE IF NOT EXISTS `client_invoice_disbursements` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint UNSIGNED NOT NULL COMMENT 'FK → client_invoices.id',
  `gl_account_id` bigint UNSIGNED DEFAULT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `disbursement_date` date DEFAULT NULL,
  `supplier` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Who the firm paid e.g. High Court Registrar',
  `receipt_reference` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'External receipt or proof-of-payment reference',
  `amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `is_taxable` tinyint(1) NOT NULL DEFAULT '0',
  `tax_rate` decimal(5,2) NOT NULL DEFAULT '0.00',
  `tax_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total_amount` decimal(12,2) GENERATED ALWAYS AS ((`amount` + `tax_amount`)) STORED,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_disb_invoice` (`invoice_id`),
  KEY `client_invoice_disbursements_gl_account_id_index` (`gl_account_id`)
) ;

-- --------------------------------------------------------

--
-- Table structure for table `client_invoice_gl_accounts`
--

CREATE TABLE IF NOT EXISTS `client_invoice_gl_accounts` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint UNSIGNED NOT NULL,
  `gl_account_id` bigint UNSIGNED DEFAULT NULL,
  `gl_account_code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `line_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(18,2) NOT NULL DEFAULT '0.00',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `client_invoice_gl_accounts_invoice_id_gl_account_id_index` (`invoice_id`,`gl_account_id`),
  KEY `client_invoice_gl_accounts_invoice_id_index` (`invoice_id`),
  KEY `client_invoice_gl_accounts_gl_account_id_index` (`gl_account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `client_invoice_lines`
--

CREATE TABLE IF NOT EXISTS `client_invoice_lines` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint UNSIGNED NOT NULL COMMENT 'FK → client_invoices.id',
  `charge_type` enum('FIXED_FEE','HOURLY','PER_APPEARANCE','RETAINER_DRAW','ADJUSTMENT') COLLATE utf8mb4_unicode_ci NOT NULL,
  `tariff_id` int DEFAULT NULL COMMENT 'FK → tariffs — NULL for free-text lines',
  `arrangement_id` bigint UNSIGNED DEFAULT NULL COMMENT 'FK → fee_arrangements',
  `service_code` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `service_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `billing_method` enum('FIXED_FEE','HOURLY','PER_APPEARANCE','PER_STAGE','RETAINER_PLUS','CONTINGENCY','SUBSCRIPTION') COLLATE utf8mb4_unicode_ci NOT NULL,
  `rate_snapshot` decimal(12,2) NOT NULL COMMENT 'CRITICAL: rate at time of billing. Never update. Allows audit of "what rate was charged on this date."',
  `billing_increment` int NOT NULL DEFAULT '60' COMMENT 'Snapshot of tariffs.billing_increment',
  `lawyer_id` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'The lawyer whose work this line charges',
  `work_date_from` date DEFAULT NULL,
  `work_date_to` date DEFAULT NULL,
  `total_raw_minutes` int NOT NULL DEFAULT '0',
  `total_rounded_minutes` int NOT NULL DEFAULT '0',
  `hours_decimal` decimal(8,4) GENERATED ALWAYS AS (round((`total_rounded_minutes` / 60.0),4)) STORED,
  `quantity` decimal(10,4) NOT NULL DEFAULT '1.0000',
  `base_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `discount_pct` decimal(5,2) NOT NULL DEFAULT '0.00',
  `discount_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `line_total` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'base_amount − discount_amount. Tax added at invoice level.',
  `description` text COLLATE utf8mb4_unicode_ci COMMENT 'Client-facing narrative for this charge line',
  `sort_order` int NOT NULL DEFAULT '0',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_cil_invoice` (`invoice_id`),
  KEY `idx_cil_tariff` (`tariff_id`),
  KEY `idx_cil_lawyer` (`lawyer_id`),
  KEY `idx_cil_charge_type` (`charge_type`),
  KEY `idx_cil_arrangement` (`arrangement_id`)
) ;

--
-- Dumping data for table `client_invoice_lines`
--

INSERT INTO `client_invoice_lines` (`id`, `invoice_id`, `charge_type`, `tariff_id`, `arrangement_id`, `service_code`, `service_name`, `billing_method`, `rate_snapshot`, `billing_increment`, `lawyer_id`, `work_date_from`, `work_date_to`, `total_raw_minutes`, `total_rounded_minutes`, `quantity`, `base_amount`, `discount_pct`, `discount_amount`, `line_total`, `description`, `sort_order`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 1, 'HOURLY', 1, 1, 'CIV-DRAFT-HR', 'Contract Drafting – Hourly', 'HOURLY', 75.00, 60, '1', '2026-01-06', '2026-01-08', 220, 225, 1.0000, 281.25, 0.00, 0.00, 281.25, NULL, 0, NULL, NULL, '2026-03-27 06:17:50', '2026-03-27 06:17:50'),
(2, 2, 'FIXED_FEE', 5, 2, 'FAM-DIV-FIXED', 'Divorce Proceedings – Full Service', 'FIXED_FEE', 1200.00, 60, '2', NULL, NULL, 0, 0, 1.0000, 1200.00, 0.00, 0.00, 1200.00, NULL, 0, NULL, NULL, '2026-03-27 06:18:52', '2026-03-27 06:18:52');

-- --------------------------------------------------------

--
-- Table structure for table `client_invoice_taxes`
--

CREATE TABLE IF NOT EXISTS `client_invoice_taxes` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint UNSIGNED NOT NULL,
  `tax_id` bigint UNSIGNED NOT NULL COMMENT 'FK → taxes.tax_id',
  `tax_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Snapshot of taxes.tax_name at invoice time',
  `tax_rate` decimal(5,2) NOT NULL,
  `taxable_base` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'The amount this tax is applied to',
  `tax_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_itax_invoice` (`invoice_id`),
  KEY `idx_itax_tax` (`tax_id`)
) ;

--
-- Dumping data for table `client_invoice_taxes`
--

INSERT INTO `client_invoice_taxes` (`id`, `invoice_id`, `tax_id`, `tax_name`, `tax_rate`, `taxable_base`, `tax_amount`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 'VAT', 15.00, 281.25, 42.19, '2026-03-27 06:18:28', '2026-03-27 06:18:28'),
(2, 2, 1, 'VAT', 15.00, 1200.00, 180.00, '2026-03-27 06:19:05', '2026-03-27 06:19:05');

-- --------------------------------------------------------

--
-- Table structure for table `client_journals`
--

CREATE TABLE IF NOT EXISTS `client_journals` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `client_code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `client_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `narration` text COLLATE utf8mb4_unicode_ci,
  `dr` decimal(15,2) DEFAULT '0.00',
  `cr` decimal(15,2) DEFAULT '0.00',
  `status` enum('pending','approved','rejected','reversed') COLLATE utf8mb4_unicode_ci DEFAULT 'pending',
  `client_id` int DEFAULT NULL,
  `transaction_code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transaction_code` (`transaction_code`),
  KEY `idx_date` (`date`),
  KEY `idx_client_code` (`client_code`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `client_journals`
--

INSERT INTO `client_journals` (`id`, `date`, `client_code`, `client_name`, `narration`, `dr`, `cr`, `status`, `client_id`, `transaction_code`, `created_at`, `updated_at`) VALUES
(1, '2026-01-05', 'CL-0001', 'James Whitaker', 'Retainer deposit received into trust - corporate advisory', 2500.00, 0.00, 'approved', 1, 'CJ-2026-0001', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(2, '2026-01-08', 'CL-0002', 'Emily Carter', 'Filing fees paid from trust - High Court application', 0.00, 350.00, 'approved', 2, 'CJ-2026-0002', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(3, '2026-01-12', 'CL-0003', 'Michael Dube', 'Trust funds received - litigation retainer for Dube Logistics', 1800.00, 0.00, 'approved', 3, 'CJ-2026-0003', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(4, '2026-01-15', 'CL001', 'Tendai Moyo', 'Sheriff fees disbursed from trust - process serving', 0.00, 180.00, 'approved', 8, 'CJ-2026-0004', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(5, '2026-01-18', 'CL002', 'Rudo Chikore', 'Advocate fees paid from trust - labour court brief', 0.00, 950.00, 'approved', 9, 'CJ-2026-0005', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(6, '2026-01-22', 'CL003', 'Farai Dube', 'Retainer received - regulatory compliance case ZimPower', 3200.00, 0.00, 'approved', 10, 'CJ-2026-0006', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(7, '2026-01-25', 'CL004', 'Chipo Sibanda', 'Courier fees disbursed from trust - document delivery Delta Beverages', 0.00, 75.00, 'approved', 11, 'CJ-2026-0007', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(8, '2026-01-28', 'CL005', 'Blessing Ndlovu', 'Trust interest earned on client funds - hospitality matter', 62.50, 0.00, 'approved', 12, 'CJ-2026-0008', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(9, '2026-02-03', 'CL006', 'Memory Zhou', 'High Court filing fee paid from trust - banking dispute', 0.00, 420.00, 'approved', 13, 'CJ-2026-0009', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(10, '2026-02-06', 'CL007', 'Simba Katsande', 'Retainer deposit - tender review and procurement advisory', 1500.00, 0.00, 'approved', 14, 'CJ-2026-0010', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(11, '2026-02-10', 'CL008', 'Nyasha Mukandi', 'Advocate brief fees paid from trust - student contract matter', 0.00, 600.00, 'approved', 15, 'CJ-2026-0011', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(12, '2026-02-13', 'CL009', 'Tawanda Mapfumo', 'Retainer received - mining compliance RioZim', 4500.00, 0.00, 'approved', 16, 'CJ-2026-0012', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(13, '2026-02-17', 'CL010', 'Rutendo Goronga', 'Trust admin fees charged - civil litigation file management', 0.00, 150.00, 'approved', 17, 'CJ-2026-0013', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(14, '2026-02-20', 'CL011', 'Tatenda Chirwa', 'Retainer deposit - loan agreement advisory ZB Bank matter', 2000.00, 0.00, 'approved', 19, 'CJ-2026-0014', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(15, '2026-02-24', 'CL012', 'Lindiwe Ncube', 'Filing fees paid from trust - lease agreement High Court', 0.00, 310.00, 'approved', 20, 'CJ-2026-0015', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(16, '2026-03-01', 'CL013', 'Kudakwashe Banda', 'Trust funds received - employment contract dispute ZESA', 1200.00, 0.00, 'approved', 21, 'CJ-2026-0016', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(17, '2026-03-04', 'CL014', 'Tsitsi Muchengeti', 'Sheriff fees paid from trust - workplace grievance service', 0.00, 200.00, 'approved', 22, 'CJ-2026-0017', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(18, '2026-03-07', 'CL015', 'Elvis Madondo', 'Retainer received - industrial safety compliance ZISCO Steel', 2800.00, 0.00, 'approved', 23, 'CJ-2026-0018', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(19, '2026-03-10', 'CL016', 'Rumbidzai Chinoda', 'Courier fees disbursed from trust - document exchange Steward Bank', 0.00, 90.00, 'approved', 24, 'CJ-2026-0019', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(20, '2026-03-13', 'CL017', 'Brian Zhou', 'Trust interest credited - export compliance matter', 48.75, 0.00, 'approved', 25, 'CJ-2026-0020', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(21, '2026-03-16', 'CL018', 'Faith Makoni', 'Filing fees paid from trust - Teacher Service Commission matter', 0.00, 275.00, 'approved', 26, 'CJ-2026-0021', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(22, '2026-03-19', 'CL019', 'Percy Ndlovu', 'Retainer deposit - tourism licensing dispute', 1750.00, 0.00, 'approved', 27, 'CJ-2026-0022', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(23, '2026-03-22', 'CL020', 'Shamiso Gumbo', 'Advocate fees paid from trust - business registration matter Startup Hub', 0.00, 780.00, 'approved', 28, 'CJ-2026-0023', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(24, '2026-03-25', 'CL-0005', 'Daniel Mukasa', 'Trust funds received - regulatory safety compliance Mukasa Engineering', 3500.00, 0.00, 'approved', 5, 'CJ-2026-0024', '2026-04-01 10:53:15', '2026-04-01 10:53:15'),
(25, '2026-03-28', 'CL1870787', 'Herr Gwena', 'Trust admin fees charged - HNWI cross-border advisory Gwena AG', 0.00, 400.00, 'approved', 18, 'CJ-2026-0025', '2026-04-01 10:53:15', '2026-04-01 10:53:15');

-- --------------------------------------------------------

--
-- Table structure for table `client_quotations`
--

CREATE TABLE IF NOT EXISTS `client_quotations` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `quotation_number` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `quotation_date` date NOT NULL,
  `client_id` bigint UNSIGNED DEFAULT NULL COMMENT 'FK → clients.id',
  `client_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Denormalised for quick display / printing',
  `matter_id` bigint UNSIGNED DEFAULT NULL,
  `case_id` bigint UNSIGNED DEFAULT NULL,
  `responsible_lawyer` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FK → lawyers.lawyer_id',
  `validity_days` int NOT NULL DEFAULT '30',
  `expiry_date` date GENERATED ALWAYS AS ((`quotation_date` + interval `validity_days` day)) STORED,
  `terms` text COLLATE utf8mb4_unicode_ci,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `scope_of_work` text COLLATE utf8mb4_unicode_ci COMMENT 'Plain-language description of services quoted',
  `currency_id` bigint UNSIGNED DEFAULT NULL,
  `subtotal` decimal(12,2) NOT NULL DEFAULT '0.00',
  `tax_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  `discount_total` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `status` enum('draft','sent','accepted','rejected','expired','converted') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `sent_at` timestamp NULL DEFAULT NULL,
  `responded_at` timestamp NULL DEFAULT NULL,
  `converted_invoice_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Set when this quotation is converted to an invoice',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_quotation_number` (`quotation_number`),
  KEY `idx_quot_client` (`client_id`),
  KEY `idx_quot_matter` (`matter_id`),
  KEY `idx_quot_lawyer` (`responsible_lawyer`),
  KEY `idx_quot_status` (`status`),
  KEY `idx_quot_date` (`quotation_date`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Client quotation (estimate). Each line is a client_quotation_line. On acceptance, a fee_arrangement is created and status → accepted.';

--
-- Dumping data for table `client_quotations`
--

INSERT INTO `client_quotations` (`id`, `quotation_number`, `quotation_date`, `client_id`, `client_name`, `matter_id`, `case_id`, `responsible_lawyer`, `validity_days`, `terms`, `notes`, `scope_of_work`, `currency_id`, `subtotal`, `tax_total`, `discount_total`, `total_amount`, `status`, `sent_at`, `responded_at`, `converted_invoice_id`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'QT-001', '2026-01-09', 2, 'John Dube', 102, NULL, '2', 30, NULL, NULL, NULL, 1, 1200.00, 180.00, 0.00, 1380.00, 'converted', NULL, NULL, NULL, NULL, NULL, '2026-03-27 06:17:02', '2026-03-27 06:17:02');

-- --------------------------------------------------------

--
-- Table structure for table `client_quotation_lines`
--

CREATE TABLE IF NOT EXISTS `client_quotation_lines` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `quotation_id` bigint UNSIGNED NOT NULL COMMENT 'FK → client_quotations.id',
  `tariff_id` int DEFAULT NULL COMMENT 'FK → tariffs (NULL = free-text line)',
  `charge_type` enum('FIXED_FEE','HOURLY','PER_APPEARANCE','DISBURSEMENT','OTHER') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'FIXED_FEE',
  `service_code` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `quantity` decimal(10,4) NOT NULL DEFAULT '1.0000' COMMENT 'Units or estimated hours',
  `unit_price` decimal(12,2) NOT NULL DEFAULT '0.00',
  `discount_pct` decimal(5,2) NOT NULL DEFAULT '0.00',
  `discount_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `tax_rate` decimal(5,2) NOT NULL DEFAULT '0.00',
  `tax_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `line_total` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '(unit_price × quantity − discount) + tax',
  `sort_order` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_qline_quotation` (`quotation_id`),
  KEY `idx_qline_tariff` (`tariff_id`)
) ;

--
-- Dumping data for table `client_quotation_lines`
--

INSERT INTO `client_quotation_lines` (`id`, `quotation_id`, `tariff_id`, `charge_type`, `service_code`, `description`, `quantity`, `unit_price`, `discount_pct`, `discount_amount`, `tax_rate`, `tax_amount`, `line_total`, `sort_order`, `created_at`, `updated_at`) VALUES
(1, 1, 5, 'FIXED_FEE', NULL, 'Full divorce proceedings', 1.0000, 1200.00, 0.00, 0.00, 15.00, 180.00, 1380.00, 0, '2026-03-27 06:17:13', '2026-03-27 06:17:13');

-- --------------------------------------------------------

--
-- Table structure for table `client_receipts`
--

CREATE TABLE IF NOT EXISTS `client_receipts` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `receipt_number` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `receipt_date` date NOT NULL,
  `client_id` bigint UNSIGNED NOT NULL COMMENT 'FK → clients.id',
  `matter_id` bigint UNSIGNED DEFAULT NULL,
  `responsible_lawyer` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_method` enum('cash','bank_transfer','cheque','mobile_money','card','trust_transfer','other') COLLATE utf8mb4_unicode_ci NOT NULL,
  `payment_reference` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Bank ref, cheque number, mobile money ref etc.',
  `bank_account` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint UNSIGNED DEFAULT NULL,
  `total_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'Must equal sum of receipt_lines.amount_applied',
  `exchange_rate` decimal(15,6) NOT NULL DEFAULT '1.000000',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `status` enum('draft','processed','reversed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `reversed_at` timestamp NULL DEFAULT NULL,
  `reversal_reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_receipt_number` (`receipt_number`),
  KEY `idx_rec_client` (`client_id`),
  KEY `idx_rec_matter` (`matter_id`),
  KEY `idx_rec_status` (`status`),
  KEY `idx_rec_date` (`receipt_date`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Payment receipt. One receipt can allocate payment across multiple invoices via client_receipt_lines.';

--
-- Dumping data for table `client_receipts`
--

INSERT INTO `client_receipts` (`id`, `receipt_number`, `receipt_date`, `client_id`, `matter_id`, `responsible_lawyer`, `payment_method`, `payment_reference`, `bank_account`, `currency_id`, `total_amount`, `exchange_rate`, `notes`, `status`, `reversed_at`, `reversal_reason`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'RCPT-001', '2026-01-20', 1, 101, NULL, 'bank_transfer', NULL, NULL, 1, 150.00, 1.000000, NULL, 'processed', NULL, NULL, NULL, NULL, '2026-03-27 06:19:14', '2026-03-27 06:19:14');

-- --------------------------------------------------------

--
-- Table structure for table `client_receipt_lines`
--

CREATE TABLE IF NOT EXISTS `client_receipt_lines` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `receipt_id` bigint UNSIGNED NOT NULL COMMENT 'FK → client_receipts.id',
  `invoice_id` bigint UNSIGNED NOT NULL COMMENT 'FK → client_invoices.id',
  `account_id` bigint UNSIGNED DEFAULT NULL COMMENT 'FK → general_ledger_accounts.id',
  `description` text COLLATE utf8mb4_unicode_ci,
  `amount_applied` decimal(12,2) NOT NULL COMMENT 'How much of this receipt is applied to this invoice',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_rline_receipt` (`receipt_id`),
  KEY `idx_rline_invoice` (`invoice_id`),
  KEY `idx_rline_account` (`account_id`)
) ;

--
-- Dumping data for table `client_receipt_lines`
--

INSERT INTO `client_receipt_lines` (`id`, `receipt_id`, `invoice_id`, `account_id`, `description`, `amount_applied`, `created_at`, `updated_at`) VALUES
(1, 1, 1, NULL, NULL, 150.00, '2026-03-27 06:19:24', '2026-03-27 06:19:24');

-- --------------------------------------------------------

--
-- Table structure for table `client_trust_accounts`
--

CREATE TABLE IF NOT EXISTS `client_trust_accounts` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `client_id` bigint UNSIGNED NOT NULL,
  `account_number` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `currency` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `status` enum('active','closed','suspended') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `opened_at` timestamp NOT NULL,
  `closed_at` timestamp NULL DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `client_trust_accounts_account_number_unique` (`account_number`),
  KEY `client_trust_accounts_created_by_foreign` (`created_by`),
  KEY `client_trust_accounts_updated_by_foreign` (`updated_by`),
  KEY `client_trust_accounts_client_id_index` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `client_trust_accounts`
--

INSERT INTO `client_trust_accounts` (`id`, `client_id`, `account_number`, `currency`, `status`, `opened_at`, `closed_at`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 18, 'HERRGWENA-001', 'CUR001', 'active', '2026-03-23 22:00:00', NULL, 1, 1, '2026-03-24 18:20:38', '2026-03-24 18:20:38', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `conflict_checks`
--

CREATE TABLE IF NOT EXISTS `conflict_checks` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `requested_by` bigint UNSIGNED DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `client_names` text COLLATE utf8mb4_unicode_ci,
  `opposing_parties` text COLLATE utf8mb4_unicode_ci,
  `company_names` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `resolved_by` bigint UNSIGNED DEFAULT NULL,
  `resolved_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `conflict_checks_created_by_foreign` (`created_by`),
  KEY `conflict_checks_updated_by_foreign` (`updated_by`),
  KEY `conflict_checks_requested_by_index` (`requested_by`),
  KEY `conflict_checks_resolved_by_index` (`resolved_by`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `conflict_checks`
--

INSERT INTO `conflict_checks` (`id`, `requested_by`, `status`, `notes`, `client_names`, `opposing_parties`, `company_names`, `created_by`, `updated_by`, `resolved_by`, `resolved_at`, `created_at`, `updated_at`) VALUES
(1, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(2, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(3, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(4, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(5, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(6, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(7, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(8, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(9, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(10, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(11, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 8, 'Pending Review', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 8, 'Conflict Found', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 8, 'Cleared', 'Seeded conflict check', NULL, NULL, NULL, 8, 8, NULL, NULL, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(26, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 10:28:44', '2026-03-22 10:28:44'),
(27, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 10:29:28', '2026-03-22 10:29:28'),
(28, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 11:27:58', '2026-03-22 11:27:58'),
(29, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 11:29:35', '2026-03-22 11:29:35'),
(30, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 11:44:18', '2026-03-22 11:44:18'),
(31, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 11:46:22', '2026-03-22 11:46:22'),
(32, 1, 'Conflict Found', NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, '2026-03-22 11:51:06', '2026-03-22 11:51:06'),
(33, 1, 'Pending Review', NULL, 'herr gwena', 'james whitaker', NULL, 1, 1, NULL, NULL, '2026-03-23 08:59:28', '2026-03-23 08:59:28'),
(34, 1, 'Pending Review', NULL, 'herr gwena', 'mrs gwena', NULL, 1, 1, NULL, NULL, '2026-03-23 08:59:47', '2026-03-23 08:59:47'),
(35, 1, 'Pending Review', NULL, 'herr gwena', 'lord radio', NULL, 1, 1, NULL, NULL, '2026-03-23 09:00:01', '2026-03-23 09:00:01'),
(36, 1, 'Cleared', NULL, 'herr gwena', 'lord bedn', NULL, 1, 1, NULL, NULL, '2026-03-23 09:02:27', '2026-03-23 09:02:27'),
(37, 1, 'Cleared', NULL, 'herr gwena', 'none', NULL, 1, 1, NULL, NULL, '2026-03-23 10:48:08', '2026-03-23 10:48:08'),
(38, 1, 'Cleared', NULL, 'herr gwena', 'estate of the family', NULL, 1, 1, NULL, NULL, '2026-03-23 11:05:09', '2026-03-23 11:05:09');

-- --------------------------------------------------------

--
-- Table structure for table `conflict_results`
--

CREATE TABLE IF NOT EXISTS `conflict_results` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `conflict_check_id` bigint UNSIGNED NOT NULL,
  `matched_entity_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `matched_entity_id` bigint UNSIGNED DEFAULT NULL,
  `matched_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `match_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `conflict_results_conflict_check_id_foreign` (`conflict_check_id`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `conflict_results`
--

INSERT INTO `conflict_results` (`id`, `conflict_check_id`, `matched_entity_type`, `matched_entity_id`, `matched_name`, `match_type`, `created_at`, `updated_at`) VALUES
(1, 25, 'Matter', NULL, 'Seeded Match ZwHC', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(2, 24, 'Matter', NULL, 'Seeded Match XPLT', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(3, 23, 'Matter', NULL, 'Seeded Match az2l', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(4, 22, 'Matter', NULL, 'Seeded Match wLMj', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(5, 21, 'Matter', NULL, 'Seeded Match ncwb', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(6, 20, 'Matter', NULL, 'Seeded Match gMRb', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(7, 19, 'Matter', NULL, 'Seeded Match lxLo', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(8, 18, 'Matter', NULL, 'Seeded Match hIay', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(9, 17, 'Matter', NULL, 'Seeded Match GvAC', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(10, 16, 'Matter', NULL, 'Seeded Match xK4n', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(11, 15, 'Matter', NULL, 'Seeded Match Ded6', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 14, 'Matter', NULL, 'Seeded Match EjfZ', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 13, 'Matter', NULL, 'Seeded Match Xp7u', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 12, 'Matter', NULL, 'Seeded Match Ifh8', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 11, 'Matter', NULL, 'Seeded Match AOir', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 10, 'Matter', NULL, 'Seeded Match rfZd', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 9, 'Matter', NULL, 'Seeded Match usuK', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 8, 'Matter', NULL, 'Seeded Match Uy76', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 7, 'Matter', NULL, 'Seeded Match 1rbi', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 6, 'Matter', NULL, 'Seeded Match hWgf', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 5, 'Matter', NULL, 'Seeded Match wrgP', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 4, 'Matter', NULL, 'Seeded Match RkWH', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 3, 'Matter', NULL, 'Seeded Match nP6d', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 2, 'Matter', NULL, 'Seeded Match jcMi', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 1, 'Matter', NULL, 'Seeded Match 1SHS', 'Potential', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(26, 26, 'client', 1, 'James Whitaker', 'name', '2026-03-22 10:28:44', '2026-03-22 10:28:44'),
(27, 26, 'client', 2, 'Emily Carter', 'name', '2026-03-22 10:28:44', '2026-03-22 10:28:44'),
(28, 27, 'client', 1, 'James Whitaker', 'name', '2026-03-22 10:29:28', '2026-03-22 10:29:28'),
(29, 27, 'client', 2, 'Emily Carter', 'name', '2026-03-22 10:29:28', '2026-03-22 10:29:28'),
(30, 28, 'client', 1, 'James Whitaker', 'name', '2026-03-22 11:27:58', '2026-03-22 11:27:58'),
(31, 28, 'client', 8, 'Tendai Moyo', 'name', '2026-03-22 11:27:58', '2026-03-22 11:27:58'),
(32, 29, 'client', 1, 'James Whitaker', 'name', '2026-03-22 11:29:35', '2026-03-22 11:29:35'),
(33, 29, 'client', 15, 'Nyasha Mukandi', 'name', '2026-03-22 11:29:35', '2026-03-22 11:29:35'),
(34, 30, 'client', 1, 'James Whitaker', 'name', '2026-03-22 11:44:18', '2026-03-22 11:44:18'),
(35, 30, 'client', 2, 'Emily Carter', 'name', '2026-03-22 11:44:18', '2026-03-22 11:44:18'),
(36, 31, 'client', 13, 'Memory Zhou', 'name', '2026-03-22 11:46:22', '2026-03-22 11:46:22'),
(37, 31, 'client', 16, 'Tawanda Mapfumo', 'name', '2026-03-22 11:46:22', '2026-03-22 11:46:22'),
(38, 32, 'client', 1, 'James Whitaker', 'name', '2026-03-22 11:51:06', '2026-03-22 11:51:06'),
(39, 32, 'client', 8, 'Tendai Moyo', 'name', '2026-03-22 11:51:06', '2026-03-22 11:51:06'),
(40, 33, 'client', 18, 'Herr Gwena', 'name', '2026-03-23 08:59:28', '2026-03-23 08:59:28'),
(41, 33, 'client', 1, 'James Whitaker', 'name', '2026-03-23 08:59:28', '2026-03-23 08:59:28'),
(42, 34, 'client', 18, 'Herr Gwena', 'name', '2026-03-23 08:59:47', '2026-03-23 08:59:47'),
(43, 35, 'client', 18, 'Herr Gwena', 'name', '2026-03-23 09:00:01', '2026-03-23 09:00:01');

-- --------------------------------------------------------

--
-- Table structure for table `conflict_search_terms`
--

CREATE TABLE IF NOT EXISTS `conflict_search_terms` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `conflict_check_id` bigint UNSIGNED NOT NULL,
  `search_term` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `entity_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `conflict_search_terms_conflict_check_id_foreign` (`conflict_check_id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `conflict_search_terms`
--

INSERT INTO `conflict_search_terms` (`id`, `conflict_check_id`, `search_term`, `entity_type`, `created_at`, `updated_at`) VALUES
(1, 25, 'Seed Term C8KcB', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(2, 24, 'Seed Term uMDUN', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(3, 23, 'Seed Term 8nMMy', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(4, 22, 'Seed Term qr1K5', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(5, 21, 'Seed Term KlDXw', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(6, 20, 'Seed Term Fmy0n', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(7, 19, 'Seed Term BNzmK', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(8, 18, 'Seed Term MlUIC', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(9, 17, 'Seed Term ACXfT', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(10, 16, 'Seed Term 1h0di', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(11, 15, 'Seed Term GSoF3', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 14, 'Seed Term 99bwA', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 13, 'Seed Term EKNK8', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 12, 'Seed Term crAvv', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 11, 'Seed Term YO23w', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 10, 'Seed Term q4RUq', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 9, 'Seed Term AcO2W', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 8, 'Seed Term B1u7u', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 7, 'Seed Term NZHay', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 6, 'Seed Term VX1dW', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 5, 'Seed Term ADd6v', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 4, 'Seed Term 9Bnvi', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 3, 'Seed Term sa9pq', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 2, 'Seed Term TWIwl', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 1, 'Seed Term Khl65', 'Client', '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(26, 26, 'james whitaker', 'client', '2026-03-22 10:28:44', '2026-03-22 10:28:44'),
(27, 26, 'emily carter', 'opposing_party', '2026-03-22 10:28:44', '2026-03-22 10:28:44'),
(28, 27, 'james whitaker', 'client', '2026-03-22 10:29:28', '2026-03-22 10:29:28'),
(29, 27, 'emily carter', 'opposing_party', '2026-03-22 10:29:28', '2026-03-22 10:29:28'),
(30, 28, 'james whitaker', 'client', '2026-03-22 11:27:58', '2026-03-22 11:27:58'),
(31, 28, 'tendai moyo', 'opposing_party', '2026-03-22 11:27:58', '2026-03-22 11:27:58'),
(32, 29, 'james whitaker', 'client', '2026-03-22 11:29:35', '2026-03-22 11:29:35'),
(33, 29, 'nyasha mukandi', 'opposing_party', '2026-03-22 11:29:35', '2026-03-22 11:29:35'),
(34, 30, 'james whitaker', 'client', '2026-03-22 11:44:18', '2026-03-22 11:44:18'),
(35, 30, 'emily carter', 'opposing_party', '2026-03-22 11:44:18', '2026-03-22 11:44:18'),
(36, 31, 'memory zhou', 'client', '2026-03-22 11:46:22', '2026-03-22 11:46:22'),
(37, 31, 'tawanda mapfumo', 'opposing_party', '2026-03-22 11:46:22', '2026-03-22 11:46:22'),
(38, 32, 'james whitaker', 'client', '2026-03-22 11:51:06', '2026-03-22 11:51:06'),
(39, 32, 'tendai moyo', 'opposing_party', '2026-03-22 11:51:06', '2026-03-22 11:51:06'),
(40, 33, 'herr gwena', 'client', '2026-03-23 08:59:28', '2026-03-23 08:59:28'),
(41, 33, 'james whitaker', 'opposing_party', '2026-03-23 08:59:28', '2026-03-23 08:59:28'),
(42, 34, 'herr gwena', 'client', '2026-03-23 08:59:47', '2026-03-23 08:59:47'),
(43, 34, 'mrs gwena', 'opposing_party', '2026-03-23 08:59:47', '2026-03-23 08:59:47'),
(44, 35, 'herr gwena', 'client', '2026-03-23 09:00:01', '2026-03-23 09:00:01'),
(45, 35, 'lord radio', 'opposing_party', '2026-03-23 09:00:01', '2026-03-23 09:00:01'),
(46, 36, 'herr gwena', 'client', '2026-03-23 09:02:27', '2026-03-23 09:02:27'),
(47, 36, 'lord bedn', 'opposing_party', '2026-03-23 09:02:27', '2026-03-23 09:02:27'),
(48, 37, 'herr gwena', 'client', '2026-03-23 10:48:08', '2026-03-23 10:48:08'),
(49, 37, 'none', 'opposing_party', '2026-03-23 10:48:08', '2026-03-23 10:48:08'),
(50, 38, 'herr gwena', 'client', '2026-03-23 11:05:09', '2026-03-23 11:05:09'),
(51, 38, 'estate of the family', 'opposing_party', '2026-03-23 11:05:09', '2026-03-23 11:05:09');

-- --------------------------------------------------------

--
-- Table structure for table `court_areas`
--

CREATE TABLE IF NOT EXISTS `court_areas` (
  `area_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `area_name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `city` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT 'Zimbabwe',
  `specific_location` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`area_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `court_areas`
--

INSERT INTO `court_areas` (`area_code`, `area_name`, `city`, `country`, `specific_location`, `created_at`, `updated_at`) VALUES
('CA-BHC', 'Bulawayo High Court', 'Bulawayo', 'Zimbabwe', 'Corner Fort Street & 10th Avenue', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-BYO', 'Bulawayo Magistrates Court', 'Bulawayo', 'Zimbabwe', 'Fife Street', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-CHI', 'Chinhoyi Magistrates Court', 'Chinhoyi', 'Zimbabwe', 'Magistrates Court Complex', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-GWE', 'Gweru Magistrates Court', 'Gweru', 'Zimbabwe', 'Robert Mugabe Way', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-HHC', 'Harare High Court', 'Harare', 'Zimbabwe', 'Samora Machel Avenue', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-HRE', 'Harare Magistrates Court', 'Harare', 'Zimbabwe', 'Corner Samora Machel Ave & Rotten Row', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-MAR', 'Marondera Magistrates Court', 'Marondera', 'Zimbabwe', 'Fifth Street', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-MAS', 'Masvingo Magistrates Court', 'Masvingo', 'Zimbabwe', 'Hughes Street', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-MUT', 'Mutare Magistrates Court', 'Mutare', 'Zimbabwe', 'Aerodrome Road', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
('CA-VIC', 'Victoria Falls Magistrates Court', 'Victoria Falls', 'Zimbabwe', 'Parkway Drive', '2026-03-27 06:43:31', '2026-03-27 06:43:31');

-- --------------------------------------------------------

--
-- Table structure for table `court_types`
--

CREATE TABLE IF NOT EXISTS `court_types` (
  `court_type_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `type_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`court_type_id`),
  UNIQUE KEY `type_name` (`type_name`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `court_types`
--

INSERT INTO `court_types` (`court_type_id`, `type_name`, `description`, `created_at`, `updated_at`) VALUES
(1, 'Magistrates Court', 'Handles minor criminal and civil matters', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(2, 'High Court', 'Handles serious criminal cases and major civil disputes', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(3, 'Supreme Court', 'Final court of appeal in Zimbabwe', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(4, 'Constitutional Court', 'Interprets and enforces the Constitution', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(5, 'Labour Court', 'Handles labour and employment disputes', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(6, 'Administrative Court', 'Deals with administrative and electoral matters', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(7, 'Family Court', 'Handles family law matters including divorce and custody', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(8, 'Juvenile Court', 'Handles cases involving minors', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(9, 'Commercial Court', 'Handles commercial and business disputes', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(10, 'Small Claims Court', 'Handles low-value civil claims', '2026-03-27 06:43:31', '2026-03-27 06:43:31');

-- --------------------------------------------------------

--
-- Table structure for table `currencies`
--

CREATE TABLE IF NOT EXISTS `currencies` (
  `currency_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `currency_code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
  `currency_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `symbol` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `country` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`currency_id`),
  UNIQUE KEY `currency_code` (`currency_code`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `currencies`
--

INSERT INTO `currencies` (`currency_id`, `currency_code`, `currency_name`, `symbol`, `country`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'CUR001', 'United States Dollar', 'USD', 'United States of America', 1, '2026-01-05 07:03:06', '2026-01-05 07:03:06'),
(2, 'CUR002', 'Zimbabwe Gold', 'ZWG', 'Zimbabwe', 1, '2026-01-05 07:03:39', '2026-01-05 07:03:39'),
(3, 'CUR003', 'South African Rand', 'ZAR', 'South Africa', 1, '2026-01-05 07:04:19', '2026-01-05 07:04:19');

-- --------------------------------------------------------

--
-- Table structure for table `currency_rates`
--

CREATE TABLE IF NOT EXISTS `currency_rates` (
  `rate_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `base_currency_id` bigint UNSIGNED NOT NULL,
  `target_currency_id` bigint UNSIGNED NOT NULL,
  `rate_date` date DEFAULT NULL,
  `buy_rate` decimal(15,6) NOT NULL,
  `sell_rate` decimal(15,6) NOT NULL,
  `source` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`rate_id`),
  UNIQUE KEY `unique_currency_rate` (`base_currency_id`,`target_currency_id`,`rate_date`),
  UNIQUE KEY `unique_rate` (`base_currency_id`,`target_currency_id`,`rate_date`),
  KEY `target_currency_id` (`target_currency_id`),
  KEY `fk_currency_rates_created_by` (`created_by`),
  KEY `fk_currency_rates_updated_by` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `currency_rates`
--

INSERT INTO `currency_rates` (`rate_id`, `base_currency_id`, `target_currency_id`, `rate_date`, `buy_rate`, `sell_rate`, `source`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 2, 1, '2026-01-05', 29.500000, 30.000000, 'RBZ', 1, 1, '2026-01-05 07:04:50', '2026-03-10 21:23:01');

-- --------------------------------------------------------

--
-- Table structure for table `departments`
--

CREATE TABLE IF NOT EXISTS `departments` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `departments_code_unique` (`code`),
  KEY `departments_created_by_foreign` (`created_by`),
  KEY `departments_updated_by_foreign` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `departments`
--

INSERT INTO `departments` (`id`, `name`, `code`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Corporate Law', 'CORP', 'Handles corporate governance, mergers, and acquisitions', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(2, 'Litigation', 'LIT', 'Manages disputes, court cases, and legal proceedings', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(3, 'Intellectual Property', 'IP', 'Protects patents, trademarks, and copyrights', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(4, 'Real Estate Law', 'REAL_ESTATE', 'Deals with property transactions and disputes', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(5, 'Family Law', 'FAMILY', 'Handles divorce, custody, and family-related cases', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(6, 'Criminal Law', 'CRIMINAL', 'Represents clients in criminal cases', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(7, 'Tax Law', 'TAX', 'Advises on tax compliance and disputes', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(8, 'Employment Law', 'EMPLOYMENT', 'Handles labor laws, contracts, and disputes', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(9, 'Immigration Law', 'IMMIGRATION', 'Deals with visas, residency, and citizenship matters', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(10, 'Compliance & Risk', 'COMPLIANCE', 'Ensures regulatory compliance and risk management', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(11, 'Legal Research', 'RESEARCH', 'Supports case preparation and legal documentation', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(12, 'Administration', 'ADMIN', 'Manages internal operations and office administration', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(13, 'Finance & Accounts', 'FINANCE', 'Handles billing, payroll, and financial reporting', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(14, 'Human Resources', 'HR', 'Manages recruitment, training, and employee relations', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(15, 'Client Relations', 'CLIENT_REL', 'Manages client communication and onboarding', 1, 1, '2026-03-24 12:01:18', '2026-03-24 12:01:18', NULL),
(16, 'SECURITY', 'SECR', 'handling cyber and premise security.', 1, 1, '2026-03-31 12:10:32', '2026-03-31 12:10:32', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `diaries`
--

CREATE TABLE IF NOT EXISTS `diaries` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `date_time` datetime NOT NULL,
  `task_title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `client_case` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `task_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `priority` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `location` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `duration` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `duration_minutes` smallint UNSIGNED DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `category_id` bigint UNSIGNED DEFAULT NULL,
  `assigned_to` bigint UNSIGNED DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `diaries_created_by_foreign` (`created_by`),
  KEY `diaries_updated_by_foreign` (`updated_by`),
  KEY `diaries_date_time_index` (`date_time`),
  KEY `diaries_status_priority_index` (`status`,`priority`),
  KEY `diaries_assigned_to_index` (`assigned_to`),
  KEY `diaries_category_id_index` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `diary_attachments`
--

CREATE TABLE IF NOT EXISTS `diary_attachments` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `diary_id` bigint UNSIGNED NOT NULL,
  `original_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `file_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `mime_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `file_size` bigint UNSIGNED NOT NULL,
  `file_hash` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `diary_attachments_diary_id_index` (`diary_id`),
  KEY `diary_attachments_created_at_index` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `diary_categories`
--

CREATE TABLE IF NOT EXISTS `diary_categories` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sort_order` int UNSIGNED NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `diary_categories_name_unique` (`name`),
  KEY `diary_categories_is_active_sort_order_index` (`is_active`,`sort_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `diary_entry_tags`
--

CREATE TABLE IF NOT EXISTS `diary_entry_tags` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `diary_id` bigint UNSIGNED NOT NULL,
  `tag_id` bigint UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `diary_entry_tags_diary_id_tag_id_unique` (`diary_id`,`tag_id`),
  KEY `diary_entry_tags_diary_id_index` (`diary_id`),
  KEY `diary_entry_tags_tag_id_index` (`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `diary_reminders`
--

CREATE TABLE IF NOT EXISTS `diary_reminders` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `diary_id` bigint UNSIGNED NOT NULL,
  `remind_at` datetime NOT NULL,
  `is_sent` tinyint(1) NOT NULL DEFAULT '0',
  `message` text COLLATE utf8mb4_unicode_ci,
  `delivery_method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'email',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `diary_reminders_diary_id_remind_at_index` (`diary_id`,`remind_at`),
  KEY `diary_reminders_is_sent_index` (`is_sent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `diary_tags`
--

CREATE TABLE IF NOT EXISTS `diary_tags` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `usage_count` int UNSIGNED NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `diary_tags_name_unique` (`name`),
  KEY `diary_tags_is_active_usage_count_index` (`is_active`,`usage_count`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `features`
--

CREATE TABLE IF NOT EXISTS `features` (
  `feature_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `submodule_id` bigint UNSIGNED NOT NULL,
  `feature_name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`feature_id`),
  KEY `submodule_id` (`submodule_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `fee_arrangements`
--

CREATE TABLE IF NOT EXISTS `fee_arrangements` (
  `arrangement_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `matter_id` bigint UNSIGNED DEFAULT NULL,
  `case_id` bigint UNSIGNED DEFAULT NULL,
  `client_id` bigint UNSIGNED NOT NULL,
  `lawyer_id` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Responsible billing lawyer',
  `tariff_id` int DEFAULT NULL COMMENT 'Linked tariff (NULL = bespoke agreed_rate below)',
  `arrangement_type` enum('FIXED_FEE','HOURLY','CAPPED_HOURLY','RETAINER','CONTINGENCY','PRO_BONO') COLLATE utf8mb4_unicode_ci NOT NULL,
  `agreed_rate` decimal(12,2) DEFAULT NULL COMMENT 'Hourly rate or fixed fee as agreed with client',
  `fee_cap` decimal(12,2) DEFAULT NULL COMMENT 'Ceiling for CAPPED_HOURLY',
  `retainer_amount` decimal(12,2) DEFAULT NULL,
  `contingency_pct` decimal(5,2) DEFAULT NULL,
  `billing_frequency` enum('one_off','monthly','quarterly','milestone') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'one_off',
  `currency_id` bigint UNSIGNED DEFAULT NULL,
  `payment_terms_days` int NOT NULL DEFAULT '30',
  `status` enum('draft','active','suspended','closed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `signed_date` date DEFAULT NULL,
  `quotation_id` bigint UNSIGNED DEFAULT NULL COMMENT 'FK → client_quotations.id if this arrangement came from a quotation',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`arrangement_id`),
  KEY `idx_fa_matter` (`matter_id`),
  KEY `idx_fa_case` (`case_id`),
  KEY `idx_fa_client` (`client_id`),
  KEY `idx_fa_lawyer` (`lawyer_id`),
  KEY `idx_fa_tariff` (`tariff_id`),
  KEY `idx_fa_status` (`status`),
  KEY `idx_fa_quotation` (`quotation_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Per-matter engagement agreement. Links matter/case to a tariff or bespoke rate. Quotations become arrangements on acceptance.';

--
-- Dumping data for table `fee_arrangements`
--

INSERT INTO `fee_arrangements` (`arrangement_id`, `matter_id`, `case_id`, `client_id`, `lawyer_id`, `tariff_id`, `arrangement_type`, `agreed_rate`, `fee_cap`, `retainer_amount`, `contingency_pct`, `billing_frequency`, `currency_id`, `payment_terms_days`, `status`, `signed_date`, `quotation_id`, `notes`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 101, NULL, 1, '1', 1, 'HOURLY', 75.00, NULL, NULL, NULL, 'one_off', 1, 30, 'active', '2026-01-05', NULL, NULL, NULL, NULL, '2026-03-27 06:17:25', '2026-03-27 06:17:25'),
(2, 102, NULL, 2, '2', 5, 'FIXED_FEE', 1200.00, NULL, NULL, NULL, 'one_off', 1, 14, 'active', '2026-01-10', 1, NULL, NULL, NULL, '2026-03-27 06:17:25', '2026-03-27 06:17:25');

-- --------------------------------------------------------

--
-- Table structure for table `general_journals`
--

CREATE TABLE IF NOT EXISTS `general_journals` (
  `id` int NOT NULL AUTO_INCREMENT,
  `account_id` bigint UNSIGNED DEFAULT NULL,
  `account` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `date` date NOT NULL,
  `narration` text COLLATE utf8mb4_unicode_ci,
  `tr_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `currency_id` bigint UNSIGNED DEFAULT NULL,
  `transaction_code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `currency` varchar(3) COLLATE utf8mb4_unicode_ci DEFAULT 'USD',
  `amount` decimal(15,2) NOT NULL,
  `status` enum('pending','approved','rejected','reversed') COLLATE utf8mb4_unicode_ci DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transaction_code` (`transaction_code`),
  KEY `general_journals_account_id_index` (`account_id`),
  KEY `general_journals_currency_id_index` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `general_journals`
--

INSERT INTO `general_journals` (`id`, `account_id`, `account`, `date`, `narration`, `tr_code`, `currency_id`, `transaction_code`, `currency`, `amount`, `status`, `created_at`, `updated_at`) VALUES
(1, 10, '1000/001', '2026-01-05', 'Litigation fees earned - Whitaker Holdings Q1', 'GJ', 1, 'GJ-2026-0001', 'USD', 2500.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(2, 20, '1200/001', '2026-01-08', 'Initial consultation fee - Emily Carter contract review', 'GJ', 1, 'GJ-2026-0002', 'USD', 350.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(3, 30, '1300/002', '2026-01-12', 'High Court appearance fee - Dube Logistics litigation', 'GJ', 1, 'GJ-2026-0003', 'USD', 800.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(4, 40, '1400/003', '2026-01-15', 'Lease agreement drafted - Tendai Moyo residential property', 'GJ', 1, 'GJ-2026-0004', 'USD', 450.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(5, 50, '1500/003', '2026-01-18', 'Success fee earned - debt collection commission Chikore matter', 'GJ', 1, 'GJ-2026-0005', 'USD', 620.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(6, 80, '4000/001', '2026-01-22', 'Office rent payment - January 2026 Samora Machel Ave', 'GJ', 1, 'GJ-2026-0006', 'USD', 2800.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(7, 90, '4100/001', '2026-01-31', 'Professional staff salaries - January 2026 payroll', 'GJ', 1, 'GJ-2026-0007', 'USD', 8500.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(8, 100, '4200/001', '2026-02-03', 'Electricity consumption - January billing period', 'GJ', 1, 'GJ-2026-0008', 'USD', 415.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(9, 110, '4300/001', '2026-02-06', 'Fibre broadband - January invoice Iota Technologies', 'GJ', 1, 'GJ-2026-0009', 'USD', 280.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(10, 120, '4400/001', '2026-02-10', 'Law Society annual subscription - 2026 membership renewal', 'GJ', 1, 'GJ-2026-0010', 'USD', 480.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(11, 130, '4500/001', '2026-02-13', 'Practice management system licence - annual fee', 'GJ', 1, 'GJ-2026-0011', 'USD', 1200.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(12, 131, '4500/002', '2026-02-17', 'Accounting software licence - annual renewal', 'GJ', 1, 'GJ-2026-0012', 'USD', 650.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(13, 140, '0004/001', '2026-02-20', 'Trust account monthly bank service fee - February', 'TJ', 1, 'GJ-2026-0013', 'USD', 85.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(14, 150, '0041/002', '2026-02-24', 'Trust account audit fee - 2025 annual trust audit', 'TJ', 1, 'GJ-2026-0014', 'USD', 1800.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(15, 180, '8400/001', '2026-02-27', 'Operating account closing balance - February 2026', 'GJ', 1, 'GJ-2026-0015', 'USD', 14250.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(16, 170, '8100/001', '2026-03-01', 'Petty cash replenishment - office float top-up March', 'GJ', 1, 'GJ-2026-0016', 'USD', 500.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(17, 220, '0084/001', '2026-03-04', 'Trust current account balance - Whitaker & Dube retainers', 'TJ', 1, 'GJ-2026-0017', 'USD', 7500.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(18, 230, '0085/002', '2026-03-07', 'Trust filing float replenishment - March court season', 'TJ', 1, 'GJ-2026-0018', 'USD', 300.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(19, 160, '7100/001', '2026-03-10', 'Legal fees receivable - Mapfumo mining compliance outstanding', 'GJ', 1, 'GJ-2026-0019', 'USD', 4500.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(20, 161, '7100/002', '2026-03-13', 'Disbursements receivable - Q1 outstanding client recoveries', 'GJ', 1, 'GJ-2026-0020', 'USD', 1820.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(21, 250, '9000/001', '2026-03-16', 'Advocates payable - Farai Dube matter senior counsel brief', 'GJ', 1, 'GJ-2026-0021', 'USD', 2200.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(22, 260, '9100/001', '2026-03-19', 'Accrued salaries - March 2026 payroll provision', 'GJ', 1, 'GJ-2026-0022', 'USD', 8500.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(23, 270, '9200/001', '2026-03-22', 'VAT output - Q1 2026 legal fees billed to clients', 'GJ', 1, 'GJ-2026-0023', 'USD', 1950.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(24, 271, '9200/002', '2026-03-25', 'VAT input - Q1 2026 supplier invoices received', 'GJ', 1, 'GJ-2026-0024', 'USD', 840.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16'),
(25, 240, '0071/001', '2026-03-28', 'Client trust AR - Madondo and Mukasa outstanding trust balances', 'TJ', 1, 'GJ-2026-0025', 'USD', 6300.00, 'approved', '2026-04-01 10:53:16', '2026-04-01 10:53:16');

-- --------------------------------------------------------

--
-- Table structure for table `general_ledger_parent_accounts`
--

CREATE TABLE IF NOT EXISTS `general_ledger_parent_accounts` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `account_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'e.g. 4000',
  `account_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'e.g. Disbursement',
  `financial_category` enum('income_statement','balance_sheet') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Which financial statement this account belongs to',
  `account_type_id` bigint UNSIGNED NOT NULL COMMENT 'FK to account_types.id',
  `is_control_account` tinyint(1) NOT NULL DEFAULT '0',
  `is_trust_account` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_glpa_account_code` (`account_code`),
  KEY `idx_glpa_account_type` (`account_type_id`),
  KEY `idx_glpa_financial_category` (`financial_category`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Top-level GL accounts. Each may have many sub-accounts.';

--
-- Dumping data for table `general_ledger_parent_accounts`
--

INSERT INTO `general_ledger_parent_accounts` (`id`, `account_code`, `account_name`, `financial_category`, `account_type_id`, `is_control_account`, `is_trust_account`, `is_active`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, '1000', 'Legal Fees Income', 'income_statement', 4, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(2, '1200', 'Consultation Fee', 'income_statement', 4, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(3, '1300', 'Court Appearance Fees', 'income_statement', 4, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(4, '1400', 'Contract Drafting Fees', 'income_statement', 4, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(5, '1500', 'Commission Income', 'income_statement', 4, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(6, '0005', 'Disbursements Fees', 'income_statement', 4, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(7, '0001', 'Trust Interest Earned', 'income_statement', 22, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(8, '4000', 'Rent', 'income_statement', 5, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(9, '4100', 'Salaries & Wages', 'income_statement', 5, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(10, '4200', 'Electricity & Water', 'income_statement', 5, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(11, '4300', 'Internet', 'income_statement', 5, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(12, '4400', 'Professional Subscription', 'income_statement', 5, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(13, '4500', 'Software Licence', 'income_statement', 5, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(14, '0004', 'Trust Account - Bank Charges', 'income_statement', 19, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(15, '0041', 'Trust Account - Administration Fees', 'income_statement', 19, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(16, '7100', 'Trade Receivable', 'balance_sheet', 13, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(17, '8100', 'Petty Cash USD', 'balance_sheet', 12, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(18, '8400', 'Cash USD', 'balance_sheet', 12, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(19, '8500', 'Prepaid Expenses', 'balance_sheet', 9, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(20, '6000', 'Motor Vehicle', 'balance_sheet', 15, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(21, '6100', 'Office Equipment', 'balance_sheet', 15, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(22, '0084', 'Trust Account - Cash USD', 'balance_sheet', 23, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(23, '0085', 'Trust Account - Petty Cash USD', 'balance_sheet', 23, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(24, '0071', 'Trust Account - Trade Receivable', 'balance_sheet', 21, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(25, '9000', 'Trade Payable', 'balance_sheet', 14, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(26, '9100', 'Accrued Expenses', 'balance_sheet', 10, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(27, '9200', 'VAT', 'balance_sheet', 10, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(28, '0091', 'Trust Account - Trade Payable', 'balance_sheet', 20, 0, 1, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(29, '9400', 'Drawings', 'balance_sheet', 3, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(30, '9500', 'Retained Earnings', 'balance_sheet', 3, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(31, '9600', 'Owner Capital', 'balance_sheet', 3, 0, 0, 1, 1, 1, '2026-03-31 10:24:04', '2026-03-31 10:24:04', NULL),
(32, '5899', 'DEMO', 'income_statement', 5, 1, 0, 1, 1, 1, '2026-03-31 12:46:20', '2026-03-31 12:46:20', NULL),
(34, '2510', 'MELSOFT', 'balance_sheet', 8, 1, 0, 1, 1, 1, '2026-03-31 13:04:09', '2026-03-31 13:04:09', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `general_ledger_subaccounts`
--

CREATE TABLE IF NOT EXISTS `general_ledger_subaccounts` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `parent_id` bigint UNSIGNED NOT NULL COMMENT 'FK to general_ledger_parent_accounts.id',
  `sub_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Suffix only e.g. 100, 101',
  `account_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'e.g. Transport Fee',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_glsa_parent_sub_code` (`parent_id`,`sub_code`),
  KEY `idx_glsa_parent_id` (`parent_id`)
) ENGINE=InnoDB AUTO_INCREMENT=316 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Sub-accounts linked to a parent. Full code displayed as parent_code/sub_code.';

--
-- Dumping data for table `general_ledger_subaccounts`
--

INSERT INTO `general_ledger_subaccounts` (`id`, `parent_id`, `sub_code`, `account_name`, `is_active`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 20, '100', 'Motor Vehicle @ Cost', 1, 1, 1, '2026-03-06 13:53:20', '2026-03-06 13:53:20', NULL),
(2, 20, '101', 'Motor Vehicle - Acc Depreciation', 1, 1, 1, '2026-03-06 13:54:02', '2026-03-06 13:54:02', NULL),
(3, 21, '100', 'Office Equipment @ Cost', 1, 1, 1, '2026-03-06 13:54:52', '2026-03-06 13:54:52', NULL),
(4, 21, '101', 'Office Equipment - Acc Depreciation', 1, 1, 1, '2026-03-06 13:55:14', '2026-03-06 13:55:14', NULL),
(5, 6, '001', 'Filing Fees', 1, 1, 1, '2026-03-07 00:00:14', '2026-03-07 00:00:14', NULL),
(6, 6, '002', 'Sheriff Fees', 1, 1, 1, '2026-03-07 00:00:35', '2026-03-07 00:00:35', NULL),
(7, 6, '003', 'Advocate Fees', 1, 1, 1, '2026-03-07 00:00:52', '2026-03-07 00:00:52', NULL),
(8, 6, '004', 'Courier Fees', 1, 1, 1, '2026-03-07 00:01:36', '2026-03-07 00:01:36', NULL),
(10, 1, '001', 'Litigation Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(11, 1, '002', 'Advisory Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(12, 1, '003', 'Drafting Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(13, 1, '004', 'Compliance Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(14, 1, '005', 'General Legal Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(20, 2, '001', 'Initial Consultation', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(21, 2, '002', 'Follow-Up Consultation', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(22, 2, '003', 'Telephone Consultation', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(23, 2, '004', 'Written Legal Opinion', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(24, 2, '005', 'Urgent Consultation', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(30, 3, '001', 'Magistrates Court', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(31, 3, '002', 'High Court', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(32, 3, '003', 'Supreme Court of Appeal', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(33, 3, '004', 'Constitutional Court', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(34, 3, '005', 'Urgent Chamber Application', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(40, 4, '001', 'Commercial Contracts', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(41, 4, '002', 'Employment Contracts', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(42, 4, '003', 'Lease Agreements', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(43, 4, '004', 'Settlement Agreements', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(44, 4, '005', 'Non-Disclosure Agreements', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(50, 5, '001', 'Referral Commission', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(51, 5, '002', 'Agency Commission', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(52, 5, '003', 'Success Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(53, 5, '004', 'Brokerage Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(54, 5, '005', 'Debt Collection Commission', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(70, 7, '001', 'Trust Savings Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(71, 7, '002', 'Trust Investment Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(72, 7, '003', 'Trust Call Account Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(73, 7, '004', 'Trust Fixed Deposit Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(74, 7, '005', 'Trust Money Market Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(80, 8, '001', 'Office Rent', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(81, 8, '002', 'Parking', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(82, 8, '003', 'Storage / Archive Room', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(83, 8, '004', 'Boardroom Hire', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(84, 8, '005', 'Satellite Office Rent', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(90, 9, '001', 'Professional Staff Salaries', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(91, 9, '002', 'Support Staff Salaries', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(92, 9, '003', 'Overtime', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(93, 9, '004', 'Bonuses & Incentives', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(94, 9, '005', 'Casual Labour', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(100, 10, '001', 'Electricity', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(101, 10, '002', 'Water & Sewerage', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(102, 10, '003', 'Refuse Removal', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(103, 10, '004', 'Municipal Rates', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(104, 10, '005', 'Solar / Generator Levy', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(110, 11, '001', 'Fibre / Broadband', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(111, 11, '002', 'Backup LTE / Mobile Data', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(112, 11, '003', 'VOIP / Telephone Lines', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(113, 11, '004', 'Domain & Website Hosting', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(114, 11, '005', 'IT Support & Maintenance', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(120, 12, '001', 'Law Society Subscription', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(121, 12, '002', 'Bar Council Subscription', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(122, 12, '003', 'Legal Journals & Reports', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(123, 12, '004', 'CPD Training & Seminars', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(124, 12, '005', 'Professional Indemnity', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(130, 13, '001', 'Practice Management System', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(131, 13, '002', 'Accounting Software', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(132, 13, '003', 'MS Office / Productivity', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(133, 13, '004', 'Legal Research Platform', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(134, 13, '005', 'Cloud Backup & Storage', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(140, 14, '001', 'Monthly Service Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(141, 14, '002', 'Transaction Charges', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(142, 14, '003', 'Cash Handling Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(143, 14, '004', 'Electronic Transfer Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(144, 14, '005', 'Cheque Processing Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(150, 15, '001', 'Trust Account Setup Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(151, 15, '002', 'Trust Audit Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(152, 15, '003', 'Trust Compliance Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(153, 15, '004', 'Trust Reporting Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(154, 15, '005', 'Trust Management Fee', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(160, 16, '001', 'Legal Fees Receivable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(161, 16, '002', 'Disbursements Receivable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(162, 16, '003', 'VAT Receivable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(163, 16, '004', 'Retainer Deposits', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(164, 16, '005', 'Other Receivables', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(170, 17, '001', 'Office Petty Cash', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(171, 17, '002', 'Courier Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(172, 17, '003', 'Postage Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(173, 17, '004', 'Sundry Cash Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(174, 17, '005', 'Court Filing Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(180, 18, '001', 'Main Operating Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(181, 18, '002', 'Payroll Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(182, 18, '003', 'Savings Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(183, 18, '004', 'Foreign Currency Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(184, 18, '005', 'Cash on Hand', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(190, 19, '001', 'Prepaid Rent', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(191, 19, '002', 'Prepaid Insurance', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(192, 19, '003', 'Prepaid Subscriptions', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(193, 19, '004', 'Prepaid IT Contracts', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(194, 19, '005', 'Prepaid Retainer Costs', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(220, 22, '001', 'Trust Current Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(221, 22, '002', 'Trust Savings Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(222, 22, '003', 'Trust Call Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(223, 22, '004', 'Trust Investment Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(224, 22, '005', 'Trust Money Market Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(230, 23, '001', 'Trust Postage Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(231, 23, '002', 'Trust Filing Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(232, 23, '003', 'Trust Courier Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(233, 23, '004', 'Trust Sundry Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(234, 23, '005', 'Trust Admin Float', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(240, 24, '001', 'Client Trust AR', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(241, 24, '002', 'Trust Disbursement Recoveries', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(242, 24, '003', 'Trust Interest Receivable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(243, 24, '004', 'Trust Levy Receivable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(244, 24, '005', 'Other Trust Receivables', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(250, 25, '001', 'Advocates Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(251, 25, '002', 'Supplier Invoices Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(252, 25, '003', 'Court Fees Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(253, 25, '004', 'Counsel Fees Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(254, 25, '005', 'Other Payables', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(260, 26, '001', 'Accrued Salaries', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(261, 26, '002', 'Accrued Audit Fees', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(262, 26, '003', 'Accrued Leave Pay', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(263, 26, '004', 'Accrued Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(264, 26, '005', 'Accrued Legal Costs', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(270, 27, '001', 'VAT Output', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(271, 27, '002', 'VAT Input', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(272, 27, '003', 'VAT Control Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(273, 27, '004', 'VAT Penalties', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(274, 27, '005', 'VAT Interest', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(280, 28, '001', 'Trust Creditors', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(281, 28, '002', 'Trust Advocate Fees Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(282, 28, '003', 'Trust Disbursement Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(283, 28, '004', 'Trust Levy Payable', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(284, 28, '005', 'Other Trust Payables', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(290, 29, '001', 'Partner Drawings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(291, 29, '002', 'Director Drawings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(292, 29, '003', 'Shareholder Drawings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(293, 29, '004', 'Interim Drawings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(294, 29, '005', 'Year-End Drawings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(300, 30, '001', 'Opening Retained Earnings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(301, 30, '002', 'Current Year Earnings', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(302, 30, '003', 'Prior Year Adjustment', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(303, 30, '004', 'Dividend Reserve', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(304, 30, '005', 'General Reserve', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(310, 31, '001', 'Initial Capital Contribution', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(311, 31, '002', 'Additional Capital Contribution', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(312, 31, '003', 'Capital Reserve', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(313, 31, '004', 'Revaluation Reserve', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(314, 31, '005', 'Partner Capital Account', 1, 1, 1, '2026-03-31 10:42:08', '2026-03-31 10:42:08', NULL),
(315, 32, '100', 'DEMO 44', 1, 1, 1, '2026-03-31 13:01:17', '2026-03-31 13:01:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `group_calls`
--

CREATE TABLE IF NOT EXISTS `group_calls` (
  `call_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `chat_id` bigint UNSIGNED NOT NULL,
  `initiated_by` bigint UNSIGNED NOT NULL,
  `call_type` enum('audio','video') COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('ongoing','ended','missed') COLLATE utf8mb4_unicode_ci DEFAULT 'ongoing',
  `started_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `ended_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`call_id`),
  KEY `chat_id` (`chat_id`),
  KEY `initiated_by` (`initiated_by`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `group_call_participants`
--

CREATE TABLE IF NOT EXISTS `group_call_participants` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `call_id` bigint UNSIGNED NOT NULL,
  `user_id` bigint UNSIGNED NOT NULL,
  `join_time` timestamp NULL DEFAULT NULL,
  `leave_time` timestamp NULL DEFAULT NULL,
  `call_status` enum('joined','missed','left') COLLATE utf8mb4_unicode_ci DEFAULT 'missed',
  PRIMARY KEY (`id`),
  KEY `call_id` (`call_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `group_permissions`
--

CREATE TABLE IF NOT EXISTS `group_permissions` (
  `group_permission_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_id` bigint UNSIGNED NOT NULL,
  `feature_id` bigint UNSIGNED NOT NULL,
  `can_view` tinyint(1) NOT NULL DEFAULT '0',
  `can_add` tinyint(1) NOT NULL DEFAULT '0',
  `can_edit` tinyint(1) NOT NULL DEFAULT '0',
  `can_delete` tinyint(1) NOT NULL DEFAULT '0',
  `can_export` tinyint(1) NOT NULL DEFAULT '0',
  `can_print` tinyint(1) NOT NULL DEFAULT '0',
  `can_approve` tinyint(1) NOT NULL DEFAULT '0',
  `created_by` bigint UNSIGNED NOT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`group_permission_id`),
  UNIQUE KEY `uq_group_feature` (`group_id`,`feature_id`),
  KEY `fk_group_perm_feature` (`feature_id`),
  KEY `fk_group_perm_created_by` (`created_by`),
  KEY `fk_group_perm_updated_by` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=185 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `group_permissions`
--

INSERT INTO `group_permissions` (`group_permission_id`, `group_id`, `feature_id`, `can_view`, `can_add`, `can_edit`, `can_delete`, `can_export`, `can_print`, `can_approve`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(2, 1, 46, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(3, 1, 17, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(4, 1, 35, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(5, 1, 26, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(6, 1, 11, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(7, 1, 22, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(8, 1, 24, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(9, 1, 4, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(10, 1, 39, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(11, 1, 42, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(12, 1, 41, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(13, 1, 40, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(14, 1, 20, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(15, 1, 25, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(16, 1, 9, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(17, 1, 12, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(18, 1, 19, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(19, 1, 27, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(20, 1, 13, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(21, 1, 3, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(22, 1, 18, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(23, 1, 31, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(24, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(25, 1, 38, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(26, 1, 34, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(27, 1, 23, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(28, 1, 37, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(29, 1, 15, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(30, 1, 14, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(31, 1, 28, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(32, 1, 10, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(33, 1, 43, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(34, 1, 6, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(35, 1, 32, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(36, 1, 5, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(37, 1, 21, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(38, 1, 29, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(39, 1, 8, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(40, 1, 45, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(41, 1, 16, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(42, 1, 30, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(43, 1, 7, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(44, 1, 33, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(45, 1, 36, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(46, 1, 44, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(47, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(48, 2, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(49, 2, 17, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(50, 2, 35, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(51, 2, 26, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(52, 2, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(53, 2, 22, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(54, 2, 24, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(55, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(56, 2, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(57, 2, 42, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(58, 2, 41, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(59, 2, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(60, 2, 20, 1, 1, 1, 0, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(61, 2, 25, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(62, 2, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(63, 2, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(64, 2, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(65, 2, 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(66, 2, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(67, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:47', '2026-02-26 11:55:47'),
(68, 2, 18, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(69, 2, 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(70, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(71, 2, 38, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(72, 2, 34, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(73, 2, 23, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(74, 2, 37, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(75, 2, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(76, 2, 14, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(77, 2, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(78, 2, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(79, 2, 43, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(80, 2, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(81, 2, 32, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(82, 2, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(83, 2, 21, 1, 1, 1, 0, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(84, 2, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(85, 2, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(86, 2, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(87, 2, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(88, 2, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(89, 2, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(90, 2, 33, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(91, 2, 36, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(92, 2, 44, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(93, 3, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(94, 3, 46, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(95, 3, 17, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(96, 3, 35, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(97, 3, 26, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(98, 3, 11, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(99, 3, 22, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(100, 3, 24, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(101, 3, 4, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(102, 3, 39, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(103, 3, 42, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(104, 3, 41, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(105, 3, 40, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(106, 3, 20, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(107, 3, 25, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(108, 3, 9, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(109, 3, 12, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(110, 3, 19, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(111, 3, 27, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(112, 3, 13, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(113, 3, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(114, 3, 18, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(115, 3, 31, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(116, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(117, 3, 38, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(118, 3, 34, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(119, 3, 23, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(120, 3, 37, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(121, 3, 15, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(122, 3, 14, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(123, 3, 28, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(124, 3, 10, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(125, 3, 43, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(126, 3, 6, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(127, 3, 32, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(128, 3, 5, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(129, 3, 21, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(130, 3, 29, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(131, 3, 8, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(132, 3, 45, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(133, 3, 16, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(134, 3, 30, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(135, 3, 7, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(136, 3, 33, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(137, 3, 36, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(138, 3, 44, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(139, 4, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(140, 4, 46, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(141, 4, 17, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(142, 4, 35, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(143, 4, 26, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(144, 4, 11, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(145, 4, 22, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(146, 4, 24, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(147, 4, 4, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(148, 4, 39, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(149, 4, 42, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(150, 4, 41, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(151, 4, 40, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(152, 4, 20, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(153, 4, 25, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(154, 4, 9, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(155, 4, 12, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(156, 4, 19, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(157, 4, 27, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(158, 4, 13, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(159, 4, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(160, 4, 18, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(161, 4, 31, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(162, 4, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(163, 4, 38, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(164, 4, 34, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(165, 4, 23, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(166, 4, 37, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(167, 4, 15, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(168, 4, 14, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(169, 4, 28, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(170, 4, 10, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(171, 4, 43, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(172, 4, 6, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(173, 4, 32, 1, 0, 0, 0, 1, 1, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(174, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(175, 4, 21, 1, 1, 1, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(176, 4, 29, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(177, 4, 8, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(178, 4, 45, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(179, 4, 16, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(180, 4, 30, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(181, 4, 7, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(182, 4, 33, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(183, 4, 36, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48'),
(184, 4, 44, 0, 0, 0, 0, 0, 0, 0, 1, 1, '2026-02-26 11:55:48', '2026-02-26 11:55:48');

-- --------------------------------------------------------

--
-- Table structure for table `home_currency`
--

CREATE TABLE IF NOT EXISTS `home_currency` (
  `home_currency_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `currency_id` bigint UNSIGNED NOT NULL,
  `effective_date` date DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`home_currency_id`),
  KEY `currency_id` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `home_currency`
--

INSERT INTO `home_currency` (`home_currency_id`, `currency_id`, `effective_date`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 1, '2026-01-27', 1, '2026-01-05 07:04:25', '2026-01-27 11:59:03');

-- --------------------------------------------------------

--
-- Table structure for table `home_currency_history`
--

CREATE TABLE IF NOT EXISTS `home_currency_history` (
  `history_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `currency_id` bigint UNSIGNED NOT NULL,
  `effective_date` date DEFAULT NULL,
  `deactivated_date` date DEFAULT NULL,
  `changed_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`history_id`),
  KEY `currency_id` (`currency_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `home_currency_history`
--

INSERT INTO `home_currency_history` (`history_id`, `currency_id`, `effective_date`, `deactivated_date`, `changed_by`, `created_at`) VALUES
(1, 2, '2026-01-05', '2026-01-27', 1, '2026-01-27 13:59:03');

-- --------------------------------------------------------

--
-- Table structure for table `journal_headers`
--

CREATE TABLE IF NOT EXISTS `journal_headers` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `journal_date` date NOT NULL,
  `reference` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `source_module` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `journal_headers_created_by_foreign` (`created_by`),
  KEY `journal_headers_updated_by_foreign` (`updated_by`),
  KEY `journal_headers_journal_date_index` (`journal_date`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `journal_headers`
--

INSERT INTO `journal_headers` (`id`, `journal_date`, `reference`, `description`, `source_module`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(11, '2026-03-25', 'deposit', 'money entering', 'cashbook', 1, 1, '2026-03-25 10:00:07', '2026-03-25 10:00:07'),
(12, '2026-03-25', 'DEPOSIT', 'deposit for matter fees', 'cashbook', 1, 1, '2026-03-25 11:10:33', '2026-03-25 11:10:33'),
(13, '2026-01-05', 'TRF-2026-001', 'Retainer deposit received - Whitaker Holdings corporate advisory', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(14, '2026-01-18', 'TRF-2026-002', 'Filing fees paid from trust - High Court Dube Logistics', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(15, '2026-02-03', 'TRF-2026-003', 'Retainer deposit received - Mapfumo mining compliance RioZim', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(16, '2026-02-14', 'TRF-2026-004', 'Advocate fees paid from trust - Chikore labour court brief', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(17, '2026-02-24', 'TRF-2026-005', 'Trust interest credited - Q1 client fund balances', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(18, '2026-03-01', 'TRF-2026-006', 'Retainer deposit received - Madondo ZISCO Steel compliance', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(19, '2026-03-10', 'TRF-2026-007', 'Sheriff fees paid from trust - Muchengeti workplace grievance', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(20, '2026-03-15', 'TRF-2026-008', 'Trust petty cash replenishment - court filing season float', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(21, '2026-03-22', 'TRF-2026-009', 'Retainer deposit received - Mukasa Engineering regulatory matter', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(22, '2026-03-28', 'TRF-2026-010', 'Trust admin fees charged - Gwena AG HNWI cross-border advisory', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(23, '2026-01-02', 'BUS-2026-001', 'Legal fees received - Emily Carter contract review consultation', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(24, '2026-01-15', 'BUS-2026-002', 'Office rent payment January 2026 - Samora Machel Ave', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(25, '2026-01-31', 'BUS-2026-003', 'Salaries payment January 2026 - professional and support staff', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(26, '2026-02-05', 'BUS-2026-004', 'Consultation fee received - Katsande tender advisory', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(27, '2026-02-12', 'BUS-2026-005', 'Petty cash payment - office stationery and sundry supplies', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(28, '2026-02-20', 'BUS-2026-006', 'Internet and VOIP invoice paid - Iota Technologies February', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(29, '2026-02-28', 'BUS-2026-007', 'Commission income received - debt collection success fee Chikore', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(30, '2026-03-05', 'BUS-2026-008', 'Office rent payment March 2026 - Samora Machel Ave', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(31, '2026-03-14', 'BUS-2026-009', 'Software licence payment - practice management system annual', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(32, '2026-03-25', 'BUS-2026-010', 'Court appearance fees received - Ncube High Court matter', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(33, '2026-01-20', 'TRX-2026-001', 'Transfer from trust to business - Whitaker fees earned release', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(34, '2026-02-10', 'TRX-2026-002', 'Transfer from trust to business - Dube retainer release on billing', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(35, '2026-02-26', 'TRX-2026-003', 'Transfer from trust - Mapfumo mining compliance fees released', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(36, '2026-03-18', 'TRX-2026-004', 'Transfer from trust to business - Madondo matter fees earned', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13'),
(37, '2026-03-30', 'TRX-2026-005', 'Transfer from trust to business - Q1 retainer reconciliation release', 'cashbook', 1, 1, '2026-04-01 12:52:13', '2026-04-01 12:52:13');

-- --------------------------------------------------------

--
-- Table structure for table `journal_lines`
--

CREATE TABLE IF NOT EXISTS `journal_lines` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `journal_header_id` bigint UNSIGNED NOT NULL,
  `gl_account_id` bigint UNSIGNED NOT NULL,
  `debit` decimal(15,2) NOT NULL DEFAULT '0.00',
  `credit` decimal(15,2) NOT NULL DEFAULT '0.00',
  `description` text COLLATE utf8mb4_unicode_ci,
  `department_id` bigint UNSIGNED DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `journal_lines_created_by_foreign` (`created_by`),
  KEY `journal_lines_updated_by_foreign` (`updated_by`),
  KEY `journal_lines_journal_header_id_index` (`journal_header_id`),
  KEY `journal_lines_gl_account_id_index` (`gl_account_id`),
  KEY `journal_lines_department_id_index` (`department_id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `journal_lines`
--

INSERT INTO `journal_lines` (`id`, `journal_header_id`, `gl_account_id`, `debit`, `credit`, `description`, `department_id`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(21, 11, 11, 1000.00, 0.00, 'money entering', NULL, 1, 1, '2026-03-25 10:00:07', '2026-03-25 10:00:07'),
(22, 11, 3, 0.00, 1000.00, 'money entering', NULL, 1, 1, '2026-03-25 10:00:07', '2026-03-25 10:00:07'),
(23, 12, 9, 500.50, 0.00, 'deposit for matter fees', NULL, 1, 1, '2026-03-25 11:10:33', '2026-03-25 11:10:33'),
(24, 12, 9, 0.00, 500.50, 'deposit for matter fees', NULL, 1, 1, '2026-03-25 11:10:33', '2026-03-25 11:10:33');

-- --------------------------------------------------------

--
-- Table structure for table `journal_transactions`
--

CREATE TABLE IF NOT EXISTS `journal_transactions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `transaction_code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `journal_type` enum('general','client','supplier') COLLATE utf8mb4_unicode_ci NOT NULL,
  `journal_id` int NOT NULL,
  `date` date NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `status` enum('pending','approved','rejected','reversed') COLLATE utf8mb4_unicode_ci DEFAULT 'pending',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `transaction_code` (`transaction_code`),
  KEY `idx_journal_type` (`journal_type`,`journal_id`),
  KEY `idx_transaction_code` (`transaction_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `judgements`
--

CREATE TABLE IF NOT EXISTS `judgements` (
  `judgement_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `judgement_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`judgement_id`),
  UNIQUE KEY `judgement_code` (`judgement_code`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `judgements`
--

INSERT INTO `judgements` (`judgement_id`, `judgement_code`, `title`, `description`, `created_at`, `updated_at`) VALUES
(1, 'JDG-FIN', 'Final Judgment', 'Conclusive determination of the case on its merits', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(2, 'JDG-INT', 'Interlocutory Judgment', 'Decision on an interim matter before final resolution', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(3, 'JDG-DEF', 'Default Judgment', 'Judgment entered due to failure of a party to appear or respond', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(4, 'JDG-SUM', 'Summary Judgment', 'Judgment given where no triable issues of fact exist', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(5, 'JDG-CON', 'Consent Judgment', 'Judgment entered with agreement of all parties', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(6, 'JDG-DEC', 'Declaratory Judgment', 'Judgment declaring rights without awarding damages', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(7, 'JDG-MAN', 'Mandatory Order', 'Judgment compelling a party to perform a specific act', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(8, 'JDG-PRO', 'Prohibitory Order', 'Judgment restraining a party from certain actions', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(9, 'JDG-COS', 'Costs Order', 'Judgment determining liability for legal costs', '2026-03-27 06:43:31', '2026-03-27 06:43:31'),
(10, 'JDG-DIS', 'Dismissal Judgment', 'Judgment dismissing a case or application', '2026-03-27 06:43:31', '2026-03-27 06:43:31');

-- --------------------------------------------------------

--
-- Table structure for table `judges`
--

CREATE TABLE IF NOT EXISTS `judges` (
  `judge_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `judge_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `full_name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `court_area_code` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `court_type_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'Active',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`judge_id`),
  UNIQUE KEY `judge_code` (`judge_code`),
  KEY `court_area_code` (`court_area_code`),
  KEY `court_type_name` (`court_type_name`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `judges`
--

INSERT INTO `judges` (`judge_id`, `judge_code`, `full_name`, `court_area_code`, `court_type_name`, `contact`, `email`, `status`, `created_at`, `updated_at`, `notes`, `is_active`) VALUES
(1, 'JDG-001', 'Justice Tendai Moyo', 'CA-HHC', 'High Court', '+263771234001', 'tendai.moyo@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Senior High Court Judge', 1),
(2, 'JDG-002', 'Justice Nomsa Dube', 'CA-BHC', 'High Court', '+263771234002', 'nomsa.dube@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Experienced in criminal law', 1),
(3, 'JDG-003', 'Justice Farai Chikore', 'CA-HRE', 'Magistrates Court', '+263771234003', 'farai.chikore@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Handles civil matters', 1),
(4, 'JDG-004', 'Justice Tapiwa Nyathi', 'CA-GWE', 'Magistrates Court', '+263771234004', 'tapiwa.nyathi@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Midlands Province', 1),
(5, 'JDG-005', 'Justice Rudo Mapfumo', 'CA-MUT', 'Magistrates Court', '+263771234005', 'rudo.mapfumo@judiciary.co.zw', 'On Leave', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Currently on study leave', 1),
(6, 'JDG-006', 'Justice Blessing Hove', 'CA-BYO', 'Magistrates Court', '+263771234006', 'blessing.hove@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Commercial disputes focus', 1),
(7, 'JDG-007', 'Justice Wellington Ncube', 'CA-MAS', 'Magistrates Court', '+263771234007', 'wellington.ncube@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Southern circuit', 1),
(8, 'JDG-008', 'Justice Chipo Katsande', 'CA-CHI', 'Magistrates Court', '+263771234008', 'chipo.katsande@judiciary.co.zw', 'Suspended', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Under administrative review', 0),
(9, 'JDG-009', 'Justice Tawanda Muzenda', 'CA-MAR', 'Magistrates Court', '+263771234009', 'tawanda.muzenda@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Land dispute specialist', 1),
(10, 'JDG-010', 'Justice Nkosana Sibanda', 'CA-VIC', 'Magistrates Court', '+263771234010', 'nkosana.sibanda@judiciary.co.zw', 'Active', '2026-03-27 06:43:31', '2026-03-27 06:43:31', 'Matabeleland North circuit', 1);

-- --------------------------------------------------------

--
-- Table structure for table `lawyers`
--

CREATE TABLE IF NOT EXISTS `lawyers` (
  `lawyer_id` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `first_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone_primary` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone_secondary` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lawyer_group` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `certificate_number` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_of_admission` date DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'Active',
  `lawyer_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lawyer_tier` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `tier_id` int DEFAULT NULL,
  PRIMARY KEY (`lawyer_id`),
  UNIQUE KEY `email` (`email`),
  KEY `fk_lawyer_tier` (`tier_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lawyers`
--

INSERT INTO `lawyers` (`lawyer_id`, `first_name`, `last_name`, `email`, `phone_primary`, `phone_secondary`, `lawyer_group`, `certificate_number`, `date_of_admission`, `status`, `lawyer_type`, `lawyer_tier`, `notes`, `created_at`, `updated_at`, `tier_id`) VALUES
('1', 'Alice', 'Moyo', 'alice.moyo@wayne.enterprises.com', '+263772000001', '+263772000101', 'Civil Law', 'CERT001', '2018-05-15', 'ACTIVE', 'Contract Lawyer', 'Junior Associate', 'Specializes in commercial contracts', '2026-01-05 15:06:25', '2026-01-05 15:06:25', 1),
('2', 'Brian', 'Chikore', 'brian.chikore@wayne.enterprises.com', '+263772000002', '+263772000102', 'Family Law', 'CERT002', '2016-08-20', 'ACTIVE', 'Divorce Lawyer', 'Associate', 'Handles divorce and custody cases', '2026-01-05 15:06:25', '2026-01-05 15:06:25', 2),
('3', 'Clara', 'Mabhena', 'clara.mabhena@wayne.enterprises.com', '+263772000003', '+263772000103', 'Criminal Law', 'CERT003', '2012-11-30', 'ACTIVE', 'Criminal Defence Lawyer', 'Senior Associate', 'Experienced in criminal litigation', '2026-01-05 15:06:25', '2026-01-05 15:06:25', 3),
('L200861', 'Tadiwa', 'Gwena', 'tadiwagwena@gmail.com', '0777367773', NULL, '12', NULL, NULL, 'Active', 'Mining Rights Lawyer', NULL, NULL, '2026-01-06 07:36:48', '2026-01-06 08:01:53', NULL),
('L940147', 'ash', 'Gwena', 'lol@lol.com', '00000000', NULL, NULL, NULL, NULL, 'Active', 'Tax Advisory Lawyer', NULL, NULL, '2026-01-06 07:49:45', '2026-01-06 07:54:49', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `lawyer_groups`
--

CREATE TABLE IF NOT EXISTS `lawyer_groups` (
  `group_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`group_id`),
  UNIQUE KEY `group_name` (`group_name`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lawyer_groups`
--

INSERT INTO `lawyer_groups` (`group_id`, `group_name`, `created_at`, `updated_at`) VALUES
(1, 'Civil Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(2, 'Criminal Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(3, 'Family Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(4, 'Commercial / Corporate Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(5, 'Property & Conveyancing Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(6, 'Labour & Employment Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(7, 'Constitutional Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(8, 'Administrative Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(9, 'Human Rights Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(10, 'Notarial Practice', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(11, 'Intellectual Property Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(12, 'Mining & Energy Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(13, 'Environmental Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(14, 'Tax Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(15, 'Banking & Finance Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(16, 'Insolvency Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(17, 'Insurance Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(18, 'Estate Planning & Deceased Estates', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(19, 'Immigration Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(20, 'International Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(21, 'Arbitration & ADR', '2026-01-05 13:04:07', '2026-01-05 13:04:07'),
(22, 'Technology & Cyber Law', '2026-01-05 13:04:07', '2026-01-05 13:04:07');

-- --------------------------------------------------------

--
-- Table structure for table `lawyer_roles`
--

CREATE TABLE IF NOT EXISTS `lawyer_roles` (
  `lawyer_role_id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `side` enum('plaintiff','defendant','prosecution','defense','neutral') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'neutral',
  `is_primary` tinyint(1) NOT NULL DEFAULT '0',
  `requires_bar_status` tinyint(1) NOT NULL DEFAULT '1',
  `jurisdiction_scope` enum('US','UK','GLOBAL') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'GLOBAL',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `sort_order` int UNSIGNED DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`lawyer_role_id`),
  UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lawyer_roles`
--

INSERT INTO `lawyer_roles` (`lawyer_role_id`, `code`, `name`, `description`, `side`, `is_primary`, `requires_bar_status`, `jurisdiction_scope`, `is_active`, `sort_order`, `created_at`, `updated_at`) VALUES
(1, 'lead_counsel', 'Lead Counsel', 'Primary attorney representing the party.', 'plaintiff', 1, 1, 'GLOBAL', 1, 1, '2026-01-29 13:05:00', '2026-01-29 11:22:29'),
(2, 'co_counsel', 'Co-Counsel', 'Secondary attorney assisting lead counsel.', 'defense', 0, 1, 'GLOBAL', 1, 2, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(3, 'prosecutor', 'Prosecuting Counsel', 'Attorney representing the state in criminal cases.', 'prosecution', 1, 1, 'GLOBAL', 1, 3, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(4, 'defense_attorney', 'Defense Attorney', 'Attorney representing the defendant in criminal cases.', 'defense', 1, 1, 'GLOBAL', 1, 4, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(5, 'plaintiff_counsel', 'Plaintiff Counsel', 'Attorney representing the plaintiff in civil cases.', 'plaintiff', 1, 1, 'GLOBAL', 1, 5, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(6, 'respondent_counsel', 'Respondent Counsel', 'Attorney representing the respondent/defendant in civil cases.', 'defendant', 1, 1, 'GLOBAL', 1, 6, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(7, 'amicus_counsel', 'Amicus Curiae', 'Neutral counsel providing expertise without representing a party.', 'neutral', 0, 1, 'GLOBAL', 1, 7, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(8, 'mediator', 'Mediator', 'Neutral third-party facilitating settlement or negotiation.', 'neutral', 0, 0, 'GLOBAL', 1, 8, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(9, 'legal_advisor', 'Legal Advisor', 'Provides legal guidance without courtroom representation.', 'neutral', 0, 0, 'GLOBAL', 1, 9, '2026-01-29 13:05:00', '2026-01-29 13:05:00'),
(10, 'junior_counsel', 'Junior Counsel', 'Supports lead or co-counsel; limited independent authority.', 'defense', 0, 1, 'GLOBAL', 1, 10, '2026-01-29 13:05:00', '2026-01-29 13:05:00');

-- --------------------------------------------------------

--
-- Table structure for table `lawyer_types`
--

CREATE TABLE IF NOT EXISTS `lawyer_types` (
  `type_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_id` bigint UNSIGNED NOT NULL,
  `lawyer_type_name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`type_id`),
  KEY `group_id` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lawyer_types`
--

INSERT INTO `lawyer_types` (`type_id`, `group_id`, `lawyer_type_name`, `created_at`, `updated_at`) VALUES
(1, 1, 'Contract Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(2, 1, 'Property Disputes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(3, 1, 'Debt Collection Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(4, 1, 'Personal Injury Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(5, 1, 'Defamation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(6, 2, 'Criminal Defence Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(7, 2, 'State Prosecutor', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(8, 2, 'White Collar Crime Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(9, 2, 'Economic Crimes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(10, 2, 'Bail & Sentencing Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(11, 3, 'Divorce Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(12, 3, 'Child Custody Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(13, 3, 'Maintenance Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(14, 3, 'Adoption Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(15, 3, 'Domestic Violence Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(16, 4, 'Company Formation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(17, 4, 'Corporate Governance Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(18, 4, 'Mergers & Acquisitions Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(19, 4, 'Commercial Litigation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(20, 4, 'Shareholder Disputes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(21, 5, 'Conveyancer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(22, 5, 'Property Transfer Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(23, 5, 'Mortgage Bond Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(24, 5, 'Land Development Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(25, 6, 'Employment Disputes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(26, 6, 'Retrenchment Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(27, 6, 'Labour Arbitration Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(28, 6, 'Collective Bargaining Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(29, 7, 'Constitutional Litigation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(30, 7, 'Judicial Review Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(31, 7, 'Electoral Law Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(32, 8, 'Regulatory Compliance Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(33, 8, 'Government Decisions Review Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(34, 9, 'Human Rights Litigation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(35, 9, 'Police Abuse Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(36, 9, 'Media Freedom Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(37, 10, 'Notary Public', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(38, 10, 'Document Authentication Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(39, 11, 'Trademark Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(40, 11, 'Copyright Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(41, 11, 'Patent Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(42, 12, 'Mining Rights Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(43, 12, 'Energy Contracts Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(44, 13, 'Environmental Compliance Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(45, 13, 'Environmental Litigation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(46, 14, 'Tax Advisory Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(47, 14, 'ZIMRA Disputes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(48, 15, 'Banking Compliance Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(49, 15, 'Loan & Securities Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(50, 16, 'Liquidation Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(51, 16, 'Corporate Rescue Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(52, 17, 'Insurance Claims Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(53, 17, 'Policy Disputes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(54, 18, 'Wills & Trusts Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(55, 18, 'Executor of Estates', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(56, 18, 'Inheritance Disputes Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(57, 19, 'Work Permit Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(58, 19, 'Citizenship Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(59, 20, 'International Arbitration Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(60, 20, 'Cross-Border Trade Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(61, 21, 'Arbitrator', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(62, 21, 'Mediator', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(63, 22, 'Cybercrime Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(64, 22, 'Data Protection Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12'),
(65, 22, 'E-Commerce Lawyer', '2026-01-05 13:46:12', '2026-01-05 13:46:12');

-- --------------------------------------------------------

--
-- Table structure for table `law_firm_information`
--

CREATE TABLE IF NOT EXISTS `law_firm_information` (
  `company_id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `company_name` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_code` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `firm_initials` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `firm_logo_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `contact_email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_phone` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tax_id` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_name` text COLLATE utf8mb4_unicode_ci,
  `bank_acc_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_account_type` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bank_branch_address` text COLLATE utf8mb4_unicode_ci,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`company_id`),
  KEY `updated_by` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `law_firm_information`
--

INSERT INTO `law_firm_information` (`company_id`, `company_name`, `company_code`, `firm_initials`, `firm_logo_path`, `address`, `contact_email`, `contact_phone`, `website`, `tax_id`, `bank_name`, `bank_acc_number`, `bank_account_type`, `bank_branch_address`, `updated_by`, `updated_at`) VALUES
(1, 'Moyo & Partners Legal Practitioners', 'MPL001', 'MPL', NULL, '12 Samora Machel Avenue, 3rd Floor, Harare, Zimbabwe', 'info@moyolegal.co.zw', '+263-242-700123', 'https://www.moyolegal.co.zw', 'ZW12345678', 'CBZ Bank Limited', '0123456789012', 'nostro', 'CBZ Main Branch, Harare', 1, '2026-02-22 12:24:37');

-- --------------------------------------------------------

--
-- Table structure for table `lexa_chat_history`
--

CREATE TABLE IF NOT EXISTS `lexa_chat_history` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` bigint UNSIGNED NOT NULL,
  `conversation_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `role` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'user|assistant|system|tool',
  `message` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `model` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tokens_input` int DEFAULT NULL,
  `tokens_output` int DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_lex_chat_history_user_id` (`user_id`),
  KEY `idx_lex_chat_history_conversation_id` (`conversation_id`),
  KEY `idx_lex_chat_history_created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lexa_chat_history`
--

INSERT INTO `lexa_chat_history` (`id`, `user_id`, `conversation_id`, `role`, `message`, `model`, `tokens_input`, `tokens_output`, `metadata`, `created_at`, `updated_at`) VALUES
(1, 1, 'b1f9305b-a670-4b88-bfd9-9162803fd0b2', 'user', 'richard branson', 'meta-llama/Llama-3.2-1B-Instruct', NULL, NULL, NULL, '2026-03-27 17:34:19', '2026-03-27 17:34:19'),
(2, 1, '7e3a1bfa-9ea2-436f-986f-d28222b7df04', 'user', 'microsoft', 'meta-llama/Llama-3.2-1B-Instruct', NULL, NULL, NULL, '2026-03-27 17:34:39', '2026-03-27 17:34:39'),
(3, 1, 'fc433a58-de13-4c83-834f-90582e0208ca', 'user', 'what am i supposed to write when writing a case file as a jnr lawyer', 'meta-llama/Llama-3.2-1B-Instruct', NULL, NULL, NULL, '2026-03-27 17:35:08', '2026-03-27 17:35:08'),
(4, 1, 'fc433a58-de13-4c83-834f-90582e0208ca', 'assistant', 'When writing a case file as a junior lawyer, you should include the following essential elements:\n\n1. **Case Number**: A unique identifier assigned to the case, which includes the party involved, the type of case, and any relevant details.\n2. **Case Description**: A brief summary of the case, including the facts, relevant dates, and key points.\n3. **Parties Involved**: The names and brief descriptions of the parties involved in the case, including the plaintiff, defendant, and any other relevant parties.\n4. **Case Type**: The type of case, such as breach of contract, personal injury, or intellectual property dispute.\n5. **Issue**: A clear statement of the main issue or dispute that needs to be resolved.\n6. **Background**: An overview of the relevant background information, such as relevant laws, regulations, or precedents.\n7. **Arguments**: A summary of the arguments presented in the case, including any relevant evidence, witnesses, and testimony.\n8. **Proposed Solution**: A proposed solution or outcome of the case, which may include a settlement, judgment, or further proceedings.\n9. **Deliverables**: A list of any specific deliverables or tasks required for the case, such as draft pleadings, witness statements, or expert reports.\n10. **Dates**: Relevant dates related to the case, such as court dates, witness statements, or other important events.\n11. **Contact Information**: The contact details for you, the junior lawyer, including your name, email address, and phone number.\n12. **Attachments**: Any relevant attachments, such as court documents, witness statements, or other supporting evidence.\n\nHere\'s an example of what a completed case file might look like:\n\n**Case Number:** HC001234\n**Case Description:** Richard Branson vs. Virgin Group Ltd.\n**Parties Involved:** Richard Branson (plaintiff) and Virgin Group Ltd. (defendant)\n**Case Type:** Breach of Contract\n**Issue:** Whether Richard Branson has breached his contract with Virgin Group Ltd.\n**Background:** Richard Branson has a contract with Virgin Group Ltd. to promote their products and services, but has failed to meet his obligations under the contract.\n**Arguments:** The plaintiff argues that the defendant has breached the contract and is therefore liable for damages.\n**Proposed Solution:** The proposed solution is that the defendant pays Richard Branson a sum of £1 million in damages.\n**Deliverables:** Draft', 'meta-llama/Llama-3.2-1B-Instruct', 88, 500, '{\"endpoint\": \"https://router.huggingface.co/v1/chat/completions\"}', '2026-03-27 17:35:12', '2026-03-27 17:35:12'),
(5, 1, '9a838e60-a262-46e1-aeef-048f96f40a69', 'user', 'hello', 'meta-llama/Llama-3.2-1B-Instruct', NULL, NULL, NULL, '2026-03-30 05:37:15', '2026-03-30 05:37:15'),
(6, 1, '9a838e60-a262-46e1-aeef-048f96f40a69', 'assistant', 'Hello again. How can I assist you today?', 'meta-llama/Llama-3.2-1B-Instruct', 42, 11, '{\"endpoint\": \"https://router.huggingface.co/v1/chat/completions\"}', '2026-03-30 05:37:18', '2026-03-30 05:37:18'),
(7, 1, '9a838e60-a262-46e1-aeef-048f96f40a69', 'user', 'who is donald trump', 'meta-llama/Llama-3.2-1B-Instruct', NULL, NULL, NULL, '2026-03-30 05:37:24', '2026-03-30 05:37:24'),
(8, 1, '9a838e60-a262-46e1-aeef-048f96f40a69', 'assistant', 'Donald Trump is the 45th President of the United States, serving from 2017 to 2021. He is a businessman, television personality, and politician who gained notoriety in the 2016 presidential election as the Republican Party\'s nominee.\n\nEarly Life and Career:\n\nDonald Trump was born on June 14, 1946, in Queens, New York, to Mary Anne MacLeod and Frederick Christ Trump. He has five siblings, including his twin brother Donald Jr., who is also a businessman. Trump\'s father was a successful real estate developer who built a significant portfolio of properties in Queens and the surrounding areas.\n\nTrump attended the New York Military Academy and later studied at the University of Pennsylvania, where he graduated with a degree in economics in 1968. He then attended Harvard Business School, but did not graduate.\n\nBusiness Career:\n\nTrump\'s business career began in the 1970s, when he opened his first restaurant, the Trump Taxi and Trucking Company, in 1971. He later expanded his business empire, investing in real estate, including the Trump Tower in New York City, which he bought in 1983.\n\nIn the 1980s, Trump expanded his real estate business, buying the Grand Hyatt Hotel in New York City and opening the Trump Plaza Hotel and Casino in Atlantic City. He also invested in golf courses, resorts, and casinos around the world.\n\nPresidential Campaign and Presidency:\n\nTrump announced his candidacy for the Republican presidential nomination in June 2015, running on a platform of tax cuts, deregulation, and a tough stance on immigration. He won the nomination at the Republican National Convention in July 2016, becoming the first Republican to win the nomination since 1988.\n\nOn November 8, 2016, Trump won the presidential election, defeating Democratic nominee Hillary Clinton in a highly contested election. As president, Trump pursued a \"America First\" agenda, focusing on trade policies, immigration reform, and national security.\n\nDuring his presidency, Trump implemented various policies, including:\n\n* Border wall construction along the US-Mexico border\n* Tax cuts and deregulation\n* Immigration reform, including the \"Dream Act\" and the introduction of a travel ban on predominantly Muslim countries\n* Withdrawal from the Paris Climate Agreement\n* Repeal of the Affordable Care Act (Obamacare)\n\nControversies and Scandals:\n\nTrump\'s presidency was marked by numerous controversies and scandals, including:\n\n* Stormy Daniels and', 'meta-llama/Llama-3.2-1B-Instruct', 71, 500, '{\"endpoint\": \"https://router.huggingface.co/v1/chat/completions\"}', '2026-03-30 05:37:27', '2026-03-30 05:37:27'),
(9, 1, 'a2f47b32-c454-4710-a66e-cd349fe4856f', 'user', 'who is mugabe', 'meta-llama/Llama-3.2-1B-Instruct', NULL, NULL, NULL, '2026-03-30 06:47:53', '2026-03-30 06:47:53'),
(10, 1, 'a2f47b32-c454-4710-a66e-cd349fe4856f', 'assistant', 'Zimbabwe\'s Robert Mugabe (1924-2019) was a Zimbabwean politician who served as the country\'s first black president from 1980 to 2017. He was a key figure in the fight against apartheid in South Africa and a major force in Pan-Africanism.\n\nEarly Life and Education:\n\nRobert Mugabe was born in the village of Nkhata Bay, in what was then Northern Rhodesia (now Zambia). He was the son of a local chief and grew up in a traditional Zonde people community. Mugabe attended a Catholic boarding school in Rhodesia and later studied law at the University of Fort Hare in South Africa.\n\nMugabe joined the African National Congress (ANC) in 1947 and quickly rose through the ranks. He became a key leader in the ANC\'s fight against apartheid in South Africa, where he was arrested and imprisoned for his activism. In 1964, Mugabe was released from prison and went into exile, where he continued to fight for African independence and self-determination.\n\nReturn to Zimbabwe:\n\nIn 1968, Mugabe returned to Zimbabwe with a small group of ANC fighters. He became the vice president of the newly independent country, but soon rose to the position of first secretary general and then prime minister.\n\nMugabe\'s leadership style was characterized by authoritarianism, nationalism, and anti-imperialism. He implemented a range of policies aimed at promoting economic development, social welfare, and national unity.\n\nRepression and Coup:\n\nHowever, Mugabe\'s rule was marked by repression, censorship, and human rights abuses. He suppressed opposition movements, arrested and imprisoned critics, and imposed strict controls on the media and civil society.\n\nIn 1980, a military coup led by Mugabe\'s Zimbabwe African National Union (ZANU) overthrew the government of Prime Minister Ian Smith. Mugabe became president and ruled with an iron fist, consolidating his power and suppressing opposition.\n\nMugabe\'s rule was marked by corruption, cronyism, and widespread human rights abuses. The economy struggled, and the country was plagued by poverty, food shortages, and violence.\n\nInternational Criticism:\n\nMugabe\'s rule was widely criticized by the international community, including the United States, the European Union, and the Association of Caribbean States. The United Nations condemned his human rights abuses and forced him to leave office in 2003.\n\nAfter the 2008 presidential election, which saw Robert Mugabe\'s ZAN', 'meta-llama/Llama-3.2-1B-Instruct', 48, 500, '{\"endpoint\": \"https://router.huggingface.co/v1/chat/completions\"}', '2026-03-30 06:48:00', '2026-03-30 06:48:00');

-- --------------------------------------------------------

--
-- Table structure for table `lexa_conversations`
--

CREATE TABLE IF NOT EXISTS `lexa_conversations` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` bigint UNSIGNED NOT NULL,
  `conversation_key` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'active',
  `last_message_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_lex_conversation_key` (`conversation_key`),
  KEY `idx_lex_conversations_user_id` (`user_id`),
  KEY `idx_lex_conversations_last_message_at` (`last_message_at`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `lexa_conversations`
--

INSERT INTO `lexa_conversations` (`id`, `user_id`, `conversation_key`, `title`, `status`, `last_message_at`, `created_at`, `updated_at`) VALUES
(1, 1, 'b1f9305b-a670-4b88-bfd9-9162803fd0b2', 'richard branson', 'active', '2026-03-27 17:34:19', '2026-03-27 17:34:19', '2026-03-27 17:34:19'),
(2, 1, '7e3a1bfa-9ea2-436f-986f-d28222b7df04', 'microsoft', 'active', '2026-03-27 17:34:39', '2026-03-27 17:34:39', '2026-03-27 17:34:39'),
(3, 1, 'fc433a58-de13-4c83-834f-90582e0208ca', 'what am i supposed to write when writing a case file as a jnr lawyer', 'active', '2026-03-27 17:35:12', '2026-03-27 17:35:08', '2026-03-27 17:35:12'),
(4, 1, '9a838e60-a262-46e1-aeef-048f96f40a69', 'hello', 'active', '2026-03-30 05:37:27', '2026-03-30 05:37:15', '2026-03-30 05:37:27'),
(5, 1, 'a2f47b32-c454-4710-a66e-cd349fe4856f', 'who is mugabe', 'active', '2026-03-30 06:48:00', '2026-03-30 06:47:53', '2026-03-30 06:48:00');

-- --------------------------------------------------------

--
-- Table structure for table `matters`
--

CREATE TABLE IF NOT EXISTS `matters` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `matter_number` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `matter_title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category_id` bigint UNSIGNED DEFAULT NULL,
  `type_id` bigint UNSIGNED DEFAULT NULL,
  `status_id` bigint UNSIGNED DEFAULT NULL,
  `priority_id` bigint UNSIGNED DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `opened_date` date DEFAULT NULL,
  `closed_date` date DEFAULT NULL,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `matters_matter_number_unique` (`matter_number`),
  KEY `matters_created_by_foreign` (`created_by`),
  KEY `matters_updated_by_foreign` (`updated_by`),
  KEY `matters_type_id_index` (`type_id`),
  KEY `matters_category_id_foreign` (`category_id`),
  KEY `matters_status_id_foreign` (`status_id`),
  KEY `matters_priority_id_foreign` (`priority_id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matters`
--

INSERT INTO `matters` (`id`, `matter_number`, `matter_title`, `category_id`, `type_id`, `status_id`, `priority_id`, `description`, `opened_date`, `closed_date`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'MAT-2026-0001', 'Breach of Contract – Vendor', 4, 2, NULL, 3, 'Dispute over delayed vendor deliverables.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(2, 'MAT-2026-0002', 'Assault Investigation', 7, 4, NULL, 5, 'Investigation pending witness statements.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(3, 'MAT-2026-0003', 'Patent Infringement Claim', 15, 5, NULL, 6, 'Alleged infringement of registered process patent.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(4, 'MAT-2026-0004', 'Employment Termination Dispute', 4, 2, NULL, 4, 'Client contesting wrongful dismissal.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(5, 'MAT-2026-0005', 'Trademark Opposition', 15, 3, NULL, 2, 'Opposition filed against trademark registration.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(6, 'MAT-2026-0006', 'Landlord-Tenant Dispute', 4, 2, NULL, 3, 'Tenant refusing to vacate property.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(7, 'MAT-2026-0007', 'Product Liability Claim', 4, 5, NULL, 4, 'Injury caused by defective product.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(8, 'MAT-2026-0008', 'Fraud Investigation', 7, 4, NULL, 5, 'Financial irregularities under review.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(9, 'MAT-2026-0009', 'Copyright Infringement', 15, 5, NULL, 6, 'Unauthorized use of copyrighted material.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(10, 'MAT-2026-0010', 'Medical Malpractice', 4, 3, NULL, 4, 'Negligence claim against hospital staff.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(11, 'MAT-2026-0011', 'Insurance Dispute', 4, 2, NULL, 3, 'Claim denied by insurance provider.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(12, 'MAT-2026-0012', 'Environmental Regulation Violation', 4, 4, NULL, 5, 'Pollution incident under investigation.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(13, 'MAT-2026-0013', 'Cybercrime Investigation', 7, 5, NULL, 6, 'Hacking incident affecting multiple clients.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(14, 'MAT-2026-0014', 'Construction Dispute', 4, 2, NULL, 4, 'Contractor failing to meet specifications.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(15, 'MAT-2026-0015', 'Vehicle Accident Claim', 4, 3, NULL, 3, 'Road accident, multiple parties involved.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(16, 'MAT-2026-0016', 'Tax Evasion Investigation', 7, 4, NULL, 5, 'Audit for undeclared income.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(17, 'MAT-2026-0017', 'Intellectual Property Licensing Dispute', 15, 5, NULL, 6, 'Breach of licensing agreement.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(18, 'MAT-2026-0018', 'Debt Recovery', 4, 2, NULL, 3, 'Client seeking recovery of unpaid invoices.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(19, 'MAT-2026-0019', 'Bankruptcy Proceedings', 4, 3, NULL, 4, 'Liquidation process initiated.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(20, 'MAT-2026-0020', 'Criminal Theft Case', 7, 4, NULL, 5, 'Investigation ongoing.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(21, 'MAT-2026-0021', 'Consumer Rights Violation', 4, 2, NULL, 3, 'Complaint against retailer.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(22, 'MAT-2026-0022', 'Antitrust Investigation', 4, 3, NULL, 4, 'Market manipulation under review.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(23, 'MAT-2026-0023', 'Harassment Complaint', 7, 4, NULL, 5, 'Investigation into workplace harassment.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(24, 'MAT-2026-0024', 'Fraudulent Contract', 4, 2, NULL, 3, 'Alleged fraudulent business contract.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(25, 'MAT-2026-0025', 'Sample Case 25', 4, 3, NULL, 4, 'Placeholder case for testing.', '2026-03-13', NULL, 1, 1, '2026-03-13 11:22:12', '2026-03-13 11:22:12'),
(26, 'MAT-2026-0026', 'Seeded Matter 1', 54, 58, 39, 18, 'Seeded matter description', '2026-01-21', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(27, 'MAT-2026-0027', 'Seeded Matter 2', 54, 12, 43, 27, 'Seeded matter description', '2026-02-10', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(28, 'MAT-2026-0028', 'Seeded Matter 3', 56, 19, 35, 28, 'Seeded matter description', '2026-02-20', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(29, 'MAT-2026-0029', 'Seeded Matter 4', 44, 19, 47, 2, 'Seeded matter description', '2026-02-22', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(30, 'MAT-2026-0030', 'Seeded Matter 5', 53, 43, 39, 15, 'Seeded matter description', '2026-01-22', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(31, 'MAT-2026-0031', 'Seeded Matter 6', 58, 20, 42, 20, 'Seeded matter description', '2026-01-19', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(32, 'MAT-2026-0032', 'Seeded Matter 7', 49, 14, 48, 17, 'Seeded matter description', '2026-01-18', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(33, 'MAT-2026-0033', 'Seeded Matter 8', 63, 12, 1, 11, 'Seeded matter description', '2026-02-08', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(34, 'MAT-2026-0034', 'Seeded Matter 9', 15, 18, 49, 23, 'Seeded matter description', '2026-02-17', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(35, 'MAT-2026-0035', 'Seeded Matter 10', 7, 19, 42, 9, 'Seeded matter description', '2026-02-27', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(36, 'MAT-2026-0036', 'Seeded Matter 11', 5, 43, 3, 20, 'Seeded matter description', '2026-03-09', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(37, 'MAT-2026-0037', 'Seeded Matter 12', 35, 44, 39, 6, 'Seeded matter description', '2026-02-13', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(38, 'MAT-2026-0038', 'Seeded Matter 13', 53, 8, 32, 12, 'Seeded matter description', '2026-03-09', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(39, 'MAT-2026-0039', 'Seeded Matter 14', 12, 18, 35, 23, 'Seeded matter description', '2026-02-05', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(40, 'MAT-2026-0040', 'Seeded Matter 15', 46, 39, 45, 10, 'Seeded matter description', '2026-01-20', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(41, 'MAT-2026-0041', 'Seeded Matter 16', 18, 42, 40, 2, 'Seeded matter description', '2026-02-18', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(42, 'MAT-2026-0042', 'Seeded Matter 17', 57, 8, 35, 12, 'Seeded matter description', '2026-02-24', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(43, 'MAT-2026-0043', 'Seeded Matter 18', 46, 25, 39, 2, 'Seeded matter description', '2026-01-22', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(44, 'MAT-2026-0044', 'Seeded Matter 19', 53, 21, 1, 26, 'Seeded matter description', '2026-03-03', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(45, 'MAT-2026-0045', 'Seeded Matter 20', 25, 41, 44, 2, 'Seeded matter description', '2026-02-23', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(46, 'MAT-2026-0046', 'Seeded Matter 21', 42, 51, 48, 20, 'Seeded matter description', '2026-02-19', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(47, 'MAT-2026-0047', 'Seeded Matter 22', 64, 9, 44, 16, 'Seeded matter description', '2026-01-29', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(48, 'MAT-2026-0048', 'Seeded Matter 23', 59, 13, 52, 4, 'Seeded matter description', '2026-02-02', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(49, 'MAT-2026-0049', 'Seeded Matter 24', 44, 21, 2, 4, 'Seeded matter description', '2026-02-13', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(50, 'MAT-2026-0050', 'Seeded Matter 25', 8, 31, 45, 21, 'Seeded matter description', '2026-03-10', NULL, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(51, 'MAT-2026-0051', 'Will drafting', NULL, NULL, NULL, NULL, 'gwena inheritance', '2026-03-23', NULL, 1, 1, '2026-03-23 10:49:07', '2026-03-23 10:49:07'),
(52, 'MAT-2026-0052', 'Gwena estate allocations', 20, 13, 3, 4, 'allcocations', '2026-03-23', NULL, 1, 1, '2026-03-23 11:07:06', '2026-03-23 11:07:06');

-- --------------------------------------------------------

--
-- Table structure for table `matter_categories`
--

CREATE TABLE IF NOT EXISTS `matter_categories` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `matter_categories_name_unique` (`name`),
  KEY `matter_categories_created_by_foreign` (`created_by`),
  KEY `matter_categories_updated_by_foreign` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matter_categories`
--

INSERT INTO `matter_categories` (`id`, `name`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'ADM', 'Administrative Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(2, 'BNK', 'Bankruptcy & Insolvency', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(3, 'BOLO', 'DSDSSS', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(4, 'CIV', 'Civil Litigation', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(5, 'CON', 'Construction Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(6, 'COR', 'Corporate & Commercial', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(7, 'CRM', 'Criminal Defense', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(8, 'EMP', 'Employment & Labor Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(9, 'ENV', 'Environmental Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(10, 'EST', 'Estate Planning & Probate', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(11, 'FAM', 'Family Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(12, 'IMM', 'Immigration Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(13, 'INS', 'Insurance Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(14, 'INT', 'International Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(15, 'IP', 'Intellectual Property', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(16, 'MED', 'Medical Malpractice', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(17, 'TAX', 'Taxation Law', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(18, 'Commercial', 'Category description for Commercial', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 'Employment', 'Category description for Employment', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 'Estates', 'Category description for Estates', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 'Category 4', 'Category description for Category 4', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(22, 'Category 5', 'Category description for Category 5', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(23, 'Category 6', 'Category description for Category 6', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(24, 'Category 7', 'Category description for Category 7', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(25, 'Category 8', 'Category description for Category 8', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(26, 'Category 9', 'Category description for Category 9', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(27, 'Category 10', 'Category description for Category 10', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(28, 'Category 11', 'Category description for Category 11', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(29, 'Category 12', 'Category description for Category 12', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(30, 'Category 13', 'Category description for Category 13', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(31, 'Category 14', 'Category description for Category 14', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(32, 'Category 15', 'Category description for Category 15', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(33, 'Category 16', 'Category description for Category 16', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(34, 'Category 17', 'Category description for Category 17', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(35, 'Category 18', 'Category description for Category 18', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(36, 'Category 19', 'Category description for Category 19', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(37, 'Category 20', 'Category description for Category 20', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(38, 'Category 21', 'Category description for Category 21', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(39, 'Category 22', 'Category description for Category 22', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(40, 'Category 23', 'Category description for Category 23', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(41, 'Category 24', 'Category description for Category 24', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(42, 'Category 25', 'Category description for Category 25', 8, 8, '2026-03-19 11:04:56', '2026-03-19 11:04:56'),
(43, 'Category 1', 'Category description for Category 1', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(44, 'Category 2', 'Category description for Category 2', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(45, 'Category 3', 'Category description for Category 3', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(46, 'Category 26', 'Category description for Category 26', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(47, 'Category 27', 'Category description for Category 27', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(48, 'Category 28', 'Category description for Category 28', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(49, 'Category 29', 'Category description for Category 29', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(50, 'Category 30', 'Category description for Category 30', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(51, 'Category 31', 'Category description for Category 31', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(52, 'Category 32', 'Category description for Category 32', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(53, 'Category 33', 'Category description for Category 33', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(54, 'Category 34', 'Category description for Category 34', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(55, 'Category 35', 'Category description for Category 35', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(56, 'Category 36', 'Category description for Category 36', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(57, 'Category 37', 'Category description for Category 37', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(58, 'Category 38', 'Category description for Category 38', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(59, 'Category 39', 'Category description for Category 39', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(60, 'Category 40', 'Category description for Category 40', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(61, 'Category 41', 'Category description for Category 41', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(62, 'Category 42', 'Category description for Category 42', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(63, 'Category 43', 'Category description for Category 43', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(64, 'Category 44', 'Category description for Category 44', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
-- Table structure for table `matter_clients`
--

CREATE TABLE IF NOT EXISTS `matter_clients` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `matter_id` bigint UNSIGNED NOT NULL,
  `client_id` bigint UNSIGNED NOT NULL,
  `role_id` bigint UNSIGNED DEFAULT NULL,
  `is_primary_client` tinyint(1) NOT NULL DEFAULT '0',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `matter_clients_created_by_foreign` (`created_by`),
  KEY `matter_clients_updated_by_foreign` (`updated_by`),
  KEY `matter_clients_matter_id_index` (`matter_id`),
  KEY `matter_clients_client_id_index` (`client_id`),
  KEY `matter_clients_role_id_foreign` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matter_clients`
--

INSERT INTO `matter_clients` (`id`, `matter_id`, `client_id`, `role_id`, `is_primary_client`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(2, 2, 2, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(3, 2, 3, 7, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(4, 3, 4, 2, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(5, 3, 5, 8, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(6, 4, 6, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(7, 4, 7, 7, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(8, 4, 8, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(9, 5, 9, 2, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(10, 6, 10, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(11, 6, 11, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(12, 7, 12, 2, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(13, 7, 13, 8, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(14, 7, 14, 3, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(15, 8, 15, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(16, 8, 16, 7, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(17, 8, 17, 3, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(18, 8, 18, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(19, 9, 19, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(20, 10, 20, 2, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(21, 10, 21, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(22, 11, 22, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(23, 11, 23, 3, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(24, 11, 24, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(25, 12, 25, 2, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(26, 12, 26, 8, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(27, 12, 27, 3, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(28, 12, 28, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(29, 13, 29, 1, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(30, 13, 30, 4, 0, 1, 1, '2026-03-13 12:12:18', '2026-03-13 12:12:18'),
(31, 44, 5, 20, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(32, 16, 15, 31, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(33, 41, 8, 24, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(34, 48, 1, 8, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(35, 29, 3, 20, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(36, 48, 14, 10, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(37, 18, 15, 32, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(38, 30, 1, 13, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(39, 21, 3, 18, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(40, 40, 12, 17, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(41, 47, 3, 26, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(42, 35, 12, 15, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(43, 4, 15, 32, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(44, 30, 16, 5, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(45, 4, 9, 3, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(46, 3, 1, 19, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(47, 1, 11, 31, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(48, 12, 15, 5, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(49, 39, 8, 18, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(50, 27, 5, 16, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(51, 38, 5, 13, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(52, 37, 11, 20, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(53, 50, 17, 5, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(54, 43, 13, 18, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(55, 18, 15, 4, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
-- Table structure for table `matter_lawyers`
--

CREATE TABLE IF NOT EXISTS `matter_lawyers` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `matter_id` bigint UNSIGNED NOT NULL,
  `lawyer_id` bigint UNSIGNED DEFAULT NULL,
  `role_id` bigint UNSIGNED DEFAULT NULL,
  `is_lead_lawyer` tinyint(1) NOT NULL DEFAULT '0',
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `matter_lawyers_created_by_foreign` (`created_by`),
  KEY `matter_lawyers_updated_by_foreign` (`updated_by`),
  KEY `matter_lawyers_matter_id_index` (`matter_id`),
  KEY `matter_lawyers_lawyer_id_index` (`lawyer_id`),
  KEY `matter_lawyers_role_id_foreign` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matter_lawyers`
--

INSERT INTO `matter_lawyers` (`id`, `matter_id`, `lawyer_id`, `role_id`, `is_lead_lawyer`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 45, 4, 32, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(2, 26, 2, 33, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(3, 32, 1, 10, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(4, 47, 6, 8, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(5, 13, 7, 24, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(6, 33, 1, 6, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(7, 38, 4, 20, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(8, 21, 1, 17, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(9, 38, 9, 20, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(10, 41, 7, 1, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(11, 11, 7, 31, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 20, 6, 9, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 40, 10, 24, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 16, 7, 29, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 10, 3, 9, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 46, 5, 20, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 49, 10, 13, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 24, 3, 28, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 46, 4, 12, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 28, 7, 31, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 45, 9, 22, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 31, 6, 26, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 27, 2, 18, 0, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 14, 3, 21, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 38, 1, 7, 1, 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
-- Table structure for table `matter_outcomes`
--

CREATE TABLE IF NOT EXISTS `matter_outcomes` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `matter_outcomes_name_unique` (`name`),
  KEY `matter_outcomes_created_by_foreign` (`created_by`),
  KEY `matter_outcomes_updated_by_foreign` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matter_outcomes`
--

INSERT INTO `matter_outcomes` (`id`, `name`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'Won', 'Case resolved in favor of the client', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(2, 'Lost', 'Case resolved against the client', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(3, 'Settled', 'Case resolved via settlement agreement', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(4, 'Dismissed', 'Case dismissed by the court', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(5, 'Withdrawn', 'Case withdrawn by the client or attorney', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(6, 'Pending', 'Case still ongoing, no final outcome yet', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(7, 'Appealed', 'Case outcome is under appeal', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(8, 'Outcome 1', 'Outcome description for Outcome 1', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(9, 'Outcome 2', 'Outcome description for Outcome 2', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(10, 'Outcome 3', 'Outcome description for Outcome 3', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(11, 'Outcome 4', 'Outcome description for Outcome 4', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 'Outcome 5', 'Outcome description for Outcome 5', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 'Outcome 6', 'Outcome description for Outcome 6', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 'Outcome 7', 'Outcome description for Outcome 7', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 'Outcome 8', 'Outcome description for Outcome 8', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 'Outcome 9', 'Outcome description for Outcome 9', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 'Outcome 10', 'Outcome description for Outcome 10', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 'Outcome 11', 'Outcome description for Outcome 11', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 'Outcome 12', 'Outcome description for Outcome 12', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 'Outcome 13', 'Outcome description for Outcome 13', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 'Outcome 14', 'Outcome description for Outcome 14', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 'Outcome 15', 'Outcome description for Outcome 15', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 'Outcome 16', 'Outcome description for Outcome 16', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 'Outcome 17', 'Outcome description for Outcome 17', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 'Outcome 18', 'Outcome description for Outcome 18', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(26, 'Outcome 19', 'Outcome description for Outcome 19', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(27, 'Outcome 20', 'Outcome description for Outcome 20', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(28, 'Outcome 21', 'Outcome description for Outcome 21', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(29, 'Outcome 22', 'Outcome description for Outcome 22', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(30, 'Outcome 23', 'Outcome description for Outcome 23', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(31, 'Outcome 24', 'Outcome description for Outcome 24', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(32, 'Outcome 25', 'Outcome description for Outcome 25', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
-- Table structure for table `matter_priorities`
--

CREATE TABLE IF NOT EXISTS `matter_priorities` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `matter_priorities_name_unique` (`name`),
  KEY `matter_priorities_created_by_foreign` (`created_by`),
  KEY `matter_priorities_updated_by_foreign` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matter_priorities`
--

INSERT INTO `matter_priorities` (`id`, `name`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'Low', 'Priority description for Low', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(2, 'Normal', 'Standard case priority', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(3, 'Medium', 'Priority description for Medium', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(4, 'High', 'Priority description for High', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(5, 'Urgent', 'Immediate action required', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(6, 'Critical', 'Court-mandated or high-risk matter', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(7, 'Priority 1', 'Priority description for Priority 1', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(8, 'Priority 2', 'Priority description for Priority 2', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(9, 'Priority 3', 'Priority description for Priority 3', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(10, 'Priority 4', 'Priority description for Priority 4', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(11, 'Priority 5', 'Priority description for Priority 5', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 'Priority 6', 'Priority description for Priority 6', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 'Priority 7', 'Priority description for Priority 7', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 'Priority 8', 'Priority description for Priority 8', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 'Priority 9', 'Priority description for Priority 9', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 'Priority 10', 'Priority description for Priority 10', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 'Priority 11', 'Priority description for Priority 11', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 'Priority 12', 'Priority description for Priority 12', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 'Priority 13', 'Priority description for Priority 13', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 'Priority 14', 'Priority description for Priority 14', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 'Priority 15', 'Priority description for Priority 15', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 'Priority 16', 'Priority description for Priority 16', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 'Priority 17', 'Priority description for Priority 17', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 'Priority 18', 'Priority description for Priority 18', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 'Priority 19', 'Priority description for Priority 19', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(26, 'Priority 20', 'Priority description for Priority 20', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(27, 'Priority 21', 'Priority description for Priority 21', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(28, 'Priority 22', 'Priority description for Priority 22', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
-- Table structure for table `matter_reasons`
--

CREATE TABLE IF NOT EXISTS `matter_reasons` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint UNSIGNED DEFAULT NULL,
  `updated_by` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `matter_reasons_name_unique` (`name`),
  KEY `matter_reasons_created_by_foreign` (`created_by`),
  KEY `matter_reasons_updated_by_foreign` (`updated_by`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `matter_reasons`
--

INSERT INTO `matter_reasons` (`id`, `name`, `description`, `created_by`, `updated_by`, `created_at`, `updated_at`) VALUES
(1, 'Duplicate Case', 'The case was identified as a duplicate of an existing case and was therefore cancelled.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(2, 'Cancelled by Request', 'The case was cancelled following a formal request by the reporting party.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(3, 'Invalid Case', 'The case did not meet the minimum criteria required for processing.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(4, 'Created in Error', 'The case was created due to a system or user error and has been cancelled.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(5, 'No Jurisdiction', 'The case falls outside the organisation’s legal or operational jurisdiction.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(6, 'Insufficient Evidence', 'The case was cancelled due to a lack of supporting evidence.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(7, 'Resolved Externally', 'The matter was resolved outside the system prior to case processing.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(8, 'Non-Responsive Party', 'The involved party failed to respond within the required timeframe.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(9, 'Withdrawn by Initiator', 'The case was formally withdrawn by the individual who initiated it.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(10, 'Policy Violation', 'The case conflicted with organisational policy and could not proceed.', NULL, NULL, '2026-03-18 11:51:58', '2026-03-18 11:51:58'),
(11, 'Reason 1', 'Reason description for Reason 1', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(12, 'Reason 2', 'Reason description for Reason 2', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(13, 'Reason 3', 'Reason description for Reason 3', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(14, 'Reason 4', 'Reason description for Reason 4', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(15, 'Reason 5', 'Reason description for Reason 5', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(16, 'Reason 6', 'Reason description for Reason 6', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(17, 'Reason 7', 'Reason description for Reason 7', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(18, 'Reason 8', 'Reason description for Reason 8', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(19, 'Reason 9', 'Reason description for Reason 9', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(20, 'Reason 10', 'Reason description for Reason 10', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(21, 'Reason 11', 'Reason description for Reason 11', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(22, 'Reason 12', 'Reason description for Reason 12', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(23, 'Reason 13', 'Reason description for Reason 13', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(24, 'Reason 14', 'Reason description for Reason 14', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(25, 'Reason 15', 'Reason description for Reason 15', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(26, 'Reason 16', 'Reason description for Reason 16', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(27, 'Reason 17', 'Reason description for Reason 17', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(28, 'Reason 18', 'Reason description for Reason 18', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(29, 'Reason 19', 'Reason description for Reason 19', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(30, 'Reason 20', 'Reason description for Reason 20', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(31, 'Reason 21', 'Reason description for Reason 21', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(32, 'Reason 22', 'Reason description for Reason 22', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(33, 'Reason 23', 'Reason description for Reason 23', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(34, 'Reason 24', 'Reason description for Reason 24', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20'),
(35, 'Reason 25', 'Reason description for Reason 25', 8, 8, '2026-03-19 11:10:20', '2026-03-19 11:10:20');

-- --------------------------------------------------------

--
