summaryrefslogtreecommitdiff
path: root/lib/po/vendor-table/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/po/vendor-table/service.ts')
-rw-r--r--lib/po/vendor-table/service.ts38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/po/vendor-table/service.ts b/lib/po/vendor-table/service.ts
index bc4a693b..e73a6083 100644
--- a/lib/po/vendor-table/service.ts
+++ b/lib/po/vendor-table/service.ts
@@ -7,6 +7,7 @@ import { contracts, contractItems, ContractStatus } from "@/db/schema/contract";
import { projects } from "@/db/schema/projects";
import { vendors } from "@/db/schema/vendors";
import { items } from "@/db/schema/items";
+import { users } from "@/db/schema/users";
import { revalidatePath } from "next/cache";
import { eq, and, or, ilike, count, desc, asc, SQL } from "drizzle-orm";
@@ -223,14 +224,19 @@ export async function getVendorPOById(id: number): Promise<VendorPO | null> {
id: contracts.id,
contractNo: contracts.contractNo,
contractName: contracts.contractName,
+ contractContent: contracts.contractContent,
+ remarks: contracts.remarks,
status: contracts.status,
startDate: contracts.startDate,
endDate: contracts.endDate,
+ deliveryDate: contracts.deliveryDate,
currency: contracts.currency,
totalAmount: contracts.totalAmount,
totalAmountKrw: contracts.totalAmountKrw,
paymentTerms: contracts.paymentTerms,
deliveryTerms: contracts.deliveryTerms,
+ deliveryLocation: contracts.deliveryLocation,
+ shippmentPlace: contracts.shippmentPlace,
exchangeRate: contracts.exchangeRate,
poVersion: contracts.poVersion,
purchaseDocType: contracts.purchaseDocType,
@@ -255,10 +261,25 @@ export async function getVendorPOById(id: number): Promise<VendorPO | null> {
contractVersion: contracts.contractVersion,
createdAt: contracts.createdAt,
updatedAt: contracts.updatedAt,
+
+ // 프로젝트 정보
projectName: projects.name,
+ projectCode: projects.code,
+
+ // 벤더 정보
+ vendorName: vendors.vendorName,
+ vendorAddress: vendors.address,
+ vendorAddressDetail: vendors.addressDetail,
+ vendorPhone: vendors.phone,
+ vendorEmail: vendors.email,
+
+ // 구매담당자 정보 (purchaseGroup으로 조회)
+ purchaseManagerName: users.name,
})
.from(contracts)
.leftJoin(projects, eq(contracts.projectId, projects.id))
+ .leftJoin(vendors, eq(contracts.vendorId, vendors.id))
+ .leftJoin(users, eq(contracts.purchaseGroup, users.userCode))
.where(eq(contracts.id, id))
.limit(1);
@@ -274,7 +295,10 @@ export async function getVendorPOById(id: number): Promise<VendorPO | null> {
contractType: row.purchaseDocType || '',
details: '상세보기',
projectName: row.projectName || '',
+ projectCode: row.projectCode || undefined,
contractName: row.contractName || '',
+ contractContent: row.contractContent || undefined,
+ remarks: row.remarks || undefined,
contractPeriod: row.startDate && row.endDate ? `${row.startDate} ~ ${row.endDate}` : '',
contractQuantity: '1 LOT',
currency: row.currency || 'KRW',
@@ -282,7 +306,7 @@ export async function getVendorPOById(id: number): Promise<VendorPO | null> {
tax: '10%',
exchangeRate: row.exchangeRate?.toString() || '',
deliveryTerms: row.deliveryTerms || '',
- purchaseManager: '',
+ purchaseManager: row.purchaseManagerName || '',
poReceiveDate: row.createdAt?.toISOString().split('T')[0] || '',
contractDate: row.startDate || '',
lcNo: undefined,
@@ -290,6 +314,18 @@ export async function getVendorPOById(id: number): Promise<VendorPO | null> {
linkedContractNo: undefined,
lastModifiedDate: row.updatedAt?.toISOString().split('T')[0] || '',
lastModifiedBy: '',
+
+ // 벤더 정보
+ vendorName: row.vendorName || undefined,
+ vendorAddress: row.vendorAddress || undefined,
+ vendorAddressDetail: row.vendorAddressDetail || undefined,
+ vendorPhone: row.vendorPhone || undefined,
+ vendorEmail: row.vendorEmail || undefined,
+
+ // 구매담당자 정보
+ purchaseManagerName: row.purchaseManagerName || undefined,
+
+ // SAP 필드
poVersion: row.poVersion || undefined,
purchaseDocType: row.purchaseDocType || undefined,
purchaseOrg: row.purchaseOrg || undefined,