fix(WEB): 수량 포맷 함수 추가 및 문서 금액 표시 개선
- formatQuantity 함수: 단위별 정수/소수점 처리 - EA, SET, PCS 등 개수 단위: 정수 표시 - M, KG 등 측정 단위: 소수점 4자리까지 - 거래명세서: 품목코드 컬럼 너비 조정, 금액 '원' 제거 - 할인율: 정수일 경우 소수점 없이 표시
This commit is contained in:
@@ -45,6 +45,28 @@ import {
|
||||
type OrderStatus,
|
||||
} from "@/components/orders";
|
||||
|
||||
/**
|
||||
* 수량 포맷 함수
|
||||
* - EA, SET, PCS 등 개수 단위: 정수로 표시
|
||||
* - M, M2, KG, L 등 측정 단위: 소수점 이하 불필요한 0 제거
|
||||
*/
|
||||
function formatQuantity(quantity: number, unit?: string): string {
|
||||
const countableUnits = ["EA", "SET", "PCS", "개", "세트", "BOX", "ROLL"];
|
||||
const upperUnit = (unit || "").toUpperCase();
|
||||
|
||||
if (countableUnits.includes(upperUnit)) {
|
||||
// 개수 단위는 정수로 반올림
|
||||
return Math.round(quantity).toLocaleString();
|
||||
}
|
||||
|
||||
// 측정 단위는 소수점 4자리까지 반올림 후 불필요한 0 제거
|
||||
const rounded = Math.round(quantity * 10000) / 10000;
|
||||
return rounded.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 4
|
||||
});
|
||||
}
|
||||
|
||||
// 수정 폼 데이터
|
||||
interface EditFormData {
|
||||
// 읽기전용 정보
|
||||
@@ -496,7 +518,7 @@ export default function OrderEditPage() {
|
||||
<TableCell>{item.type || "-"}</TableCell>
|
||||
<TableCell>{item.symbol || "-"}</TableCell>
|
||||
<TableCell>{item.spec}</TableCell>
|
||||
<TableCell className="text-center">{item.quantity}</TableCell>
|
||||
<TableCell className="text-center">{formatQuantity(item.quantity, item.unit)}</TableCell>
|
||||
<TableCell className="text-center">{item.unit}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatAmount(item.unitPrice)}원
|
||||
|
||||
Reference in New Issue
Block a user