summaryrefslogtreecommitdiff
path: root/lib/basic-contract/service-vendor-info.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/basic-contract/service-vendor-info.ts')
-rw-r--r--lib/basic-contract/service-vendor-info.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/basic-contract/service-vendor-info.ts b/lib/basic-contract/service-vendor-info.ts
new file mode 100644
index 00000000..2fe2d512
--- /dev/null
+++ b/lib/basic-contract/service-vendor-info.ts
@@ -0,0 +1,35 @@
+"use server";
+
+import db from "@/db/db";
+import { vendors } from "@/db/schema";
+import { eq } from "drizzle-orm";
+
+/**
+ * 벤더 ID로 벤더 정보 조회 (사업자번호 등)
+ */
+export async function getVendorInfo(vendorId: number) {
+ try {
+ const result = await db
+ .select({
+ id: vendors.id,
+ vendorName: vendors.vendorName,
+ vendorCode: vendors.vendorCode,
+ taxId: vendors.taxId, // 사업자등록번호
+ corporateRegistrationNumber: vendors.corporateRegistrationNumber, // 법인등록번호
+ country: vendors.country, // 국가 코드 (KR: 내자, 그외: 외자)
+ })
+ .from(vendors)
+ .where(eq(vendors.id, vendorId))
+ .limit(1);
+
+ if (!result || result.length === 0) {
+ return { success: false, error: "Vendor not found" };
+ }
+
+ return { success: true, data: result[0] };
+ } catch (error) {
+ console.error("Error fetching vendor info:", error);
+ return { success: false, error: "Failed to fetch vendor info" };
+ }
+}
+