[feat] negodata: 낙찰 방식 구분(자동/직접) + 계약가·사유 저장 위치 재정리
직접 낙찰(담당자 오프라인 계약가)을 AI 자동 낙찰과 통계·화면에서 구분하기 위해
낙찰 방식을 전용 컬럼으로 박고, 계약가·사유를 성격대로 배치했다. 처음엔 계약가·사유를
sessions.custom.offline_award(JSONB) 한 뭉치에 넣었으나 성격이 갈려 정리한다.
DB (postgres-init: init.sql 정본 + alters/2026-08-11-award-type.sql 보정, 멱등)
- quotations.award_type SMALLINT — 낙찰 방식(1=자동/2=직접). 통계 조회·집계 축이라 컬럼
- quotations.custom JSONB — 직접 낙찰 사유·처리자·시각(award={reason,by,at}). 표시·감사용
- sessions.contract_price BIGINT — 직접 낙찰 계약가. bid_price/reject_price 와 같은 협력사
가격 축이라 세션에. 자동 낙찰은 NULL(투찰가가 곧 계약가)
- 기존 offline_award(JSONB) 데이터를 컬럼·견적 custom 으로 이관 후 키 제거
backend
- 자동 낙찰(close_and_decide)=AUTO, 직접 낙찰(claim_for_award)=MANUAL 로 award_type 기록
- 직접 낙찰: 계약가→세션 contract_price, 사유·처리자·시각→견적 custom.award (한 트랜잭션)
- 통계 계약가 = coalesce(contract_price, bid_price) — JSONB 캐스팅 제거(컬럼끼리, 인덱스·타입 안전)
- QuotationData 에 award_type·custom, SessionData 에 contract_price 노출
- 안 쓰게 된 merge_session_custom 제거
front
- 견적 상세 결과 밴드에 '직접 낙찰' 배지 + 낙찰 사유 표시(견적 custom.award.reason).
거부·미참여 낙찰은 이미 직접 낙찰을 함의하므로 '— 낙찰' 꼬리를 떼 중복 표기 제거
- 목록 결과 배지에 '낙찰(직접)' 표기 — AI 자동낙찰과 한눈에 구분
- offlineAward()→directAwardPrice()/awardMeta() 로 교체(세션 컬럼·견적 custom 에서 읽음)
- 협상현황 표: 부가정보(회사 필드)와 의견(custom.opinion)을 별도 컬럼으로 분리
- 미응찰 건 레일 4번 칸 라벨 '최저 투찰가'→'결과'(투찰 없을 때)
테스트: negodata 110건 통과. 프론트 tsc+eslint 통과. dev DB 적용·화면 확인.
This commit is contained in:
1 parent
6eb4dc26f8
commit
0e4ddf0f43
22 files changed
+292
-63
No files matched your search
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* quotations.award_type 코드값(SMALLINT). 낙찰이 어떻게 확정됐는지 — 통계에서 AI 협상 성과와
|
||||
담당자 오프라인 낙찰을 나눈다. 미마감·미낙찰(개찰)이면 NULL.
|
||||
AUTO=시스템이 투찰가로 자동 낙찰 / MANUAL=담당자가 개찰 건을 오프라인 협상해 계약가로 직접 낙찰.
|
||||
*/
|
||||
export type AwardType = typeof AwardType[keyof typeof AwardType];
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
export const AwardType = {
|
||||
AUTO: 1,
|
||||
MANUAL: 2,
|
||||
} as const;
|
||||
@@ -9,6 +9,7 @@ export * from './anchoringCell';
|
||||
export * from './anchoringCellLastAdjustedAt';
|
||||
export * from './anchoringHistoryRow';
|
||||
export * from './anchoringHistoryRowCreatedAt';
|
||||
export * from './awardType';
|
||||
export * from './bodyUploadItemImageV1ItemImagePost';
|
||||
export * from './cardData';
|
||||
export * from './cardDataCondition';
|
||||
@@ -126,9 +127,12 @@ export * from './quotationCardDataScript';
|
||||
export * from './quotationCardDataType';
|
||||
export * from './quotationCardDataWildCardId';
|
||||
export * from './quotationData';
|
||||
export * from './quotationDataAwardType';
|
||||
export * from './quotationDataCloseReason';
|
||||
export * from './quotationDataCreatedAt';
|
||||
export * from './quotationDataCreatorName';
|
||||
export * from './quotationDataCustom';
|
||||
export * from './quotationDataCustomAnyOf';
|
||||
export * from './quotationDataDoneCeilingRate';
|
||||
export * from './quotationDataEqualBidData';
|
||||
export * from './quotationDataEqualBidYn';
|
||||
@@ -434,6 +438,7 @@ export * from './sessionData';
|
||||
export * from './sessionDataAnchoringPrice';
|
||||
export * from './sessionDataBidAt';
|
||||
export * from './sessionDataBidPrice';
|
||||
export * from './sessionDataContractPrice';
|
||||
export * from './sessionDataCustom';
|
||||
export * from './sessionDataCustomAnyOf';
|
||||
export * from './sessionDataDoneCeilingPrice';
|
||||
|
||||
@@ -17,6 +17,8 @@ import type { QuotationDataPreferredSpName } from './quotationDataPreferredSpNam
|
||||
import type { QuotationDataEqualBidYn } from './quotationDataEqualBidYn';
|
||||
import type { QuotationDataEqualBidData } from './quotationDataEqualBidData';
|
||||
import type { QuotationDataCloseReason } from './quotationDataCloseReason';
|
||||
import type { QuotationDataAwardType } from './quotationDataAwardType';
|
||||
import type { QuotationDataCustom } from './quotationDataCustom';
|
||||
import type { QuotationDataMidAction } from './quotationDataMidAction';
|
||||
import type { QuotationDataOverAction } from './quotationDataOverAction';
|
||||
import type { QuotationDataDoneCeilingRate } from './quotationDataDoneCeilingRate';
|
||||
@@ -50,6 +52,8 @@ export interface QuotationData {
|
||||
equal_bid_yn?: QuotationDataEqualBidYn;
|
||||
equal_bid_data?: QuotationDataEqualBidData;
|
||||
close_reason?: QuotationDataCloseReason;
|
||||
award_type?: QuotationDataAwardType;
|
||||
custom?: QuotationDataCustom;
|
||||
mid_action?: QuotationDataMidAction;
|
||||
over_action?: QuotationDataOverAction;
|
||||
done_ceiling_rate?: QuotationDataDoneCeilingRate;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { AwardType } from './awardType';
|
||||
|
||||
export type QuotationDataAwardType = AwardType | null;
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { QuotationDataCustomAnyOf } from './quotationDataCustomAnyOf';
|
||||
|
||||
export type QuotationDataCustom = QuotationDataCustomAnyOf | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type QuotationDataCustomAnyOf = { [key: string]: unknown };
|
||||
@@ -13,6 +13,7 @@ import type { SessionDataBidAt } from './sessionDataBidAt';
|
||||
import type { SessionDataRejectReason } from './sessionDataRejectReason';
|
||||
import type { SessionDataRejectPrice } from './sessionDataRejectPrice';
|
||||
import type { SessionDataRejectDeliveryType } from './sessionDataRejectDeliveryType';
|
||||
import type { SessionDataContractPrice } from './sessionDataContractPrice';
|
||||
import type { SessionDataEmailSentAt } from './sessionDataEmailSentAt';
|
||||
import type { SessionDataCustom } from './sessionDataCustom';
|
||||
|
||||
@@ -34,6 +35,7 @@ export interface SessionData {
|
||||
reject_reason?: SessionDataRejectReason;
|
||||
reject_price?: SessionDataRejectPrice;
|
||||
reject_delivery_type?: SessionDataRejectDeliveryType;
|
||||
contract_price?: SessionDataContractPrice;
|
||||
email_sent_at?: SessionDataEmailSentAt;
|
||||
custom?: SessionDataCustom;
|
||||
url?: string;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type SessionDataContractPrice = number | null;
|
||||
+25
-4
@@ -1,10 +1,11 @@
|
||||
import { BadgeCheck } from 'lucide-react';
|
||||
import { BadgeCheck, Gavel } from 'lucide-react';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import type { QuotationData } from '@/api/generated/model/quotationData';
|
||||
import { StatusPill, sessionStatusTone, type PillTone } from './StatusPill';
|
||||
import { PricingSpectrum, type SpectrumBid } from './PricingSpectrum';
|
||||
import { SessionStatus } from '@/api/generated/model';
|
||||
import { AwardType, SessionStatus } from '@/api/generated/model';
|
||||
import {
|
||||
awardMeta,
|
||||
awardPrice,
|
||||
buildQuotationResult,
|
||||
ceilingPriceOf,
|
||||
@@ -42,6 +43,9 @@ export function ResultSummaryBand({
|
||||
// 1:1 은 협력사가 하나라 그 세션이 곧 이 협상이다(세션이 여럿이면 대표를 세우지 않는다).
|
||||
const oneToOne = is1v1(quotation.type);
|
||||
const solo = oneToOne && sessionViews.length === 1 ? sessionViews[0] : null;
|
||||
// 직접 낙찰 배지(담당자 오프라인 계약가)는 낙찰 방식이 MANUAL 이면 항상 보여준다 — 이게 핵심 정보다.
|
||||
const showManualBadge = quotation.award_type === AwardType.MANUAL;
|
||||
const reason = awardMeta(quotation)?.reason ?? '';
|
||||
|
||||
// 가격을 제출한 협력사만 점으로. 낙찰자는 강조.
|
||||
const bids: SpectrumBid[] = sessionViews.flatMap((s) => {
|
||||
@@ -71,7 +75,8 @@ export function ResultSummaryBand({
|
||||
: OUTCOME_TONE[r.outcome]
|
||||
}
|
||||
>
|
||||
{r.outcome === 'active'
|
||||
{/* 직접 낙찰 배지가 따로 '낙찰'을 말하므로, 그때는 '— 낙찰' 꼬리를 떼고 세션 상태만 둔다(중복 방지). */}
|
||||
{r.outcome === 'active' || showManualBadge
|
||||
? sessionStatusLabel(solo.status)
|
||||
: `${sessionStatusLabel(solo.status)} — ${CHAIN_ROUND_STATE_LABEL[r.outcome]}`}
|
||||
</StatusPill>
|
||||
@@ -91,11 +96,27 @@ export function ResultSummaryBand({
|
||||
</Typography>
|
||||
) : (
|
||||
<Typography as="p" variant="small" className="min-w-0 truncate text-[12px] font-bold">
|
||||
{r.closeReason}
|
||||
{/* 옆의 결과 배지가 이미 '개찰'을 말하므로 사유 텍스트의 '— 개찰' 꼬리는 뗀다(예: '전원 미응찰 — 개찰' → '전원 미응찰'). */}
|
||||
{r.closeReason.replace(/\s*—\s*개찰.*$/, '')}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
{/* 직접 낙찰(담당자 오프라인 계약가) — AI 자동 낙찰과 구분해 표시. 자동 낙찰엔 배지 없음. */}
|
||||
{showManualBadge && (
|
||||
<StatusPill tone="blue" className="gap-1">
|
||||
<Gavel size={11} />
|
||||
직접 낙찰
|
||||
</StatusPill>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 직접 낙찰 사유(견적 custom.award.reason) — 왜 이 협력사를 오프라인으로 낙찰했는지 근거. */}
|
||||
{showManualBadge && reason && (
|
||||
<Typography as="p" variant="caption" className="text-[11px] text-muted-foreground">
|
||||
낙찰 사유 · {reason}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<PricingSpectrum
|
||||
targetPrice={r.targetPrice}
|
||||
ceilingPrice={ceilingPriceOf(rep, ceilingRate)}
|
||||
|
||||
+27
-10
@@ -10,7 +10,7 @@ import { SessionStatus } from '@/api/generated/model';
|
||||
import { Tooltip, TooltipTrigger, TooltipContent } from '@/components/ui/tooltip';
|
||||
import { StatusPill, sessionStatusTone } from './StatusPill';
|
||||
import { AwardModal } from './AwardModal';
|
||||
import { awardPrice, offlineAward, mapServerSessionView, sessionStatusLabel } from '../../types';
|
||||
import { awardPrice, directAwardPrice, mapServerSessionView, sessionStatusLabel } from '../../types';
|
||||
import { useCompanySettings } from '@/features/settings/useCompanySettings';
|
||||
|
||||
type SessionView = ReturnType<typeof mapServerSessionView>;
|
||||
@@ -43,15 +43,15 @@ export function SessionsStatusTab({
|
||||
const { settings } = useCompanySettings();
|
||||
const sessionFields = settings.session_fields ?? [];
|
||||
const [extraSession, setExtraSession] = useState<SessionView | null>(null);
|
||||
// 부가정보 = 회사가 정의한 필드(session_fields)만. 협상완료 세션이 입력한다.
|
||||
const extraRows = (sv: SessionView | null) => {
|
||||
const custom = sv?.custom as Record<string, unknown> | undefined;
|
||||
const rows = sessionFields
|
||||
return sessionFields
|
||||
.map((f) => ({ label: f.label, value: custom?.[f.key] }))
|
||||
.filter((r) => r.value !== undefined && r.value !== null && r.value !== '');
|
||||
// 의견은 회사설정과 무관한 내장 공통 필드(custom.opinion) — 값 있으면 항상 표시
|
||||
if (custom?.opinion) rows.push({ label: '의견', value: custom.opinion });
|
||||
return rows;
|
||||
};
|
||||
// 의견은 회사설정과 무관한 공통 필드(custom.opinion) — 완료·거부 어느 쪽이든 남긴다. 부가정보와 별개 컬럼.
|
||||
const opinionOf = (sv: SessionView | null): string => String((sv?.custom as Record<string, unknown> | undefined)?.opinion ?? '');
|
||||
const [sendingAll, setSendingAll] = useState(false);
|
||||
const [sendingId, setSendingId] = useState<string | null>(null);
|
||||
const [selectedWinnerId, setSelectedWinnerId] = useState<string | null>(null);
|
||||
@@ -183,6 +183,7 @@ export function SessionsStatusTab({
|
||||
<TableHead className="p-3 font-semibold text-right">거부가격</TableHead>
|
||||
<TableHead className="p-3 font-semibold font-sans">거부배송방식</TableHead>
|
||||
<TableHead className="p-3 font-semibold font-sans">부가정보</TableHead>
|
||||
<TableHead className="p-3 font-semibold font-sans">의견</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody className="divide-y divide-border">
|
||||
@@ -332,9 +333,9 @@ export function SessionsStatusTab({
|
||||
</TableCell>
|
||||
<TableCell className="p-3 text-right font-bold text-foreground">
|
||||
{sess.bid_price ? `₩${sess.bid_price.toLocaleString()}` : '-'}
|
||||
{offlineAward(sess) && (
|
||||
{directAwardPrice(sess) != null && (
|
||||
<Typography as="span" variant="caption" className="block text-[10px] font-bold text-success">
|
||||
계약 ₩{offlineAward(sess)!.price.toLocaleString()}
|
||||
계약 ₩{directAwardPrice(sess)!.toLocaleString()}
|
||||
</Typography>
|
||||
)}
|
||||
</TableCell>
|
||||
@@ -350,6 +351,15 @@ export function SessionsStatusTab({
|
||||
<TableCell className="p-3 font-sans">
|
||||
<ExtraInfoCell rows={extraRows(sess)} onOpen={() => setExtraSession(sess)} />
|
||||
</TableCell>
|
||||
<TableCell className="p-3 font-sans text-muted-foreground">
|
||||
{opinionOf(sess) ? (
|
||||
<span className="block max-w-[220px] truncate" title={opinionOf(sess)}>
|
||||
{opinionOf(sess)}
|
||||
</span>
|
||||
) : (
|
||||
'-'
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
@@ -380,13 +390,14 @@ export function SessionsStatusTab({
|
||||
if (sess.reject_reason) rows.push({ label: '거부사유', value: sess.reject_reason });
|
||||
if (sess.reject_price) rows.push({ label: '거부가격', value: `₩${sess.reject_price.toLocaleString()}` });
|
||||
if (sess.reject_delivery_type) rows.push({ label: '거부배송방식', value: sess.reject_delivery_type });
|
||||
const offline = offlineAward(sess);
|
||||
if (offline) rows.push({ label: '계약가(오프라인)', value: `₩${offline.price.toLocaleString()}` });
|
||||
const contract = directAwardPrice(sess);
|
||||
if (contract != null) rows.push({ label: '계약가(오프라인)', value: `₩${contract.toLocaleString()}` });
|
||||
if (showEndTimeCol) rows.push({ label: '마감시각', value: sess.end_time || '-' });
|
||||
const extras = extraRows(sess);
|
||||
if (extras.length > 0) {
|
||||
rows.push({ label: '부가정보', value: extras.map((r) => `${r.label} ${String(r.value)}`).join(' · ') });
|
||||
}
|
||||
if (opinionOf(sess)) rows.push({ label: '의견', value: opinionOf(sess) });
|
||||
return (
|
||||
<div key={sess.session_id} className={cn('p-3', isWinner && 'bg-success/10')}>
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -487,7 +498,7 @@ export function SessionsStatusTab({
|
||||
</button>
|
||||
</div>
|
||||
<Typography as="p" variant="muted" className="text-[11px] mb-3">{extraSession.supplier_name}</Typography>
|
||||
{extraRows(extraSession).length > 0 ? (
|
||||
{extraRows(extraSession).length > 0 || opinionOf(extraSession) ? (
|
||||
<div className="divide-y divide-border/60">
|
||||
{extraRows(extraSession).map((r) => (
|
||||
<div key={r.label} className="flex items-center justify-between py-2 text-xs">
|
||||
@@ -495,6 +506,12 @@ export function SessionsStatusTab({
|
||||
<span className="font-semibold text-foreground">{String(r.value)}</span>
|
||||
</div>
|
||||
))}
|
||||
{opinionOf(extraSession) && (
|
||||
<div className="flex items-start justify-between gap-3 py-2 text-xs">
|
||||
<span className="shrink-0 text-muted-foreground">의견</span>
|
||||
<span className="whitespace-pre-wrap text-right font-semibold text-foreground">{opinionOf(extraSession)}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<Typography as="p" variant="small" className="py-4 text-center text-muted-foreground text-xs">입력된 부가정보가 없습니다.</Typography>
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
is1v1,
|
||||
CHAIN_ROUND_STATE_LABEL,
|
||||
} from '../types';
|
||||
import { QuotationStatus } from '@/api/generated/model';
|
||||
import { AwardType, QuotationStatus } from '@/api/generated/model';
|
||||
|
||||
type QuotationTableProps = {
|
||||
data: Estimate[];
|
||||
@@ -153,6 +153,8 @@ export function QuotationTable({ data, products, onOpenDetail, onFilterChain, se
|
||||
cell: (est) => {
|
||||
const state = chainRoundState(est);
|
||||
const winner = state === 'awarded' ? est.preferred_sp_name : null;
|
||||
// 담당자 오프라인 직접 낙찰이면 표시 — 목록에서 AI 자동낙찰과 한눈에 갈린다.
|
||||
const manual = state === 'awarded' && est.award_type === AwardType.MANUAL;
|
||||
return (
|
||||
<Typography
|
||||
as="span"
|
||||
@@ -162,6 +164,7 @@ export function QuotationTable({ data, products, onOpenDetail, onFilterChain, se
|
||||
>
|
||||
<span className="truncate">
|
||||
{CHAIN_ROUND_STATE_LABEL[state]}
|
||||
{manual ? '(직접)' : ''}
|
||||
{winner ? ` - ${winner}` : ''}
|
||||
</span>
|
||||
</Typography>
|
||||
|
||||
@@ -249,6 +249,7 @@ export type SessionView = {
|
||||
bid_at: string;
|
||||
reject_reason: string | null;
|
||||
reject_price: number | null;
|
||||
contract_price: number | null; // 직접 낙찰 계약가(원). 자동낙찰은 null(bid_price 가 계약가)
|
||||
reject_delivery_type: string | null;
|
||||
end_time: string;
|
||||
url: string; // 세션 chat 실행 URL(공급사 협상 프론트)
|
||||
@@ -323,11 +324,15 @@ export function buildPriceRail(
|
||||
// 목표가·상한가는 상품 단위(1견적=1상품)라 대표 세션 하나로 읽는다. 앵커는 공급사 단위라 1:1 에서만.
|
||||
const rep = sessions.find((s) => s.target_price > 0) ?? sessions[0];
|
||||
const priced = sessions.map(awardPrice).filter((v): v is number => v != null);
|
||||
const resultPrice = r.outcome === 'awarded' ? r.winnerPrice : r.lowestBid;
|
||||
// 가격을 낸 협력사가 하나도 없으면 '투찰가' 라벨은 거짓말이 된다 — 값 유무로 라벨을 가른다.
|
||||
const noBids = resultPrice == null;
|
||||
|
||||
const resultLabel =
|
||||
r.outcome === 'awarded' ? '낙찰가'
|
||||
: r.outcome === 'opened' ? '최저 투찰가'
|
||||
: oneToOne ? '현재 제시가' : '현재 최저 투찰가';
|
||||
: noBids ? '결과'
|
||||
: r.outcome === 'opened' ? '최저 투찰가'
|
||||
: oneToOne ? '현재 제시가' : '현재 최저 투찰가';
|
||||
const resultBadge =
|
||||
r.outcome === 'awarded' ? null
|
||||
: r.outcome === 'opened' ? '낙찰자 미정'
|
||||
@@ -342,7 +347,7 @@ export function buildPriceRail(
|
||||
ceilingPrice: ceilingPriceOf(rep, ceilingRate),
|
||||
ceilingRate,
|
||||
resultLabel,
|
||||
resultPrice: r.outcome === 'awarded' ? r.winnerPrice : r.lowestBid,
|
||||
resultPrice,
|
||||
resultBadge,
|
||||
// 절감은 낙찰 확정 건만 — 진행 중 잠정 최저가로 절감을 말하면 나중에 뒤집힌다.
|
||||
savings: r.outcome === 'awarded' ? r.savings : null,
|
||||
@@ -359,18 +364,22 @@ export function awardPrice(s: SessionView): number | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 오프라인 협상 결과로 담당자가 확정한 계약가(sessions.custom.offline_award).
|
||||
// 결렬·미응찰 건을 오프라인으로 다시 협상해 낙찰시킨 경우라 협력사 제출가와 다를 수 있다.
|
||||
export function offlineAward(s: SessionView): { price: number; note: string; at: string } | null {
|
||||
const raw = s.custom?.offline_award as { price?: unknown; note?: unknown; at?: unknown } | undefined;
|
||||
const price = Number(raw?.price);
|
||||
if (!raw || !Number.isFinite(price) || price <= 0) return null;
|
||||
return { price, note: String(raw.note ?? ''), at: String(raw.at ?? '') };
|
||||
// 직접 낙찰 계약가(sessions.contract_price). 결렬·미응찰 건을 오프라인으로 다시 협상해 낙찰한 값이라
|
||||
// 협력사 제출가(투찰가·거부가)와 다를 수 있다. 없으면 null(자동 낙찰 등).
|
||||
export function directAwardPrice(s: SessionView): number | null {
|
||||
return s.contract_price != null && s.contract_price > 0 ? s.contract_price : null;
|
||||
}
|
||||
|
||||
// 확정 계약가 — 담당자가 넣은 값이 있으면 그것, 없으면 협력사 제출가. 결과 표기·절감 계산의 기준.
|
||||
// 직접 낙찰 사유·처리자·시각(quotations.custom.award). 견적 단위 결정이라 견적에서 읽는다. 없으면 null.
|
||||
export function awardMeta(q: { custom?: Record<string, unknown> | null }): { reason: string; by: string; at: string } | null {
|
||||
const raw = (q.custom?.award ?? null) as { reason?: unknown; by?: unknown; at?: unknown } | null;
|
||||
if (!raw) return null;
|
||||
return { reason: String(raw.reason ?? ''), by: String(raw.by ?? ''), at: String(raw.at ?? '') };
|
||||
}
|
||||
|
||||
// 확정 계약가 — 직접 낙찰가가 있으면 그것, 없으면 협력사 제출가. 결과 표기·절감 계산의 기준.
|
||||
export function contractPrice(s: SessionView): number | null {
|
||||
return offlineAward(s)?.price ?? awardPrice(s);
|
||||
return directAwardPrice(s) ?? awardPrice(s);
|
||||
}
|
||||
|
||||
export function buildQuotationResult(q: QuotationData, sessions: SessionView[]): QuotationResultView {
|
||||
@@ -480,6 +489,7 @@ export function mapServerSessionView(sd: SessionData, partners: Partner[], produ
|
||||
bid_at: sd.bid_at ? fmtDateTime(sd.bid_at) : '-',
|
||||
reject_reason: sd.reject_reason ?? null,
|
||||
reject_price: sd.reject_price ?? null,
|
||||
contract_price: sd.contract_price ?? null,
|
||||
reject_delivery_type: sd.reject_delivery_type
|
||||
? DELIVERY_TYPE_LABEL[sd.reject_delivery_type] || String(sd.reject_delivery_type)
|
||||
: null,
|
||||
|
||||
Reference in new issue
Block a user