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)}원
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
))
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user