diff options
Diffstat (limited to 'app/api/vendors/route.ts')
| -rw-r--r-- | app/api/vendors/route.ts | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/app/api/vendors/route.ts b/app/api/vendors/route.ts index 760f183e..27b79385 100644 --- a/app/api/vendors/route.ts +++ b/app/api/vendors/route.ts @@ -162,20 +162,22 @@ export async function POST(request: NextRequest) { ) } - // Check for existing taxId - const existingVendor = await db - .select({ id: vendors.id }) - .from(vendors) - .where(eq(vendors.taxId, vendorData.taxId)) - .limit(1) - - if (existingVendor.length > 0) { - return NextResponse.json( - { - error: `이미 등록된 사업자등록번호입니다. (Tax ID ${vendorData.taxId} already exists in the system)` - }, - { status: 400 } - ) + // Check for existing taxId (only if taxId is provided) + if (vendorData.taxId && vendorData.taxId.trim()) { + const existingVendor = await db + .select({ id: vendors.id }) + .from(vendors) + .where(eq(vendors.taxId, vendorData.taxId)) + .limit(1) + + if (existingVendor.length > 0) { + return NextResponse.json( + { + error: `이미 등록된 사업자등록번호입니다. (Tax ID ${vendorData.taxId} already exists in the system)` + }, + { status: 400 } + ) + } } // Create vendor and handle files in transaction |
