mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: hook up the invice customize api
This commit is contained in:
@@ -26,20 +26,21 @@ export class PdfTemplatesController extends BaseController {
|
||||
'/:template_id',
|
||||
[
|
||||
param('template_id').exists().isInt().toInt(),
|
||||
check('template_name').exists(),
|
||||
check('attributes').exists(),
|
||||
],
|
||||
this.validationResult,
|
||||
this.editPdfTemplate.bind(this)
|
||||
);
|
||||
router.get('/', this.getPdfTemplates.bind(this));
|
||||
router.get(
|
||||
'/:template_id',
|
||||
[param('template_id').exists().isInt().toInt()],
|
||||
this.validationResult,
|
||||
this.getPdfTemplate.bind(this)
|
||||
);
|
||||
router.get('/', this.getPdfTemplates.bind(this));
|
||||
router.post(
|
||||
'/invoices',
|
||||
'/',
|
||||
[check('template_name').exists(), check('attributes').exists()],
|
||||
this.validationResult,
|
||||
this.createPdfInvoiceTemplate.bind(this)
|
||||
@@ -70,13 +71,13 @@ export class PdfTemplatesController extends BaseController {
|
||||
async editPdfTemplate(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
const { template_id: templateId } = req.params;
|
||||
const { attributes } = this.matchedBodyData(req);
|
||||
const editTemplateDTO = this.matchedBodyData(req);
|
||||
|
||||
try {
|
||||
const result = await this.pdfTemplateApplication.editPdfTemplate(
|
||||
tenantId,
|
||||
Number(templateId),
|
||||
attributes
|
||||
editTemplateDTO
|
||||
);
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
|
||||
@@ -30,11 +30,14 @@ export class EditPdfTemplate {
|
||||
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||
|
||||
return this.uow.withTransaction(tenantId, async (trx) => {
|
||||
await PdfTemplate.query(trx)
|
||||
.patch({
|
||||
...editTemplateDTO,
|
||||
})
|
||||
.where('id', templateId);
|
||||
await this.eventPublisher.emitAsync(events.pdfTemplate.onEditing, {
|
||||
tenantId,
|
||||
templateId,
|
||||
});
|
||||
await PdfTemplate.query(trx).where('id', templateId).update({
|
||||
templateName: editTemplateDTO.templateName,
|
||||
attributes: editTemplateDTO.attributes,
|
||||
});
|
||||
|
||||
await this.eventPublisher.emitAsync(events.pdfTemplate.onEdited, {
|
||||
tenantId,
|
||||
|
||||
Reference in New Issue
Block a user