Skip to content

Commit

Permalink
feat: change default mail template messages
Browse files Browse the repository at this point in the history
  • Loading branch information
abouolia committed Nov 26, 2024
1 parent 7b5f0d3 commit 4f57782
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ export class SendSaleEstimateMail {
tenantId,
estimateId
);
return transformEstimateToMailDataArgs(estimate);
const commonArgs = await this.contactMailNotification.getCommonFormatArgs(
tenantId
);
return {
...commonArgs,
...transformEstimateToMailDataArgs(estimate),
};
};

/**
Expand Down
23 changes: 11 additions & 12 deletions packages/server/src/services/Sales/Estimates/constants.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
export const DEFAULT_ESTIMATE_REMINDER_MAIL_SUBJECT =
'Estimate {Estimate Number} is awaiting your approval';
export const DEFAULT_ESTIMATE_REMINDER_MAIL_CONTENT = `<p>Dear {Customer Name}</p>
<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>
export const DEFAULT_ESTIMATE_REMINDER_MAIL_CONTENT = `Hi {Customer Name},
<p>
<i>Regards</i><br />
<i>{Company Name}</i>
</p>
`;
Here's estimate # {Estimate Number} for {Estimate Amount}
This estimate is valid until {Estimate Expiration Date}, and we’re happy to discuss any adjustments you or questions may have.
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 = {
SALE_ESTIMATE_NOT_FOUND: 'SALE_ESTIMATE_NOT_FOUND',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Transformer } from '@/lib/Transformer/Transformer';
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';

export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer {
/**
Expand All @@ -13,6 +12,8 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
'primaryColor',
'total',
'totalLabel',
'subtotal',
'subtotalLabel',
'paymentNumberLabel',
'paymentNumber',
'items',
Expand Down Expand Up @@ -75,6 +76,14 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
return this.options.paymentReceived.formattedAmount;
}

/**
* Subtotal label.
* @returns {string}
*/
public subtotalLabel(): string {
return 'Subtotal';
}

/**
* Payment number label.
* @returns {string}
Expand Down
23 changes: 10 additions & 13 deletions packages/server/src/services/Sales/PaymentReceived/constants.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
export const DEFAULT_PAYMENT_MAIL_SUBJECT =
'Payment Received for {Customer Name} from {Company Name}';
export const DEFAULT_PAYMENT_MAIL_CONTENT = `
<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>
' Payment Confirmation from {Company Name} – Thank You!';
export const DEFAULT_PAYMENT_MAIL_CONTENT = `Dear {Customer Name}
<p>
<i>Regards</i><br />
<i>{Company Name}</i>
</p>
`;
Thank you for your payment. It was a pleasure doing business with you. We look forward to work together again!
Payment Transaction: {Payment Number}
Payment Date : {Payment Date}
Amount : {Payment Amount}
Regards,
{Company Name}`;

export const ERRORS = {
PAYMENT_RECEIVE_NO_EXISTS: 'PAYMENT_RECEIVE_NO_EXISTS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
'total',
'totalLabel',

'subtotal',
'subtotalLabel',

'paidAmount',
'paidAmountLabel',

Expand Down Expand Up @@ -64,15 +67,15 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
* @returns {string}
*/
public receiptNumber(): string {
return this.options.receipt.number;
return this.options.receipt.receiptNumber;
}

/**
* Receipt number label.
* @returns {string}
*/
public receiptNumberLabel(): string {
return 'Receipt Number';
return 'Receipt # {receiptNumber}';
}

/**
Expand All @@ -95,7 +98,7 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
* Receipt total.
*/
public total(): string {
return this.options.receipt.totalFormatted;
return this.options.receipt.formattedAmount;
}

/**
Expand All @@ -106,6 +109,22 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ export class SaleReceiptMailNotification {
tenantId,
receiptId
);
return transformReceiptToMailDataArgs(receipt);
const commonArgs = await this.contactMailNotification.getCommonFormatArgs(
tenantId
);
return {
...commonArgs,
...transformReceiptToMailDataArgs(receipt),
};
};

/**
Expand Down
25 changes: 12 additions & 13 deletions packages/server/src/services/Sales/Receipts/constants.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
export const DEFAULT_RECEIPT_MAIL_SUBJECT =
'Receipt {Receipt Number} from {Company Name}';
export const DEFAULT_RECEIPT_MAIL_CONTENT = `
<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>
<i>Regards</i><br />
<i>{Company Name}</i>
</p>
`;
export const DEFAULT_RECEIPT_MAIL_CONTENT = `Hi {Customer Name},
Here's receipt # {Receipt Number} for Receipt {Receipt Amount}
The receipt paid on {Receipt Date}, and the total amount paid is {Receipt Amount}.
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 = {
SALE_RECEIPT_NOT_FOUND: 'SALE_RECEIPT_NOT_FOUND',
Expand Down
21 changes: 3 additions & 18 deletions shared/email-components/src/lib/ReceiptPaymentEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EmailTemplate } from './EmailTemplate';
export interface ReceiptEmailTemplateProps {
preview: string;

// # Company

companyName?: string;
companyLogoUri: string;

Expand All @@ -36,10 +36,6 @@ export interface ReceiptEmailTemplateProps {
subtotal?: string;
subtotalLabel?: string;

// # View receipt button.
viewReceiptButtonLabel?: string;
viewReceiptButtonUrl?: string;

// # Message
message?: string;
}
Expand Down Expand Up @@ -68,10 +64,6 @@ export const ReceiptEmailTemplate: React.FC<
receiptNumberLabel = 'Receipt # {receiptNumber}',
receiptNumber = 'REC-00001',

// # View invoice button
viewReceiptButtonLabel = 'View Estimate',
viewReceiptButtonUrl,

// # Message
message = '',

Expand All @@ -87,9 +79,11 @@ export const ReceiptEmailTemplate: React.FC<
<Row>
<Heading style={invoiceCompanyNameStyle}>{companyName}</Heading>
</Row>

<Row>
<Text style={amountStyle}>{total}</Text>
</Row>

<Row>
<Text style={receiptNumberStyle}>
{receiptNumberLabel?.replace('{receiptNumber}', receiptNumber)}
Expand All @@ -98,15 +92,6 @@ export const ReceiptEmailTemplate: React.FC<
</Section>

<Text style={messageStyle}>{message}</Text>
<Button
href={viewReceiptButtonUrl}
style={{
...viewInvoiceButtonStyle,
backgroundColor: primaryColor,
}}
>
{viewReceiptButtonLabel}
</Button>

<Section style={totalsSectionStyle}>
{items.map((item, index) => (
Expand Down

0 comments on commit 4f57782

Please sign in to comment.