mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
refactor(nestjs): wip import module
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import { Response } from 'express';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Headers,
|
||||
HttpCode,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
Res,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ISaleInvoiceWriteoffDTO,
|
||||
@@ -29,6 +32,7 @@ import {
|
||||
CreateSaleInvoiceDto,
|
||||
EditSaleInvoiceDto,
|
||||
} from './dtos/SaleInvoice.dto';
|
||||
import { AcceptType } from '@/constants/accept-type';
|
||||
|
||||
@Controller('sale-invoices')
|
||||
@ApiTags('sale-invoices')
|
||||
@@ -154,8 +158,22 @@ export class SaleInvoicesController {
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
getSaleInvoice(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.getSaleInvoice(id);
|
||||
async getSaleInvoice(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Headers('accept') acceptHeader: string,
|
||||
@Res({ passthrough: true }) res: Response,
|
||||
) {
|
||||
if (acceptHeader.includes(AcceptType.ApplicationPdf)) {
|
||||
const pdfContent = await this.saleInvoiceApplication.saleInvoicePdf(id);
|
||||
|
||||
res.set({
|
||||
'Content-Type': 'application/pdf',
|
||||
'Content-Length': pdfContent.length,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
} else {
|
||||
return this.saleInvoiceApplication.getSaleInvoice(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Get()
|
||||
@@ -239,19 +257,6 @@ export class SaleInvoicesController {
|
||||
return this.saleInvoiceApplication.getInvoicePayments(id);
|
||||
}
|
||||
|
||||
@Get(':id/pdf')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice PDF.' })
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The sale invoice id',
|
||||
})
|
||||
saleInvoicePdf(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.saleInvoiceApplication.saleInvoicePdf(id);
|
||||
}
|
||||
|
||||
@Get(':id/html')
|
||||
@ApiOperation({ summary: 'Retrieves the sale invoice HTML.' })
|
||||
@ApiResponse({ status: 404, description: 'The sale invoice not found.' })
|
||||
|
||||
Reference in New Issue
Block a user