Files
psp_api/prisma/schema/inventory.prisma
T
ahasani eb6e0e7a0d feat(inventories): add cardex retrieval for inventory and product
feat(pos): update sale invoice creation to include customer and item details
feat(pos): enhance POS account service to include today's sales information
feat(pos): refactor order DTO to create sale invoice with detailed item structure
feat(products): add minimum stock alert level to product creation and update DTOs
fix(triggers): implement stock validation and movement logging for sales invoice items
refactor(database): update sales invoices schema to include posAccountId and remove inventoryId
2025-12-30 21:04:01 +03:30

82 lines
3.6 KiB
Plaintext

model Inventory {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
location String? @db.VarChar(255)
isActive Boolean @default(true)
createdAt DateTime @default(now()) @db.Timestamp(0)
updatedAt DateTime @updatedAt @db.Timestamp(0)
deletedAt DateTime? @db.Timestamp(0)
isPointOfSale Boolean @default(false)
inventoryTransfersFrom InventoryTransfer[] @relation("Inventory_From")
inventoryTransfersTo InventoryTransfer[] @relation("Inventory_To")
purchaseReceipts PurchaseReceipt[]
stockAdjustments StockAdjustment[] @relation("Inventory_Stock_Adjustments")
stockBalances StockBalance[] @relation("StockBalance_inventory")
counterStockMovements StockMovement[] @relation("StockMovement_CounterInventory")
stockMovements StockMovement[] @relation("StockMovement_Inventory")
inventoryBankAccounts InventoryBankAccount[]
@@map("Inventories")
}
model InventoryBankAccount {
inventoryId Int
bankAccountId Int
inventory Inventory @relation(fields: [inventoryId], references: [id])
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
posAccounts PosAccount[]
purchaseReceiptPayments PurchaseReceiptPayments[]
@@id([inventoryId, bankAccountId])
@@index([bankAccountId])
@@map("Inventory_Bank_Accounts")
}
model PosAccount {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
code String @unique() @db.VarChar(10)
description String? @db.VarChar(500)
bankAccountId Int
inventoryId Int
createdAt DateTime @default(now()) @db.Timestamp(0)
updatedAt DateTime @updatedAt @db.Timestamp(0)
deletedAt DateTime? @db.Timestamp(0)
inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId])
salesInvoices SalesInvoice[]
@@index([inventoryId])
@@map("Pos_Accounts")
}
model InventoryTransfer {
id Int @id @default(autoincrement())
code String @unique @db.VarChar(100)
description String? @db.Text
createdAt DateTime @default(now()) @db.Timestamp(0)
fromInventoryId Int
toInventoryId Int
items InventoryTransferItem[] @relation("InventoryTransfer_Items")
fromInventory Inventory @relation("Inventory_From", fields: [fromInventoryId], references: [id])
toInventory Inventory @relation("Inventory_To", fields: [toInventoryId], references: [id])
@@index([fromInventoryId], map: "Inventory_Transfers_fromInventoryId_fkey")
@@index([toInventoryId], map: "Inventory_Transfers_toInventoryId_fkey")
@@map("Inventory_Transfers")
}
model InventoryTransferItem {
id Int @id @default(autoincrement())
count Decimal @db.Decimal(10, 0)
productId Int
transferId Int
product Product @relation("InventoryTransferItem_Product", fields: [productId], references: [id])
transfer InventoryTransfer @relation("InventoryTransfer_Items", fields: [transferId], references: [id])
@@index([productId], map: "Inventory_Transfer_Items_productId_fkey")
@@index([transferId], map: "Inventory_Transfer_Items_transferId_fkey")
@@map("Inventory_Transfer_Items")
}