[feat] negodata: 신규 견적유형 + 목표가·앵커링 산정 + 협력사유형 + 협상카드 용도
- 견적유형 4종: QuotationType 에 신규협상(3)·신규견적(4) 추가(1·2 재 고정)
- 목표가 산정: items(매입가·판매가·인터넷최저가) + quotations.md_price +
quotation_settings.internet_average_fee 로 _calc_target_price(KTC 이식, 신규/재 분리),
세션 target_price·target_anchoring_price 저장
- 협력사유형: quotations.supplier_type(SupplierType) + 직전유형 조회 API(/supplier/{id}/last-type)
- 협상카드 용도: nego_cards/wild_cards.usage_type(CardUsageType: 공통/신규견적전용/재견적전용)
- 스키마(01-schema.sql)·ORM·protocol·service·crud·프론트(생성타입/폼) 일괄, /backend enums·models 미러
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
21e9f71f53
commit
103c80046e
59 files changed
+871
-78
No files matched your search
@@ -9,11 +9,13 @@ import { Input } from '@/components/ui/input';
|
||||
import { Sheet } from '@/components/ui/sheet';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { type NegotiationCard, type CardTab, generateCardCode } from '../types';
|
||||
import { CardUsageType } from '@/api/generated/model';
|
||||
import type { CardInput } from '../hooks/useCards';
|
||||
import { CardScriptEditor, deserialize, serializeToText } from '../editor';
|
||||
|
||||
const schema = z.object({
|
||||
isWildcard: z.boolean(),
|
||||
usageType: z.number(),
|
||||
code: z.string().trim().min(1, '카드번호는 필수 기입 사항입니다.'),
|
||||
title: z.string().trim().min(1, '카드이름은 필수 기입 사항입니다.'),
|
||||
editorScript: z
|
||||
@@ -45,6 +47,7 @@ function buildDefaults(
|
||||
if (mode === 'edit' && card) {
|
||||
return {
|
||||
isWildcard: card.isWildcard,
|
||||
usageType: card.usageType,
|
||||
code: card.code,
|
||||
title: card.title,
|
||||
// 저장된 Slate JSON 우선, 없으면 레거시 평문 script 를 변수 노드로 복원.
|
||||
@@ -57,6 +60,7 @@ function buildDefaults(
|
||||
const wild = activeTab === 'WILD';
|
||||
return {
|
||||
isWildcard: wild,
|
||||
usageType: CardUsageType.COMMON, // 기본: 공통(신규·재 모두)
|
||||
code: generateCardCode(wild),
|
||||
title: '',
|
||||
editorScript: deserialize(), // 새 빈 값(공용 상수 mutate 방지)
|
||||
@@ -100,6 +104,7 @@ export function CardFormSheet({
|
||||
editorScript: v.editorScript,
|
||||
status: v.status,
|
||||
isWildcard: v.isWildcard,
|
||||
usageType: v.usageType,
|
||||
triggerCondition: v.triggerCondition,
|
||||
memo: v.memo,
|
||||
};
|
||||
@@ -220,6 +225,34 @@ export function CardFormSheet({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 카드 용도(usage_type): 공통 / 신규전용 / 재전용 */}
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="small" className="font-semibold">카드 용도</Typography>
|
||||
<Controller
|
||||
control={control}
|
||||
name="usageType"
|
||||
render={({ field }) => (
|
||||
<Select value={String(field.value)} onValueChange={(v) => field.onChange(Number(v))}>
|
||||
<SelectTrigger id="form-card-usage-type" className="w-full">
|
||||
<SelectValue>
|
||||
{(value) =>
|
||||
value === String(CardUsageType.NEW)
|
||||
? '신규견적전용'
|
||||
: value === String(CardUsageType.REUSE)
|
||||
? '재견적전용'
|
||||
: '공통'}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value={String(CardUsageType.COMMON)}>공통</SelectItem>
|
||||
<SelectItem value={String(CardUsageType.NEW)}>신규견적전용</SelectItem>
|
||||
<SelectItem value={String(CardUsageType.REUSE)}>재견적전용</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Title */}
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="small" className="font-semibold">카드이름</Typography>
|
||||
|
||||
@@ -21,6 +21,7 @@ export type CardInput = {
|
||||
editorScript: Descendant[];
|
||||
status: 'ACTIVE' | 'INACTIVE';
|
||||
isWildcard: boolean;
|
||||
usageType: number; // usage_type(CardUsageType): 1=공통 2=신규견적전용 3=재견적전용
|
||||
triggerCondition?: string;
|
||||
memo?: string;
|
||||
};
|
||||
@@ -36,6 +37,7 @@ function cardError(res: ResCard): string | null {
|
||||
function toReq(input: CardInput): ReqCreateCard {
|
||||
return {
|
||||
is_wildcard: input.isWildcard,
|
||||
usage_type: input.usageType,
|
||||
name: input.title,
|
||||
number: input.code,
|
||||
script: serializeToText(input.editorScript), // 평문 미리보기({변수} 토큰 포함)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { NegotiationCard } from '@/types';
|
||||
import type { CardData } from '@/api/generated/model/cardData';
|
||||
import { CardStatus } from '@/api/generated/model';
|
||||
import { CardStatus, CardUsageType } from '@/api/generated/model';
|
||||
|
||||
export type { NegotiationCard };
|
||||
|
||||
@@ -17,6 +17,7 @@ export function mapCardData(c: CardData): NegotiationCard {
|
||||
return {
|
||||
id: c.nego_card_id,
|
||||
isWildcard: c.is_wildcard ?? false,
|
||||
usageType: c.usage_type ?? CardUsageType.COMMON,
|
||||
code: c.number ?? '',
|
||||
title: c.name ?? '',
|
||||
scriptPreview: c.script ?? '',
|
||||
|
||||
@@ -33,6 +33,8 @@ const schema = z.object({
|
||||
vatYn: z.boolean(),
|
||||
deliveryFeeYn: z.boolean(),
|
||||
internetLowestPriceYn: z.boolean(),
|
||||
purchasePrice: z.number({ message: '숫자를 입력해 주십시오.' }).min(0, '매입가는 0 이상이어야 합니다.'),
|
||||
sellingPrice: z.number({ message: '숫자를 입력해 주십시오.' }).min(0, '판매가는 0 이상이어야 합니다.'),
|
||||
});
|
||||
|
||||
type FormValues = z.infer<typeof schema>;
|
||||
@@ -71,6 +73,8 @@ function buildDefaults(mode: 'create' | 'edit', product: Product | null): FormVa
|
||||
vatYn: product.vat_yn !== false,
|
||||
deliveryFeeYn: product.delivery_fee_yn || false,
|
||||
internetLowestPriceYn: product.internet_lowest_price_yn || false,
|
||||
purchasePrice: product.purchase_price || 0,
|
||||
sellingPrice: product.selling_price || 0,
|
||||
};
|
||||
}
|
||||
return {
|
||||
@@ -91,6 +95,8 @@ function buildDefaults(mode: 'create' | 'edit', product: Product | null): FormVa
|
||||
vatYn: true,
|
||||
deliveryFeeYn: false,
|
||||
internetLowestPriceYn: true,
|
||||
purchasePrice: 0,
|
||||
sellingPrice: 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -145,6 +151,8 @@ export function ProductFormSheet({
|
||||
vat_yn: v.vatYn,
|
||||
delivery_fee_yn: v.deliveryFeeYn,
|
||||
internet_lowest_price_yn: v.internetLowestPriceYn,
|
||||
purchase_price: v.purchasePrice,
|
||||
selling_price: v.sellingPrice,
|
||||
};
|
||||
|
||||
if (mode === 'create') {
|
||||
@@ -262,6 +270,33 @@ export function ProductFormSheet({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{/* 매입가 */}
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">매입가 (₩)</Typography>
|
||||
<Input
|
||||
id="form-product-purchase-price"
|
||||
type="number"
|
||||
{...register('purchasePrice', { valueAsNumber: true })}
|
||||
className={`${inputClass} font-mono`}
|
||||
placeholder="0"
|
||||
/>
|
||||
{errors.purchasePrice && <p className="text-[10px] text-rose-500">{errors.purchasePrice.message}</p>}
|
||||
</div>
|
||||
{/* 판매가 */}
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">판매가 (₩)</Typography>
|
||||
<Input
|
||||
id="form-product-selling-price"
|
||||
type="number"
|
||||
{...register('sellingPrice', { valueAsNumber: true })}
|
||||
className={`${inputClass} font-mono`}
|
||||
placeholder="0"
|
||||
/>
|
||||
{errors.sellingPrice && <p className="text-[10px] text-rose-500">{errors.sellingPrice.message}</p>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{/* Model Name */}
|
||||
<div className="space-y-1">
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { X, PlusSquare, ArrowRight, Loader2 } from 'lucide-react';
|
||||
import { useGetSupplierLastType } from '@/api/generated/quotation/quotation';
|
||||
import { updateItem } from '@/api/generated/item/item';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -7,7 +9,8 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
||||
import type { Product, Partner, QuotationSetting, NegotiationCard } from '../types';
|
||||
import type { CreateQuotationInput } from '../hooks/useQuotations';
|
||||
import { QuotationType } from '@/api/generated/model';
|
||||
import { QUOTATION_TYPE_OPTIONS } from '../types';
|
||||
import { QUOTATION_TYPE_OPTIONS, supplierTypeOptions } from '../types';
|
||||
import { showToast } from '@/lib/notify';
|
||||
|
||||
// datetime-local 디폴트값: 현재 한국시간(Asia/Seoul)의 'YYYY-MM-DDTHH:mm'.
|
||||
// sv-SE 로케일이 'YYYY-MM-DD HH:mm:ss' 를 주고, timeZone 명시로 브라우저 TZ 와 무관하게 KST 로 고정한다.
|
||||
@@ -44,9 +47,37 @@ export function QuotationCreateModal({
|
||||
const [settingId, setSettingId] = useState(quotationSettings[0]?.qt_setting_id ?? '');
|
||||
const [selectedCardIds, setSelectedCardIds] = useState<string[]>([]);
|
||||
const [memo, setMemo] = useState('');
|
||||
const [mdPrice, setMdPrice] = useState(''); // MD 제시가(원). 비우면 미전송 → 서버가 마진식으로 목표가 산정
|
||||
const [purchaseInput, setPurchaseInput] = useState(''); // 재견적·재협상 매입가(상품 저장값 디폴트, 필수)
|
||||
const [sellingInput, setSellingInput] = useState(''); // 재견적·재협상 판매가(상품 저장값 디폴트, 선택)
|
||||
const [supplierType, setSupplierType] = useState(''); // 협력사 유형(SupplierType). 재견적 1:1 → 견적에 기록
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const typeOptions = QUOTATION_TYPE_OPTIONS;
|
||||
|
||||
// 협력사 유형은 재협상(1:1)에서만. 선택된 협력사의 직전 견적 supplier_type 을 조회해 디폴트로 채운다.
|
||||
const renegoSupplierId = type === QuotationType.RENEGO ? (selectedPartnerIds[0] ?? '') : '';
|
||||
const lastTypeQuery = useGetSupplierLastType(renegoSupplierId, {
|
||||
query: { enabled: !!renegoSupplierId },
|
||||
});
|
||||
const prevSupplierType = lastTypeQuery.data?.supplier_type ?? null; // 협력사 직전 견적 유형(없으면 null)
|
||||
const prevQtNumber = lastTypeQuery.data?.qt_number ?? '';
|
||||
// 협력사가 정해지면 직전 견적 유형으로 디폴트(이후 사용자가 바꾸면 그 값 유지).
|
||||
useEffect(() => {
|
||||
setSupplierType(prevSupplierType != null ? String(prevSupplierType) : '');
|
||||
}, [renegoSupplierId, prevSupplierType]);
|
||||
|
||||
// 재견적·재협상(RE)에서만 매입가/판매가 입력을 노출한다. 상품이 정해지면 그 상품 저장값으로 디폴트.
|
||||
const selectedProduct = products.find((p) => p.id === productId);
|
||||
const isReType = type === QuotationType.RENEGO || type === QuotationType.REQUOTE;
|
||||
const showPrices = isReType && !!productId;
|
||||
// 상품/유형이 바뀌면 그 상품의 저장된 매입가·판매가로 입력칸을 채운다(이후 사용자가 고치면 유지).
|
||||
useEffect(() => {
|
||||
if (!isReType || !selectedProduct) return;
|
||||
setPurchaseInput(selectedProduct.purchase_price != null ? String(selectedProduct.purchase_price) : '');
|
||||
setSellingInput(selectedProduct.selling_price != null ? String(selectedProduct.selling_price) : '');
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [productId, isReType]);
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
const togglePartner = (id: string) =>
|
||||
@@ -64,6 +95,17 @@ export function QuotationCreateModal({
|
||||
if (submitting) return;
|
||||
setSubmitting(true);
|
||||
try {
|
||||
// 재견적·재협상은 매입가 필수 — 입력된 매입가/판매가를 상품에 저장한 뒤 진행한다.
|
||||
if (showPrices) {
|
||||
if (!purchaseInput) {
|
||||
showToast('재견적·재협상은 매입가가 필수입니다.', 'error');
|
||||
return; // finally 에서 submitting 해제
|
||||
}
|
||||
await updateItem(productId, {
|
||||
purchase_price: Number(purchaseInput),
|
||||
selling_price: sellingInput ? Number(sellingInput) : undefined,
|
||||
});
|
||||
}
|
||||
// 서버가 견적+세션 생성을 끝내고 응답할 때까지 기다린 뒤에 완료(닫기) 처리한다.
|
||||
const ok = await onCreate({
|
||||
title,
|
||||
@@ -74,6 +116,8 @@ export function QuotationCreateModal({
|
||||
settingId,
|
||||
cardIds: selectedCardIds,
|
||||
memo,
|
||||
mdPrice: mdPrice ? Number(mdPrice) : null,
|
||||
supplierType: supplierType ? Number(supplierType) : null,
|
||||
});
|
||||
if (ok) onClose();
|
||||
} finally {
|
||||
@@ -92,7 +136,7 @@ export function QuotationCreateModal({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="w-full max-w-xl bg-card border border-border rounded-lg shadow-2xl p-6 overflow-hidden animate-scale-up font-mono">
|
||||
<div className="w-full max-w-2xl bg-card border border-border rounded-lg shadow-2xl p-6 overflow-hidden animate-scale-up font-mono">
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between pb-4 border-b border-border">
|
||||
@@ -107,11 +151,11 @@ export function QuotationCreateModal({
|
||||
|
||||
{/* Steps indicator */}
|
||||
<div className="flex items-center justify-between gap-2 py-4 border-b border-border/40 text-[10px] text-muted-foreground">
|
||||
<Typography as="span" variant="label" className={`font-semibold ${step >= 1 ? 'text-primary' : 'text-muted-foreground'}`}>1. 기본 등록</Typography>
|
||||
<Typography as="span" variant="label" className={`font-semibold ${step >= 1 ? 'text-primary' : 'text-muted-foreground'}`}>1. 기본 정보</Typography>
|
||||
<ArrowRight size={10} />
|
||||
<Typography as="span" variant="label" className={`font-semibold ${step >= 2 ? 'text-primary' : 'text-muted-foreground'}`}>2. 협력사 선택</Typography>
|
||||
<Typography as="span" variant="label" className={`font-semibold ${step >= 2 ? 'text-primary' : 'text-muted-foreground'}`}>2. 협력사 초청</Typography>
|
||||
<ArrowRight size={10} />
|
||||
<Typography as="span" variant="label" className={`font-semibold ${step >= 3 ? 'text-primary' : 'text-muted-foreground'}`}>3. 설정 및 완료</Typography>
|
||||
<Typography as="span" variant="label" className={`font-semibold ${step >= 3 ? 'text-primary' : 'text-muted-foreground'}`}>3. 설정·완료</Typography>
|
||||
</div>
|
||||
|
||||
{/* Step content */}
|
||||
@@ -119,21 +163,10 @@ export function QuotationCreateModal({
|
||||
|
||||
{step === 1 && (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">견적건명</Typography>
|
||||
<Input
|
||||
id="wizard-title"
|
||||
type="text"
|
||||
className="text-xs"
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
placeholder="예: 6월 배터리 원부자재 견적 의뢰"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{/* 견적 유형이 맨 위 — 신규/재 여부가 아래 매입가 필수 여부까지 결정한다 */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">유형</Typography>
|
||||
<Typography as="label" variant="label">견적 유형</Typography>
|
||||
<Select
|
||||
value={String(type)}
|
||||
onValueChange={(v) => {
|
||||
@@ -167,6 +200,18 @@ export function QuotationCreateModal({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">견적건명</Typography>
|
||||
<Input
|
||||
id="wizard-title"
|
||||
type="text"
|
||||
className="text-xs"
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
placeholder="예: 6월 배터리 원부자재 견적 의뢰"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">상품</Typography>
|
||||
<Select value={productId} onValueChange={setProductId}>
|
||||
@@ -189,6 +234,50 @@ export function QuotationCreateModal({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* MD 제시가 — 신규·재 공통(입력 시 목표가로 사용) */}
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">MD 제시가 (선택)</Typography>
|
||||
<Input
|
||||
id="wizard-md-price"
|
||||
type="number"
|
||||
min={0}
|
||||
className="text-xs"
|
||||
value={mdPrice}
|
||||
onChange={(e) => setMdPrice(e.target.value)}
|
||||
placeholder="입력 시 목표가로 사용 · 미입력 시 자동 산정"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 재견적·재협상 — 매입가(필수)·판매가, 선택 상품의 저장값으로 디폴트 */}
|
||||
{showPrices && (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label" className="text-amber-600">매입가 (필수)</Typography>
|
||||
<Input
|
||||
id="wizard-purchase-price"
|
||||
type="number"
|
||||
min={0}
|
||||
className="text-xs"
|
||||
value={purchaseInput}
|
||||
onChange={(e) => setPurchaseInput(e.target.value)}
|
||||
placeholder="상품 저장값 · 비우면 진행 불가"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">판매가 (선택)</Typography>
|
||||
<Input
|
||||
id="wizard-selling-price"
|
||||
type="number"
|
||||
min={0}
|
||||
className="text-xs"
|
||||
value={sellingInput}
|
||||
onChange={(e) => setSellingInput(e.target.value)}
|
||||
placeholder="상품 저장값 · 마진 상한 산정에 사용"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -226,6 +315,34 @@ export function QuotationCreateModal({
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* 협력사 유형 — 재협상(1:1)에서 협력사 선택 후 노출. 직전 견적 값 자동 디폴트. */}
|
||||
{type === QuotationType.RENEGO && selectedPartnerIds.length > 0 && (
|
||||
<div className="space-y-1 pt-3 border-t border-border/40">
|
||||
<Typography as="label" variant="label">협력사 유형</Typography>
|
||||
<Select value={supplierType} onValueChange={(v) => setSupplierType(v ?? '')}>
|
||||
<SelectTrigger id="wizard-supplier-type" className="w-full">
|
||||
<SelectValue>
|
||||
{(value) =>
|
||||
value
|
||||
? supplierTypeOptions.find((o) => String(o.value) === value)?.label ?? ''
|
||||
: '협력사 유형 선택...'
|
||||
}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{supplierTypeOptions.map((o) => (
|
||||
<SelectItem key={o.value} value={String(o.value)}>{o.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{prevSupplierType != null && (
|
||||
<Typography as="span" variant="small" className="text-[10px] text-muted-foreground">
|
||||
이전 견적({prevQtNumber}) 값으로 자동 선택됨 · 수정 가능
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -317,7 +434,17 @@ export function QuotationCreateModal({
|
||||
|
||||
<div className="flex gap-2">
|
||||
{step < 3 ? (
|
||||
<Button type="button" size="sm" onClick={() => setStep((prev) => prev + 1)}>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
if (step === 1 && showPrices && !purchaseInput) {
|
||||
showToast('재견적·재협상은 매입가가 필수입니다.', 'error');
|
||||
return;
|
||||
}
|
||||
setStep((prev) => prev + 1);
|
||||
}}
|
||||
>
|
||||
다음 단계로
|
||||
</Button>
|
||||
) : (
|
||||
|
||||
@@ -24,16 +24,18 @@ export function QuotationSettingsModal({
|
||||
}: QuotationSettingsModalProps) {
|
||||
const [targetMargin, setTargetMargin] = useState('');
|
||||
const [anchoringValue, setAnchoringValue] = useState('');
|
||||
const [internetFee, setInternetFee] = useState('7.8');
|
||||
const [cardUseCount, setCardUseCount] = useState('');
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
const handleAdd = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const ok = onAdd({ targetMargin, anchoringValue, cardUseCount });
|
||||
const ok = onAdd({ targetMargin, anchoringValue, internetFee, cardUseCount });
|
||||
if (ok) {
|
||||
setTargetMargin('');
|
||||
setAnchoringValue('');
|
||||
setInternetFee('7.8');
|
||||
setCardUseCount('');
|
||||
}
|
||||
};
|
||||
@@ -99,7 +101,7 @@ export function QuotationSettingsModal({
|
||||
<form onSubmit={handleAdd} className="space-y-3 pt-4 border-t border-border/60">
|
||||
<span className="font-bold text-foreground block text-xs">신규 견적 세팅 추가</span>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">목표 마진율 (%)</Typography>
|
||||
<Input type="number" step="0.1" value={targetMargin} onChange={(e) => setTargetMargin(e.target.value)} placeholder="예: 12" />
|
||||
@@ -108,6 +110,10 @@ export function QuotationSettingsModal({
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">앵커링 값</Typography>
|
||||
<Input type="number" step="0.01" value={anchoringValue} onChange={(e) => setAnchoringValue(e.target.value)} placeholder="예: 0.01" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">인터넷 수수료율 (%)</Typography>
|
||||
<Input type="number" step="0.1" value={internetFee} onChange={(e) => setInternetFee(e.target.value)} placeholder="예: 7.8" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="muted" className="text-[10px] font-semibold">카드 사용 횟수</Typography>
|
||||
<Input type="number" step="1" value={cardUseCount} onChange={(e) => setCardUseCount(e.target.value)} placeholder="예: 3" />
|
||||
|
||||
@@ -36,11 +36,14 @@ export type CreateQuotationInput = {
|
||||
settingId: string;
|
||||
cardIds: string[];
|
||||
memo: string;
|
||||
mdPrice?: number | null; // MD 제시가(원). 비우면 미전송 → 서버가 기존 마진식으로 목표가 산정
|
||||
supplierType?: number | null; // 협력사 유형(SupplierType). 재견적 1:1 → 견적에 기록
|
||||
};
|
||||
|
||||
export type SettingInput = {
|
||||
targetMargin: string;
|
||||
anchoringValue: string;
|
||||
internetFee: string;
|
||||
cardUseCount: string;
|
||||
};
|
||||
|
||||
@@ -116,13 +119,14 @@ export function useQuotations(params: ListQuotationsParams) {
|
||||
const addSetting = (input: SettingInput): boolean => {
|
||||
const marginPct = Number(String(input.targetMargin).replace('%', '').trim());
|
||||
const anchoring = Number(String(input.anchoringValue).trim());
|
||||
const feePct = Number(String(input.internetFee).replace('%', '').trim());
|
||||
const cardCount = parseInt(String(input.cardUseCount).replace(/[^0-9-]/g, ''), 10);
|
||||
if (!Number.isFinite(marginPct) || !Number.isFinite(anchoring) || !Number.isInteger(cardCount)) {
|
||||
showToast('목표 마진율·앵커링 값·카드 사용 횟수를 숫자로 입력해야 합니다.', 'error');
|
||||
if (!Number.isFinite(marginPct) || !Number.isFinite(anchoring) || !Number.isFinite(feePct) || !Number.isInteger(cardCount)) {
|
||||
showToast('목표 마진율·앵커링 값·수수료율·카드 사용 횟수를 숫자로 입력해야 합니다.', 'error');
|
||||
return false;
|
||||
}
|
||||
createSettingMutation.mutate(
|
||||
{ data: { target_margin_rate: marginPct / 100, anchoring_value: anchoring, card_count: cardCount } },
|
||||
{ data: { target_margin_rate: marginPct / 100, anchoring_value: anchoring, internet_average_fee: feePct / 100, card_count: cardCount } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
invalidateSettings();
|
||||
@@ -183,6 +187,8 @@ export function useQuotations(params: ListQuotationsParams) {
|
||||
manager_email: me?.email || undefined,
|
||||
manager_contact_number: me?.contact || undefined,
|
||||
memo: input.memo.trim() || undefined,
|
||||
md_price: input.mdPrice && input.mdPrice > 0 ? input.mdPrice : undefined,
|
||||
supplier_type: input.supplierType ?? undefined,
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { QuotationSettingData } from '@/api/generated/model/quotationSettin
|
||||
import type { QuotationData } from '@/api/generated/model/quotationData';
|
||||
import type { SessionData } from '@/api/generated/model/sessionData';
|
||||
import type { QuotationCardData } from '@/api/generated/model/quotationCardData';
|
||||
import { QuotationType, QuotationStatus, SessionStatus, CardType } from '@/api/generated/model';
|
||||
import { QuotationType, QuotationStatus, SessionStatus, CardType, SupplierType } from '@/api/generated/model';
|
||||
import { DELIVERY_TYPE_LABEL } from '@/lib/enumLabels';
|
||||
import { toMinPrice } from '@/features/products/types';
|
||||
import type { Product, Partner, NegotiationCard } from '@/types';
|
||||
@@ -136,14 +136,29 @@ export const QUOTATION_STATUS_OPTIONS = Object.values(QuotationStatus).map((valu
|
||||
export const QUOTATION_TYPE_LABEL: Record<QuotationType, string> = {
|
||||
[QuotationType.RENEGO]: '재협상',
|
||||
[QuotationType.REQUOTE]: '재견적',
|
||||
[QuotationType.NEW_NEGO]: '신규협상',
|
||||
[QuotationType.NEW_QUOTE]: '신규견적',
|
||||
};
|
||||
export const quotationTypeLabel = (t?: number | null): string =>
|
||||
t != null ? QUOTATION_TYPE_LABEL[t as QuotationType] ?? String(t) : '';
|
||||
export const QUOTATION_TYPE_OPTIONS = [QuotationType.REQUOTE, QuotationType.RENEGO].map((value) => ({
|
||||
export const QUOTATION_TYPE_OPTIONS = [
|
||||
QuotationType.NEW_QUOTE,
|
||||
QuotationType.NEW_NEGO,
|
||||
QuotationType.REQUOTE,
|
||||
QuotationType.RENEGO,
|
||||
].map((value) => ({
|
||||
value,
|
||||
label: QUOTATION_TYPE_LABEL[value],
|
||||
}));
|
||||
|
||||
// 협력사 유형 선택지(견적생성 모달). 재견적은 1:1이라 견적에 협력사 유형을 박는다. 없음(ETC=0) 포함.
|
||||
export const supplierTypeOptions: { value: number; label: string }[] = [
|
||||
{ value: SupplierType.DISTRIBUTION, label: '유통' },
|
||||
{ value: SupplierType.MANUFACTURE, label: '제조' },
|
||||
{ value: SupplierType.SOLE_AGENCY, label: '총판' },
|
||||
{ value: SupplierType.ETC, label: '없음' },
|
||||
];
|
||||
|
||||
// ── 라운드 체인(같은 견적번호) ───────────────────────────────────────────
|
||||
// 한 라운드(견적)의 결과를 한 단어로. 낙찰=종료, 동가/마감=후속 라운드 가능, 진행중=아직 안 닫힘.
|
||||
export type ChainRoundState = 'awarded' | 'equal' | 'closed' | 'active';
|
||||
|
||||
Reference in new issue
Block a user