Files
psp_api/prisma/schema/inventory.prisma
T
ahasani b4f226fb3a refactor(inventories): restructure inventory and pos account modules, remove deprecated DTOs and controllers
- Removed create and update DTOs for inventory.
- Deleted inventories controller and service.
- Introduced new inventory bank accounts module with controller and service.
- Added new pos accounts module with controller and service.
- Updated Prisma models to reflect changes in bank account relationships.
- Adjusted PosAccount and SalesInvoice models for stricter type definitions.
- Implemented new response mapping for inventory and pos account services.
2025-12-26 01:20:03 +03:30

84 lines
4.1 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")
// productCharges ProductCharge[] @relation("Inventory_Product_Charges")
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")
posAccounts PosAccount[] @relation("Inventory_PosAccounts")
inventoryBankAccounts InventoryBankAccount[] @relation("Inventory_Bank_Accounts_inventoryId_fkey")
@@map("Inventories")
}
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, 2)
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")
}
model InventoryBankAccount {
inventoryId Int
bankAccountId Int
inventory Inventory @relation("Inventory_Bank_Accounts_inventoryId_fkey", fields: [inventoryId], references: [id])
bankAccount BankAccount @relation("Inventory_Bank_Accounts_bankAccountId_fkey", fields: [bankAccountId], references: [id])
posAccounts PosAccount[] @relation("Pos_Accounts_inventoryBankAccountId_fkey")
@@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)
inventory Inventory @relation("Inventory_PosAccounts", fields: [inventoryId], references: [id])
inventoryBankAccount InventoryBankAccount? @relation("Pos_Accounts_inventoryBankAccountId_fkey", fields: [bankAccountId, inventoryId], references: [bankAccountId, inventoryId])
bankAccount BankAccount? @relation(fields: [bankAccountId], references: [id])
@@map("Pos_Accounts")
}