Files
psp_api/src/modules/consumer/statistics/statistics.service.ts
T

60 lines
1.4 KiB
TypeScript
Raw Normal View History

import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
@Injectable()
export class StatisticsService {
constructor(private readonly prisma: PrismaService) {}
async getInvoices(consumer_id: string) {
const startOfToday = new Date()
startOfToday.setHours(0, 0, 0, 0)
const invoices = await this.prisma.salesInvoice.findMany({
where: {
consumer_account: {
consumer_id,
},
created_at: {
gte: startOfToday,
},
},
select: {
id: true,
code: true,
total_amount: true,
created_at: true,
consumer_account: {
select: {
role: true,
account: {
select: {
username: true,
},
},
},
},
pos: {
select: {
id: true,
name: true,
complex: {
select: {
id: true,
name: true,
business_activity: {
select: {
id: true,
name: true,
},
},
},
},
},
},
},
})
return ResponseMapper.list(invoices)
}
}