feat(assets): pair ASSIGNMENT movement on itemChanged AVAILABLE→ASSIGNED
This commit is contained in:
@@ -453,6 +453,18 @@ export async function updateAssetUseCase(
|
||||
},
|
||||
tx,
|
||||
)
|
||||
|
||||
await MovementService.create(
|
||||
{
|
||||
assetId: id,
|
||||
quantity: 1,
|
||||
type: "ASSIGNMENT",
|
||||
details: `Asset assigned from item ${transition.previousItemId} to item ${transition.nextItemId}`,
|
||||
userId: actorId,
|
||||
previousStatus: transition.previousStatus,
|
||||
},
|
||||
tx,
|
||||
)
|
||||
}
|
||||
|
||||
if (transition.willBeAssigned && transition.nextPersonId) {
|
||||
@@ -526,19 +538,21 @@ export async function updateAssetUseCase(
|
||||
tx,
|
||||
)
|
||||
|
||||
await MovementService.create(
|
||||
{
|
||||
type: "ASSIGNMENT",
|
||||
quantity: 1,
|
||||
itemId,
|
||||
assetId: id,
|
||||
personId: transition.nextPersonId,
|
||||
assignmentId: createdAssignment.id,
|
||||
userId: actorId,
|
||||
previousStatus: transition.previousStatus,
|
||||
},
|
||||
tx,
|
||||
)
|
||||
if (!(transition.itemChanged && transition.wasAvailable)) {
|
||||
await MovementService.create(
|
||||
{
|
||||
type: "ASSIGNMENT",
|
||||
quantity: 1,
|
||||
itemId,
|
||||
assetId: id,
|
||||
personId: transition.nextPersonId,
|
||||
assignmentId: createdAssignment.id,
|
||||
userId: actorId,
|
||||
previousStatus: transition.previousStatus,
|
||||
},
|
||||
tx,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user