mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: add discount functionality to sales and purchase transactions
- Introduced discount_type and discount fields in Bills and SalesReceipts controllers. - Updated database migrations to include discount and discount_type in estimates and credit notes tables. - Enhanced SaleReceipt and SaleEstimate models to support discount attributes. - Implemented formatting for discount amounts in transformers and PDF templates. - Updated email templates to display discount information. This commit enhances the handling of discounts across various transaction types, improving the overall functionality and user experience.
This commit is contained in:
@@ -13,9 +13,12 @@ export class SaleReceiptTransformer extends Transformer {
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'formattedSubtotal',
|
||||
'discountAmountFormatted',
|
||||
'discountPercentageFormatted',
|
||||
'subtotalFormatted',
|
||||
'subtotalLocalFormatted',
|
||||
'totalFormatted',
|
||||
'totalLocalFormatted',
|
||||
'adjustmentFormatted',
|
||||
'formattedAmount',
|
||||
'formattedReceiptDate',
|
||||
@@ -58,8 +61,37 @@ export class SaleReceiptTransformer extends Transformer {
|
||||
* @param {ISaleReceipt} receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedSubtotal = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.amount, { money: false });
|
||||
protected subtotalFormatted = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.subtotal, { money: false });
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the estimate formatted subtotal in local currency.
|
||||
* @param {ISaleReceipt} receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected subtotalLocalFormatted = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.subtotalLocal, {
|
||||
currencyCode: receipt.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the receipt formatted total.
|
||||
* @param receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected totalFormatted = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.total, { money: false });
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the receipt formatted total in local currency.
|
||||
* @param receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected totalLocalFormatted = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.totalLocal, { money: false });
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,7 +99,7 @@ export class SaleReceiptTransformer extends Transformer {
|
||||
* @param {ISaleReceipt} estimate
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedAmount = (receipt: ISaleReceipt): string => {
|
||||
protected amountFormatted = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.amount, {
|
||||
currencyCode: receipt.currencyCode,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user