inventory

This commit is contained in:
2025-12-14 23:02:55 +03:30
parent 996cd0016c
commit 0ac1b39100
16 changed files with 453 additions and 30 deletions
@@ -0,0 +1,20 @@
import { Entity, ManyToOne, Property, Unique } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
import { Food } from '../../foods/entities/food.entity';
@Entity({ tableName: 'inventory' })
@Unique({ properties: ['food', 'restaurant'] })
export class Inventory extends BaseEntity {
@ManyToOne(() => Food, { unique: true })
food!: Food;
@ManyToOne(() => Restaurant)
restaurant!: Restaurant;
@Property({ type: 'int' })
totalStock!: number;
@Property({ type: 'int' })
availableStock!: number;
}
@@ -0,0 +1,23 @@
import { Entity, Enum, ManyToOne, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Food } from '../../foods/entities/food.entity';
import { Order } from '../../orders/entities/order.entity';
import { ReservationStatus } from '../inteface/reservation';
@Entity({ tableName: 'reservations' })
export class Reservation extends BaseEntity {
@ManyToOne(() => Food)
food!: Food;
@ManyToOne(() => Order)
order!: Order;
@Property({ type: 'int' })
quantity!: number;
@Property({ type: 'date' })
expiresAt!: Date;
@Enum(() => ReservationStatus)
status: ReservationStatus = ReservationStatus.ACTIVE;
}