feat: change default mail template messages

This commit is contained in:
Ahmed Bouhuolia
2024-11-26 13:15:15 +02:00
parent 7b5f0d3930
commit 4f57782be4
8 changed files with 81 additions and 61 deletions

View File

@@ -80,7 +80,13 @@ export class SendSaleEstimateMail {
tenantId, tenantId,
estimateId estimateId
); );
return transformEstimateToMailDataArgs(estimate); const commonArgs = await this.contactMailNotification.getCommonFormatArgs(
tenantId
);
return {
...commonArgs,
...transformEstimateToMailDataArgs(estimate),
};
}; };
/** /**

View File

@@ -1,18 +1,17 @@
export const DEFAULT_ESTIMATE_REMINDER_MAIL_SUBJECT = export const DEFAULT_ESTIMATE_REMINDER_MAIL_SUBJECT =
'Estimate {Estimate Number} is awaiting your approval'; 'Estimate {Estimate Number} is awaiting your approval';
export const DEFAULT_ESTIMATE_REMINDER_MAIL_CONTENT = `<p>Dear {Customer Name}</p> export const DEFAULT_ESTIMATE_REMINDER_MAIL_CONTENT = `Hi {Customer Name},
<p>Thank you for your business, You can view or print your estimate from attachements.</p>
<p>
Estimate <strong>#{Estimate Number}</strong><br />
Expiration Date : <strong>{Estimate Expiration Date}</strong><br />
Amount : <strong>{Estimate Amount}</strong></br />
</p>
<p> Here's estimate # {Estimate Number} for {Estimate Amount}
<i>Regards</i><br />
<i>{Company Name}</i> This estimate is valid until {Estimate Expiration Date}, and were happy to discuss any adjustments you or questions may have.
</p>
`; Please find your estimate attached to this email for your reference.
If you have any questions, please let us know.
Thanks,
{Company Name}`;
export const ERRORS = { export const ERRORS = {
SALE_ESTIMATE_NOT_FOUND: 'SALE_ESTIMATE_NOT_FOUND', SALE_ESTIMATE_NOT_FOUND: 'SALE_ESTIMATE_NOT_FOUND',

View File

@@ -1,5 +1,4 @@
import { Transformer } from '@/lib/Transformer/Transformer'; import { Transformer } from '@/lib/Transformer/Transformer';
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';
export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer { export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer {
/** /**
@@ -13,6 +12,8 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
'primaryColor', 'primaryColor',
'total', 'total',
'totalLabel', 'totalLabel',
'subtotal',
'subtotalLabel',
'paymentNumberLabel', 'paymentNumberLabel',
'paymentNumber', 'paymentNumber',
'items', 'items',
@@ -75,6 +76,14 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
return this.options.paymentReceived.formattedAmount; return this.options.paymentReceived.formattedAmount;
} }
/**
* Subtotal label.
* @returns {string}
*/
public subtotalLabel(): string {
return 'Subtotal';
}
/** /**
* Payment number label. * Payment number label.
* @returns {string} * @returns {string}

View File

@@ -1,18 +1,15 @@
export const DEFAULT_PAYMENT_MAIL_SUBJECT = export const DEFAULT_PAYMENT_MAIL_SUBJECT =
'Payment Received for {Customer Name} from {Company Name}'; ' Payment Confirmation from {Company Name} Thank You!';
export const DEFAULT_PAYMENT_MAIL_CONTENT = ` export const DEFAULT_PAYMENT_MAIL_CONTENT = `Dear {Customer Name}
<p>Dear {Customer Name}</p>
<p>Thank you for your payment. It was a pleasure doing business with you. We look forward to work together again!</p>
<p>
Payment Date : <strong>{Payment Date}</strong><br />
Amount : <strong>{Payment Amount}</strong></br />
</p>
<p> Thank you for your payment. It was a pleasure doing business with you. We look forward to work together again!
<i>Regards</i><br />
<i>{Company Name}</i> Payment Transaction: {Payment Number}
</p> Payment Date : {Payment Date}
`; Amount : {Payment Amount}
Regards,
{Company Name}`;
export const ERRORS = { export const ERRORS = {
PAYMENT_RECEIVE_NO_EXISTS: 'PAYMENT_RECEIVE_NO_EXISTS', PAYMENT_RECEIVE_NO_EXISTS: 'PAYMENT_RECEIVE_NO_EXISTS',

View File

@@ -20,6 +20,9 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
'total', 'total',
'totalLabel', 'totalLabel',
'subtotal',
'subtotalLabel',
'paidAmount', 'paidAmount',
'paidAmountLabel', 'paidAmountLabel',
@@ -64,7 +67,7 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
* @returns {string} * @returns {string}
*/ */
public receiptNumber(): string { public receiptNumber(): string {
return this.options.receipt.number; return this.options.receipt.receiptNumber;
} }
/** /**
@@ -72,7 +75,7 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
* @returns {string} * @returns {string}
*/ */
public receiptNumberLabel(): string { public receiptNumberLabel(): string {
return 'Receipt Number'; return 'Receipt # {receiptNumber}';
} }
/** /**
@@ -95,7 +98,7 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
* Receipt total. * Receipt total.
*/ */
public total(): string { public total(): string {
return this.options.receipt.totalFormatted; return this.options.receipt.formattedAmount;
} }
/** /**
@@ -106,6 +109,22 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
return 'Total'; return 'Total';
} }
/**
* Receipt subtotal.
* @returns {string}
*/
public subtotal(): string {
return this.options.receipt.formattedSubtotal;
}
/**
* Receipt subtotal label.
* @returns {string}
*/
public subtotalLabel(): string {
return 'Subtotal';
}
/** /**
* Receipt mail items attributes. * Receipt mail items attributes.
*/ */

View File

@@ -115,7 +115,13 @@ export class SaleReceiptMailNotification {
tenantId, tenantId,
receiptId receiptId
); );
return transformReceiptToMailDataArgs(receipt); const commonArgs = await this.contactMailNotification.getCommonFormatArgs(
tenantId
);
return {
...commonArgs,
...transformReceiptToMailDataArgs(receipt),
};
}; };
/** /**

View File

@@ -1,18 +1,17 @@
export const DEFAULT_RECEIPT_MAIL_SUBJECT = export const DEFAULT_RECEIPT_MAIL_SUBJECT =
'Receipt {Receipt Number} from {Company Name}'; 'Receipt {Receipt Number} from {Company Name}';
export const DEFAULT_RECEIPT_MAIL_CONTENT = ` export const DEFAULT_RECEIPT_MAIL_CONTENT = `Hi {Customer Name},
<p>Dear {Customer Name}</p>
<p>Thank you for your business, You can view or print your receipt from attachements.</p>
<p>
Receipt <strong>#{Receipt Number}</strong><br />
Amount : <strong>{Receipt Amount}</strong></br />
</p>
<p> Here's receipt # {Receipt Number} for Receipt {Receipt Amount}
<i>Regards</i><br />
<i>{Company Name}</i> The receipt paid on {Receipt Date}, and the total amount paid is {Receipt Amount}.
</p>
`; Please find your sale receipt attached to this email for your reference
If you have any questions, please let us know.
Thanks,
{Company Name}`;
export const ERRORS = { export const ERRORS = {
SALE_RECEIPT_NOT_FOUND: 'SALE_RECEIPT_NOT_FOUND', SALE_RECEIPT_NOT_FOUND: 'SALE_RECEIPT_NOT_FOUND',

View File

@@ -14,7 +14,7 @@ import { EmailTemplate } from './EmailTemplate';
export interface ReceiptEmailTemplateProps { export interface ReceiptEmailTemplateProps {
preview: string; preview: string;
// # Company
companyName?: string; companyName?: string;
companyLogoUri: string; companyLogoUri: string;
@@ -36,10 +36,6 @@ export interface ReceiptEmailTemplateProps {
subtotal?: string; subtotal?: string;
subtotalLabel?: string; subtotalLabel?: string;
// # View receipt button.
viewReceiptButtonLabel?: string;
viewReceiptButtonUrl?: string;
// # Message // # Message
message?: string; message?: string;
} }
@@ -68,10 +64,6 @@ export const ReceiptEmailTemplate: React.FC<
receiptNumberLabel = 'Receipt # {receiptNumber}', receiptNumberLabel = 'Receipt # {receiptNumber}',
receiptNumber = 'REC-00001', receiptNumber = 'REC-00001',
// # View invoice button
viewReceiptButtonLabel = 'View Estimate',
viewReceiptButtonUrl,
// # Message // # Message
message = '', message = '',
@@ -87,9 +79,11 @@ export const ReceiptEmailTemplate: React.FC<
<Row> <Row>
<Heading style={invoiceCompanyNameStyle}>{companyName}</Heading> <Heading style={invoiceCompanyNameStyle}>{companyName}</Heading>
</Row> </Row>
<Row> <Row>
<Text style={amountStyle}>{total}</Text> <Text style={amountStyle}>{total}</Text>
</Row> </Row>
<Row> <Row>
<Text style={receiptNumberStyle}> <Text style={receiptNumberStyle}>
{receiptNumberLabel?.replace('{receiptNumber}', receiptNumber)} {receiptNumberLabel?.replace('{receiptNumber}', receiptNumber)}
@@ -98,15 +92,6 @@ export const ReceiptEmailTemplate: React.FC<
</Section> </Section>
<Text style={messageStyle}>{message}</Text> <Text style={messageStyle}>{message}</Text>
<Button
href={viewReceiptButtonUrl}
style={{
...viewInvoiceButtonStyle,
backgroundColor: primaryColor,
}}
>
{viewReceiptButtonLabel}
</Button>
<Section style={totalsSectionStyle}> <Section style={totalsSectionStyle}>
{items.map((item, index) => ( {items.map((item, index) => (