mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: add discount and adjustment fields to email templates.
This commit is contained in:
@@ -26,6 +26,9 @@ export interface ISaleEstimate {
|
||||
branchId?: number;
|
||||
warehouseId?: number;
|
||||
|
||||
total?: number;
|
||||
totalLocal?: number;
|
||||
|
||||
discountAmount?: number;
|
||||
discountPercentage?: number | null;
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
|
||||
'subtotal',
|
||||
'subtotalLabel',
|
||||
|
||||
'discount',
|
||||
'discountLabel',
|
||||
|
||||
'adjustment',
|
||||
'adjustmentLabel',
|
||||
|
||||
'dueAmount',
|
||||
'dueAmountLabel',
|
||||
|
||||
@@ -103,7 +109,7 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
|
||||
* Estimate total.
|
||||
*/
|
||||
public total(): string {
|
||||
return this.options.estimate.formattedAmount;
|
||||
return this.options.estimate.totalFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,11 +120,43 @@ export class GetEstimateMailTemplateAttributesTransformer extends Transformer {
|
||||
return 'Total';
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate discount.
|
||||
* @returns {string}
|
||||
*/
|
||||
public discount(): string {
|
||||
return this.options.estimate?.discountAmountFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate discount label.
|
||||
* @returns {string}
|
||||
*/
|
||||
public discountLabel(): string {
|
||||
return 'Discount';
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate adjustment.
|
||||
* @returns {string}
|
||||
*/
|
||||
public adjustment(): string {
|
||||
return this.options.estimate?.adjustmentFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate adjustment label.
|
||||
* @returns {string}
|
||||
*/
|
||||
public adjustmentLabel(): string {
|
||||
return 'Adjustment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate subtotal.
|
||||
*/
|
||||
public subtotal(): string {
|
||||
return this.options.estimate.formattedAmount;
|
||||
return this.options.estimate.formattedSubtotal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ export class SaleEstimateTransfromer extends Transformer {
|
||||
'discountAmountFormatted',
|
||||
'discountPercentageFormatted',
|
||||
'adjustmentFormatted',
|
||||
'totalFormatted',
|
||||
'totalLocalFormatted',
|
||||
'formattedCreatedAt',
|
||||
'entries',
|
||||
'attachments',
|
||||
@@ -134,6 +136,27 @@ export class SaleEstimateTransfromer extends Transformer {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted estimate total.
|
||||
* @returns {string}
|
||||
*/
|
||||
protected totalFormatted = (estimate: ISaleEstimate): string => {
|
||||
return formatNumber(estimate.total, {
|
||||
currencyCode: estimate.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted estimate total in local currency.
|
||||
* @param estimate
|
||||
* @returns {string}
|
||||
*/
|
||||
protected totalLocalFormatted = (estimate: ISaleEstimate): string => {
|
||||
return formatNumber(estimate.totalLocal, {
|
||||
currencyCode: estimate.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the entries of the sale estimate.
|
||||
* @param {ISaleEstimate} estimate
|
||||
|
||||
@@ -18,9 +18,6 @@ export class SaleEstimatesPdf {
|
||||
@Inject()
|
||||
private chromiumlyTenancy: ChromiumlyTenancy;
|
||||
|
||||
@Inject()
|
||||
private templateInjectable: TemplateInjectable;
|
||||
|
||||
@Inject()
|
||||
private getSaleEstimate: GetSaleEstimate;
|
||||
|
||||
@@ -62,6 +59,7 @@ export class SaleEstimatesPdf {
|
||||
// Retireves the sale estimate html.
|
||||
const htmlContent = await this.saleEstimateHtml(tenantId, saleEstimateId);
|
||||
|
||||
// Converts the html content to pdf.
|
||||
const content = await this.chromiumlyTenancy.convertHtmlContent(
|
||||
tenantId,
|
||||
htmlContent
|
||||
|
||||
@@ -23,6 +23,15 @@ export class GetInvoiceMailTemplateAttributesTransformer extends Transformer {
|
||||
'invoiceNumber',
|
||||
'invoiceNumberLabel',
|
||||
|
||||
'subtotal',
|
||||
'subtotalLabel',
|
||||
|
||||
'discount',
|
||||
'discountLabel',
|
||||
|
||||
'adjustment',
|
||||
'adjustmentLabel',
|
||||
|
||||
'total',
|
||||
'totalLabel',
|
||||
|
||||
@@ -76,6 +85,30 @@ export class GetInvoiceMailTemplateAttributesTransformer extends Transformer {
|
||||
return 'Invoice # {invoiceNumber}';
|
||||
}
|
||||
|
||||
public subtotal(): string {
|
||||
return this.options.invoice?.subtotalFormatted;
|
||||
}
|
||||
|
||||
public subtotalLabel(): string {
|
||||
return 'Subtotal';
|
||||
}
|
||||
|
||||
public discount(): string {
|
||||
return this.options.invoice?.discountAmountFormatted;
|
||||
}
|
||||
|
||||
public discountLabel(): string {
|
||||
return 'Discount';
|
||||
}
|
||||
|
||||
public adjustment(): string {
|
||||
return this.options.invoice?.adjustmentFormatted;
|
||||
}
|
||||
|
||||
public adjustmentLabel(): string {
|
||||
return 'Adjustment';
|
||||
}
|
||||
|
||||
public total(): string {
|
||||
return this.options.invoice?.totalFormatted;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,12 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
|
||||
'total',
|
||||
'totalLabel',
|
||||
|
||||
'discount',
|
||||
'discountLabel',
|
||||
|
||||
'adjustment',
|
||||
'adjustmentLabel',
|
||||
|
||||
'subtotal',
|
||||
'subtotalLabel',
|
||||
|
||||
@@ -98,7 +104,7 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
|
||||
* Receipt total.
|
||||
*/
|
||||
public total(): string {
|
||||
return this.options.receipt.formattedAmount;
|
||||
return this.options.receipt.totalFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,12 +115,44 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer
|
||||
return 'Total';
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt discount.
|
||||
* @returns {string}
|
||||
*/
|
||||
public discount(): string {
|
||||
return this.options.receipt?.discountAmountFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt discount label.
|
||||
* @returns {string}
|
||||
*/
|
||||
public discountLabel(): string {
|
||||
return 'Discount';
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt adjustment.
|
||||
* @returns {string}
|
||||
*/
|
||||
public adjustment(): string {
|
||||
return this.options.receipt?.adjustmentFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt adjustment label.
|
||||
* @returns {string}
|
||||
*/
|
||||
public adjustmentLabel(): string {
|
||||
return 'Adjustment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt subtotal.
|
||||
* @returns {string}
|
||||
*/
|
||||
public subtotal(): string {
|
||||
return this.options.receipt.formattedSubtotal;
|
||||
return this.options.receipt.subtotalFormatted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user