CREATE TABLE IF NOT EXISTS `LiabilitiesRegister` (
  `ID` INT NOT NULL AUTO_INCREMENT,
  `liability_code` VARCHAR(60) NOT NULL,
  `creditor_name` VARCHAR(255) NOT NULL,
  `liability_type` VARCHAR(120) NULL,
  `total_amount` BIGINT NOT NULL DEFAULT 0,
  `start_date` DATE NULL,
  `due_date` DATE NULL,
  `paid_amount` BIGINT NOT NULL DEFAULT 0,
  `balance` BIGINT NULL,
  `payment_status` VARCHAR(80) NOT NULL DEFAULT 'pending',
  `interest_rate` DECIMAL(7,4) NULL,
  `account_id` INT NULL,
  `expense_ref_id` INT NULL,
  `note` TEXT NULL,
  `EnteredByUserId` INT NULL,
  `EntryDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `UpdateDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  UNIQUE KEY `uq_liability_code` (`liability_code`),
  KEY `idx_liabilities_account` (`account_id`),
  KEY `idx_liabilities_due_date` (`due_date`),
  KEY `idx_liabilities_status` (`payment_status`),
  KEY `idx_liabilities_expense_ref` (`expense_ref_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
