diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 519607a..917e1ba 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -33,30 +33,38 @@ enum Status { } model Item { - id Int @id @default(autoincrement()) - SKU String? @unique - Amount Int - Comment String? - name String - manufacturer String - category Category @relation(fields: [categoryId], references: [id]) - categoryId Int - status Status - StorageLocation StorageLocation? @relation(fields: [storageLocationId], references: [id]) + id Int @id @unique @default(autoincrement()) + SKU String? @unique + amount Int @default(1) + name String + Comment String? + status Status @default(normal) /// TODO: Would it be better to create a separate model for this as well instead of providing several static statuses to choose from(enum)? + + manufacturer String /// TODO: Do we need this as a mandatory field? Probably we can add another model for manufacturer. + + category Category @relation(fields: [categoryId], references: [id]) + categoryId Int + + items Item[] @relation("items") /// Item beinhaltet.. + baseItem Item[] @relation("items") /// Item zugehörig zu. + + storageLocation StorageLocation? @relation(fields: [storageLocationId], references: [id]) storageLocationId Int? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - importedBy String? + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + importedBy String? } model StorageLocation { id Int @id @default(autoincrement()) - name String @unique + name String @unique /// This is our LocationID for external use prefixed with: '%StorageUnit%_' storageUnit StorageUnit? @relation(fields: [storageUnitId], references: [id]) storageUnitId Int? Item Item[] } +/// A StorageUnit is the base and can hold multiple StorageLocations. model StorageUnit { id Int @id @default(autoincrement()) name String @@ -74,3 +82,22 @@ model Category { description String? Item Item[] } + +/// TODO: Add relationship to StorageUnit, Item and if necessary to StorageLocation. +model Owner { + id Int @id @default(autoincrement()) + type OwnerType @default(person) + name String + lastName String? + street String + houseNumber String + zipCode String + city String + country String +} + +enum OwnerType { + person + customer + company +} diff --git a/src/assets/configHandler.ts b/src/assets/configHandler.ts index 2ad7905..3663f35 100644 --- a/src/assets/configHandler.ts +++ b/src/assets/configHandler.ts @@ -54,7 +54,7 @@ export default class config { } // BUG: If file does'nt exist -> fail. -// ToDo: Check for SyntaxError on fileread and ask if the user wants to continue -> overwrite everything. This behavior is currently standard. +// TODO: Check for SyntaxError on fileread and ask if the user wants to continue -> overwrite everything. This behavior is currently standard. /* diff --git a/src/routes/frontend/manage/import/csvImport.ts b/src/routes/frontend/manage/import/csvImport.ts index c301e28..7e72100 100644 --- a/src/routes/frontend/manage/import/csvImport.ts +++ b/src/routes/frontend/manage/import/csvImport.ts @@ -55,7 +55,7 @@ export default (req: Request, res: Response) => { const promise = prisma.item.create({ data: { name: record.name, - Amount: parseInt(record.amount), + amount: parseInt(record.amount), Comment: record.comment, category: { connect: {