diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-20 19:36:01 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-20 19:36:01 +0900 |
| commit | 935fd22e17afc034a472bc2d159de7b9f5e5dcae (patch) | |
| tree | 6beea33ab38750be17632dffca5e05e644647365 /lib/po/vendor-table/service.ts | |
| parent | b75b1cd920efd61923f7b2dbc4c49987b7b0c4e1 (diff) | |
(김준회) PO, POS, swp
- PO: 발주서출력기능 초안
- 벤더측 POS 다운로드 기능 추가
- Contract 생성시 Status 설정 (mapper)
- swp document registration table 로직 리팩터링
- swp: 입력가능 문서번호 validation 추가 (리스트 메뉴에서 Completed 된 건)
Diffstat (limited to 'lib/po/vendor-table/service.ts')
| -rw-r--r-- | lib/po/vendor-table/service.ts | 38 |
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, |
