1
0
Files
bigcapital/packages/server/src/modules/System/models/TenantMetadataModel.ts
T
Ahmed Bouhuolia b98485c5f3 fix(server): PDF template logo not showing on reopen
Generate presigned URL for companyLogoKey when retrieving PDF template
to allow the logo to display when reopening the branding template drawer.

- Inject GetAttachmentPresignedUrl service in GetPdfTemplateService
- Generate companyLogoUri from companyLogoKey in template attributes
- Add companyLogoUri to transformer included attributes

Fixes the issue where logo uploads and saves but doesn't show when
reopening the branding template customization drawer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 05:22:01 +02:00

85 lines
2.3 KiB
TypeScript

import { BaseModel } from '@/models/Model';
import {
defaultOrganizationAddressFormat,
organizationAddressTextFormat,
} from '@/utils/address-text-format';
import { findByIsoCountryCode } from '@bigcapital/utils';
export class TenantMetadata extends BaseModel {
public baseCurrency!: string;
public name!: string;
public tenantId!: number;
public industry!: string;
public location!: string;
public language!: string;
public timezone!: string;
public dateFormat!: string;
public fiscalYear!: string;
public primaryColor!: string;
public logoKey!: string;
public logoUri!: string;
public address!: Record<string, any>;
/**
* Json schema.
*/
static get jsonSchema() {
return {
type: 'object',
required: ['tenantId', 'name', 'baseCurrency'],
properties: {
tenantId: { type: 'integer' },
name: { type: 'string', maxLength: 255 },
industry: { type: 'string', maxLength: 255 },
location: { type: 'string', maxLength: 255 },
baseCurrency: { type: 'string', maxLength: 3 },
language: { type: 'string', maxLength: 255 },
timezone: { type: 'string', maxLength: 255 },
dateFormat: { type: 'string', maxLength: 255 },
fiscalYear: { type: 'string', maxLength: 255 },
primaryColor: { type: 'string', maxLength: 7 }, // Assuming hex color code
logoKey: { type: 'string', maxLength: 255 },
address: { type: 'object' },
},
};
}
/**
* Table name.
*/
static tableName = 'tenants_metadata';
/**
* Timestamps columns.
*/
get timestamps() {
return [];
}
/**
* Virtual attributes.
*/
static get virtualAttributes() {
return ['logoUri'];
}
/**
* Retrieves the organization address formatted text.
* @returns {string}
*/
public get addressTextFormatted() {
const addressCountry = findByIsoCountryCode(this.location);
return organizationAddressTextFormat(defaultOrganizationAddressFormat, {
organizationName: this.name,
address1: this.address?.address1,
address2: this.address?.address2,
state: this.address?.stateProvince,
city: this.address?.city,
postalCode: this.address?.postalCode,
phone: this.address?.phone,
country: addressCountry?.name ?? '',
});
}
}