fix: discount & adjustment sale transactions bugs

This commit is contained in:
Ahmed Bouhuolia
2024-12-05 14:47:11 +02:00
parent 391dc77071
commit beec09788e
10 changed files with 35 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ export const transformEstimateToPdfTemplate = (
quantity: entry.quantityFormatted,
total: entry.totalFormatted,
})),
total: estimate.formattedSubtotal,
total: estimate.totalFormatted,
subtotal: estimate.formattedSubtotal,
adjustment: estimate.adjustmentFormatted,
customerNote: estimate.note,

View File

@@ -82,21 +82,21 @@ export class GetSaleReceiptMailStateTransformer extends SaleReceiptTransformer {
};
/**
*
* Retrieves the total amount.
* @param receipt
* @returns
*/
protected total = (receipt) => {
return receipt.amount;
return receipt.total;
};
/**
*
* Retrieves the formatted total amount.
* @param receipt
* @returns
* @returns {string}
*/
protected totalFormatted = (receipt) => {
return this.formatMoney(receipt.amount, {
return this.formatMoney(receipt.total, {
currencyCode: receipt.currencyCode,
});
};
@@ -118,7 +118,7 @@ export class GetSaleReceiptMailStateTransformer extends SaleReceiptTransformer {
* @returns
*/
protected subtotal = (receipt) => {
return receipt.amount;
return receipt.subtotal;
};
/**
@@ -127,7 +127,7 @@ export class GetSaleReceiptMailStateTransformer extends SaleReceiptTransformer {
* @returns
*/
protected subtotalFormatted = (receipt) => {
return this.formatMoney(receipt.amount, {
return this.formatMoney(receipt.subtotal, {
currencyCode: receipt.currencyCode,
});
};

View File

@@ -413,7 +413,10 @@ export const formatSmsMessage = (message: string, args) => {
const variable = `{${key}}`;
const value = _.defaultTo(args[key], '');
formattedMessage = formattedMessage.replace(variable, value);
formattedMessage = formattedMessage.replace(
new RegExp(variable, 'g'),
value
);
});
return formattedMessage;
};