mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(server): add pdf template crud endpoints
This commit is contained in:
29
packages/server/src/services/PdfTemplate/GetPdfTemplate.ts
Normal file
29
packages/server/src/services/PdfTemplate/GetPdfTemplate.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Knex } from 'knex';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class GetPdfTemplate {
|
||||
@Inject()
|
||||
private tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Retrieves a pdf template by its ID.
|
||||
* @param {number} tenantId - The ID of the tenant.
|
||||
* @param {number} templateId - The ID of the pdf template to retrieve.
|
||||
* @return {Promise<any>} - The retrieved pdf template.
|
||||
*/
|
||||
async getPdfTemplate(
|
||||
tenantId: number,
|
||||
templateId: number,
|
||||
trx?: Knex.Transaction
|
||||
): Promise<any> {
|
||||
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||
|
||||
const template = await PdfTemplate.query(trx)
|
||||
.findById(templateId)
|
||||
.throwIfNotFound();
|
||||
|
||||
return template;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user