mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +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 { Inject, Service } from 'typedi';
|
||||||
import { isEmpty } from 'lodash';
|
import { isNil } from 'lodash';
|
||||||
|
import HasTenancyService from '../Tenancy/TenancyService';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class BrandingTemplateDTOTransformer {
|
export class BrandingTemplateDTOTransformer {
|
||||||
@@ -22,11 +21,12 @@ export class BrandingTemplateDTOTransformer {
|
|||||||
const { PdfTemplate } = this.tenancy.models(tenantId);
|
const { PdfTemplate } = this.tenancy.models(tenantId);
|
||||||
const attributeName = 'pdfTemplateId';
|
const attributeName = 'pdfTemplateId';
|
||||||
|
|
||||||
const defaultTemplate = await PdfTemplate.query().findOne({
|
const defaultTemplate = await PdfTemplate.query()
|
||||||
resource,
|
.modify('default')
|
||||||
default: true,
|
.findOne({ resource });
|
||||||
});
|
|
||||||
if (!defaultTemplate || !isEmpty(object[attributeName])) {
|
// If the default template is not found OR the given object has no defined template id.
|
||||||
|
if (!defaultTemplate || !isNil(object[attributeName])) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user