feat: wip mail receipt preview

This commit is contained in:
Ahmed Bouhuolia
2024-11-25 16:22:40 +02:00
parent ca44d6346d
commit 2594e37dc7
12 changed files with 109 additions and 955 deletions

View File

@@ -22,6 +22,9 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
'total',
'totalLabel',
'subtotal',
'subtotalLabel',
'dueAmount',
'dueAmountLabel',
@@ -57,7 +60,7 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
}
/**
* Primary color
* Primary color.
* @returns {string}
*/
public primaryColor(): string {
@@ -69,7 +72,7 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
* @returns {string}
*/
public estimateNumber(): string {
return this.options.estimate.number;
return this.options.estimate.estimateNumber;
}
/**
@@ -77,7 +80,7 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
* @returns {string}
*/
public estimateNumberLabel(): string {
return 'Estimate Number';
return 'Estimate No: {estimateNumber}';
}
/**
@@ -85,7 +88,7 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
* @returns {string}
*/
public expirationDate(): string {
return this.options.estimate.expirationDate;
return this.options.estimate.formattedExpirationDate;
}
/**
@@ -93,14 +96,14 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
* @returns {string}
*/
public expirationDateLabel(): string {
return 'Expiration Date';
return 'Expiration Date: {expirationDate}';
}
/**
* Estimate total.
*/
public total(): string {
return this.options.estimate.totalFormatted;
return this.options.estimate.formattedAmount;
}
/**
@@ -111,6 +114,21 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
return 'Total';
}
/**
* Estimate subtotal.
*/
public subtotal(): string {
return this.options.estimate.formattedAmount;
}
/**
* Estimate subtotal label.
* @returns {string}
*/
public subtotalLabel(): string {
return 'Subtotal';
}
/**
* Estimate mail items attributes.
*/

View File

@@ -52,7 +52,7 @@ export class GetSaleEstimateMailStateTransformer extends SaleEstimateTransfromer
* @returns {string | null}
*/
protected companyLogoUri = (invoice) => {
return invoice.pdfTemplate?.companyLogoUri;
return invoice.pdfTemplate?.companyLogoUri || null;
};
/**
@@ -60,7 +60,7 @@ export class GetSaleEstimateMailStateTransformer extends SaleEstimateTransfromer
* @returns {string}
*/
protected primaryColor = (invoice) => {
return invoice.pdfTemplate?.attributes?.primaryColor;
return invoice.pdfTemplate?.attributes?.primaryColor || null;
};
/**

View File

@@ -1,4 +1,5 @@
import { Transformer } from '@/lib/Transformer/Transformer';
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';
export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer {
/**
@@ -14,6 +15,7 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
'totalLabel',
'paymentNumberLabel',
'paymentNumber',
'items',
];
};
@@ -65,9 +67,17 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
return 'Total';
}
/**
* Subtotal.
* @returns {string}
*/
public subtotal(): string {
return this.options.paymentReceived.formattedAmount;
}
/**
* Payment number label.
* @returns
* @returns {string}
*/
public paymentNumberLabel(): string {
return 'Payment # {paymentNumber}';
@@ -80,4 +90,51 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer
public paymentNumber(): string {
return this.options.paymentReceived.paymentReceiveNumber;
}
/**
* Items.
* @returns
*/
public items() {
return this.item(
this.options.paymentReceived.entries,
new GetPaymentReceivedMailTemplateItemAttrsTransformer()
);
}
}
class GetPaymentReceivedMailTemplateItemAttrsTransformer extends Transformer {
/**
* Included attributes.
* @returns {Array}
*/
public includeAttributes = () => {
return ['label', 'total'];
};
/**
* Excluded attributes.
* @returns {string[]}
*/
public excludeAttributes = () => {
return ['*'];
};
/**
*
* @param entry
* @returns
*/
public label(entry) {
return entry.invoice.invoiceNo;
}
/**
*
* @param entry
* @returns
*/
public total(entry) {
return entry.paymentAmountFormatted;
}
}