diff --git a/src/components/material/StockStatus/StockStatusList.tsx b/src/components/material/StockStatus/StockStatusList.tsx index 3975f92b..2a076add 100644 --- a/src/components/material/StockStatus/StockStatusList.tsx +++ b/src/components/material/StockStatus/StockStatusList.tsx @@ -152,6 +152,11 @@ export function StockStatusList() { } return true; + }).sort((a, b) => { + // 최종 입출고 일자 내림차순 (최신 거래가 위) + const dateA = a.lastTransactionDate === '-' ? '' : a.lastTransactionDate; + const dateB = b.lastTransactionDate === '-' ? '' : b.lastTransactionDate; + return dateB.localeCompare(dateA); }); // ===== 행 클릭 → 플로팅 액션 메뉴 ===== @@ -329,6 +334,7 @@ export function StockStatusList() { { key: 'safetyStock', label: '안전재고', className: 'w-[80px] text-center', copyable: true }, { key: 'maxStock', label: '최대재고', className: 'w-[80px] text-center', copyable: true }, { key: 'wipQty', label: '재공품', className: 'w-[80px] text-center', copyable: true }, + { key: 'lastTransactionDate', label: '최종 입출고', className: 'w-[100px] text-center', sortable: true, copyable: true }, { key: 'useStatus', label: '상태', className: 'w-[80px] text-center' }, ], []); @@ -361,6 +367,7 @@ export function StockStatusList() { {item.safetyStock} {item.maxStock} {item.wipQty} + {item.lastTransactionDate} {USE_STATUS_LABELS[item.useStatus]} diff --git a/src/components/material/StockStatus/actions.ts b/src/components/material/StockStatus/actions.ts index ef485ea4..e2297346 100644 --- a/src/components/material/StockStatus/actions.ts +++ b/src/components/material/StockStatus/actions.ts @@ -143,6 +143,13 @@ function transformApiToListItem(data: ItemApiData): StockItem { lotCount: hasStock ? (stock.lot_count || 0) : 0, lotDaysElapsed: hasStock ? (stock.days_elapsed || 0) : 0, status: hasStock ? stock.status : null, + lastTransactionDate: (() => { + if (!hasStock) return '-'; + const receipt = stock.last_receipt_date || ''; + const issue = stock.last_issue_date || ''; + if (receipt && issue) return receipt > issue ? receipt : issue; + return receipt || issue || '-'; + })(), useStatus: data.is_active === false ? 'inactive' : 'active', location: hasStock ? (stock.location || '-') : '-', hasStock, diff --git a/src/components/material/StockStatus/types.ts b/src/components/material/StockStatus/types.ts index 406b7474..f9c656c9 100644 --- a/src/components/material/StockStatus/types.ts +++ b/src/components/material/StockStatus/types.ts @@ -76,6 +76,7 @@ export interface StockItem { lotDaysElapsed: number; // Stock.days_elapsed (없으면 0) status: StockStatusType | null; // Stock.status (없으면 null) useStatus: 'active' | 'inactive'; // 사용/미사용 상태 + lastTransactionDate: string; // 최종 입출고 일자 (last_receipt_date, last_issue_date 중 최신) location: string; // Stock.location (없으면 '-') hasStock: boolean; // Stock 데이터 존재 여부 }