56 lines
2.7 KiB
Plaintext
56 lines
2.7 KiB
Plaintext
|
|
model PurchaseReceipt {
|
||
|
|
id Int @id @default(autoincrement())
|
||
|
|
code String @unique @db.VarChar(100)
|
||
|
|
totalAmount Decimal @db.Decimal(10, 2)
|
||
|
|
paidAmount Decimal @default(0.00) @db.Decimal(10, 2)
|
||
|
|
isSettled Boolean @default(false)
|
||
|
|
description String? @db.Text
|
||
|
|
createdAt DateTime @default(now()) @db.Timestamp(0)
|
||
|
|
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||
|
|
supplierId Int
|
||
|
|
inventoryId Int
|
||
|
|
items PurchaseReceiptItem[] @relation("PurchaseReceipt_Items")
|
||
|
|
inventory Inventory @relation(fields: [inventoryId], references: [id])
|
||
|
|
supplier Supplier @relation(fields: [supplierId], references: [id])
|
||
|
|
purchaseReceiptPayments 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, 2)
|
||
|
|
fee Decimal @db.Decimal(10, 2)
|
||
|
|
total Decimal @db.Decimal(10, 2)
|
||
|
|
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 {
|
||
|
|
id Int @id @default(autoincrement())
|
||
|
|
amount Decimal @db.Decimal(10, 2)
|
||
|
|
paymentMethod payment_method_type
|
||
|
|
bankAccountId Int?
|
||
|
|
description String? @db.Text
|
||
|
|
payedAt DateTime @db.Timestamp(0)
|
||
|
|
receiptId Int
|
||
|
|
createdAt DateTime @default(now()) @db.Timestamp(0)
|
||
|
|
|
||
|
|
purchaseReceipt PurchaseReceipt @relation(fields: [receiptId], references: [id])
|
||
|
|
bankAccount BankAccount? @relation(fields: [bankAccountId], references: [id])
|
||
|
|
|
||
|
|
@@index([receiptId], map: "Purchase_Receipt_Payments_receiptId_fkey")
|
||
|
|
@@index([bankAccountId], map: "Purchase_Receipt_Payments_bankAccountId_fkey")
|
||
|
|
@@map("Purchase_Receipt_Payments")
|
||
|
|
}
|