feat: enhance inventory management with category and location filters
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -14,6 +14,20 @@ type InventoryQuery = {
|
||||
export class InventoryService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
private readonly productWithCategoryInclude = {
|
||||
include: {
|
||||
categoryRef: {
|
||||
include: {
|
||||
parent: {
|
||||
include: {
|
||||
parent: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
private throwInventoryItemNotFound(id: number): never {
|
||||
throw new NotFoundException(`Inventory item with id ${id} not found`);
|
||||
}
|
||||
@@ -59,7 +73,7 @@ export class InventoryService {
|
||||
return this.prisma.inventoryItem.findMany({
|
||||
where,
|
||||
include: {
|
||||
product: true,
|
||||
product: this.productWithCategoryInclude,
|
||||
},
|
||||
orderBy,
|
||||
});
|
||||
@@ -78,7 +92,7 @@ export class InventoryService {
|
||||
quantity: new Prisma.Decimal(newQuantity),
|
||||
},
|
||||
include: {
|
||||
product: true,
|
||||
product: this.productWithCategoryInclude,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -154,7 +168,7 @@ export class InventoryService {
|
||||
: undefined,
|
||||
},
|
||||
include: {
|
||||
product: true,
|
||||
product: this.productWithCategoryInclude,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -222,7 +236,7 @@ export class InventoryService {
|
||||
where: { id },
|
||||
data: updateData,
|
||||
include: {
|
||||
product: true,
|
||||
product: this.productWithCategoryInclude,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user