-- Checks Phase 2: add statuses/movements for cash settlement and replacement
ALTER TABLE checks
  MODIFY COLUMN current_status ENUM('received','endorsed','returned','settled_cash','replaced','canceled') NOT NULL DEFAULT 'received';

ALTER TABLE check_movements
  MODIFY COLUMN movement_type ENUM('receive','endorse','return','cash_settlement','replace') NOT NULL;

INSERT IGNORE INTO permissions (code, name, module) VALUES
('checks.settle', 'تسوية شيك مرتد نقدًا', 'checks'),
('checks.replace', 'استبدال شيك مرتد', 'checks');

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT 1, p.id FROM permissions p WHERE p.code IN ('checks.settle','checks.replace');
