-- V96: incar 갭 수수료 도메인 공통코드 5종 (V55 패턴 동일)
--      INCOME_STATUS / REFERRAL_TYPE / CALC_TYPE / SUPPORT_STATUS / AWARD_TYPE

-- ===== 그룹 =====
INSERT INTO common_code_group (group_code, group_name, description, is_system, sort_order) VALUES
 ('INCOME_STATUS',  '수입수수료상태',   'CALCULATED/CONFIRMED/CANCELLED',                    'Y', 390),
 ('REFERRAL_TYPE',  '소개이관유형',     'REFERRAL=소개/TRANSFER=이관',                       'Y', 400),
 ('CALC_TYPE',      '계산방식',         'RATE=정률/FIXED=정액',                              'Y', 410),
 ('SUPPORT_STATUS', '지원금상태',       'CALCULATED/PAID/CLAWED_BACK/CANCELLED',             'Y', 420),
 ('AWARD_TYPE',     '시상유형',         'NEW_RECRUIT/CORPORATE/RETENTION/PERFORMANCE',       'Y', 430)
ON CONFLICT (group_code) DO NOTHING;

-- ===== 상세 =====
INSERT INTO common_code (group_code, code, code_name, sort_order) VALUES
 -- INCOME_STATUS
 ('INCOME_STATUS', 'CALCULATED', '계산완료',  10),
 ('INCOME_STATUS', 'CONFIRMED',  '확정',      20),
 ('INCOME_STATUS', 'CANCELLED',  '취소',      30),
 -- REFERRAL_TYPE
 ('REFERRAL_TYPE', 'REFERRAL',   '소개',      10),
 ('REFERRAL_TYPE', 'TRANSFER',   '이관',      20),
 -- CALC_TYPE
 ('CALC_TYPE',     'RATE',       '정률',      10),
 ('CALC_TYPE',     'FIXED',      '정액',      20),
 -- SUPPORT_STATUS
 ('SUPPORT_STATUS', 'CALCULATED', '계산완료', 10),
 ('SUPPORT_STATUS', 'PAID',       '지급완료', 20),
 ('SUPPORT_STATUS', 'CLAWED_BACK','환수완료', 30),
 ('SUPPORT_STATUS', 'CANCELLED',  '취소',     40),
 -- AWARD_TYPE
 ('AWARD_TYPE', 'NEW_RECRUIT',  '신인도입',  10),
 ('AWARD_TYPE', 'CORPORATE',    '법인',      20),
 ('AWARD_TYPE', 'RETENTION',    '유지율',    30),
 ('AWARD_TYPE', 'PERFORMANCE',  '실적',      40)
ON CONFLICT (group_code, code) DO NOTHING;
