init to statistics and manage pos type users

This commit is contained in:
2026-04-13 13:21:50 +03:30
parent 9cef733370
commit 388aa25de4
31 changed files with 385 additions and 251 deletions
@@ -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)
}
}