feat: add bank account relation to PurchaseReceiptPayments and update related services

- Added bank account relation to PurchaseReceiptPayments model.
- Updated BankAccount model to include purchaseReceiptPayments relation.
- Modified PurchaseReceiptPayments service to handle bank account data during payment creation.
- Enhanced SuppliersService to order suppliers by creation date.
- Updated SupplierInvoicesService to include bank account details in invoice payments and order payments by payedAt.
- Added foreign key constraint for bankAccountId in PurchaseReceiptPayments table.
This commit is contained in:
2025-12-29 10:14:56 +03:30
parent b35a3633ed
commit 1bb206a608
8 changed files with 330 additions and 23 deletions
@@ -0,0 +1,2 @@
-- AddForeignKey
ALTER TABLE `Purchase_Receipt_Payments` ADD CONSTRAINT `Purchase_Receipt_Payments_bankAccountId_fkey` FOREIGN KEY (`bankAccountId`) REFERENCES `Bank_Accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
+1
View File
@@ -27,6 +27,7 @@ model BankAccount {
branch BankBranch @relation("Bank_Accounts_branchId_fkey", fields: [branchId], references: [id])
inventoryBankAccounts InventoryBankAccount[]
purchaseReceiptPayments PurchaseReceiptPayments[]
@@map("Bank_Accounts")
}
+2 -2
View File
@@ -42,13 +42,13 @@ model PurchaseReceiptPayments {
paymentMethod PaymentMethodType
type PaymentType
bankAccountId Int
inventoryId 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])
receipt PurchaseReceipt @relation(fields: [receiptId], references: [id])
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
@@index([receiptId], map: "Purchase_Receipt_Payments_receiptId_fkey")
@@map("Purchase_Receipt_Payments")