mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
Merge pull request #690 from bigcapitalhq/fix-remove-empty-lines-from-address
fix: Remove empty lines from address formats
This commit is contained in:
@@ -104,12 +104,24 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected formattedCustomerAddress(invoice) {
|
get customerAddressFormat() {
|
||||||
return contactAddressTextFormat(invoice.customer, `{ADDRESS_1}
|
return `{ADDRESS_1}
|
||||||
{ADDRESS_2}
|
{ADDRESS_2}
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
{CITY} {STATE} {POSTAL_CODE}
|
||||||
{COUNTRY}
|
{COUNTRY}
|
||||||
{PHONE}`);
|
{PHONE}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the formatted customer address.
|
||||||
|
* @param invoice
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
protected formattedCustomerAddress(invoice) {
|
||||||
|
return contactAddressTextFormat(
|
||||||
|
invoice.customer,
|
||||||
|
this.customerAddressFormat
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { organizationAddressTextFormat } from '@/utils/address-text-format';
|
import {
|
||||||
|
defaultOrganizationAddressFormat,
|
||||||
|
organizationAddressTextFormat,
|
||||||
|
} from '@/utils/address-text-format';
|
||||||
import BaseModel from 'models/Model';
|
import BaseModel from 'models/Model';
|
||||||
import { getUploadedObjectUri } from '../../services/Attachments/utils';
|
import { getUploadedObjectUri } from '../../services/Attachments/utils';
|
||||||
|
|
||||||
@@ -67,14 +70,7 @@ export default class TenantMetadata extends BaseModel {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
public get addressTextFormatted() {
|
public get addressTextFormatted() {
|
||||||
const defaultMessage = `<strong>{ORGANIZATION_NAME}</strong>
|
return organizationAddressTextFormat(defaultOrganizationAddressFormat, {
|
||||||
{ADDRESS_1}
|
|
||||||
{ADDRESS_2}
|
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
|
||||||
{COUNTRY}
|
|
||||||
{PHONE}
|
|
||||||
`;
|
|
||||||
return organizationAddressTextFormat(defaultMessage, {
|
|
||||||
organizationName: this.name,
|
organizationName: this.name,
|
||||||
address1: this.address?.address1,
|
address1: this.address?.address1,
|
||||||
address2: this.address?.address2,
|
address2: this.address?.address2,
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ interface OrganizationAddressFormatArgs {
|
|||||||
phone?: string;
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultMessage = `
|
export const defaultOrganizationAddressFormat = `
|
||||||
<strong>{ORGANIZATION_NAME}</strong>
|
<strong>{ORGANIZATION_NAME}</strong>
|
||||||
{ADDRESS_1}
|
{ADDRESS_1}
|
||||||
{ADDRESS_2}
|
{ADDRESS_2}
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
{CITY} {STATE} {POSTAL_CODE}
|
||||||
{COUNTRY}
|
{COUNTRY}
|
||||||
{PHONE}
|
{PHONE}
|
||||||
`;
|
`;
|
||||||
/**
|
/**
|
||||||
* Formats the address text based on the provided message and arguments.
|
* Formats the address text based on the provided message and arguments.
|
||||||
@@ -36,7 +36,9 @@ const formatText = (message: string, replacements: Record<string, string>) => {
|
|||||||
},
|
},
|
||||||
message
|
message
|
||||||
);
|
);
|
||||||
formattedMessage = formattedMessage.replace(/\n{2,}/g, '\n').trim();
|
// Removes any empty lines.
|
||||||
|
formattedMessage = formattedMessage.replace(/^\s*[\r\n]/gm, '');
|
||||||
|
formattedMessage = formattedMessage.replace(/\n{2,}/g, '\n');
|
||||||
formattedMessage = formattedMessage.replace(/\n/g, '<br />');
|
formattedMessage = formattedMessage.replace(/\n/g, '<br />');
|
||||||
formattedMessage = formattedMessage.trim();
|
formattedMessage = formattedMessage.trim();
|
||||||
|
|
||||||
@@ -72,17 +74,17 @@ interface ContactAddressTextFormatArgs {
|
|||||||
phone?: string;
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contactFormatMessage = `{CONTACT_NAME}
|
export const defaultContactAddressFormat = `{CONTACT_NAME}
|
||||||
{ADDRESS_1}
|
{ADDRESS_1}
|
||||||
{ADDRESS_2}
|
{ADDRESS_2}
|
||||||
{CITY}, {STATE} {POSTAL_CODE}
|
{CITY} {STATE} {POSTAL_CODE}
|
||||||
{COUNTRY}
|
{COUNTRY}
|
||||||
{PHONE}
|
{PHONE}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const contactAddressTextFormat = (
|
export const contactAddressTextFormat = (
|
||||||
contact: IContact,
|
contact: IContact,
|
||||||
message: string = contactFormatMessage
|
message: string = defaultContactAddressFormat
|
||||||
) => {
|
) => {
|
||||||
const args = {
|
const args = {
|
||||||
displayName: contact.displayName,
|
displayName: contact.displayName,
|
||||||
|
|||||||
Reference in New Issue
Block a user