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
+4 -1
View File
@@ -13,10 +13,13 @@ export class PosController {
async getInfo(@PosInfo('pos_id') pos_id: string, @Res({ passthrough: true }) res) {
const result = await this.service.getInfo(pos_id)
console.log('firstaaaaa')
if (result) {
console.log('first')
// @ts-ignore
res.cookie('posId', pos_id, {
httpOnly: true,
httpOnly: false,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
+15 -2
View File
@@ -4,8 +4,8 @@ import { PrismaService } from '@/prisma/prisma.service'
import {
ForbiddenException,
Injectable,
MisdirectedException,
NestMiddleware,
PreconditionFailedException,
} from '@nestjs/common'
import { JwtService } from '@nestjs/jwt'
import { NextFunction, Request, Response } from 'express'
@@ -32,6 +32,11 @@ export class PosMiddleware implements NestMiddleware {
return doForbidden()
}
if (req.url.startsWith('/api/v1/pos/accessible')) {
req.decodedToken = tokenAccount!
return next()
}
if (!posId || typeof posId !== 'string') {
const pos = await this.prisma.pos.findMany({
where: {
@@ -46,6 +51,13 @@ export class PosMiddleware implements NestMiddleware {
},
},
},
permission_pos: {
some: {
permission: {
consumer_account_id: account_id,
},
},
},
},
})
@@ -54,7 +66,8 @@ export class PosMiddleware implements NestMiddleware {
}
if (pos.length === 1) {
posId = pos[0].id
} else throw new MisdirectedException()
} else
throw new PreconditionFailedException('پایانه‌ی مورد نظر خود را انتخاب کنید.')
}
const pos = await this.prisma.pos.findUnique({
+23
View File
@@ -68,6 +68,29 @@ export class PosService {
},
},
},
permission_pos: {
some: {
permission: {
consumer_account_id: account_id,
},
},
},
},
select: {
id: true,
name: true,
complex: {
select: {
id: true,
name: true,
business_activity: {
select: {
id: true,
name: true,
},
},
},
},
},
})
@@ -166,7 +166,7 @@ export class SalesInvoicesService {
// id: newCustomerId || undefined,
// },
// },
account: {
consumer_account: {
connect: {
id: consumer_account_id,
},