feat: add receiptName field to InventoryItem model and update related DTOs and service

This commit is contained in:
Nils-Johan Gynther
2026-04-16 21:22:34 +02:00
parent af88a0dc81
commit 2a0da005ff
7 changed files with 25 additions and 2 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `InventoryItem` ADD COLUMN `receiptName` VARCHAR(191) NULL;
+1
View File
@@ -30,6 +30,7 @@ model InventoryItem {
quantity Decimal @db.Decimal(10, 2) quantity Decimal @db.Decimal(10, 2)
unit String unit String
brand String? brand String?
receiptName String?
location String? location String?
priority Int? priority Int?
purchaseDate DateTime? purchaseDate DateTime?
@@ -36,6 +36,10 @@ export class CreateInventoryDto {
@IsString() @IsString()
brand?: string; brand?: string;
@IsOptional()
@IsString()
receiptName?: string;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
opened?: boolean; opened?: boolean;
@@ -39,6 +39,10 @@ export class UpdateInventoryDto {
@IsString() @IsString()
brand?: string; brand?: string;
@IsOptional()
@IsString()
receiptName?: string;
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
opened?: boolean; opened?: boolean;
@@ -143,6 +143,7 @@ export class InventoryService {
quantity: new Prisma.Decimal(data.quantity), quantity: new Prisma.Decimal(data.quantity),
location: data.location?.trim() || undefined, location: data.location?.trim() || undefined,
brand: data.brand?.trim() || undefined, brand: data.brand?.trim() || undefined,
receiptName: data.receiptName?.trim() || undefined,
suitableFor: data.suitableFor?.trim() || undefined, suitableFor: data.suitableFor?.trim() || undefined,
comment: data.comment?.trim() || undefined, comment: data.comment?.trim() || undefined,
purchaseDate: data.purchaseDate purchaseDate: data.purchaseDate
@@ -201,6 +202,10 @@ export class InventoryService {
updateData.brand = data.brand.trim(); updateData.brand = data.brand.trim();
} }
if (typeof data.receiptName === 'string') {
updateData.receiptName = data.receiptName.trim();
}
if (typeof data.priority === 'number') { if (typeof data.priority === 'number') {
updateData.priority = data.priority; updateData.priority = data.priority;
} }
+7
View File
@@ -24,6 +24,7 @@ INSERT IGNORE INTO `Product` (`name`, `normalizedName`, `isActive`, `createdAt`,
('Chips', 'chips', 1, NOW(), NOW()), ('Chips', 'chips', 1, NOW(), NOW()),
('Choklad', 'choklad', 1, NOW(), NOW()), ('Choklad', 'choklad', 1, NOW(), NOW()),
('Citron', 'citron', 1, NOW(), NOW()), ('Citron', 'citron', 1, NOW(), NOW()),
('Crème fraiche', 'cremefraiche', 1, NOW(), NOW()),
('Curry (mild)', 'currymild', 1, NOW(), NOW()), ('Curry (mild)', 'currymild', 1, NOW(), NOW()),
('Curry (stark)', 'currystark', 1, NOW(), NOW()), ('Curry (stark)', 'currystark', 1, NOW(), NOW()),
('Dill', 'dill', 1, NOW(), NOW()), ('Dill', 'dill', 1, NOW(), NOW()),
@@ -54,6 +55,7 @@ INSERT IGNORE INTO `Product` (`name`, `normalizedName`, `isActive`, `createdAt`,
('Grädde', 'gradde', 1, NOW(), NOW()), ('Grädde', 'gradde', 1, NOW(), NOW()),
('Gräddfil', 'graddfil', 1, NOW(), NOW()), ('Gräddfil', 'graddfil', 1, NOW(), NOW()),
('Grönkål', 'gronkal', 1, NOW(), NOW()), ('Grönkål', 'gronkal', 1, NOW(), NOW()),
('Gröna druvor', 'gronadruvor', 1, NOW(), NOW()),
('Gurka', 'gurka', 1, NOW(), NOW()), ('Gurka', 'gurka', 1, NOW(), NOW()),
('Gås', 'gas', 1, NOW(), NOW()), ('Gås', 'gas', 1, NOW(), NOW()),
('Hallon', 'hallon', 1, NOW(), NOW()), ('Hallon', 'hallon', 1, NOW(), NOW()),
@@ -111,12 +113,15 @@ INSERT IGNORE INTO `Product` (`name`, `normalizedName`, `isActive`, `createdAt`,
('Lime', 'lime', 1, NOW(), NOW()), ('Lime', 'lime', 1, NOW(), NOW()),
('Linser', 'linser', 1, NOW(), NOW()), ('Linser', 'linser', 1, NOW(), NOW()),
('Läsk', 'lask', 1, NOW(), NOW()), ('Läsk', 'lask', 1, NOW(), NOW()),
('Lättmjölk', 'lattmjolk', 1, NOW(), NOW()),
('Lök', 'lok', 1, NOW(), NOW()), ('Lök', 'lok', 1, NOW(), NOW()),
('Macka', 'macka', 1, NOW(), NOW()), ('Macka', 'macka', 1, NOW(), NOW()),
('Majonnäs', 'majonnas', 1, NOW(), NOW()), ('Majonnäs', 'majonnas', 1, NOW(), NOW()),
('Malen kanel', 'malenkanel', 1, NOW(), NOW()), ('Malen kanel', 'malenkanel', 1, NOW(), NOW()),
('Malet kummin', 'maletkummin', 1, NOW(), NOW()), ('Malet kummin', 'maletkummin', 1, NOW(), NOW()),
('Mango', 'mango', 1, NOW(), NOW()), ('Mango', 'mango', 1, NOW(), NOW()),
('Marmelad', 'marmelad', 1, NOW(), NOW()),
('Mellanmjölk', 'mellanmjolk', 1, NOW(), NOW()),
('Mjöl', 'mjol', 1, NOW(), NOW()), ('Mjöl', 'mjol', 1, NOW(), NOW()),
('Mjölk', 'mjolk', 1, NOW(), NOW()), ('Mjölk', 'mjolk', 1, NOW(), NOW()),
('Morot', 'morot', 1, NOW(), NOW()), ('Morot', 'morot', 1, NOW(), NOW()),
@@ -150,6 +155,7 @@ INSERT IGNORE INTO `Product` (`name`, `normalizedName`, `isActive`, `createdAt`,
('Russin', 'russin', 1, NOW(), NOW()), ('Russin', 'russin', 1, NOW(), NOW()),
('Räkor', 'rakor', 1, NOW(), NOW()), ('Räkor', 'rakor', 1, NOW(), NOW()),
('Råbiff', 'rabiff', 1, NOW(), NOW()), ('Råbiff', 'rabiff', 1, NOW(), NOW()),
('Röda druvor', 'rodadruvor', 1, NOW(), NOW()),
('Rödbeta', 'rodbeta', 1, NOW(), NOW()), ('Rödbeta', 'rodbeta', 1, NOW(), NOW()),
('Rödlök', 'rodlok', 1, NOW(), NOW()), ('Rödlök', 'rodlok', 1, NOW(), NOW()),
('Rökt paprikapulver', 'roktpaprikapulver', 1, NOW(), NOW()), ('Rökt paprikapulver', 'roktpaprikapulver', 1, NOW(), NOW()),
@@ -163,6 +169,7 @@ INSERT IGNORE INTO `Product` (`name`, `normalizedName`, `isActive`, `createdAt`,
('Socker', 'socker', 1, NOW(), NOW()), ('Socker', 'socker', 1, NOW(), NOW()),
('Spaghetti', 'spaghetti', 1, NOW(), NOW()), ('Spaghetti', 'spaghetti', 1, NOW(), NOW()),
('Spenat', 'spenat', 1, NOW(), NOW()), ('Spenat', 'spenat', 1, NOW(), NOW()),
('Standardmjölk', 'standardmjolk', 1, NOW(), NOW()),
('Stark paprikapulver', 'starkpaprikapulver', 1, NOW(), NOW()), ('Stark paprikapulver', 'starkpaprikapulver', 1, NOW(), NOW()),
('Strömming', 'stromming', 1, NOW(), NOW()), ('Strömming', 'stromming', 1, NOW(), NOW()),
('Svartpeppar', 'svartpeppar', 1, NOW(), NOW()), ('Svartpeppar', 'svartpeppar', 1, NOW(), NOW()),
+1 -1
View File
@@ -162,7 +162,7 @@ export default function ReceiptImportClient() {
productId: r.selectedProductId, productId: r.selectedProductId,
quantity: parseFloat(r.editQty) || r.quantity, quantity: parseFloat(r.editQty) || r.quantity,
unit: r.editUnit, unit: r.editUnit,
brand: r.rawName, receiptName: r.rawName,
}), }),
}), }),
), ),