Files
psp_api/prisma/schema/purchase.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

59 lines
2.7 KiB
Plaintext

model PurchaseReceipt {
id Int @id @default(autoincrement())
code String @unique @db.VarChar(100)
totalAmount Decimal @db.Decimal(15, 2)
paidAmount Decimal @default(0.00) @db.Decimal(15, 2)
description String? @db.Text
createdAt DateTime @default(now()) @db.Timestamp(0)
updatedAt DateTime @updatedAt @db.Timestamp(0)
status PurchaseReceiptStatus @default(UNPAID)
supplierId Int
inventoryId Int
items PurchaseReceiptItem[] @relation("PurchaseReceipt_Items")
inventory Inventory @relation(fields: [inventoryId], references: [id])
supplier Supplier @relation(fields: [supplierId], references: [id])
payments PurchaseReceiptPayments[]
@@index([inventoryId], map: "Purchase_Receipts_inventoryId_fkey")
@@index([supplierId], map: "Purchase_Receipts_supplierId_fkey")
@@map("Purchase_Receipts")
}
model PurchaseReceiptItem {
id Int @id @default(autoincrement())
count Decimal @db.Decimal(10, 0)
fee Decimal @db.Decimal(15, 2)
total Decimal @db.Decimal(15, 2)
receiptId Int
productId Int
description String? @db.Text
createdAt DateTime @default(now()) @db.Timestamp(0)
product Product @relation("Product_PurchaseReceiptItems", fields: [productId], references: [id])
receipt PurchaseReceipt @relation("PurchaseReceipt_Items", fields: [receiptId], references: [id])
@@index([productId], map: "Purchase_Receipt_Items_productId_fkey")
@@index([receiptId], map: "Purchase_Receipt_Items_receiptId_fkey")
@@map("Purchase_Receipt_Items")
}
model PurchaseReceiptPayments {
id Int @id @default(autoincrement())
amount Decimal @db.Decimal(15, 2)
paymentMethod PaymentMethodType
type PaymentType
bankAccountId Int
receiptId Int
payedAt DateTime @db.Timestamp(0)
description String? @db.Text
createdAt DateTime @default(now()) @db.Timestamp(0)
receipt PurchaseReceipt @relation(fields: [receiptId], references: [id])
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
inventoryBankAccount InventoryBankAccount? @relation(fields: [inventoryBankAccountInventoryId, inventoryBankAccountBankAccountId], references: [inventoryId, bankAccountId])
inventoryBankAccountInventoryId Int?
inventoryBankAccountBankAccountId Int?
@@index([receiptId], map: "Purchase_Receipt_Payments_receiptId_fkey")
@@map("Purchase_Receipt_Payments")
}