From bd0f39f1314ccad5bd14a5362cac50d1fc20675f Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Fri, 31 Jul 2026 10:22:51 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20negodata=C2=B7agent:=20=EB=AA=A9?= =?UTF-8?q?=ED=91=9C=EA=B0=80=20=EB=84=A4=EA=B3=A0=20=EC=A0=81=EC=9A=A9/?= =?UTF-8?q?=EB=AF=B8=EC=A0=81=EC=9A=A9=20=EC=82=B0=EC=A0=95=EA=B7=BC?= =?UTF-8?q?=EA=B1=B0=C2=B7=EC=99=80=EC=9D=BC=EB=93=9C=EC=B9=B4=EB=93=9C=20?= =?UTF-8?q?1%=2010=EC=9B=90=20=EB=B0=98=EC=98=AC=EB=A6=BC=C2=B7=ED=91=9C?= =?UTF-8?q?=20xl=20=EC=A0=84=ED=99=98=C2=B7QA=20=EC=B2=B4=ED=81=AC?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/negotiation/chat/service/chat_engine.py | 2 +- docs/negotiation-qa-checklist.md | 108 ++++++++++++++++++ .../backend/services/quotation/pricing.py | 34 +++++- .../front/src/components/ui/data-table.tsx | 7 +- .../components/QuotationCreateModal.tsx | 107 ++++++++++++++--- .../SessionsStatusTab.tsx | 6 +- .../QuotationDetailSheet/TargetPriceModal.tsx | 20 +++- .../components/QuotationDetailSheet/index.tsx | 6 +- 8 files changed, 260 insertions(+), 30 deletions(-) create mode 100644 docs/negotiation-qa-checklist.md diff --git a/agent/negotiation/chat/service/chat_engine.py b/agent/negotiation/chat/service/chat_engine.py index ff4b006..7dd4cfa 100644 --- a/agent/negotiation/chat/service/chat_engine.py +++ b/agent/negotiation/chat/service/chat_engine.py @@ -211,7 +211,7 @@ class ChatEngine: # 와일드카드는 실제로 노출할 때만 '사용됨'으로 마킹한다 — 가격협상으로 돌아가는 # 경우에도 마킹하면 이후 라운드에서 정당한 1% 카드까지 억제된다. ctx["wildcard_used"] = True - ctx["offer_1pct"] = int(round(price * 0.99)) # 1% 인하가 (멘트 변수) + ctx["offer_1pct"] = int(price * 0.99 / 10 + 0.5) * 10 # 1% 인하가 (멘트 변수) — 10원 반올림(앵커·카운터와 통일) ctx["pending_counter_price"] = ctx["offer_1pct"] # 수락 시 이 가격으로 타결 return "wild_card_1pct" # 1.02 초과 ~ entry(1.05) 구간: 견적에서 선택한 와일드카드의 전술로 카운터 제시. diff --git a/docs/negotiation-qa-checklist.md b/docs/negotiation-qa-checklist.md new file mode 100644 index 0000000..6bb2940 --- /dev/null +++ b/docs/negotiation-qa-checklist.md @@ -0,0 +1,108 @@ +# 협상 QA 체크리스트 (260727 요청 검증) + +> 대상: **negodata 어드민**(:3000) + **negosium 공급사 포털**(:3300). 두 앱을 함께 돌려야 하는 플로우라 루트 `docs/`에 둔다. +> 형식: 케이스별 `~하면 → ~나와야 한다`. 근거는 코드 검증(2026-07-30) 기준. ⚠=현재 알려진 이슈. +> 런타임 주의: negosium front/backend는 이미지 빌드라 코드 수정은 **재빌드해야 반영**된다. + +--- + +## 0. 요청사항 반영 현황 (코드 검증 결과, Excel 상태열 아님) + +| # | 요청 | 판정 | 비고 | +|---|------|------|------| +| 2 | 견적관리 리스트+히스토리·상세 | ✅ | /quotation + `?detail=` 시트(협상현황/대화/카드, 라운드 타임라인) | +| 3 | 재협상 리스트·심사 | ✅ | /renegotiation 대기/승인/반려 | +| 4 | MD→구매담당자·판매가 미노출·위치 | ✅ | | +| 5/23 | 목표가=매입가×(1−네고율) 자동 | ✅ | 재/재견적 한정, 네고율=견적세팅 목표마진 | +| 6 | 공급가=매입가 일원화 | ⚙ 설정 | 코드 지원됨(`hideCls`). IMK `hidden_fields`에 `"price"` 추가하면 매입가만 남음 | +| 7 | 최저가 크롤 + VAT산식 | ⚠ 인프라 / 논이슈 | VAT는 설정·아이템별 처리(논이슈). 단 dev의 lps-worker 크래시+수집테이블 0행 → 수집 파이프라인 확인 필요 | +| 8 | 신규 상품 공급사 입력칸 | ✅ | | +| 9 | SG명/유통레벨 콤보·취급상품 삭제 | ❌ 미구현 | §9 참조 | +| 10 | 리드타임→표준납기 | ✅ 수정 | Summary.tsx 하드코딩 라벨 회사설정 반영으로 수정(2026-07-30) | +| 11 | 단가 VAT별도 | ✅ | 회사설정 `item_vat_yn` 동적(IMK는 vat_yn hidden) | +| 12 | 앵커 10원 반올림 | ✅ | `calc_anchoring_price` + 카드 카운터(`compute_counter`) + 와일드카드 1%(2026-07-31 수정) 모두 10원 반올림 | +| 13 | 절충안 계산식 | ✅ | `compute_counter` 점검, 버그 없음 | +| 14/17 | 결렬 희망가 입력란 통일 | ✅ | 단일 RejectForm | +| 15 | 마무리 배송 콤보/기타의견/투찰요약 | ✅ | ExtraInfoBar가 session_fields select 렌더 → 콤보 [직납/IMK배송/IMK집배송] | +| 16 | 제안가 갭·반올림 | ✅ | 갭은 정상(목표가=후보 min×수수료). 봇 제안가(카운터·와일드카드 1%)도 10원 반올림 반영(2026-07-31) | +| 18/22 | 성공률 기준·결렬 무관 | ✅ | 게이지는 참고용, 판정과 무관(§D). 타결=목표가 아래로/봇 카운터 수락, 결렬=카드3+최종제안 소진까지 목표가 위 | +| 19/25 | 종료 의견 단계 | ✅ | 타결 ExtraInfoBar(custom.opinion)+결렬 RejectForm 의견 | +| 20 | 결렬사유 상시노출·필수 | ✅ 검증 | 결렬 세션 9/9 사유 존재. §20 참조 | +| 21 | 카드 3회 초과 | ✅ 정상 | 3회=협상카드 한도. 와일드카드·최종제안은 별도로 붙는 구조라 보이는 카드가 3장을 넘을 수 있음(§21) | +| 24 | 목표가 필드 1→3.낙찰기준 이동 | ✅ | | + +--- + +## A. 견적 생성 (어드민) +- **A1** 재/재견적에서 매입가 10,000·네고율(견적세팅 목표마진) 2% 입력 → 목표가(구매담당자 제시가) 필드에 **9,800 자동 채움**(10원 반올림) +- **A2** 목표가 직접 안 건드리고 생성 → `md_price=null`로 전송, 서버가 후보 최솟값으로 재산정 +- **A3** **신규**협상/신규견적 → 매입가 후보 빠지고 인터넷최저가만 사용 → 자동 목표가가 매입가 기반이 아님(A1과 다른 게 정상) +- **A4** 1.기본정보엔 목표가 없어야 / **3.낙찰기준** 스텝에 목표가+산정후보 나와야 +- **A5** 판매가 입력칸 없어야 / 라벨 "구매담당자 제시가" + +## B. 앵커·제안가 +- **B1** 협상 시작 → 세션 앵커가 = 목표가×(1−1%), **끝자리 0** (예 목표 7,650 → 앵커 7,570) +- **B2** 봇 재제안가 전부 **끝자리 0** — 카드 카운터(절충가·목표가 제시)와 **와일드카드 1% 인하가** 포함 (예 제시 15,555 → 1% 인하가 15,400). 1원 단위가 보이면 불량 + +## C. 협상 진행 (실시간 챗, 공급사 포털) +- **C1** 제시가 **≤ 앵커가** → **즉시 협상완료(투찰 확정)**, 성공률 99 +- **C2** 앵커가 < 제시가 ≤ 앵커×1.02 → **와일드카드 1% 인하 요청**(세션 1회), 성공률 99~80 +- **C3** 앵커×1.02 초과 → **일반 협상카드로 재제안(최대 3번)**, 성공률 표시(제시가 낮을수록↑) +- **C4** 카드 소진 또는 재제안 3번 후에도 앵커 밑 못 내림 → **협상 실패(결렬, 투찰 없음)** +- **C5** 카드 사용한도 3은 **협상카드에만** 적용. **와일드카드·최종제안은 별도로 붙어** 공급사가 보는 카드가 3장을 넘을 수 있음(정상, §21) +- **C6** 단가는 **VAT별도** 표기(IMK는 VAT 라벨 자체 숨김) + +## D. 타결/결렬 판정 & 성공률 게이지 +- **판정 규칙**: 유저가 **목표가 아래로 내리거나** 봇이 되받은 제시가(카운터)를 **수락하면 타결**. **카드(3장)+최종제안**까지 다 소진될 때까지 **목표가 위에서 버티면 결렬**. +- **D1** 성공률 게이지는 **참고용일 뿐 판정과 무관** — 제시가 낮을수록 게이지↑(상한 99, **100% 도달 안 함**). +- **D2** 성공률 낮아도 무조건 결렬 아님. 최종 마감(낙찰/개찰)은 별도 기준(§G). + +## E. 협상 타결(완료) 마무리 +- **E1** 협상완료 → **부가정보 입력 단계 등장** (표준납기·최소주문수량·발주배수·배송유형·의견) +- **E2** 배송유형 → **콤보 [직납/IMK배송/IMK집배송]**로 떠야 (자유입력·다른 라벨이면 불량) +- **E3** 의견(선택) 작성 → `custom.opinion` 저장돼야 +- **E4** 입력 완료 → **투찰결과 요약 갱신 후 최종 안내**, 요약에 부가정보·의견 반영 +- **E5** 어드민 상세(협상현황/요약)에서 부가정보 **표시+잠금(읽기전용)** + +## F. 협상 결렬(실패) +- **F1** 결렬 → **결렬 사유 입력 단계 항상 노출 + 필수**(견적/유형 무관 동일 폼) +- **F2** 사유 프리셋(단가인상/수량/단종/품절)+기타, **기타 선택 시 사유 텍스트 필수** +- **F3** 희망가격 입력 = **단일 폼**(RSP/CM 동일) +- **F4** 의견(선택) 작성 가능 +- **F5** 검증: 결렬(협상거부) 세션은 **100% 사유가 기록**돼야 (사유 없는 결렬 세션 = 불량). §20 + +## G. 마감 · 낙찰/개찰 +- **G1** 투찰가 ≤ 앵커가 → **낙찰** +- **G2** 앵커~목표가 → 1:1은 **사용자 지정**(mid_action), 1:N은 낙찰 +- **G3** 목표가 초과 → 1:1 **사용자 지정**(over_action, 관례 개찰), 1:N 낙찰 +- **G4** 동가(최저 2곳+)·전원 미응찰·협상거부 → **개찰**(낙찰자 미정, 결렬 아님) / 마감사유 라벨 정확히 + +## H. 재협상 요청·심사 (공급사→어드민) +- **H1** 개찰 마감 + 본인 마지막 라운드 → **재협상 요청 가능**(사유+희망가), 담당자 알림 1건 +- **H2** 낙찰건/남의 세션 요청 → **거부** +- **H3** 같은 세션 2회 요청 → 2번째 **거부**; 철회 후 재요청 가능 +- **H4** 어드민 /renegotiation 대기 탭 접수 → **승인 시 다음 차수 견적 생성**, 반려 시 사유 필수 + +--- + +## 알려진 이슈 상세 + +### §9. 협력사 SG명/유통레벨 콤보·취급상품 삭제 — 미구현 +요청 4가지 모두 현재 구조와 다르다: +1. **분류카테고리 → SG명**: 지금 '분류카테고리'는 **입력 필드가 아니라 취급상품에서 파생 집계**되는 읽기전용 값(`SupplierItemsManager.tsx`). 회사 라벨(labels.category)로 "SG명" 표기만 되지, 직접 고르는 필드가 아님. +2. **선택콤보(취급 SG명)**: 등록된 SG명 중 선택하는 콤보 없음. +3. **유통레벨 콤보(제조/총판/대리점/일반유통)**: 없음. 유사한 건 취급상품별 **공급유형** 콤보인데 값이 다름(유통/제조/총판/없음). '대리점'·'일반유통' 값 자체가 코드에 없음. IMK 설정의 `supplier_fields.distribution_level`은 콤보가 아니라 **텍스트** 커스텀 필드. +4. **취급상품 칸 삭제**: 삭제 안 됨(등록/수정폼·엑셀업로드에 그대로). +- 근본: IMK는 SG명·유통레벨을 **협력사 레벨 속성(콤보)**으로 두고 취급상품 목록은 없애길 원함. 현재는 반대로 **취급상품(supplier_items)에서 카테고리·공급유형을 파생**하는 모델. → 데이터 모델 전환이 필요한 작업. + +### §20. 결렬 사유 상시 노출·필수 — 검증 완료 +- agent의 모든 실패 경로가 단일 step `"협상실패"`(chat_end)로 수렴 → backend가 rejectRSP/CM로 무조건 매핑 → 프론트 통일 RejectForm(사유 필수). 세션 상태 분기 없음. +- 실데이터: 협상거부(status=5) 9건 **전부 reject_reason 존재**, 사유 없는 결렬 0건. +- 원 버그의 "견적마다 상이"는 *대화 중 결렬*(사유 있음) vs *미참여/마감 자동종료*(대화 자체 없음 → 사유 없음)의 구분이었을 뿐, 결렬 플로우는 일관됨. + +### §21. 카드 3회 초과 — 정상 동작(버그 아님) +`card_count=3`은 **협상카드 사용 한도**다. 와일드카드와 최종제안(종결)은 이 한도와 **별개로 각각 붙는** 구조라, 공급사가 보는 카드가 3장을 넘을 수 있다. +1. **와일드카드 1장**(1% 인하/동적 카운터) — 협상카드 카운트와 별개. +2. **최종제안 1장**(중간값 절충/최후통첩) — 카드 소진 후 마지막 국면에 별도로 붙음. + → 협상카드 3 + 와일드 1 + 최종제안 1 = 최대 5장 노출(예: EST-202607-4DB5). +- 참고(엣지): 세션에 견적세팅(card_count)이 연결 안 되면 한도가 안 걸릴 수 있으니, 설정이 항상 세션에 물리는지만 확인. diff --git a/negodata/backend/services/quotation/pricing.py b/negodata/backend/services/quotation/pricing.py index 4e81808..a31fbce 100644 --- a/negodata/backend/services/quotation/pricing.py +++ b/negodata/backend/services/quotation/pricing.py @@ -25,7 +25,12 @@ class PricingMixin: # 강등 시 딸려가는 것: quotation_settings 컬럼(날짜 SQL 파일)·세팅 화면·산정내역 표기·테스트. # 목표가 후보 basis 코드 ↔ 표시 라벨(산정내역 응답에서 프론트가 그대로 표기). - _CANDIDATE_LABELS = {"md": "구매담당자 제시가", "internet": "인터넷 최저가", "purchase": "매입가", "selling": "판매가"} + # *_raw = 네고율 미적용(원가) 변형 — 견적등록에서 네고를 끈 목표가를 역산해 근거를 가려낼 때 쓴다(적용/미적용은 프론트 sub 로 구분). + _CANDIDATE_LABELS = { + "md": "구매담당자 제시가", "internet": "인터넷 최저가", + "purchase": "매입가", "selling": "판매가", + "purchase_raw": "매입가", "selling_raw": "판매가", + } # 가격 소스별로, 회사 설정 hidden_fields 에서 쓰는 필드 이름. 숨긴 가격은 목표가 후보에서도 뺀다. _SOURCE_HIDDEN_FIELD = {"internet": "internet_lowest_price", "purchase": "purchase_price", "selling": "selling_price"} @@ -202,11 +207,30 @@ class PricingMixin: is_new = QuotationType.is_new(quotation.type) md = quotation.md_price - # 산정내역 화면은 구매담당자 제시가(md)가 있어도 후보를 다 보여준다(생성 로직과 달리 '표시용'). - # 생성 시엔 md 가 있으면 md 하나만 쓰지만(_calc_target_price), 여기선 md + 상품후보를 함께 나열해 근거를 드러낸다. + # 산정내역 화면은 저장된 목표가를 '가격 × 네고율(적용/미적용)'로 역산해 어느 근거인지 스스로 가려낸다. + # 생성 로직(_calc_target_price)은 네고 적용 후보의 최저만 쓰지만, 견적등록에서 네고를 끄면 목표가가 + # 매입가/판매가 '원가'가 된다. 그래서 원가(미적용) 변형까지 만들어 저장 목표가와 대조하고, + # 어느 후보에도 안 맞을 때만 구매담당자 제시가(md)로 간주한다. + target = int(sess.target_price) base_cands = self._candidates(None, internet, purchase, selling, fee, margin, is_new, hidden) - cands = ([("md", float(int(md)))] if md else []) + base_cands - chosen_basis = next((b for b, v in cands if int(v) == sess.target_price), None) + raw_variants = {} # {소스 basis: (원가 basis, 원가값)} — 재견적의 매입가·판매가 네고 미적용(10원 반올림) + if not is_new: + if purchase and self._SOURCE_HIDDEN_FIELD["purchase"] not in hidden: + raw_variants["purchase"] = ("purchase_raw", round(int(purchase) / 10) * 10) + if selling and self._SOURCE_HIDDEN_FIELD["selling"] not in hidden: + raw_variants["selling"] = ("selling_raw", round(int(selling) / 10) * 10) + # 채택 근거: 네고 적용 후보 → 원가(미적용) 변형 → (없으면) 구매담당자 제시가 순으로 목표가와 대조. + chosen_basis = next((b for b, v in base_cands if int(v) == target), None) + if chosen_basis is None: + chosen_basis = next((rb for _s, (rb, rv) in raw_variants.items() if rv == target), None) + if chosen_basis is None and md: + chosen_basis = "md" + # 화면 후보 — 소스별 1행. 채택이 원가 변형이면 그 소스를 원가로 바꿔 '네고율 미적용'으로 표기. + # 어느 상품후보에도 안 맞아 md 로 간주된 경우에만 구매담당자 제시가 행을 앞세운다. + cands = [("md", float(int(md)))] if md and chosen_basis == "md" else [] + for b, v in base_cands: + raw = raw_variants.get(b) + cands.append(raw if raw and raw[0] == chosen_basis else (b, int(v))) is_inherited = chosen_basis is None res.is_new = is_new diff --git a/negodata/front/src/components/ui/data-table.tsx b/negodata/front/src/components/ui/data-table.tsx index bbb4eff..702b261 100644 --- a/negodata/front/src/components/ui/data-table.tsx +++ b/negodata/front/src/components/ui/data-table.tsx @@ -12,7 +12,8 @@ import { // 컬럼 설정형 데이터 테이블. 래퍼/헤더/행/빈상태/정렬·패딩, 그리고 행 선택(체크박스)까지 // 여기서 책임지고, 페이지는 컬럼 정의(header/cell)와 선택 상태만 넘긴다. 표 룩의 단일 출처. -// md 미만(모바일)에서는 같은 컬럼 정의로 카드(라벨:값) 리스트를 렌더해 가로 스크롤을 없앤다. +// xl 미만(모바일~태블릿)에서는 같은 컬럼 정의로 카드(라벨:값) 리스트를 렌더해 가로 스크롤/잘림을 없앤다. +// (표는 컬럼이 많아 태블릿 가로폭에서 넘쳐 잘리므로, 데스크톱 xl+ 에서만 표로 보여준다.) export type Column = { id?: string header: ReactNode @@ -98,7 +99,7 @@ export function DataTable({ return (
-
+
@@ -182,7 +183,7 @@ export function DataTable({
-
+
{data.length > 0 ? ( data.map((row) => { const key = rowKey(row) diff --git a/negodata/front/src/features/quotations/components/QuotationCreateModal.tsx b/negodata/front/src/features/quotations/components/QuotationCreateModal.tsx index 98c5332..b4d7e4b 100644 --- a/negodata/front/src/features/quotations/components/QuotationCreateModal.tsx +++ b/negodata/front/src/features/quotations/components/QuotationCreateModal.tsx @@ -97,6 +97,11 @@ export function QuotationCreateModal({ const [overAction, setOverAction] = useState(DEFAULT_OVER_ACTION); // 목표가 초과 구간: 낙찰/개찰 (1:1 전용) const [submitting, setSubmitting] = useState(false); const [mdTouched, setMdTouched] = useState(false); // 담당자가 제시가를 직접 건드렸는지 — 안 건드렸으면 자동 산출값을 채운다 + // 매입가 네고율 차감 — 이 견적에서만 조정. 안 건드리면 세팅 기본값을 따른다(negoTouched=false). 네고율 값 자체는 세팅값 고정. + const [negoTouched, setNegoTouched] = useState(false); + const [applyNego, setApplyNego] = useState(false); // 매입가에서 네고율 차감 여부 + // 목표가로 채택한 후보 키 — null이면 최저 후보를 기본 채택. + const [selectedCandidateKey, setSelectedCandidateKey] = useState(null); const type = toQuotationType(mode, isNew); // 4코드 합성값 const oneToOne = is1v1(type); // 1:1 협상 여부 — 협력사 단일선택·낙찰기준·협상카드 노출을 가른다 @@ -109,6 +114,13 @@ export function QuotationCreateModal({ const navigate = useNavigate(); + // 세팅 목록은 비동기 도착 — useState 초기값은 최초 마운트 때 목록이 비어 있으면 ''로 굳는다. + // 목록이 채워지면 기본(첫) 세팅을 선택하고, 이미 유효한 선택은 유지한다. + useEffect(() => { + if (quotationSettings.length === 0) return; + setSettingId((prev) => (prev && quotationSettings.some((s) => s.qt_setting_id === prev) ? prev : quotationSettings[0].qt_setting_id)); + }, [quotationSettings]); + // ── 픽리스트 서버검색(상품/협력사/카드) — size 캡 없이 검색으로 도달. 미검색이면 부모가 넘긴 목록으로 기본 노출. const [productQ, setProductQ] = useState(''); const [productLabel, setProductLabel] = useState(''); @@ -263,26 +275,50 @@ export function QuotationCreateModal({ return { id, code: d?.code ?? '', title: d?.title ?? id, isWildcard: d?.isWildcard ?? false }; }); const selectedSetting = quotationSettings.find((s) => s.qt_setting_id === settingId); - const margin = parsePercent(selectedSetting?.target_margin); + const settingMargin = parsePercent(selectedSetting?.target_margin); // 세팅 네고율(비율) + const settingMarginPct = +(settingMargin * 100).toFixed(1); + // 매입가 네고율 차감 여부 — 안 건드리면 세팅값(>0이면 차감), 건드리면 체크박스값. 네고율 값은 세팅값 고정. + const negoAvailable = settingMargin > 0; + const effectiveApplyNego = negoTouched ? applyNego : negoAvailable; + const margin = effectiveApplyNego ? settingMargin : 0; // 미적용이면 0 → 매입가/판매가 그대로 + const negoLabel = (base: string) => + margin > 0 ? `${base} × (1−네고율 ${+(margin * 100).toFixed(1)}%)` : `${base} (네고율 미적용)`; // 목표가 산정 후보(계산식+결과값) — 인터넷최저가×(1−수수료)·매입가/판매가×(1−네고율). 회사설정 숨김필드는 제외(백엔드와 동일). const targetBreakdown = [ { key: 'internet_lowest_price', label: `${label('item.internet_lowest_price')} × (1−수수료 ${+(INTERNET_AVERAGE_FEE * 100).toFixed(1)}%)`, raw: internetLowest, rate: INTERNET_AVERAGE_FEE, show: internetLowest != null }, - { key: 'purchase_price', label: `${label('item.purchase_price')} × (1−네고율 ${+(margin * 100).toFixed(1)}%)`, raw: purchase, rate: margin, show: isReType && purchase != null }, - { key: 'selling_price', label: `${label('item.selling_price')} × (1−네고율 ${+(margin * 100).toFixed(1)}%)`, raw: selling, rate: margin, show: isReType && selling != null }, + { key: 'purchase_price', label: negoLabel(label('item.purchase_price')), raw: purchase, rate: margin, show: isReType && purchase != null }, + { key: 'selling_price', label: negoLabel(label('item.selling_price')), raw: selling, rate: margin, show: isReType && selling != null }, ] .filter((c) => c.show && c.raw != null && c.raw > 0 && !isHidden(c.key)) // 서버 _candidates 와 동일하게 10원 단위 반올림(IMK #11) — 후보·목표가·저장값이 다 일치. .map((c) => ({ key: c.key, label: c.label, raw: c.raw as number, value: Math.round(((c.raw as number) * (1 - c.rate)) / 10) * 10 })); const autoTarget = targetBreakdown.length ? Math.min(...targetBreakdown.map((c) => c.value)) : null; - // 구매담당자 제시가 필드엔 자동 산출값을 미리 보여주되(IMK #4), 담당자가 직접 건드렸을 때만 md_price 로 전송한다. + // 기본 채택 후보 = 최저(동률이면 첫 후보). 네고율 체크박스는 매입가 후보(없으면 판매가)에 붙인다. + const minCandidateKey = targetBreakdown.find((c) => c.value === autoTarget)?.key ?? null; + const negoCandidateKey = negoAvailable + ? (targetBreakdown.find((c) => c.key === 'purchase_price')?.key ?? targetBreakdown.find((c) => c.key === 'selling_price')?.key ?? null) + : null; + // 채택 후보 — 사용자가 고르면 그 후보, 아니면 최저. 상품 변경 등으로 선택 키가 사라지면 최저로 폴백. + const pickedCandidate = selectedCandidateKey ? targetBreakdown.find((c) => c.key === selectedCandidateKey) : undefined; + const activeCandidateKey = pickedCandidate ? pickedCandidate.key : minCandidateKey; + const targetFromCandidate = pickedCandidate ? pickedCandidate.value : autoTarget; + // 구매담당자 제시가 필드엔 채택 후보값을 미리 보여주되(IMK #4), 담당자가 직접 건드렸을 때만 md_price 로 전송한다. // (자동값을 md 로 보내면 서버가 'MD 입력가'로 저장해 산정내역이 매입가 대신 MD로 잡히고 후보가 안 보인다.) - const effectiveMdPrice = mdTouched ? mdPrice : (autoTarget != null ? String(autoTarget) : mdPrice); + const effectiveMdPrice = mdTouched ? mdPrice : (targetFromCandidate != null ? String(targetFromCandidate) : mdPrice); const mdNum = Number(effectiveMdPrice) || 0; + // 기본(최저·세팅네고)에서 벗어난 선택/토글이면 그 목표가를 md_price 로 박아 서버 저장값과 화면을 일치시킨다. + // (서버는 세팅 rate·최저로 재계산하므로, 오버라이드를 안 보내면 후보 화면과 저장 목표가가 어긋난다.) + const divergedFromDefault = negoTouched || (!!pickedCandidate && pickedCandidate.key !== minCandidateKey); + const submitMdPrice = mdTouched && mdPrice + ? Number(mdPrice) + : divergedFromDefault && targetFromCandidate != null + ? targetFromCandidate + : null; const hasItemCandidate = internetLowest != null || (isReType && (purchase != null || selling != null)); const mdRequired = !!productId && !hasItemCandidate; const targetReady = mdNum > 0 || hasItemCandidate; - // 최종 목표가 = 제시가(자동/수동) 있으면 그 값, 없으면 자동 산출값. - const estimatedTargetPrice = mdNum > 0 ? mdNum : autoTarget; + // 최종 목표가 = 제시가(자동/수동) 있으면 그 값, 없으면 채택 후보값. + const estimatedTargetPrice = mdNum > 0 ? mdNum : targetFromCandidate; const targetPriceLimit = unitPrice != null && unitPrice > 0 ? unitPrice * TARGET_PRICE_UNIT_LIMIT_MULTIPLIER : null; @@ -327,6 +363,12 @@ export function QuotationCreateModal({ setSelectedCardIds((prev) => [...new Set([...prev, ...rows.map((r) => r.id)])]); }; const clearAllCards = () => setSelectedCardIds([]); + // 후보 택1 — 그 후보값이 목표가로 들어가게 md 직접입력 오버라이드를 해제한다. + const selectCandidate = (key: string) => { + setSelectedCandidateKey(key); + setMdTouched(false); + setMdPrice(''); + }; const handleSubmit = async () => { if (submitting) return; @@ -355,7 +397,7 @@ export function QuotationCreateModal({ settingId, cardIds: oneToOne ? selectedCardIds : [], memo, - mdPrice: mdTouched && mdPrice ? Number(mdPrice) : null, + mdPrice: submitMdPrice, midAction: oneToOne ? midAction : undefined, overAction: oneToOne ? overAction : undefined, }); @@ -563,7 +605,7 @@ export function QuotationCreateModal({
)} - {/* 목표가 산정 후보(계산식+결과값) — 참고용, 위. 채택된 최저는 녹색 강조. */} + {/* 목표가 산정 후보 — 후보 택1로 목표가 결정(기본=최저). 매입가 후보 행의 체크박스로 네고율 차감 여부 조정. 숨김필드는 제외. */} {productId && targetBreakdown.length > 0 && (
@@ -578,14 +620,53 @@ export function QuotationCreateModal({ 상품 상세에서 수정
-
+ + 후보를 선택하면 그 값이 목표가로 정해집니다 (기본: 최저). + +
{targetBreakdown.map((c) => { const isMin = autoTarget != null && c.value === autoTarget; + const isActive = c.key === activeCandidateKey; + const showNego = c.key === negoCandidateKey; return ( -
+
selectCandidate(c.key)} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + selectCandidate(c.key); + } + }} + className={cn( + 'flex items-center gap-2 rounded px-2 py-1.5 cursor-pointer transition-colors', + isActive ? 'bg-primary/5 ring-1 ring-inset ring-primary' : 'hover:bg-muted/40', + )} + > + {/* 라디오 표시 */} + + {isActive && } + {c.label} + {showNego && ( + + )} {c.raw.toLocaleString()} - ₩{c.value.toLocaleString()} + ₩{c.value.toLocaleString()} {isMin && 최저} @@ -615,7 +696,7 @@ export function QuotationCreateModal({ /> {autoTarget != null - ? '후보 중 최저가 자동 입력됨 · 이 값이 목표가(1순위)로 쓰입니다. 수정 가능.' + ? '위에서 선택한 후보값이 목표가(1순위)로 입력됩니다. 수정 가능.' : '자동 산출값이 없어 직접 입력이 필요합니다.'} {!targetReady && ( diff --git a/negodata/front/src/features/quotations/components/QuotationDetailSheet/SessionsStatusTab.tsx b/negodata/front/src/features/quotations/components/QuotationDetailSheet/SessionsStatusTab.tsx index e11cc1a..dcba4f1 100644 --- a/negodata/front/src/features/quotations/components/QuotationDetailSheet/SessionsStatusTab.tsx +++ b/negodata/front/src/features/quotations/components/QuotationDetailSheet/SessionsStatusTab.tsx @@ -165,7 +165,7 @@ export function SessionsStatusTab({
)} -
+
@@ -347,8 +347,8 @@ export function SessionsStatusTab({
- {/* 모바일·태블릿: 13컬럼 표 대신 세션당 카드 한 장(목록 화면들과 같은 전환 기준 lg) */} -
+ {/* 모바일·태블릿: 13컬럼 표(min-w 1250px)는 태블릿 가로폭에서 넘쳐 잘리므로 세션당 카드로 — 목록 화면들과 같은 전환 기준 xl */} +
{sessionViews.length === 0 && ( 참여 중인 협상 세션이 없습니다. diff --git a/negodata/front/src/features/quotations/components/QuotationDetailSheet/TargetPriceModal.tsx b/negodata/front/src/features/quotations/components/QuotationDetailSheet/TargetPriceModal.tsx index e46455b..9d81ec5 100644 --- a/negodata/front/src/features/quotations/components/QuotationDetailSheet/TargetPriceModal.tsx +++ b/negodata/front/src/features/quotations/components/QuotationDetailSheet/TargetPriceModal.tsx @@ -24,6 +24,8 @@ const candidateSub = (marginLabel: string): Record => ({ internet: '인터넷 평균 수수료 적용', purchase: `${marginLabel} 적용`, selling: `${marginLabel} 적용`, + purchase_raw: `${marginLabel} 미적용`, + selling_raw: `${marginLabel} 미적용`, }); export function TargetPriceModal({ @@ -79,7 +81,7 @@ export function TargetPriceModal({
- {/* 선정방식 */} + {/* 선정방식 — 목표가가 어느 후보들 중에서 산정되는지 설명. 매입가·판매가는 견적등록 네고율 적용/미적용에 따라 원가일 수 있어 문구에 반영. */}
목표가 선정방식 1. 구매담당자 제시가 존재 시, 최우선 적용 @@ -87,10 +89,22 @@ export function TargetPriceModal({ 2. 다음 중 가장 작은 값 — {[ !hiddenPrice.includes('internet_lowest_price') && `${label('item.internet_lowest_price')}×(1−수수료)`, - !hiddenPrice.includes('purchase_price') && `${label('item.purchase_price')}×(1−${label('target_margin')})`, - !hiddenPrice.includes('selling_price') && `${label('item.selling_price')}×(1−${label('target_margin')})`, + !hiddenPrice.includes('purchase_price') && `${label('item.purchase_price')}×(1−${label('target_margin')}) 또는 원가`, + !hiddenPrice.includes('selling_price') && `${label('item.selling_price')}×(1−${label('target_margin')}) 또는 원가`, ].filter(Boolean).join(' | ')} + {/* 네고 적용/미적용 안내 — 숨김 안 된 매입가·판매가만 언급(신규견적은 인터넷최저가만이라 생략). */} + {!bd.is_new && (() => { + const negoSources = [ + !hiddenPrice.includes('purchase_price') && label('item.purchase_price'), + !hiddenPrice.includes('selling_price') && label('item.selling_price'), + ].filter(Boolean); + return negoSources.length > 0 ? ( + + * {negoSources.join('·')}는 견적등록의 네고율 적용 여부에 따라 원가(미적용)로도 산정됩니다. + + ) : null; + })()} * 인터넷 평균 수수료: {bd.fee} · {label('target_margin')}: {bd.margin}{bd.is_new ? ' · 신규견적이라 인터넷최저가만 적용' : ''} diff --git a/negodata/front/src/features/quotations/components/QuotationDetailSheet/index.tsx b/negodata/front/src/features/quotations/components/QuotationDetailSheet/index.tsx index c002578..ff20e98 100644 --- a/negodata/front/src/features/quotations/components/QuotationDetailSheet/index.tsx +++ b/negodata/front/src/features/quotations/components/QuotationDetailSheet/index.tsx @@ -152,13 +152,15 @@ export function QuotationDetailSheet({ // 부모로 체이닝돼 모바일에서 뒤 화면이 스크롤된다. return createPortal(
- {/* 백드롭(어두운 영역) — 클릭 시 닫힘. 좌상단에 뒤로가기(직전 화면 히스토리 back). 모바일(md 미만)에서는 숨김 */} + {/* 백드롭(어두운 영역) — 클릭 시 닫힘. 좌상단에 뒤로가기(직전 화면 히스토리 back). + 패널이 w-full max-w-5xl(64rem/1024px)이라 뷰포트<1024px에선 패널이 폭을 다 먹고 백드롭이 0이 됨. + 그때 absolute 뒤로버튼이 패널 위로 겹치므로, 백드롭에 버튼 여유폭이 남는 1152px+에서만 노출(태블릿 폭에선 숨김). */}