From 50adedf48ee4674ebe00f1ee72d93485183cdc51 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 5 Sep 2025 11:44:32 +0000 Subject: (대표님, 최겸, 임수민) EDP 입력 진행률, 견적목록관리, EDP excel import 오류수정, GTC-Contract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/procurement-select/service.ts | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 lib/procurement-select/service.ts (limited to 'lib/procurement-select/service.ts') diff --git a/lib/procurement-select/service.ts b/lib/procurement-select/service.ts new file mode 100644 index 00000000..14fe54d7 --- /dev/null +++ b/lib/procurement-select/service.ts @@ -0,0 +1,85 @@ +'use server' + +import db from "@/db/db" +import { + incoterms, placeOfShipping, paymentTerms +} from "@/db/schema" +import { eq } from "drizzle-orm" + +export async function getIncotermsForSelection() { + try { + const data = await db + .select({ + code: incoterms.code, + description: incoterms.description, + }) + .from(incoterms) + .where(eq(incoterms.isActive, true)) + .orderBy(incoterms.code) + + return data + + } catch (error) { + console.error("Error fetching incoterms:", error) + throw new Error("Failed to fetch incoterms") + } +} + + +export async function getPaymentTermsForSelection() { + try { + const data = await db + .select({ + code: paymentTerms.code, + description: paymentTerms.description, + }) + .from(paymentTerms) + .where(eq(paymentTerms.isActive, true)) + .orderBy(paymentTerms.code) + + return data + + } catch (error) { + console.error("Error fetching paymentTerms:", error) + throw new Error("Failed to fetch paymentTerms") + } +} + + +export async function getPlaceOfShippingForSelection() { + try { + const data = await db + .select({ + code: placeOfShipping.code, + description: placeOfShipping.description, + }) + .from(placeOfShipping) + .where(eq(placeOfShipping.isActive, true)) + .orderBy(placeOfShipping.code) + + return data + + } catch (error) { + console.error("Error fetching placeOfShipping:", error) + throw new Error("Failed to fetch placeOfShipping") + } +} + +export async function getPlaceOfDestinationForSelection() { + try { + const data = await db + .select({ + code: placeOfShipping.code, + description: placeOfShipping.description, + }) + .from(placeOfShipping) + .where(eq(placeOfShipping.isActive, true)) + .orderBy(placeOfShipping.code) + + return data + + } catch (error) { + console.error("Error fetching placeOfShipping:", error) + throw new Error("Failed to fetch placeOfShipping") + } +} \ No newline at end of file -- cgit v1.2.3