feat(movements): gate StockMovementLine on trackingType QUANTITY
This commit is contained in:
@@ -146,7 +146,7 @@ export async function createAssignmentUseCase(
|
||||
return createAssignmentError({ itemId: ["Item not found"] })
|
||||
}
|
||||
|
||||
if (item.stock < quantity) {
|
||||
if (item.trackingType === "QUANTITY" && item.stock < quantity) {
|
||||
return createAssignmentError({
|
||||
quantity: ["Item does not have enough stock"],
|
||||
})
|
||||
@@ -166,16 +166,18 @@ export async function createAssignmentUseCase(
|
||||
}
|
||||
}
|
||||
|
||||
const stockWasDecremented = await ItemService.decrementStockIfAvailable(
|
||||
itemId,
|
||||
quantity,
|
||||
tx,
|
||||
)
|
||||
if (item.trackingType === "QUANTITY") {
|
||||
const stockWasDecremented = await ItemService.decrementStockIfAvailable(
|
||||
itemId,
|
||||
quantity,
|
||||
tx,
|
||||
)
|
||||
|
||||
if (!stockWasDecremented) {
|
||||
return createAssignmentError({
|
||||
quantity: ["Item does not have enough stock"],
|
||||
})
|
||||
if (!stockWasDecremented) {
|
||||
return createAssignmentError({
|
||||
quantity: ["Item does not have enough stock"],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (assetId) {
|
||||
|
||||
Reference in New Issue
Block a user