Files
psp_api/prisma/schema/stock.prisma
T
ahasani cbe51b9343 feat: implement bank accounts, branches, and banks modules with CRUD operations
- Added BankAccountsController, BankAccountsService, and related DTOs for managing bank accounts.
- Implemented BankBranchesController, BankBranchesService, and related DTOs for managing bank branches.
- Created BanksController and BanksService for retrieving bank information.
- Integrated Prisma for database operations across all modules.
- Added response mapping for consistent API responses.
2025-12-24 21:24:59 +03:30

62 lines
3.0 KiB
Plaintext

model StockMovement {
id Int @id @default(autoincrement())
type MovementType
quantity Decimal @db.Decimal(10, 2)
fee Decimal @db.Decimal(10, 2)
totalCost Decimal @db.Decimal(10, 2)
referenceType MovementReferenceType
referenceId String
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
avgCost Decimal @db.Decimal(10, 2)
supplierId Int?
remainedInStock Decimal @default(0.00) @db.Decimal(10, 2)
counterInventoryId Int?
customerId Int?
counterInventory Inventory? @relation("StockMovement_CounterInventory", fields: [counterInventoryId], references: [id])
customer Customer? @relation("StockMovement_Customer", 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, 2)
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")
}