Files
ga-commission-system/ga-common/src/main/resources/db/migration/V91__인정실적_환산율.sql
T
GA Pro bfc724669b feat: incar 갭 반영 수수료/운영 14개 도메인 풀스택 + 배치통합 + 신입교육자료
incar CMS(116메뉴) 벤치마킹 갭분석으로 ga-pro에 없던 14개 도메인을 풀스택 추가.

P7 수수료 계산 7종 (V88~V96):
- 수입수수료+수지차, 소개·이관수수료, 정착지원금, 인정실적+환산율,
  시상, 생보운영지원수수료, 지점장수당
- 각 rule/ledger + 공식(보험료×요율, 수입−지급 등) Service 내장

P8 운영/정산 7종 (V97~V105):
- 단계마감, 본사정산, 등급평가, 공동계약, 보증보험, 적립금, 수수료시뮬레이터
- close/reopen/apply/simulate/upsert 등 액션 + 손익·잔액·등급 산정 로직

배치 통합 (V106):
- settle_master.other_commission_total 컬럼 추가(DEFAULT 0, 백필)
- 설계사 지급성 9종 원장 aggregateByAgent → AggregateStep gross 합산
- 빈 원장 0 → 기존 정산결과·무결성 불변(비파괴적)

테스트: P7/P8 Service 공식 단위테스트 21건(ga-api:test 57건 전체 통과)
프론트: 화면 14개 + React.lazy 코드 스플리팅(단일 4MB → 130+ 청크)
문서: DOMAIN_GAP_P7/P8.md, 신입교육_보험과수수료_완전기초.md, DOMAIN_KNOWLEDGE/HANDOFF 갱신

검증: 전체 ./gradlew build(test 포함) SUCCESSFUL, Flyway V88~V106 success,
GET+액션POST smoke 5xx 0건, 9개 집계쿼리 SQL 유효성 확인, 공식 런타임 실측.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 15:45:10 +09:00

71 lines
4.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- V91: 인정실적 + 환산보험료 (product_conversion_rate + recognized_performance_ledger)
-- 환산보험료 = 보험료 × 상품별 환산율.
-- 인정실적 = 환산보험료 × 인정율.
-- 시상/등급 산정의 기초 데이터.
-- ============================================================
-- 1. product_conversion_rate — 상품별 환산율 마스터
-- ============================================================
CREATE TABLE product_conversion_rate (
rate_id BIGSERIAL PRIMARY KEY,
product_id BIGINT NOT NULL REFERENCES product(product_id),
conversion_rate NUMERIC(7,4) NOT NULL,
effective_from DATE NOT NULL,
effective_to DATE,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_by BIGINT,
updated_at TIMESTAMP,
UNIQUE (product_id, effective_from),
CHECK (conversion_rate >= 0 AND conversion_rate <= 1)
);
COMMENT ON TABLE product_conversion_rate IS '상품별 환산율 마스터 — 인정실적 산출을 위한 보험료 환산율';
COMMENT ON COLUMN product_conversion_rate.rate_id IS '환산율 PK';
COMMENT ON COLUMN product_conversion_rate.product_id IS '적용 상품 FK';
COMMENT ON COLUMN product_conversion_rate.conversion_rate IS '환산율 (소수, 예: 0.5 = 50%)';
COMMENT ON COLUMN product_conversion_rate.effective_from IS '적용 시작일';
COMMENT ON COLUMN product_conversion_rate.effective_to IS '적용 종료일 (NULL=현재 유효)';
CREATE INDEX idx_pcr_product_from ON product_conversion_rate(product_id, effective_from);
-- ============================================================
-- 2. recognized_performance_ledger — 인정실적 원장
-- ============================================================
CREATE TABLE recognized_performance_ledger (
ledger_id BIGSERIAL PRIMARY KEY,
agent_id BIGINT NOT NULL REFERENCES agent(agent_id),
contract_id BIGINT NOT NULL REFERENCES contract(contract_id),
settle_month CHAR(6) NOT NULL,
premium_amount NUMERIC(15,2) NOT NULL,
conversion_rate NUMERIC(7,4) NOT NULL,
converted_premium NUMERIC(15,2) NOT NULL,
recognition_rate NUMERIC(7,4) NOT NULL,
recognized_amount NUMERIC(15,2) NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'CALCULATED',
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP,
CHECK (status IN ('CALCULATED','CONFIRMED','CANCELLED')),
CHECK (premium_amount >= 0),
CHECK (conversion_rate >= 0 AND conversion_rate <= 1),
CHECK (converted_premium >= 0),
CHECK (recognition_rate >= 0 AND recognition_rate <= 1),
CHECK (recognized_amount >= 0)
);
COMMENT ON TABLE recognized_performance_ledger IS '인정실적 원장 — 설계사별 계약 단위 환산보험료 및 인정실적';
COMMENT ON COLUMN recognized_performance_ledger.ledger_id IS '원장 PK';
COMMENT ON COLUMN recognized_performance_ledger.agent_id IS '설계사 FK';
COMMENT ON COLUMN recognized_performance_ledger.contract_id IS '대상 계약 FK';
COMMENT ON COLUMN recognized_performance_ledger.settle_month IS '정산 귀속월 (YYYYMM)';
COMMENT ON COLUMN recognized_performance_ledger.premium_amount IS '보험료';
COMMENT ON COLUMN recognized_performance_ledger.conversion_rate IS '적용 환산율 (product_conversion_rate 스냅샷)';
COMMENT ON COLUMN recognized_performance_ledger.converted_premium IS '환산보험료 = premium_amount × conversion_rate';
COMMENT ON COLUMN recognized_performance_ledger.recognition_rate IS '인정율 (설계사 등급/정책 기준)';
COMMENT ON COLUMN recognized_performance_ledger.recognized_amount IS '인정실적 = converted_premium × recognition_rate';
COMMENT ON COLUMN recognized_performance_ledger.status IS '상태 (CALCULATED/CONFIRMED/CANCELLED)';
CREATE INDEX idx_rpl_agent_month ON recognized_performance_ledger(agent_id, settle_month);
CREATE INDEX idx_rpl_contract ON recognized_performance_ledger(contract_id);