Files
psp_api/src/common/services/saleInvoices/sale-invoice-access.service.ts
T
ahasani 23bfe1ecbe Refactor: Remove stored procedures and replace with direct database operations
feat: Add economic code and guild information to sales invoice selection

fix: Update error messages for invoice access and creation to use "صورت‌حساب"

fix: Change error messages in SaleInvoicesService to use "صورت‌حساب" instead of "فاکتور"

fix: Update error messages in SalesInvoicesService for not found cases to use "صورت‌حساب"

fix: Modify TSP service to handle invoice updates and error messages consistently with "صورت‌حساب"

fix: Update common DTO descriptions to refer to "صورت‌حساب" instead of "فاکتور"

fix: Adjust utility functions to handle invoice references and error messages with "صورت‌حساب"
2026-06-11 16:13:17 +03:30

30 lines
847 B
TypeScript

import { PrismaService } from '@/prisma/prisma.service'
import { BadRequestException, Injectable } from '@nestjs/common'
import { ConsumerRole } from 'generated/prisma/enums'
@Injectable()
export class SharedSaleInvoiceAccessService {
constructor(private readonly prisma: PrismaService) {}
async getConsumerIdWithPosAccess(
consumerAccountId: string,
posId: string,
): Promise<string> {
const consumer = await this.prisma.consumerAccount.findUnique({
where: {
id: consumerAccountId,
OR: [{ pos: { id: posId } }, { role: ConsumerRole.OWNER }],
},
select: {
consumer_id: true,
},
})
if (!consumer) {
throw new BadRequestException('شما دسترسی لازم برای ارسال صورت‌حساب را ندارید.')
}
return consumer.consumer_id
}
}