feat: enhance sales invoice functionality with inquiry, send, retry, and revoke actions
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user