[refactor] negodata: 목표가 산정 정리 — purchase_only 죽은코드 제거(백+프론트)·산정 재료 로더 공용화·자동재생성 잔재 주석 정정

This commit is contained in:
minaChoi committed 2026-07-27 16:07:21 +09:00
1 parent bacf6271df
commit 7b612824be
9 files changed
+209 -226

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ class DashboardCRUD(IDashboardCRUD):
async def ruptured(self, cdb: AsyncSession, company_id, owner, limit) -> Tuple[ErrorType, list, int]:
try:
# 결렬 = 마감됐는데 단독낙찰(preferred_sp_yn)도 동가(equal_bid_yn)도 아님 → 둘 다 NULL(거부/한도로 그냥 마감).
# 결렬 = 마감됐는데 낙찰(preferred_sp_yn)도 동가(equal_bid_yn)도 아님 → 둘 다 NULL(가격미달·거부·미응찰 개찰).
where = and_(
*_company_scope(company_id, owner),
quotations.status == QuotationStatus.CLOSED.value,
+10 -30
View File
@@ -51,6 +51,10 @@ class IQuotationCRUD(ABC):
async def get_setting_rates(self, cdb: AsyncSession, qt_setting_id) -> Tuple[ErrorType, dict]:
pass
@abstractmethod
async def get_company_settings(self, cdb: AsyncSession, user_id) -> dict:
pass
@abstractmethod
async def add_rows(self, cdb: AsyncSession, obj_list: list) -> ErrorType:
pass
@@ -384,11 +388,9 @@ class QuotationCRUD(IQuotationCRUD):
LOG.e_no_callstack(ex)
return ErrorType.DB_RUN_FAILED, {}
async def get_target_price_mode(self, cdb: AsyncSession, user_id):
# 견적 소유 유저 → 회사 설정에서 목표가 산정에 영향을 주는 두 가지를 함께 읽는다.
# features.target_price_mode: 'purchase' 면 매입가만 후보(IMK #10)
# hidden_fields: 화면에서 감춘 가격 필드는 후보에서도 뺀다(감춘 값이 목표가를 정하면 설명이 안 된다)
# 반환: (mode, hidden_fields set). 미설정이면 (None, set()) → 기존 로직 그대로.
async def get_company_settings(self, cdb: AsyncSession, user_id):
# 이 유저가 속한 회사의 settings(JSONB) 전체를 돌려준다. 회사가 없거나 조회에 실패하면 빈 dict.
# 어떤 키를 어떻게 해석할지(목표가 정책·메일 브랜딩 등)는 호출하는 쪽 몫이다.
try:
query = (
select(companies.settings)
@@ -399,33 +401,11 @@ class QuotationCRUD(IQuotationCRUD):
)
err, rows = await DB_SESSION_MNG.execute(cdb, query)
if err != ErrorType.SUCCESS or not rows:
return None, set()
settings = rows[0] or {}
mode = (settings.get("features") or {}).get("target_price_mode")
hidden = set(settings.get("hidden_fields") or [])
return mode, hidden
return {}
return rows[0] or {}
except Exception as ex:
LOG.e_no_callstack(ex)
return None, set()
async def get_email_header(self, cdb: AsyncSession, user_id):
# 견적 소유 유저 → 회사 → companies.settings.branding.email_header. 초청 메일 헤더 브랜딩용. 없으면 None.
try:
query = (
select(companies.settings)
.select_from(users)
.join(companies, companies.company_id == users.company_id)
.where(users.user_id == user_id, companies.deleted == False) # noqa: E712
.limit(1)
)
err, rows = await DB_SESSION_MNG.execute(cdb, query)
if err != ErrorType.SUCCESS or not rows:
return None
settings = rows[0] or {}
return (settings.get("branding") or {}).get("email_header")
except Exception as ex:
LOG.e_no_callstack(ex)
return None
return {}
async def get_item_companies(self, cdb: AsyncSession, item_ids) -> Tuple[ErrorType, dict]:
"""item_id -> company_id(소유 회사) 매핑. 앵커링 칸(회사×유형×가격구간) 해석 입력."""