feat(inventory): support line-based assignments and movements
This commit is contained in:
@@ -37,6 +37,14 @@ function isUniqueConstraintError(error: unknown) {
|
||||
)
|
||||
}
|
||||
|
||||
function buildSkuFromName(name: string) {
|
||||
return name
|
||||
.trim()
|
||||
.toUpperCase()
|
||||
.replace(/[^A-Z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "")
|
||||
}
|
||||
|
||||
export async function createItemUseCase(
|
||||
input: CreateItemUseCaseInput,
|
||||
): Promise<ItemUseCaseResult> {
|
||||
@@ -58,7 +66,9 @@ export async function createItemUseCase(
|
||||
|
||||
const item = await ItemService.create(
|
||||
{
|
||||
sku: buildSkuFromName(name),
|
||||
name,
|
||||
trackingType: "QUANTITY",
|
||||
category: { connect: { id: categoryId } },
|
||||
stock: stock || 0,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user