2025-12-24 21:24:59 +03:30
|
|
|
model PurchaseReceipt {
|
2025-12-26 22:09:46 +03:30
|
|
|
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[]
|
2025-12-24 21:24:59 +03:30
|
|
|
|
|
|
|
|
@@index([inventoryId], map: "Purchase_Receipts_inventoryId_fkey")
|
|
|
|
|
@@index([supplierId], map: "Purchase_Receipts_supplierId_fkey")
|
|
|
|
|
@@map("Purchase_Receipts")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model PurchaseReceiptItem {
|
|
|
|
|
id Int @id @default(autoincrement())
|
2025-12-26 22:09:46 +03:30
|
|
|
count Decimal @db.Decimal(10, 0)
|
|
|
|
|
fee Decimal @db.Decimal(15, 2)
|
|
|
|
|
total Decimal @db.Decimal(15, 2)
|
2025-12-24 21:24:59 +03:30
|
|
|
description String? @db.Text
|
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamp(0)
|
|
|
|
|
receiptId Int
|
|
|
|
|
productId Int
|
|
|
|
|
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 {
|
2025-12-26 22:09:46 +03:30
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
amount Decimal @db.Decimal(15, 2)
|
|
|
|
|
paymentMethod PaymentMethodType
|
|
|
|
|
type PaymentType
|
|
|
|
|
bankAccountId Int
|
|
|
|
|
inventoryId Int
|
|
|
|
|
description String? @db.Text
|
|
|
|
|
payedAt DateTime @db.Timestamp(0)
|
2025-12-24 21:24:59 +03:30
|
|
|
receiptId Int
|
2025-12-26 22:09:46 +03:30
|
|
|
createdAt DateTime @default(now()) @db.Timestamp(0)
|
2025-12-24 21:24:59 +03:30
|
|
|
|
2025-12-26 22:09:46 +03:30
|
|
|
purchaseReceipt PurchaseReceipt @relation(fields: [receiptId], references: [id])
|
|
|
|
|
inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId])
|
2025-12-24 21:24:59 +03:30
|
|
|
|
|
|
|
|
@@index([receiptId], map: "Purchase_Receipt_Payments_receiptId_fkey")
|
|
|
|
|
@@map("Purchase_Receipt_Payments")
|
|
|
|
|
}
|