Files
psp_api/prisma/schema/inventory.prisma
T
ahasani d98507fc1f fix: update SupplierLedger model to use correct enum casing and adjust types
feat: enhance PosAccountsService to include inventoryBankAccount details in responses

refactor: modify PosService to return structured inventory and bank account data

chore: remove isSettled field from CreatePurchaseReceiptDto and adjust related logic

feat: add payments selection in SuppliersService for better payment tracking

chore: apply database migrations to adjust decimal types and enforce constraints

chore: create index on Pos_Accounts for improved query performance

feat: define Supplier and SupplierLedger models in Prisma schema for better data management
2025-12-26 22:09:46 +03:30

82 lines
3.7 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[]
salesInvoices SalesInvoice[] @relation("Inventory_SalesInvoices")
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])
@@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")
}