CREATE TABLE chart_of_account_types (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(100) NOT NULL,
    code VARCHAR(10) NOT NULL UNIQUE,
    description TEXT,
    is_active BOOLEAN DEFAULT true,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Insert default chart of account types
INSERT INTO chart_of_account_types (name, code, description) VALUES
('Assets', 'ASSET', 'Resources owned by the organization'),
('Liabilities', 'LIABILITY', 'Debts and obligations'),
('Equity', 'EQUITY', 'Owner''s interest in the organization'),
('Revenue', 'REVENUE', 'Income from business operations'),
('Expenses', 'EXPENSE', 'Costs incurred in business operations');

CREATE INDEX idx_chart_of_account_types_code ON chart_of_account_types(code);
CREATE INDEX idx_chart_of_account_types_is_active ON chart_of_account_types(is_active);
