af9695e23c
- Removed old supplier DTOs and controller, replacing them with new implementations. - Introduced new CreateSupplierDto and UpdateSupplierDto in the index directory. - Updated SuppliersController to handle new routes and methods. - Implemented SuppliersService with updated logic for creating, finding, updating, and removing suppliers. - Added new invoices module with corresponding controller and service for handling invoice-related operations. - Created new DTOs for handling receipt payments and updated the service to manage payment creation and retrieval. - Updated Prisma migrations to reflect changes in the database schema, including dropping unnecessary columns.
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { Injectable } from '@nestjs/common'
|
|
import { ResponseMapper } from '../../common/response/response-mapper'
|
|
import { PrismaService } from '../../prisma/prisma.service'
|
|
|
|
@Injectable()
|
|
export class PurchaseReceiptPaymentsService {
|
|
constructor(private prisma: PrismaService) {}
|
|
|
|
async create(data: any) {
|
|
const item = await this.prisma.purchaseReceiptPayments.create({ data })
|
|
return ResponseMapper.create(item)
|
|
}
|
|
|
|
async findAll() {
|
|
const items = await this.prisma.purchaseReceiptPayments.findMany({
|
|
include: {
|
|
receipt: {
|
|
select: {
|
|
id: true,
|
|
code: true,
|
|
totalAmount: true,
|
|
paidAmount: true,
|
|
status: true,
|
|
supplier: {
|
|
select: { id: true, firstName: true, lastName: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
return ResponseMapper.list(items)
|
|
}
|
|
|
|
async findOne(id: number) {
|
|
const item = await this.prisma.purchaseReceiptPayments.findUnique({
|
|
where: { id },
|
|
include: {
|
|
receipt: {
|
|
select: {
|
|
id: true,
|
|
code: true,
|
|
totalAmount: true,
|
|
paidAmount: true,
|
|
status: true,
|
|
supplier: {
|
|
select: { id: true, firstName: true, lastName: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
if (!item) return null
|
|
return ResponseMapper.single(item)
|
|
}
|
|
|
|
async update(id: number, data: any) {
|
|
const item = await this.prisma.purchaseReceiptPayments.update({ where: { id }, data })
|
|
return ResponseMapper.update(item)
|
|
}
|
|
|
|
async remove(id: number) {
|
|
const item = await this.prisma.purchaseReceiptPayments.delete({ where: { id } })
|
|
return ResponseMapper.single(item)
|
|
}
|
|
}
|