mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
Merge pull request #696 from bigcapitalhq/fix-changing-pdf-template
fix: Changing the pdf template of the invoice
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import * as R from 'ramda';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isNil } from 'lodash';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class BrandingTemplateDTOTransformer {
|
||||
@@ -22,11 +21,12 @@ export class BrandingTemplateDTOTransformer {
|
||||
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||
const attributeName = 'pdfTemplateId';
|
||||
|
||||
const defaultTemplate = await PdfTemplate.query().findOne({
|
||||
resource,
|
||||
default: true,
|
||||
});
|
||||
if (!defaultTemplate || !isEmpty(object[attributeName])) {
|
||||
const defaultTemplate = await PdfTemplate.query()
|
||||
.modify('default')
|
||||
.findOne({ resource });
|
||||
|
||||
// If the default template is not found OR the given object has no defined template id.
|
||||
if (!defaultTemplate || !isNil(object[attributeName])) {
|
||||
return object;
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user