mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
Merge pull request #736 from bigcapitalhq/fix-company-logo-mail-receipt
fix: company logo does not show up in mail receipt preview
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
|
import { getUploadedObjectUri } from '@/services/Attachments/utils';
|
||||||
import TenantModel from 'models/TenantModel';
|
import TenantModel from 'models/TenantModel';
|
||||||
|
|
||||||
export class PdfTemplate extends TenantModel {
|
export class PdfTemplate extends TenantModel {
|
||||||
|
public readonly attributes: Record<string, any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table name.
|
* Table name.
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +50,17 @@ export class PdfTemplate extends TenantModel {
|
|||||||
* Virtual attributes.
|
* Virtual attributes.
|
||||||
*/
|
*/
|
||||||
static get virtualAttributes() {
|
static get virtualAttributes() {
|
||||||
return [];
|
return ['companyLogoUri'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the company logo uri.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
get companyLogoUri() {
|
||||||
|
return this.attributes.companyLogoKey
|
||||||
|
? getUploadedObjectUri(this.attributes.companyLogoKey)
|
||||||
|
: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,9 +35,12 @@ export class CreditNoteBrandingTemplate {
|
|||||||
...defaultCreditNoteBrandingAttributes,
|
...defaultCreditNoteBrandingAttributes,
|
||||||
...commonOrgBrandingAttrs,
|
...commonOrgBrandingAttrs,
|
||||||
};
|
};
|
||||||
|
const brandingTemplateAttrs = {
|
||||||
|
...template.attributes,
|
||||||
|
companyLogoUri: template.companyLogoUri,
|
||||||
|
};
|
||||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||||
template.attributes,
|
brandingTemplateAttrs,
|
||||||
organizationBrandingAttrs
|
organizationBrandingAttrs
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { Transformer } from '@/lib/Transformer/Transformer';
|
import { Transformer } from '@/lib/Transformer/Transformer';
|
||||||
import { getTransactionTypeLabel } from '@/utils/transactions-types';
|
import { getTransactionTypeLabel } from '@/utils/transactions-types';
|
||||||
import { getUploadedObjectUri } from '../Attachments/utils';
|
|
||||||
|
|
||||||
export class GetPdfTemplateTransformer extends Transformer {
|
export class GetPdfTemplateTransformer extends Transformer {
|
||||||
/**
|
/**
|
||||||
* Includeded attributes.
|
* Included attributes.
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
*/
|
*/
|
||||||
public includeAttributes = (): string[] => {
|
public includeAttributes = (): string[] => {
|
||||||
@@ -44,20 +43,10 @@ export class GetPdfTemplateTransformer extends Transformer {
|
|||||||
|
|
||||||
class GetPdfTemplateAttributesTransformer extends Transformer {
|
class GetPdfTemplateAttributesTransformer extends Transformer {
|
||||||
/**
|
/**
|
||||||
* Includeded attributes.
|
* Included attributes.
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
*/
|
*/
|
||||||
public includeAttributes = (): string[] => {
|
public includeAttributes = (): string[] => {
|
||||||
return ['companyLogoUri'];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the company logo uri.
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
protected companyLogoUri(template) {
|
|
||||||
return template.companyLogoKey
|
|
||||||
? getUploadedObjectUri(template.companyLogoKey)
|
|
||||||
: '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ export interface ICreateInvoicePdfTemplateDTO {
|
|||||||
showStatement?: boolean;
|
showStatement?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface CommonOrganizationBrandingAttributes {
|
export interface CommonOrganizationBrandingAttributes {
|
||||||
companyName?: string;
|
companyName?: string;
|
||||||
primaryColor?: string;
|
primaryColor?: string;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export class GetInvoiceMailTemplateAttributesTransformer extends Transformer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public companyLogoUri(): string {
|
public companyLogoUri(): string {
|
||||||
return this.options.brandingTemplate?.attributes?.companyLogoUri;
|
return this.options.brandingTemplate?.companyLogoUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public companyName(): string {
|
public companyName(): string {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export class GetSaleInvoiceMailState {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the invoice mail state of the given sale invoice.
|
* Retrieves the invoice mail state of the given sale invoice.
|
||||||
* Invoice mail state includes the mail options, branding attributes and the invoice details.
|
* Invoice mail state includes the mail options, branding attributes and the invoice details.
|
||||||
*
|
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
* @param {number} saleInvoiceId
|
* @param {number} saleInvoiceId
|
||||||
* @returns {Promise<SaleInvoiceMailState>}
|
* @returns {Promise<SaleInvoiceMailState>}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Transformer } from '@/lib/Transformer/Transformer';
|
|
||||||
import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
|
import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
|
||||||
import { ItemEntryTransformer } from './ItemEntryTransformer';
|
import { ItemEntryTransformer } from './ItemEntryTransformer';
|
||||||
|
|
||||||
@@ -11,6 +10,10 @@ export class GetSaleInvoiceMailStateTransformer extends SaleInvoiceTransformer {
|
|||||||
return ['*'];
|
return ['*'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Included attributes.
|
||||||
|
* @returns {Array}
|
||||||
|
*/
|
||||||
public includeAttributes = (): string[] => {
|
public includeAttributes = (): string[] => {
|
||||||
return [
|
return [
|
||||||
'invoiceDate',
|
'invoiceDate',
|
||||||
@@ -39,14 +42,26 @@ export class GetSaleInvoiceMailStateTransformer extends SaleInvoiceTransformer {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the company name.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
protected companyName = () => {
|
protected companyName = () => {
|
||||||
return this.context.organization.name;
|
return this.context.organization.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the company logo uri.
|
||||||
|
* @returns {string | null}
|
||||||
|
*/
|
||||||
protected companyLogoUri = (invoice) => {
|
protected companyLogoUri = (invoice) => {
|
||||||
return invoice.pdfTemplate?.attributes?.companyLogoUri;
|
return invoice.pdfTemplate?.companyLogoUri;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the primary color.
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
protected primaryColor = (invoice) => {
|
protected primaryColor = (invoice) => {
|
||||||
return invoice.pdfTemplate?.attributes?.primaryColor;
|
return invoice.pdfTemplate?.attributes?.primaryColor;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,8 +33,12 @@ export class SaleEstimatePdfTemplate {
|
|||||||
...defaultEstimatePdfBrandingAttributes,
|
...defaultEstimatePdfBrandingAttributes,
|
||||||
...commonOrgBrandingAttrs,
|
...commonOrgBrandingAttrs,
|
||||||
};
|
};
|
||||||
|
const brandingTemplateAttrs = {
|
||||||
|
...template.attributes,
|
||||||
|
companyLogoUri: template.companyLogoUri,
|
||||||
|
};
|
||||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||||
template.attributes,
|
brandingTemplateAttrs,
|
||||||
orgainizationBrandingAttrs
|
orgainizationBrandingAttrs
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -32,8 +32,12 @@ export class SaleInvoicePdfTemplate {
|
|||||||
...defaultInvoicePdfTemplateAttributes,
|
...defaultInvoicePdfTemplateAttributes,
|
||||||
...commonOrgBrandingAttrs,
|
...commonOrgBrandingAttrs,
|
||||||
};
|
};
|
||||||
|
const brandingTemplateAttrs = {
|
||||||
|
...template.attributes,
|
||||||
|
companyLogoUri: template.companyLogoUri,
|
||||||
|
};
|
||||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||||
template.attributes,
|
brandingTemplateAttrs,
|
||||||
organizationBrandingAttrs
|
organizationBrandingAttrs
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ import { GetInvoicePaymentsService } from './GetInvoicePaymentsService';
|
|||||||
import { SaleInvoiceNotifyBySms } from './SaleInvoiceNotifyBySms';
|
import { SaleInvoiceNotifyBySms } from './SaleInvoiceNotifyBySms';
|
||||||
import { SendInvoiceMailReminder } from './SendSaleInvoiceMailReminder';
|
import { SendInvoiceMailReminder } from './SendSaleInvoiceMailReminder';
|
||||||
import { SendSaleInvoiceMail } from './SendSaleInvoiceMail';
|
import { SendSaleInvoiceMail } from './SendSaleInvoiceMail';
|
||||||
import { GetSaleInvoiceMailReminder } from './GetSaleInvoiceMailReminder';
|
|
||||||
import { GetSaleInvoiceState } from './GetSaleInvoiceState';
|
import { GetSaleInvoiceState } from './GetSaleInvoiceState';
|
||||||
import { GetSaleInvoiceBrandTemplate } from './GetSaleInvoiceBrandTemplate';
|
|
||||||
import { GetSaleInvoiceMailState } from './GetSaleInvoiceMailState';
|
import { GetSaleInvoiceMailState } from './GetSaleInvoiceMailState';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
@@ -366,7 +364,10 @@ export class SaleInvoiceApplication {
|
|||||||
* @param {number} saleInvoiceid
|
* @param {number} saleInvoiceid
|
||||||
* @returns {Promise<SaleInvoiceMailState>}
|
* @returns {Promise<SaleInvoiceMailState>}
|
||||||
*/
|
*/
|
||||||
public getSaleInvoiceMailState(tenantId: number, saleInvoiceid: number) {
|
public getSaleInvoiceMailState(
|
||||||
|
tenantId: number,
|
||||||
|
saleInvoiceid: number
|
||||||
|
): Promise<SaleInvoiceMailState> {
|
||||||
return this.getSaleInvoiceMailStateService.getInvoiceMailState(
|
return this.getSaleInvoiceMailStateService.getInvoiceMailState(
|
||||||
tenantId,
|
tenantId,
|
||||||
saleInvoiceid
|
saleInvoiceid
|
||||||
|
|||||||
@@ -37,8 +37,12 @@ export class PaymentReceivedBrandingTemplate {
|
|||||||
...defaultPaymentReceivedPdfTemplateAttributes,
|
...defaultPaymentReceivedPdfTemplateAttributes,
|
||||||
...commonOrgBrandingAttrs,
|
...commonOrgBrandingAttrs,
|
||||||
};
|
};
|
||||||
|
const brandingTemplateAttrs = {
|
||||||
|
...template.attributes,
|
||||||
|
companyLogoUri: template.companyLogoUri,
|
||||||
|
};
|
||||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||||
template.attributes,
|
brandingTemplateAttrs,
|
||||||
organizationBrandingAttrs
|
organizationBrandingAttrs
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -37,8 +37,12 @@ export class SaleReceiptBrandingTemplate {
|
|||||||
...defaultSaleReceiptBrandingAttributes,
|
...defaultSaleReceiptBrandingAttributes,
|
||||||
...commonOrgBrandingAttrs,
|
...commonOrgBrandingAttrs,
|
||||||
};
|
};
|
||||||
|
const brandingTemplateAttrs = {
|
||||||
|
...template.attributes,
|
||||||
|
companyLogoUri: template.companyLogoUri,
|
||||||
|
};
|
||||||
const attributes = mergePdfTemplateWithDefaultAttributes(
|
const attributes = mergePdfTemplateWithDefaultAttributes(
|
||||||
template.attributes,
|
brandingTemplateAttrs,
|
||||||
organizationBrandingAttrs
|
organizationBrandingAttrs
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ export function InvoiceMailReceipt({
|
|||||||
h="90px"
|
h="90px"
|
||||||
w="90px"
|
w="90px"
|
||||||
mx="auto"
|
mx="auto"
|
||||||
|
borderRadius="3px"
|
||||||
backgroundRepeat="no-repeat"
|
backgroundRepeat="no-repeat"
|
||||||
backgroundPosition="center center"
|
backgroundPosition="center center"
|
||||||
backgroundSize="contain"
|
backgroundSize="contain"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function InvoiceMailReceiptPreviewConneceted() {
|
|||||||
<Box px={4} pt={8} pb={16}>
|
<Box px={4} pt={8} pb={16}>
|
||||||
<InvoiceMailReceiptPreview
|
<InvoiceMailReceiptPreview
|
||||||
companyName={invoiceMailState?.companyName}
|
companyName={invoiceMailState?.companyName}
|
||||||
// companyLogoUri={invoiceMailState?.companyLogoUri}
|
companyLogoUri={invoiceMailState?.companyLogoUri}
|
||||||
|
|
||||||
primaryColor={invoiceMailState?.primaryColor}
|
primaryColor={invoiceMailState?.primaryColor}
|
||||||
total={invoiceMailState?.totalFormatted}
|
total={invoiceMailState?.totalFormatted}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-nocheck
|
|
||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
import { Spinner } from '@blueprintjs/core';
|
import { Spinner } from '@blueprintjs/core';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ export function useSendSaleInvoiceMail(
|
|||||||
// --------------------------------------
|
// --------------------------------------
|
||||||
export interface GetSaleInvoiceDefaultOptionsResponse {
|
export interface GetSaleInvoiceDefaultOptionsResponse {
|
||||||
companyName: string;
|
companyName: string;
|
||||||
|
companyLogoUri: string;
|
||||||
|
|
||||||
dueDate: string;
|
dueDate: string;
|
||||||
dueDateFormatted: string;
|
dueDateFormatted: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user