summaryrefslogtreecommitdiff
path: root/db/schema/contract.ts
diff options
context:
space:
mode:
Diffstat (limited to 'db/schema/contract.ts')
-rw-r--r--db/schema/contract.ts70
1 files changed, 53 insertions, 17 deletions
diff --git a/db/schema/contract.ts b/db/schema/contract.ts
index f56fc36e..4790d717 100644
--- a/db/schema/contract.ts
+++ b/db/schema/contract.ts
@@ -8,7 +8,6 @@ import {
date,
boolean,
unique,
- jsonb,
uniqueIndex, pgView
} from "drizzle-orm/pg-core"
import { projects } from "./projects"
@@ -31,37 +30,74 @@ export const contracts = pgTable("contracts", {
.references(() => vendors.id, { onDelete: "cascade" }),
// 계약/PO 번호(유니크)
- contractNo: varchar("contract_no", { length: 100 }).notNull().unique(),
- contractName: varchar("contract_name", { length: 255 }).notNull(),
+ contractNo: varchar("contract_no", { length: 100 }).notNull().unique(), // EBELN
+ contractName: varchar("contract_name", { length: 255 }).notNull(), // ZTITLE
// 계약/PO 상태나 기간
- status: varchar("status", { length: 50 }).notNull().default("ACTIVE"),
+ status: varchar("status", { length: 50 }).notNull().default("ACTIVE"), // ?
startDate: date("start_date"), // 발주일(혹은 유효 시작일)
endDate: date("end_date"), // 계약 종료일/유효 기간 등
- // --- PO에 자주 쓰이는 필드 추가 ---
- paymentTerms: text("payment_terms"), // 지급 조건(예: 30일 후 현금, 선금/잔금 등)
- deliveryTerms: text("delivery_terms"), // 납품 조건(Incoterms 등)
- deliveryDate: date("delivery_date"), // 납품 기한(납기 예정일)
- deliveryLocation: varchar("delivery_location", { length: 255 }), // 납품 장소
+ // --- SAP ECC 인터페이스 매핑 필드들 ---
+ // 기본 PO 정보
+ paymentTerms: text("payment_terms"), // 지급 조건 (ZTERM - 지급조건코드)
+ deliveryTerms: text("delivery_terms"), // 납품 조건 (INCO1 - 인도조건코드)
+ deliveryDate: date("delivery_date"), // 납품 기한 (ZPO_DLV_DT - PO납기일자, 개별 품목별)
+ shippmentPlace: varchar("shippment_place", { length: 255 }), // 선적지 (ZSHIPMT_PLC_CD - 선적지코드)
+ deliveryLocation: varchar("delivery_location", { length: 255 }), // 하역지 (ZUNLD_PLC_CD - 하역지코드)
+
+ // SAP ECC 추가 필드들
+ poVersion: integer("po_version"), // PO 버전 (ZPO_VER - 발주버전)
+ purchaseDocType: varchar("purchase_doc_type", { length: 10 }), // 구매문서유형 (BSART)
+ purchaseOrg: varchar("purchase_org", { length: 10 }), // 구매조직 (EKORG - 구매조직코드)
+ purchaseGroup: varchar("purchase_group", { length: 10 }), // 구매그룹 (EKGRP - 구매그룹코드)
+ exchangeRate: numeric("exchange_rate", { precision: 9, scale: 5 }), // 환율 (WKURS)
+ poConfirmStatus: varchar("po_confirm_status", { length: 10 }), // PO확인상태 (ZPO_CNFM_STAT)
+
+ // 계약/보증 관련
+ contractGuaranteeCode: varchar("contract_guarantee_code", { length: 2 }), // 계약보증코드 (ZCNRT_GRNT_CD)
+ defectGuaranteeCode: varchar("defect_guarantee_code", { length: 2 }), // 하자보증코드 (ZDFCT_GRNT_CD)
+ guaranteePeriodCode: varchar("guarantee_period_code", { length: 2 }), // 보증기간코드 (ZGRNT_PRD_CD)
+ advancePaymentYn: varchar("advance_payment_yn", { length: 1 }), // 선급금여부 (ZPAMT_YN)
+
+ // 금액 관련 (KRW 변환)
+ budgetAmount: numeric("budget_amount", { precision: 17, scale: 2 }), // 예산금액 (ZBGT_AMT)
+ budgetCurrency: varchar("budget_currency", { length: 5 }), // 예산통화 (ZBGT_CURR)
+ totalAmountKrw: numeric("total_amount_krw", { precision: 17, scale: 2 }), // 발주금액KRW (ZPO_AMT_KRW)
+
+ // 전자계약/승인 관련
+ electronicContractYn: varchar("electronic_contract_yn", { length: 1 }), // 전자계약필요여부 (ZELC_CNRT_ND_YN)
+ electronicApprovalDate: date("electronic_approval_date"), // 전자승인일자 (ZELC_AGR_DT)
+ electronicApprovalTime: varchar("electronic_approval_time", { length: 6 }), // 전자승인시간 (ZELC_AGR_TM)
+ ownerApprovalYn: varchar("owner_approval_yn", { length: 1 }), // 선주승인필요여부 (ZOWN_AGR_IND_YN)
+
+ // 기타
+ plannedInOutFlag: varchar("planned_in_out_flag", { length: 1 }), // 계획내외구분 (ZPLN_INO_GB)
+ settlementStandard: varchar("settlement_standard", { length: 1 }), // 정산기준 (ZECAL_BSE)
+ weightSettlementFlag: varchar("weight_settlement_flag", { length: 1 }), // 중량정산구분 (ZWGT_ECAL_GB)
+
+ // 연동제 관련
+ priceIndexYn: varchar("price_index_yn", { length: 1 }), // 납품대금연동제대상여부 (ZDLV_PRICE_T)
+ writtenContractNo: varchar("written_contract_no", { length: 20 }), // 서면계약번호 (ZWEBELN)
+ contractVersion: integer("contract_version"), // 서면계약차수 (ZVER_NO)
// 가격/금액 관련
- currency: varchar("currency", { length: 10 }).default("KRW"), // 통화 (KRW, USD 등)
- totalAmount: numeric("total_amount", { precision: 12, scale: 2 }), // 총 계약 금액(아이템 합산 등)
- discount: numeric("discount", { precision: 12, scale: 2 }), // 전체 할인
- tax: numeric("tax", { precision: 12, scale: 2 }), // 전체 세금
- shippingFee: numeric("shipping_fee", { precision: 12, scale: 2 }), // 배송비
- netTotal: numeric("net_total", { precision: 12, scale: 2 }), // (합계) - (할인) + (세금) + (배송비)
+ currency: varchar("currency", { length: 10 }).default("KRW"), // 통화 (KRW, USD 등) // ZPO_CURR
+ totalAmount: numeric("total_amount", { precision: 12, scale: 2 }), // 총 계약 금액(아이템 합산 등) // ZPO_AMT
+ discount: numeric("discount", { precision: 12, scale: 2 }), // 전체 할인 // 인터페이스에 없음 (개별 품목별로는 있음)
+ tax: numeric("tax", { precision: 12, scale: 2 }), // 전체 세금 // 인터페이스에 없음 (개별 품목별로는 있음)
+ shippingFee: numeric("shipping_fee", { precision: 12, scale: 2 }), // 배송비 // 인터페이스에 없음 (개별 품목별로는 있음)
+ netTotal: numeric("net_total", { precision: 12, scale: 2 }), // (합계) - (할인) + (세금) + (배송비) // 인터페이스에 없음 (개별 품목별로는 있음)
// 부분 납품/부분 결제 가능 여부
partialShippingAllowed: boolean("partial_shipping_allowed").default(false),
partialPaymentAllowed: boolean("partial_payment_allowed").default(false),
// 추가 메모/비고
- remarks: text("remarks"),
+ remarks: text("remarks"), // 발주노트 1, 2가 있는데 메모용인것으로 추정
// 버전 관리 (PO 재발행 등)
- version: integer("version").default(1),
+ version: integer("version").default(1),
// 생성/수정 시각
createdAt: timestamp("created_at").defaultNow().notNull(),