init to statistics and manage pos type users
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user