210 lines
6.1 KiB
TypeScript
210 lines
6.1 KiB
TypeScript
import { ConsumeInventoryDto } from './dto/consume-inventory.dto';
|
|
import { Prisma } from '@prisma/client';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
import { CreateInventoryDto } from './dto/create-inventory.dto';
|
|
import { UpdateInventoryDto } from './dto/update-inventory.dto';
|
|
type InventoryQuery = {
|
|
location?: string;
|
|
sort?: string;
|
|
};
|
|
export declare class InventoryService {
|
|
private prisma;
|
|
constructor(prisma: PrismaService);
|
|
private throwInventoryItemNotFound;
|
|
private findInventoryItemByIdOrThrow;
|
|
private ensureProductExists;
|
|
findAll(query?: InventoryQuery): Promise<({
|
|
product: {
|
|
category: string | null;
|
|
status: string;
|
|
name: string;
|
|
categoryId: number | null;
|
|
canonicalName: string | null;
|
|
id: number;
|
|
normalizedName: string;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
} & {
|
|
id: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
productId: number;
|
|
quantity: Prisma.Decimal;
|
|
unit: string;
|
|
brand: string | null;
|
|
origin: string | null;
|
|
receiptName: string | null;
|
|
location: string | null;
|
|
purchaseDate: Date | null;
|
|
opened: boolean | null;
|
|
suitableFor: string | null;
|
|
bestBeforeDate: Date | null;
|
|
comment: string | null;
|
|
})[]>;
|
|
consume(id: number, data: ConsumeInventoryDto): Promise<{
|
|
product: {
|
|
category: string | null;
|
|
status: string;
|
|
name: string;
|
|
categoryId: number | null;
|
|
canonicalName: string | null;
|
|
id: number;
|
|
normalizedName: string;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
} & {
|
|
id: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
productId: number;
|
|
quantity: Prisma.Decimal;
|
|
unit: string;
|
|
brand: string | null;
|
|
origin: string | null;
|
|
receiptName: string | null;
|
|
location: string | null;
|
|
purchaseDate: Date | null;
|
|
opened: boolean | null;
|
|
suitableFor: string | null;
|
|
bestBeforeDate: Date | null;
|
|
comment: string | null;
|
|
}>;
|
|
findConsumptionHistory(id: number): Promise<{
|
|
inventoryItem: {
|
|
unit: string;
|
|
};
|
|
id: number;
|
|
createdAt: Date;
|
|
comment: string | null;
|
|
amountUsed: Prisma.Decimal;
|
|
inventoryItemId: number;
|
|
}[]>;
|
|
findExpiring(): Promise<({
|
|
product: {
|
|
category: string | null;
|
|
status: string;
|
|
name: string;
|
|
categoryId: number | null;
|
|
canonicalName: string | null;
|
|
id: number;
|
|
normalizedName: string;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
} & {
|
|
id: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
productId: number;
|
|
quantity: Prisma.Decimal;
|
|
unit: string;
|
|
brand: string | null;
|
|
origin: string | null;
|
|
receiptName: string | null;
|
|
location: string | null;
|
|
purchaseDate: Date | null;
|
|
opened: boolean | null;
|
|
suitableFor: string | null;
|
|
bestBeforeDate: Date | null;
|
|
comment: string | null;
|
|
})[]>;
|
|
create(data: CreateInventoryDto): Promise<{
|
|
product: {
|
|
category: string | null;
|
|
status: string;
|
|
name: string;
|
|
categoryId: number | null;
|
|
canonicalName: string | null;
|
|
id: number;
|
|
normalizedName: string;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
} & {
|
|
id: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
productId: number;
|
|
quantity: Prisma.Decimal;
|
|
unit: string;
|
|
brand: string | null;
|
|
origin: string | null;
|
|
receiptName: string | null;
|
|
location: string | null;
|
|
purchaseDate: Date | null;
|
|
opened: boolean | null;
|
|
suitableFor: string | null;
|
|
bestBeforeDate: Date | null;
|
|
comment: string | null;
|
|
}>;
|
|
update(id: number, data: UpdateInventoryDto): Promise<{
|
|
product: {
|
|
category: string | null;
|
|
status: string;
|
|
name: string;
|
|
categoryId: number | null;
|
|
canonicalName: string | null;
|
|
id: number;
|
|
normalizedName: string;
|
|
isActive: boolean;
|
|
deletedAt: Date | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
ownerId: number;
|
|
isPrivate: boolean;
|
|
};
|
|
} & {
|
|
id: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
productId: number;
|
|
quantity: Prisma.Decimal;
|
|
unit: string;
|
|
brand: string | null;
|
|
origin: string | null;
|
|
receiptName: string | null;
|
|
location: string | null;
|
|
purchaseDate: Date | null;
|
|
opened: boolean | null;
|
|
suitableFor: string | null;
|
|
bestBeforeDate: Date | null;
|
|
comment: string | null;
|
|
}>;
|
|
remove(id: number): Promise<{
|
|
id: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
productId: number;
|
|
quantity: Prisma.Decimal;
|
|
unit: string;
|
|
brand: string | null;
|
|
origin: string | null;
|
|
receiptName: string | null;
|
|
location: string | null;
|
|
purchaseDate: Date | null;
|
|
opened: boolean | null;
|
|
suitableFor: string | null;
|
|
bestBeforeDate: Date | null;
|
|
comment: string | null;
|
|
}>;
|
|
}
|
|
export {};
|