[feat] negodata: 마감 close_reason 개편 + 견적상세 단가조정 스펙트럼

- 마감사유 quotations.close_reason(SMALLINT, 8종) 신설 — 낙찰/재협상3종/유찰4종 구분, 재생성 한도 카운팅. quotation_settings 에 mid_action·over_action·regen_limit(3구간 가격정책) 추가. models.py·enums.py·01-schema.sql·crud·service·테스트 정합.
- 프론트 노출: CloseReason/PriceGateAction 라벨·배지, 목록 마감결과 컬럼, 견적세팅 모달 3구간. orval 생성모델 갱신.
- 견적상세 결과밴드: 목표가→낙찰가→절감 stat 트리오를 단가조정 흐름 스펙트럼(목표가·최저·최고 투찰가)으로 교체. lowestBid/highestBid 는 bid_price 파생(DB 컬럼 아님), 최초가 컬럼 없어 시작앵커=최고 투찰가로 대체. 라벨 방향 값순 번갈아 배치로 겹침 방지.
- 라벨 정정: "단독 낙찰"→"낙찰"(낙찰은 단수), "목표 대비"→"목표가 대비".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 4.8 committed 2026-07-03 08:37:40 +09:00
1 parent d0b6e785af
commit e23349c11e
32 files changed
+1087 -325

No files matched your search

+21 -14
View File
@@ -117,7 +117,7 @@ class IQuotationCRUD(ABC):
pass
@abstractmethod
async def list_chain_close_flags(self, cdb: AsyncSession, number, current_round) -> Tuple[ErrorType, list]:
async def list_chain_close_reasons(self, cdb: AsyncSession, number, current_round) -> Tuple[ErrorType, list]:
pass
@abstractmethod
@@ -405,11 +405,15 @@ class QuotationCRUD(IQuotationCRUD):
return ErrorType.DB_RUN_FAILED, None
async def get_setting_rates(self, cdb: AsyncSession, qt_setting_id) -> Tuple[ErrorType, dict]:
"""견적 세팅의 율: {margin, anchoring}. 목표가·앵커링가 산정 입력. (인터넷 수수료는 상수)"""
"""견적 세팅의 율+마감정책: {margin, anchoring, mid_action, over_action, regen_limit}.
목표가·앵커링가 산정 입력 + 마감 가격게이트 정책. (인터넷 수수료는 상수)"""
try:
query = select(
quotation_settings.target_margin_rate,
quotation_settings.anchoring_value,
quotation_settings.mid_action,
quotation_settings.over_action,
quotation_settings.regen_limit,
).where(quotation_settings.qt_setting_id == qt_setting_id).limit(1)
err_type, rows = await DB_SESSION_MNG.execute(cdb, query)
if err_type != ErrorType.SUCCESS:
@@ -420,6 +424,9 @@ class QuotationCRUD(IQuotationCRUD):
return ErrorType.SUCCESS, {
"margin": float(r[0]) if r[0] is not None else None,
"anchoring": float(r[1]) if r[1] is not None else None,
"mid_action": r[2],
"over_action": r[3],
"regen_limit": r[4],
}
except Exception as ex:
LOG.e_no_callstack(ex)
@@ -554,15 +561,12 @@ class QuotationCRUD(IQuotationCRUD):
LOG.e_no_callstack(ex)
return ErrorType.DB_RUN_FAILED, []
async def list_chain_close_flags(self, cdb: AsyncSession, number, current_round) -> Tuple[ErrorType, list]:
"""[재생성 한도] 같은 견적번호(체인)의 이전 라운드(round < current_round)들의 (preferred_sp_yn, equal_bid_yn) 목록. 삭제 제외.
마감 사유 식별용 표식:
- equal_bid_yn=True → 동가 재생성
- preferred_sp_yn=False AND equal_bid_yn=False → 미참여 재생성
- preferred_sp_yn=True → 단독낙찰(체인 어느 쪽에도 안 셈)
- 둘 다 NULL → 거부/한도 그냥 마감(안 셈)"""
async def list_chain_close_reasons(self, cdb: AsyncSession, number, current_round) -> Tuple[ErrorType, list]:
"""[재생성 한도] 같은 견적번호(체인)의 이전 라운드(round < current_round)들의 close_reason 코드 목록. 삭제 제외.
_chain_regen_counts 가 REGEN_* 값(목표초과재협상/동가재입찰/미참여재소집)만 사유별로 센다.
낙찰(AWARDED)·유찰(FAIL_*)·미마감(NULL)은 재생성 한도에 안 셈."""
try:
query = select(quotations.preferred_sp_yn, quotations.equal_bid_yn).where(
query = select(quotations.close_reason).where(
quotations.number == number,
quotations.round < current_round,
quotations.deleted == False, # noqa: E712
@@ -570,7 +574,8 @@ class QuotationCRUD(IQuotationCRUD):
err_type, rows = await DB_SESSION_MNG.execute(cdb, query)
if err_type != ErrorType.SUCCESS:
return err_type, []
return ErrorType.SUCCESS, list(rows)
# 단일 컬럼 select → 각 행이 스칼라(close_reason 코드 or None)
return ErrorType.SUCCESS, [r for r in rows]
except Exception as ex:
LOG.e_no_callstack(ex)
return ErrorType.DB_RUN_FAILED, []
@@ -594,11 +599,13 @@ class QuotationCRUD(IQuotationCRUD):
return ErrorType.DB_RUN_FAILED, 0
async def list_sessions_status(self, cdb: AsyncSession, qt_id) -> Tuple[ErrorType, list]:
"""[마감 판정] 견적의 모든 세션 → (status, supplier_id, bid_price, supplier_name). 삭제 제외.
공급사가 지워졌어도 세션 집계엔 포함되도록 outerjoin(이때 name 은 None)."""
"""[마감 판정] 견적의 모든 세션 → (status, supplier_id, bid_price, name, target_price, target_anchoring_price). 삭제 제외.
공급사가 지워졌어도 세션 집계엔 포함되도록 outerjoin(이때 name 은 None).
target/anchoring 은 마감 가격게이트 입력(견적당 상품 1개라 세션 공통값)."""
try:
query = (
select(sessions.status, sessions.supplier_id, sessions.bid_price, suppliers.name)
select(sessions.status, sessions.supplier_id, sessions.bid_price, suppliers.name,
sessions.target_price, sessions.target_anchoring_price)
.outerjoin(suppliers, suppliers.supplier_id == sessions.supplier_id)
.where(sessions.quotation_id == qt_id, sessions.deleted == False) # noqa: E712
)