fix(WEB): 수량 포맷 함수 추가 및 문서 금액 표시 개선

- formatQuantity 함수: 단위별 정수/소수점 처리
  - EA, SET, PCS 등 개수 단위: 정수 표시
  - M, KG 등 측정 단위: 소수점 4자리까지
- 거래명세서: 품목코드 컬럼 너비 조정, 금액 '원' 제거
- 할인율: 정수일 경우 소수점 없이 표시
This commit is contained in:
2026-01-26 15:29:39 +09:00
parent e6905ca17e
commit 3456237a39
4 changed files with 79 additions and 10 deletions

View File

@@ -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)}

View File

@@ -11,6 +11,13 @@ import { formatAmount } from "@/utils/formatAmount";
import { OrderItem } from "../actions";
import { DocumentHeader } from "@/components/document-system";
/**
* 수량 포맷 함수 (정수로 표시)
*/
function formatQuantity(quantity: number): string {
return Math.round(quantity).toLocaleString();
}
// 제품 정보 타입
interface ProductInfo {
productName: string;
@@ -116,7 +123,7 @@ export function ContractDocument({
</div>
<div>
<span className="text-gray-500 text-xs"></span>
<p className="font-medium">{product.quantity} SET</p>
<p className="font-medium">{formatQuantity(product.quantity)} SET</p>
</div>
{product.code && (
<div>

View File

@@ -7,6 +7,26 @@
import { OrderItem } from "../actions";
/**
* 수량 포맷 함수
* - 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();
}
const rounded = Math.round(quantity * 10000) / 10000;
return rounded.toLocaleString(undefined, {
minimumFractionDigits: 0,
maximumFractionDigits: 4
});
}
interface PurchaseOrderDocumentProps {
orderNumber: string;
client: string;
@@ -157,7 +177,7 @@ export function PurchaseOrderDocument({
<td className="p-2 text-center border-r border-gray-300">
{item.width ? `${item.width}` : "-"}
</td>
<td className="p-2 text-center border-r border-gray-300">{item.quantity}</td>
<td className="p-2 text-center border-r border-gray-300">{formatQuantity(item.quantity, item.unit)}</td>
<td className="p-2 text-center">{item.symbol || "-"}</td>
</tr>
))

View File

@@ -11,6 +11,26 @@ import { formatAmount } from "@/utils/formatAmount";
import { OrderItem } from "../actions";
import { DocumentHeader } from "@/components/document-system";
/**
* 수량 포맷 함수
* - 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();
}
const rounded = Math.round(quantity * 10000) / 10000;
return rounded.toLocaleString(undefined, {
minimumFractionDigits: 0,
maximumFractionDigits: 4
});
}
interface TransactionDocumentProps {
orderNumber: string;
orderDate: string;
@@ -125,7 +145,7 @@ export function TransactionDocument({
<thead>
<tr className="bg-gray-100 border-b border-gray-300">
<th className="p-2 text-center font-medium border-r border-gray-300 w-12"></th>
<th className="p-2 text-center font-medium border-r border-gray-300 w-20"></th>
<th className="p-2 text-center font-medium border-r border-gray-300 w-28"></th>
<th className="p-2 text-left font-medium border-r border-gray-300"></th>
<th className="p-2 text-center font-medium border-r border-gray-300 w-24"></th>
<th className="p-2 text-center font-medium border-r border-gray-300 w-12"></th>
@@ -142,7 +162,7 @@ export function TransactionDocument({
<td className="p-2 text-center border-r border-gray-300">{item.itemCode}</td>
<td className="p-2 border-r border-gray-300">{item.itemName}</td>
<td className="p-2 text-center border-r border-gray-300">{item.spec}</td>
<td className="p-2 text-center border-r border-gray-300">{item.quantity}</td>
<td className="p-2 text-center border-r border-gray-300">{formatQuantity(item.quantity, item.unit)}</td>
<td className="p-2 text-center border-r border-gray-300">{item.unit}</td>
<td className="p-2 text-right border-r border-gray-300">{formatAmount(item.unitPrice)}</td>
<td className="p-2 text-right">{formatAmount(item.amount)}</td>
@@ -165,23 +185,23 @@ export function TransactionDocument({
<tbody>
<tr className="border-b border-gray-300">
<td className="p-2 bg-gray-100 border-r border-gray-300 w-32"></td>
<td className="p-2 text-right">{formatAmount(subtotal)}</td>
<td className="p-2 text-right">{formatAmount(subtotal)}</td>
</tr>
<tr className="border-b border-gray-300">
<td className="p-2 bg-gray-100 border-r border-gray-300"></td>
<td className="p-2 text-right">{discountRate}%</td>
<td className="p-2 text-right">{Number.isInteger(discountRate) ? discountRate : Math.round(discountRate)}%</td>
</tr>
<tr className="border-b border-gray-300">
<td className="p-2 bg-gray-100 border-r border-gray-300"></td>
<td className="p-2 text-right text-red-600">-{formatAmount(discountAmount)}</td>
<td className="p-2 text-right text-red-600">{discountAmount > 0 ? `-${formatAmount(discountAmount)}` : formatAmount(discountAmount)}</td>
</tr>
<tr className="border-b border-gray-300">
<td className="p-2 bg-gray-100 border-r border-gray-300"> </td>
<td className="p-2 text-right">{formatAmount(afterDiscount)}</td>
<td className="p-2 text-right">{formatAmount(afterDiscount)}</td>
</tr>
<tr className="border-b border-gray-300">
<td className="p-2 bg-gray-100 border-r border-gray-300"> (10%)</td>
<td className="p-2 text-right">{formatAmount(vat)}</td>
<td className="p-2 text-right">{formatAmount(vat)}</td>
</tr>
<tr>
<td className="p-2 bg-gray-100 border-r border-gray-300 font-medium"> </td>