mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: download invoice document on payment page
This commit is contained in:
@@ -102,12 +102,13 @@ export class PublicSharableLinkController extends BaseController {
|
|||||||
const { paymentLinkId } = req.params;
|
const { paymentLinkId } = req.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const pdfContent = await this.paymentLinkApp.getPaymentLinkInvoicePdf(
|
const [pdfContent, filename] =
|
||||||
paymentLinkId
|
await this.paymentLinkApp.getPaymentLinkInvoicePdf(paymentLinkId);
|
||||||
);
|
|
||||||
res.set({
|
res.set({
|
||||||
'Content-Type': 'application/pdf',
|
'Content-Type': 'application/pdf',
|
||||||
'Content-Length': pdfContent.length,
|
'Content-Length': pdfContent.length,
|
||||||
|
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||||
});
|
});
|
||||||
res.send(pdfContent);
|
res.send(pdfContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ export class GetPaymentLinkInvoicePdf {
|
|||||||
* Retrieves the sale invoice PDF of the given payment link id.
|
* Retrieves the sale invoice PDF of the given payment link id.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
* @param {number} paymentLinkId
|
* @param {number} paymentLinkId
|
||||||
* @returns {Promise<Buffer>}
|
* @returns {Promise<Buffer, string>}
|
||||||
*/
|
*/
|
||||||
async getPaymentLinkInvoicePdf(paymentLinkId: string): Promise<Buffer> {
|
async getPaymentLinkInvoicePdf(
|
||||||
|
paymentLinkId: string
|
||||||
|
): Promise<[Buffer, string]> {
|
||||||
const paymentLink = await PaymentLink.query()
|
const paymentLink = await PaymentLink.query()
|
||||||
.findOne('linkId', paymentLinkId)
|
.findOne('linkId', paymentLinkId)
|
||||||
.where('resourceType', 'SaleInvoice')
|
.where('resourceType', 'SaleInvoice')
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ export class PaymentLinksApplication {
|
|||||||
* @param {number} paymentLinkId
|
* @param {number} paymentLinkId
|
||||||
* @returns {Promise<Buffer> }
|
* @returns {Promise<Buffer> }
|
||||||
*/
|
*/
|
||||||
public getPaymentLinkInvoicePdf(paymentLinkId: string): Promise<Buffer> {
|
public getPaymentLinkInvoicePdf(
|
||||||
|
paymentLinkId: string
|
||||||
|
): Promise<[Buffer, string]> {
|
||||||
return this.getPaymentLinkInvoicePdfService.getPaymentLinkInvoicePdf(
|
return this.getPaymentLinkInvoicePdfService.getPaymentLinkInvoicePdf(
|
||||||
paymentLinkId
|
paymentLinkId
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user