feat: [재고현황] 최종 입출고 일자 컬럼 추가 + 최신 거래 기준 정렬
- StockItem에 lastTransactionDate 필드 추가 (last_receipt_date/last_issue_date 중 최신) - 테이블에 '최종 입출고' 컬럼 추가 - 기본 정렬: 최종 입출고 일자 내림차순 (최신 거래가 위)
This commit is contained in:
@@ -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() {
|
||||
<TableCell className="text-center">{item.safetyStock}</TableCell>
|
||||
<TableCell className="text-center">{item.maxStock}</TableCell>
|
||||
<TableCell className="text-center">{item.wipQty}</TableCell>
|
||||
<TableCell className="text-center text-xs text-muted-foreground">{item.lastTransactionDate}</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<span className={item.useStatus === 'inactive' ? 'text-gray-400' : ''}>
|
||||
{USE_STATUS_LABELS[item.useStatus]}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 데이터 존재 여부
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user