feat(inventory): support line-based assignments and movements

This commit is contained in:
2026-06-19 01:05:33 +02:00
parent 8e6a00c2a9
commit 6d34a2f74f
17 changed files with 713 additions and 189 deletions
+13 -3
View File
@@ -3,6 +3,8 @@ import type {
PrismaClient,
UserRole,
} from "@/generated/prisma/client"
import { UserStatus } from "@/generated/prisma/client"
import { normalizeEmail } from "@/lib/email"
let sequence = 0
@@ -21,14 +23,20 @@ export async function createTestUser(
}> = {},
) {
const suffix = nextSuffix()
const email = overrides.email ?? `test-user-${suffix}@example.test`
const status =
(overrides.isActive ?? true) ? UserStatus.ACTIVE : UserStatus.DISABLED
return prisma.user.create({
data: {
email: overrides.email ?? `test-user-${suffix}@example.test`,
email,
emailNormalized: normalizeEmail(email),
name: overrides.name ?? "Test User",
password: "hashed-password",
passwordHash: "hashed-password",
role: overrides.role ?? "ADMIN",
isActive: overrides.isActive ?? true,
status,
...(status === UserStatus.ACTIVE ? { activatedAt: new Date() } : {}),
passwordChangedAt: new Date(),
},
})
}
@@ -83,7 +91,9 @@ export async function createTestItem(
return prisma.item.create({
data: {
sku: `TEST-SKU-${suffix}`,
name: overrides.name ?? `Test Item ${suffix}`,
trackingType: "QUANTITY",
stock: overrides.stock ?? 0,
category: { connect: { id: categoryId } },
},
+1 -1
View File
@@ -13,7 +13,7 @@ type TestDatabaseState = {
const state: TestDatabaseState = {}
const TABLES_TO_TRUNCATE = [
"Movement",
"InventoryMovement",
"Assignment",
"Asset",
"Item",