From 659c46ed04758584b79a8f97074d3213bb7e252e Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Tue, 2 Sep 2025 08:36:03 +0000
Subject: (김준회) 벤더기본정보 - 매출정보 처리 (수동입력은 구현하지 않았음)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/vendor-basic-info/basic-info-client.tsx | 198 +++++++++++++++++++++-------
1 file changed, 148 insertions(+), 50 deletions(-)
(limited to 'lib/vendor-basic-info/basic-info-client.tsx')
diff --git a/lib/vendor-basic-info/basic-info-client.tsx b/lib/vendor-basic-info/basic-info-client.tsx
index ce8e4dfc..82133f28 100644
--- a/lib/vendor-basic-info/basic-info-client.tsx
+++ b/lib/vendor-basic-info/basic-info-client.tsx
@@ -27,6 +27,7 @@ import { AdditionalInfoDialog } from "@/components/vendor-regular-registrations/
import { getSiteVisitRequestsByVendorId } from "@/lib/site-visit/service";
import { fetchVendorRegistrationStatus } from "@/lib/vendor-regular-registrations/service";
import { getVendorAttachmentsByType, getVendorPeriodicGrade, getVendorTypeInfo } from "@/lib/vendor-info/service";
+import { useCreditIntegration } from "./use-credit-integration";
// downloadFile은 동적으로 import
import {
Table,
@@ -327,6 +328,20 @@ export default function BasicInfoClient({
const [editMode, setEditMode] = useState(false);
const [isPending, startTransition] = useTransition();
+ // 신용평가사 데이터 통합 훅
+ const {
+ loading: creditLoading,
+ error: creditError,
+ creditResults,
+ selectedCreditService,
+ bestResult,
+ getCurrentResult,
+ handleCreditServiceChange,
+ transformCreditToSalesData,
+ creditServices,
+ reload: reloadCreditData
+ } = useCreditIntegration(vendorId);
+
// 다이얼로그 상태
const [pqDialogOpen, setPqDialogOpen] = useState(false);
const [siteVisitDialogOpen, setSiteVisitDialogOpen] = useState(false);
@@ -1178,6 +1193,71 @@ export default function BasicInfoClient({
subtitle="(3개년)"
noPadding={true}
content={
+
+ {/* 신용평가사 선택 */}
+
+
+
신용평가사 데이터
+ {creditLoading && (
+
+ )}
+
+
+
+
+
+ {getCurrentResult() && (
+
+ 선택됨: {getCurrentResult()?.name}
+ {selectedCreditService === 'auto' && bestResult && (
+ ({bestResult.dataCount}개 항목으로 자동선택)
+ )}
+
+ )}
+
+ {creditError && (
+
+ {creditError}
+
+ )}
+
+ {!creditLoading && !creditError && creditResults.length > 0 && !getCurrentResult()?.data && (
+
+ 신용평가 데이터가 없습니다
+
+ )}
+
+
+
+ {/* 테이블 */}
@@ -1263,59 +1343,77 @@ export default function BasicInfoClient({
- {["20231231", "20221231", "20211231"].map((dateKey) => {
- const year = dateKey;
- const salesData = initialData.salesInfo?.[year];
- const metricsData = initialData.calculatedMetrics?.[dateKey];
+ {(() => {
+ // 신용평가사 데이터 우선 사용, 없으면 기존 데이터 사용
+ const currentResult = getCurrentResult();
+ const creditTransformedData = currentResult?.data ? transformCreditToSalesData(currentResult.data) : null;
+
+ const salesData = creditTransformedData?.salesInfo || initialData.salesInfo || {};
+ const metricsData = creditTransformedData?.calculatedMetrics || initialData.calculatedMetrics || {};
+
+ // 실제 데이터에서 연도 추출 (고정 연도 사용하지 않음)
+ const years = Object.keys(salesData).sort().reverse().slice(0, 3);
+
+ // 데이터가 없는 경우 기본 연도 사용
+ if (years.length === 0 && !getCurrentResult()?.data) {
+ years.push("20231231", "20221231", "20211231");
+ }
+
+ return years.map((dateKey) => {
+ const formattedDate = dateKey; // YYYYMMDD 형식으로 표시
+ const yearSalesData = salesData[dateKey];
+ const yearMetricsData = metricsData[dateKey];
- return (
-
-
- {year}
-
-
- {salesData
- ? (
- parseInt(salesData.totalDebt.replace(/,/g, "")) +
- parseInt(salesData.totalEquity.replace(/,/g, ""))
- ).toLocaleString()
- : "-"}
-
-
- {salesData?.totalDebt || "-"}
-
-
- {salesData?.totalEquity || "-"}
-
-
- {salesData?.operatingProfit || "-"}
-
-
- {salesData?.netIncome || "-"}
-
-
- {metricsData?.debtRatio?.toFixed(1) || "-"}
-
-
- {metricsData?.borrowingDependency?.toFixed(1) || "-"}
-
-
- {metricsData?.operatingMargin?.toFixed(1) || "-"}
-
-
- {metricsData?.netMargin?.toFixed(1) || "-"}
-
-
- {metricsData?.salesGrowth?.toFixed(1) || "-"}
-
-
- {metricsData?.currentRatio?.toFixed(1) || "-"}
-
-
- );
- })}
+ return (
+
+
+ {formattedDate}
+
+
+ {yearSalesData && yearSalesData.totalDebt && yearSalesData.totalEquity
+ ? (
+ parseInt(yearSalesData.totalDebt.replace(/,/g, "")) +
+ parseInt(yearSalesData.totalEquity.replace(/,/g, ""))
+ ).toLocaleString()
+ : "-"}
+
+
+ {yearSalesData?.totalDebt || "-"}
+
+
+ {yearSalesData?.totalEquity || "-"}
+
+
+ {yearSalesData?.operatingProfit || "-"}
+
+
+ {yearSalesData?.netIncome || "-"}
+
+
+ {yearMetricsData?.debtRatio ? yearMetricsData.debtRatio.toFixed(1) : "-"}
+
+
+ {yearMetricsData?.borrowingDependency ? yearMetricsData.borrowingDependency.toFixed(1) : "-"}
+
+
+ {yearMetricsData?.operatingMargin ? yearMetricsData.operatingMargin.toFixed(1) : "-"}
+
+
+ {yearMetricsData?.netMargin ? yearMetricsData.netMargin.toFixed(1) : "-"}
+
+
+ {yearMetricsData?.salesGrowth ? yearMetricsData.salesGrowth.toFixed(1) : "-"}
+
+
+ {yearMetricsData?.currentRatio ? yearMetricsData.currentRatio.toFixed(1) : "-"}
+
+
+ );
+ });
+ })()}
+
}
/>
--
cgit v1.2.3