update revoke
This commit is contained in:
@@ -258,48 +258,14 @@ export class SalesInvoicesService {
|
||||
|
||||
return ResponseMapper.single({
|
||||
...rest,
|
||||
status: tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||
status: translateEnumValue(
|
||||
'TspProviderResponseStatus',
|
||||
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||
),
|
||||
})
|
||||
} else throw new NotFoundException('فاکتور مورد نظر شما یافت نشد.')
|
||||
}
|
||||
|
||||
async send(invoiceId: string, posInfo: IPosPayload) {
|
||||
const consumer_id = await this.checkAccessToInvoice(
|
||||
posInfo.consumer_account_id,
|
||||
posInfo.pos_id,
|
||||
)
|
||||
const invoice = await this.salesInvoiceTaxService.send(consumer_id, invoiceId)
|
||||
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
|
||||
async revoke(invoiceId: string, posInfo: IPosPayload) {
|
||||
await this.checkAccessToInvoice(posInfo.consumer_account_id, posInfo.pos_id)
|
||||
|
||||
const invoice = await this.salesInvoiceTaxService.revoke(posInfo.pos_id, invoiceId)
|
||||
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
|
||||
async inquiry(consumer_account_id: string, pos_id: string, invoiceId: string) {
|
||||
const consumer_id = await this.checkAccessToInvoice(consumer_account_id, pos_id)
|
||||
const invoice = await this.salesInvoiceTaxService.get(invoiceId, pos_id, consumer_id)
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
|
||||
// async sendBulk(invoiceIds: string[], posInfo: IPosPayload) {
|
||||
// if (!invoiceIds.length) {
|
||||
// throw new BadRequestException('invoice_ids is required and cannot be empty.')
|
||||
// }
|
||||
|
||||
// await this.salesInvoiceTaxService.sendBulk(invoiceIds, posInfo.pos_id)
|
||||
|
||||
// return ResponseMapper.single({
|
||||
// invoice_ids: invoiceIds,
|
||||
// sent_to_tax: true,
|
||||
// })
|
||||
// }
|
||||
|
||||
async create(data: CreateSalesInvoiceDto, posInfo: IPosPayload) {
|
||||
const { business_id, pos_id, consumer_account_id, complex_id } = posInfo
|
||||
const normalizedInvoiceDate = this.normalizeInvoiceDate(data.invoice_date)
|
||||
@@ -360,6 +326,43 @@ export class SalesInvoicesService {
|
||||
throw new BadRequestException('ایجاد فاکتور با خطا مواجه شد.')
|
||||
}
|
||||
|
||||
async send(invoiceId: string, posInfo: IPosPayload) {
|
||||
const consumer_id = await this.checkAccessToInvoice(
|
||||
posInfo.consumer_account_id,
|
||||
posInfo.pos_id,
|
||||
)
|
||||
const invoice = await this.salesInvoiceTaxService.send(consumer_id, invoiceId)
|
||||
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
|
||||
async revoke(invoiceId: string, posInfo: IPosPayload) {
|
||||
await this.checkAccessToInvoice(posInfo.consumer_account_id, posInfo.pos_id)
|
||||
|
||||
const invoice = await this.salesInvoiceTaxService.revoke(posInfo.pos_id, invoiceId)
|
||||
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
|
||||
async inquiry(consumer_account_id: string, pos_id: string, invoiceId: string) {
|
||||
const consumer_id = await this.checkAccessToInvoice(consumer_account_id, pos_id)
|
||||
const invoice = await this.salesInvoiceTaxService.get(invoiceId, pos_id, consumer_id)
|
||||
return ResponseMapper.single(invoice)
|
||||
}
|
||||
|
||||
// async sendBulk(invoiceIds: string[], posInfo: IPosPayload) {
|
||||
// if (!invoiceIds.length) {
|
||||
// throw new BadRequestException('invoice_ids is required and cannot be empty.')
|
||||
// }
|
||||
|
||||
// await this.salesInvoiceTaxService.sendBulk(invoiceIds, posInfo.pos_id)
|
||||
|
||||
// return ResponseMapper.single({
|
||||
// invoice_ids: invoiceIds,
|
||||
// sent_to_tax: true,
|
||||
// })
|
||||
// }
|
||||
|
||||
private isRetryableInvoiceConflict(error: unknown) {
|
||||
if (!(error instanceof Prisma.PrismaClientKnownRequestError)) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user