feat: add unit mapping functionality
Test Suite / test (24.15.0) (push) Has been cancelled

- Added new API path for unit mappings in `api_paths.dart`.
- Implemented `upsertUnitMapping` method in `ImportRepository` to handle unit mapping creation.
- Updated `ReceiptImportTab` to learn and save unit mappings during receipt import.
- Created DTO for unit mapping with validation in `create-unit-mapping.dto.ts`.
- Added SQL migration for `UnitMapping` table creation with necessary constraints.
This commit is contained in:
Nils-Johan Gynther
2026-05-07 10:00:42 +02:00
parent 26823fbf35
commit a68a0ca86f
35 changed files with 558 additions and 24 deletions
+17 -4
View File
@@ -16,6 +16,19 @@ const prisma_service_1 = require("../prisma/prisma.service");
let InventoryService = class InventoryService {
constructor(prisma) {
this.prisma = prisma;
this.productWithCategoryInclude = {
include: {
categoryRef: {
include: {
parent: {
include: {
parent: true,
},
},
},
},
},
};
}
throwInventoryItemNotFound(id) {
throw new common_1.NotFoundException(`Inventory item with id ${id} not found`);
@@ -61,7 +74,7 @@ let InventoryService = class InventoryService {
return this.prisma.inventoryItem.findMany({
where,
include: {
product: true,
product: this.productWithCategoryInclude,
},
orderBy,
});
@@ -77,7 +90,7 @@ let InventoryService = class InventoryService {
quantity: new client_1.Prisma.Decimal(newQuantity),
},
include: {
product: true,
product: this.productWithCategoryInclude,
},
});
await tx.inventoryConsumption.create({
@@ -146,7 +159,7 @@ let InventoryService = class InventoryService {
: undefined,
},
include: {
product: true,
product: this.productWithCategoryInclude,
},
});
}
@@ -199,7 +212,7 @@ let InventoryService = class InventoryService {
where: { id },
data: updateData,
include: {
product: true,
product: this.productWithCategoryInclude,
},
});
}