feat(inventory): support line-based assignments and movements
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
type Assignment,
|
||||
type ItemStatus,
|
||||
type AssetStatus,
|
||||
Prisma,
|
||||
} from "@/generated/prisma/client"
|
||||
import prisma from "@/lib/prisma"
|
||||
@@ -12,6 +11,7 @@ import { AssetService } from "@/services/asset.service"
|
||||
import { AssignmentService } from "@/services/assignment.service"
|
||||
import { ItemService } from "@/services/item.service"
|
||||
import { MovementService } from "@/services/movement.service"
|
||||
import type { Assignment } from "@/types"
|
||||
|
||||
type FieldErrors = Record<string, string[]>
|
||||
|
||||
@@ -63,8 +63,8 @@ class AssetTransitionError extends Error {
|
||||
}
|
||||
|
||||
type AssetTransitionInput = {
|
||||
previousStatus: ItemStatus
|
||||
nextStatus: ItemStatus
|
||||
previousStatus: AssetStatus
|
||||
nextStatus: AssetStatus
|
||||
previousItemId: string | null
|
||||
nextItemId: string
|
||||
activeAssignment: Assignment | null
|
||||
@@ -261,7 +261,11 @@ export async function updateAssetUseCase(
|
||||
if (transition.activeAssignment && !transition.willBeAssigned) {
|
||||
const activeAssignment = transition.activeAssignment
|
||||
const assignmentWasReturned =
|
||||
await AssignmentService.markReturnedIfActive(activeAssignment.id, tx)
|
||||
await AssignmentService.markReturnedIfActive(
|
||||
activeAssignment.id,
|
||||
actorId,
|
||||
tx,
|
||||
)
|
||||
|
||||
if (!assignmentWasReturned) {
|
||||
throw new AssetTransitionError({
|
||||
|
||||
Reference in New Issue
Block a user