mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: estimate, receipt, credit note mail preview
This commit is contained in:
@@ -411,9 +411,8 @@ export default class PaymentReceivesController extends BaseController {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const data = await this.paymentReceiveApplication.getPaymentReceivedState(
|
||||
tenantId
|
||||
);
|
||||
const data =
|
||||
await this.paymentReceiveApplication.getPaymentReceivedState(tenantId);
|
||||
return res.status(200).send({ data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
@@ -471,7 +470,7 @@ export default class PaymentReceivesController extends BaseController {
|
||||
ACCEPT_TYPE.APPLICATION_JSON,
|
||||
ACCEPT_TYPE.APPLICATION_PDF,
|
||||
]);
|
||||
// Response in pdf format.
|
||||
// Responses pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF === acceptType) {
|
||||
const [pdfContent, filename] =
|
||||
await this.paymentReceiveApplication.getPaymentReceivePdf(
|
||||
@@ -484,7 +483,14 @@ export default class PaymentReceivesController extends BaseController {
|
||||
'Content-Disposition': `attachment; filename="${filename}"`,
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Response in json format.
|
||||
// Responses html format.
|
||||
} else if (ACCEPT_TYPE.APPLICATION_TEXT_HTML === acceptType) {
|
||||
const htmlContent = this.paymentReceiveApplication.getPaymentReceivedHtml(
|
||||
tenantId,
|
||||
paymentReceiveId
|
||||
);
|
||||
return res.status(200).send({ htmlContent });
|
||||
// Responses json format.
|
||||
} else {
|
||||
const paymentReceive =
|
||||
await this.paymentReceiveApplication.getPaymentReceive(
|
||||
|
||||
@@ -13,11 +13,8 @@ import DynamicListingService from '@/services/DynamicListing/DynamicListService'
|
||||
import { ServiceError } from '@/exceptions';
|
||||
import CheckPolicies from '@/api/middleware/CheckPolicies';
|
||||
import { SaleEstimatesApplication } from '@/services/Sales/Estimates/SaleEstimatesApplication';
|
||||
import { ACCEPT_TYPE } from '@/interfaces/Http';
|
||||
|
||||
const ACCEPT_TYPE = {
|
||||
APPLICATION_PDF: 'application/pdf',
|
||||
APPLICATION_JSON: 'application/json',
|
||||
};
|
||||
@Service()
|
||||
export default class SalesEstimatesController extends BaseController {
|
||||
@Inject()
|
||||
@@ -395,6 +392,7 @@ export default class SalesEstimatesController extends BaseController {
|
||||
const acceptType = accept.types([
|
||||
ACCEPT_TYPE.APPLICATION_JSON,
|
||||
ACCEPT_TYPE.APPLICATION_PDF,
|
||||
ACCEPT_TYPE.APPLICATION_TEXT_HTML,
|
||||
]);
|
||||
// Retrieves estimate in pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF == acceptType) {
|
||||
@@ -410,7 +408,14 @@ export default class SalesEstimatesController extends BaseController {
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Retrieves estimates in json format.
|
||||
} else {
|
||||
} else if (ACCEPT_TYPE.APPLICATION_TEXT_HTML === acceptType) {
|
||||
const htmlContent =
|
||||
await this.saleEstimatesApplication.getSaleEstimateHtml(
|
||||
tenantId,
|
||||
estimateId
|
||||
);
|
||||
return res.status(200).send({ htmlContent });
|
||||
} else if (ACCEPT_TYPE.APPLICATION_JSON) {
|
||||
const estimate = await this.saleEstimatesApplication.getSaleEstimate(
|
||||
tenantId,
|
||||
estimateId
|
||||
|
||||
@@ -353,6 +353,7 @@ export default class SalesReceiptsController extends BaseController {
|
||||
const acceptType = accept.types([
|
||||
ACCEPT_TYPE.APPLICATION_JSON,
|
||||
ACCEPT_TYPE.APPLICATION_PDF,
|
||||
ACCEPT_TYPE.APPLICATION_TEXT_HTML,
|
||||
]);
|
||||
// Retrieves receipt in pdf format.
|
||||
if (ACCEPT_TYPE.APPLICATION_PDF == acceptType) {
|
||||
@@ -368,6 +369,12 @@ export default class SalesReceiptsController extends BaseController {
|
||||
});
|
||||
res.send(pdfContent);
|
||||
// Retrieves receipt in json format.
|
||||
} else if (ACCEPT_TYPE.APPLICATION_TEXT_HTML === acceptType) {
|
||||
const htmlContent = await this.saleReceiptsApplication.getSaleReceiptHtml(
|
||||
tenantId,
|
||||
saleReceiptId
|
||||
);
|
||||
res.send({ htmlContent });
|
||||
} else {
|
||||
const saleReceipt = await this.saleReceiptsApplication.getSaleReceipt(
|
||||
tenantId,
|
||||
|
||||
Reference in New Issue
Block a user