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

57 lines
2.5 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)
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(15, 2)
paymentMethod PaymentMethodType
type PaymentType
bankAccountId Int
inventoryId 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])
inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId])
@@index([receiptId], map: "Purchase_Receipt_Payments_receiptId_fkey")
@@map("Purchase_Receipt_Payments")
}