-- Create common_codes table
CREATE TABLE IF NOT EXISTS common_codes (
    code_group      VARCHAR(50)     NOT NULL,
    code_value      VARCHAR(50)     NOT NULL,
    code_name       VARCHAR(100)    NOT NULL,
    sort_order      INT             DEFAULT 0,
    is_active       BOOLEAN         DEFAULT TRUE,
    PRIMARY KEY (code_group, code_value)
);

-- Seed data for BUSINESS_TYPE
INSERT INTO common_codes (code_group, code_value, code_name, sort_order) VALUES
('BUSINESS_TYPE', '일반제조업', '일반제조업', 10),
('BUSINESS_TYPE', '도소매업', '도소매업', 20),
('BUSINESS_TYPE', '서비스업', '서비스업', 30),
('BUSINESS_TYPE', '정보통신업', '정보통신업', 40),
('BUSINESS_TYPE', '부동산업', '부동산업', 50),
('BUSINESS_TYPE', '건설업', '건설업', 60),
('BUSINESS_TYPE', '음식점업', '음식점업', 70),
('BUSINESS_TYPE', '프리랜서', '프리랜서', 80),
('BUSINESS_TYPE', '기타', '기타', 90)
ON CONFLICT (code_group, code_value) DO NOTHING;

-- Seed data for TAX_RISK_LEVEL
INSERT INTO common_codes (code_group, code_value, code_name, sort_order) VALUES
('TAX_RISK_LEVEL', 'low', '낮음', 10),
('TAX_RISK_LEVEL', 'normal', '보통', 20),
('TAX_RISK_LEVEL', 'high', '높음', 30)
ON CONFLICT (code_group, code_value) DO NOTHING;

-- Seed data for FILING_TYPE
INSERT INTO common_codes (code_group, code_value, code_name, sort_order) VALUES
('FILING_TYPE', '종합소득세', '종합소득세', 10),
('FILING_TYPE', '부가가치세', '부가가치세', 20),
('FILING_TYPE', '법인세', '법인세', 30),
('FILING_TYPE', '원천세', '원천세', 40),
('FILING_TYPE', '양도소득세', '양도소득세', 50),
('FILING_TYPE', '상속/증여세', '상속/증여세', 60)
ON CONFLICT (code_group, code_value) DO NOTHING;

-- Seed data for SERVICE_TYPE
INSERT INTO common_codes (code_group, code_value, code_name, sort_order) VALUES
('SERVICE_TYPE', '개인 기장대리', '개인 기장대리', 10),
('SERVICE_TYPE', '법인 기장대리', '법인 기장대리', 20),
('SERVICE_TYPE', '세무조정', '세무조정', 30),
('SERVICE_TYPE', '세무컨설팅', '세무컨설팅', 40),
('SERVICE_TYPE', '불복청구', '불복청구', 50)
ON CONFLICT (code_group, code_value) DO NOTHING;
