diff options
Diffstat (limited to 'src/app/api/stock-opname/location/route.tsx')
| -rw-r--r-- | src/app/api/stock-opname/location/route.tsx | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/app/api/stock-opname/location/route.tsx b/src/app/api/stock-opname/location/route.tsx index 1009486..e6c20ec 100644 --- a/src/app/api/stock-opname/location/route.tsx +++ b/src/app/api/stock-opname/location/route.tsx @@ -1,28 +1,8 @@ import { DetailTeam, StockOpnameLocationRes } from "@/common/types/stockOpname"; -import { Location, Team } from "@prisma/client"; +import { Team } from "@prisma/client"; import { NextRequest, NextResponse } from "next/server"; import { prisma } from "prisma/client"; - - -const getOpnameQuantity = async (where: { locationId: number, productId: number }) => { - const detailTeam: DetailTeam = { - COUNT1: { quantity: undefined, user: undefined }, - COUNT2: { quantity: undefined, user: undefined }, - VERIFICATION: { quantity: undefined, user: undefined }, - } - for (const team of Object.keys(Team)) { - const opname = await prisma.stockOpname.findFirst({ - where: { ...where, team: team as Team }, - select: { quantity: true, user: true }, - }) - if (!opname) continue - detailTeam[team as Team]['quantity'] = opname?.quantity - detailTeam[team as Team]['user'] = opname?.user - } - return detailTeam -} - export async function GET(request: NextRequest) { const searchParams = request.nextUrl.searchParams; const productId = searchParams.get('productId') ?? ''; @@ -54,4 +34,23 @@ export async function GET(request: NextRequest) { } return NextResponse.json(result) +} + +const getOpnameQuantity = async (where: { locationId: number, productId: number }) => { + const detailTeam: DetailTeam = { + COUNT1: { quantity: undefined, user: undefined }, + COUNT2: { quantity: undefined, user: undefined }, + COUNT3: { quantity: undefined, user: undefined }, + VERIFICATION: { quantity: undefined, user: undefined }, + } + for (const team of Object.keys(Team)) { + const opname = await prisma.stockOpname.findFirst({ + where: { ...where, team: team as Team }, + select: { quantity: true, user: true }, + }) + if (!opname) continue + detailTeam[team as Team]['quantity'] = opname?.quantity + detailTeam[team as Team]['user'] = opname?.user + } + return detailTeam }
\ No newline at end of file |
