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:
@@ -90,10 +90,35 @@ export class SupplierInvoicesService {
|
||||
},
|
||||
},
|
||||
},
|
||||
bankAccount: {
|
||||
select: {
|
||||
branch: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
bank: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
shortName: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accountNumber: true,
|
||||
cardNumber: true,
|
||||
name: true,
|
||||
id: true,
|
||||
iban: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
omit: {
|
||||
receiptId: true,
|
||||
},
|
||||
orderBy: {
|
||||
payedAt: 'desc',
|
||||
},
|
||||
})
|
||||
return ResponseMapper.list(items)
|
||||
}
|
||||
@@ -123,15 +148,21 @@ export class SupplierInvoicesService {
|
||||
}
|
||||
|
||||
async createPayment(invoiceId: number, data: CreateReceiptPaymentDto) {
|
||||
const { bankAccountId, ...rest } = data
|
||||
const payment = await this.prisma.purchaseReceiptPayments.create({
|
||||
data: {
|
||||
...data,
|
||||
...rest,
|
||||
payedAt: new Date(data.payedAt),
|
||||
receipt: {
|
||||
connect: {
|
||||
id: invoiceId,
|
||||
},
|
||||
},
|
||||
bankAccount: {
|
||||
connect: {
|
||||
id: bankAccountId,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
receipt: true,
|
||||
|
||||
Reference in New Issue
Block a user