- 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:
+17
-4
@@ -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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user