Files
psp_api/prisma/schema/stock.prisma
T
ahasani 5fd6611aca feat: implement POS order management system
- Added CreateOrderDto and CreateOrderItemDto for order creation.
- Developed PosOrdersController to handle order-related endpoints.
- Created PosOrdersService for business logic related to orders.
- Implemented PosOrdersWorkflow for order processing workflows.
- Established Prisma integration for database operations in orders.
- Introduced SalesInvoicesModule and related DTOs for sales invoice management.
- Enhanced SalesInvoicesService and SalesInvoicesWorkflow for invoice processing.
2026-01-07 15:25:59 +03:30

88 lines
3.7 KiB
Plaintext

model StockMovement {
id Int @id @default(autoincrement())
type MovementType
quantity Decimal @db.Decimal(10, 0)
unitPrice Decimal @db.Decimal(15, 2)
totalCost Decimal @db.Decimal(15, 2)
referenceType MovementReferenceType
referenceId String
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
avgCost Decimal @db.Decimal(15, 2)
supplierId Int?
remainedInStock Decimal @default(0.00) @db.Decimal(10, 0)
counterInventoryId Int?
customerId Int?
counterInventory Inventory? @relation("StockMovement_CounterInventory", fields: [counterInventoryId], references: [id])
customer Customer? @relation(fields: [customerId], references: [id])
inventory Inventory @relation("StockMovement_Inventory", fields: [inventoryId], references: [id])
product Product @relation("StockMovement_Product", fields: [productId], references: [id])
supplier Supplier? @relation("StockMovement_Supplier", fields: [supplierId], references: [id])
@@index([inventoryId], map: "Stock_Movements_inventoryId_fkey")
@@index([productId], map: "Stock_Movements_productId_fkey")
@@index([counterInventoryId], map: "Stock_Movements_counterInventoryId_fkey")
@@index([customerId], map: "Stock_Movements_customerId_fkey")
@@index([supplierId], map: "Stock_Movements_supplierId_fkey")
@@map("Stock_Movements")
}
model StockBalance {
quantity Decimal @default(0.000) @db.Decimal(14, 3)
totalCost Decimal @default(0.00) @db.Decimal(14, 2)
updatedAt DateTime @updatedAt @db.Timestamp(0)
avgCost Decimal @default(0.00) @db.Decimal(14, 2)
inventoryId Int
productId Int
createdAt DateTime @default(now()) @db.Timestamp(0)
id Int @id @default(autoincrement())
inventory Inventory @relation("StockBalance_inventory", fields: [inventoryId], references: [id])
product Product @relation("StockBalance_Product", fields: [productId], references: [id])
@@unique([productId, inventoryId])
@@index([productId])
@@index([inventoryId])
@@map("Stock_Balance")
}
model StockAdjustment {
id Int @id @default(autoincrement())
adjustedQuantity Decimal @db.Decimal(10, 0)
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
inventory Inventory @relation("Inventory_Stock_Adjustments", fields: [inventoryId], references: [id])
product Product @relation("Product_Stock_Adjustments", fields: [productId], references: [id])
@@index([inventoryId], map: "Stock_Adjustments_inventoryId_fkey")
@@index([productId], map: "Stock_Adjustments_productId_fkey")
@@map("Stock_Adjustments")
}
model StockReservation {
id Int @id @default(autoincrement())
quantity Decimal @db.Decimal(10, 0)
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
orderId Int
inventory Inventory @relation(fields: [inventoryId], references: [id])
product Product @relation(fields: [productId], references: [id])
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
@@index([inventoryId])
@@index([productId])
@@map("Stock_Reservations")
}
view StockAvailableView {
productId Int
inventoryId Int
physicalQuantity Decimal @db.Decimal(10, 0)
reservedQuantity Decimal @db.Decimal(10, 0)
availableQuantity Decimal @db.Decimal(10, 0)
@@map("Stock_Available_View")
}