- 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:
@@ -7,6 +7,24 @@ export declare class InventoryController {
|
||||
constructor(inventoryService: InventoryService);
|
||||
consume(id: number, body: ConsumeInventoryDto): Promise<{
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
@@ -50,6 +68,24 @@ export declare class InventoryController {
|
||||
}[]>;
|
||||
findAll(location?: string, sort?: string): Promise<({
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
@@ -116,6 +152,24 @@ export declare class InventoryController {
|
||||
})[]>;
|
||||
create(body: CreateInventoryDto): Promise<{
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
@@ -149,6 +203,24 @@ export declare class InventoryController {
|
||||
}>;
|
||||
update(id: number, body: UpdateInventoryDto): Promise<{
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
|
||||
+73
@@ -10,11 +10,30 @@ type InventoryQuery = {
|
||||
export declare class InventoryService {
|
||||
private prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
private readonly productWithCategoryInclude;
|
||||
private throwInventoryItemNotFound;
|
||||
private findInventoryItemByIdOrThrow;
|
||||
private ensureProductExists;
|
||||
findAll(query?: InventoryQuery): Promise<({
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
@@ -48,6 +67,24 @@ export declare class InventoryService {
|
||||
})[]>;
|
||||
consume(id: number, data: ConsumeInventoryDto): Promise<{
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
@@ -124,6 +161,24 @@ export declare class InventoryService {
|
||||
})[]>;
|
||||
create(data: CreateInventoryDto): Promise<{
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
@@ -157,6 +212,24 @@ export declare class InventoryService {
|
||||
}>;
|
||||
update(id: number, data: UpdateInventoryDto): Promise<{
|
||||
product: {
|
||||
categoryRef: ({
|
||||
parent: ({
|
||||
parent: {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
} | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
id: number;
|
||||
parentId: number | null;
|
||||
}) | null;
|
||||
} & {
|
||||
name: string;
|
||||
category: string | null;
|
||||
status: string;
|
||||
|
||||
+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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user