23bfe1ecbe
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 "صورتحساب"
30 lines
847 B
TypeScript
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
|
|
}
|
|
}
|