CREATE TABLE IF NOT EXISTS `profit_sharing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `settlement_month` varchar(7) NOT NULL,
  `total_revenue` decimal(15,2) DEFAULT 0.00,
  `total_payroll_expense` decimal(15,2) DEFAULT 0.00,
  `other_expenses` decimal(15,2) DEFAULT 0.00,
  `other_expenses_details` json DEFAULT NULL,
  `owner_id` int(11) NOT NULL,
  `partner_id` int(11) NOT NULL,
  `owner_payout` decimal(15,2) DEFAULT 0.00,
  `partner_payout` decimal(15,2) DEFAULT 0.00,
  `owner_debt_deduction` decimal(15,2) DEFAULT 0.00,
  `partner_debt_deduction` decimal(15,2) DEFAULT 0.00,
  `owner_remaining_debt` decimal(15,2) DEFAULT 0.00,
  `partner_remaining_debt` decimal(15,2) DEFAULT 0.00,
  `owner_debt_details` json DEFAULT NULL,
  `partner_debt_details` json DEFAULT NULL,
  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_settlement` (`settlement_month`,`owner_id`,`partner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
