diff --git a/src/components/accounting/PurchaseManagement/actions.ts b/src/components/accounting/PurchaseManagement/actions.ts index 18eb8c57..f9f9ed65 100644 --- a/src/components/accounting/PurchaseManagement/actions.ts +++ b/src/components/accounting/PurchaseManagement/actions.ts @@ -31,6 +31,18 @@ interface PurchaseApiData { status: string; purchase_type?: string; withdrawal_id?: number; + approval_id?: number; + approval?: { + id: number; + document_number: string; + title: string; + content?: Record; + form?: { + id: number; + name: string; + category: string; + }; + }; tax_invoice_received: boolean; created_at?: string; updated_at?: string; @@ -60,6 +72,23 @@ function transformApiToFrontend(data: PurchaseApiData): PurchaseRecord { ? (data.purchase_type as PurchaseType) : 'unset'; + // 품의서/지출결의서 연결 정보 변환 + let sourceDocument: PurchaseRecord['sourceDocument'] = undefined; + if (data.approval) { + // form.category로 문서 유형 결정 (proposal=품의서, expense_report=지출결의서) + const docType = data.approval.form?.category === 'expense_report' ? 'expense_report' : 'proposal'; + // content에서 예상금액 추출 (품의서 양식에 따라 다를 수 있음) + const expectedCost = (data.approval.content?.expected_cost as number) || + (data.approval.content?.total_amount as number) || 0; + + sourceDocument = { + type: docType, + documentNo: data.approval.document_number, + title: data.approval.title, + expectedCost, + }; + } + return { id: String(data.id), purchaseNo: data.purchase_number, @@ -72,6 +101,8 @@ function transformApiToFrontend(data: PurchaseApiData): PurchaseRecord { purchaseType, evidenceType: 'tax_invoice', status: data.status === 'confirmed' ? 'completed' : 'pending', + approvalId: data.approval_id ? String(data.approval_id) : undefined, + sourceDocument, items: [], taxInvoiceReceived: data.tax_invoice_received ?? false, createdAt: data.created_at || '', @@ -90,6 +121,7 @@ function transformFrontendToApi(data: Partial): Record합계 + {tableTotals.totalSupplyAmount.toLocaleString()} {tableTotals.totalVat.toLocaleString()} {tableTotals.totalAmount.toLocaleString()} @@ -424,6 +426,15 @@ export function PurchaseManagement() { {item.purchaseNo} {item.purchaseDate} {item.vendorName} + + {item.sourceDocument ? ( + + {item.sourceDocument.type === 'proposal' ? '품의서' : '지출결의서'} + + ) : ( + - + )} + {item.supplyAmount.toLocaleString()} {item.vat.toLocaleString()} {item.totalAmount.toLocaleString()} @@ -489,6 +500,7 @@ export function PurchaseManagement() { onClick={() => handleRowClick(item)} details={[ { label: '매입일', value: item.purchaseDate }, + { label: '연결문서', value: item.sourceDocument ? (item.sourceDocument.type === 'proposal' ? '품의서' : '지출결의서') : '-' }, { label: '공급가액', value: `${item.supplyAmount.toLocaleString()}원` }, { label: '합계금액', value: `${item.totalAmount.toLocaleString()}원` }, ]} diff --git a/src/components/accounting/PurchaseManagement/types.ts b/src/components/accounting/PurchaseManagement/types.ts index 48620580..88f2cab8 100644 --- a/src/components/accounting/PurchaseManagement/types.ts +++ b/src/components/accounting/PurchaseManagement/types.ts @@ -54,7 +54,9 @@ export interface PurchaseRecord { purchaseType: PurchaseType; // 매입유형 evidenceType: EvidenceType; // 증빙유형 status: PurchaseStatus; // 상태 - // 근거 문서 + // 연결된 결재문서 ID (품의서/지출결의서) + approvalId?: string; + // 근거 문서 (API에서 조회됨) sourceDocument?: { type: 'proposal' | 'expense_report'; // 품의서 | 지출결의서 documentNo: string;