Files
psp_api/src/modules/consumer/saleInvoices/saleInvoices.controller.ts
T

69 lines
2.2 KiB
TypeScript
Raw Normal View History

import { PosInfo } from '@/common/decorators/posInfo.decorator'
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
import type { IPosPayload } from '@/common/models'
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
import { ConsumerSaleInvoicesFilterDto } from './dto/saleInvoices-filter.dto'
import type {
SaleInvoicesServiceFindAllResponseDto,
SaleInvoicesServiceFindOneResponseDto,
} from './dto/saleInvoices-response.dto'
import { SendBulkSaleInvoicesDto } from './dto/send-saleInvoices.dto'
import { SaleInvoicesService } from './saleInvoices.service'
@ApiTags('ConsumerSaleInvoices')
@Controller('consumer/sale-invoices')
export class StatisticsController {
constructor(private readonly service: SaleInvoicesService) {}
@Get('')
async findAll(
@TokenAccount('userId') consumerId: string,
@Query('page') page = '1',
@Query('perPage') perPage = '10',
): Promise<SaleInvoicesServiceFindAllResponseDto> {
const filter: ConsumerSaleInvoicesFilterDto = {
page: Number(page) || 1,
perPage: Number(perPage) || 10,
}
return this.service.findAll(consumerId, filter)
}
@Get(':id')
async findOne(
@TokenAccount('userId') consumerId: string,
@Param('id') id: string,
): Promise<SaleInvoicesServiceFindOneResponseDto> {
return this.service.findOne(consumerId, id)
}
@Post('send_tax_bulk')
async sendBulk(
@TokenAccount('userId') consumerId: string,
@Body() data: SendBulkSaleInvoicesDto,
) {
return this.service.sendBulk(consumerId, data.invoice_ids)
}
@Get(':id/inquiry')
inquiry(@PosInfo() posInfo: IPosPayload, @Param('id') id: string) {
return this.service.inquiry(posInfo.consumer_account_id, posInfo.pos_id, id)
}
@Post(':id/send')
send(@Param('id') id: string, @PosInfo() posInfo: IPosPayload) {
return this.service.send(id, posInfo)
}
@Post(':id/retry')
retry(@Param('id') id: string, @PosInfo() posInfo: IPosPayload) {
return this.service.retry(id, posInfo)
}
@Post(':id/revoke')
revoke(@Param('id') id: string, @PosInfo() posInfo: IPosPayload) {
return this.service.revoke(id, posInfo)
}
}