0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Set negative pricing in Offers index to 0 (#19174)

fixes ADM-24

- sets a negative amount to 0
- this usually occurs if the tier amount was changed after the offer has
been created.
This commit is contained in:
Ronald Langeveld 2023-11-29 16:10:10 +02:00 committed by GitHub
parent f8ad5fb2ea
commit 9a6d71884b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,11 @@ export const getOfferDiscount = (type: string, amount: number, cadence: string,
break; break;
}; };
// Check if updatedPrice is negative, if so, set it to 0
if (updatedPrice < 0) {
updatedPrice = 0;
}
const updatedPriceWithCurrency = getSymbol(currency) + numberWithCommas(formatToTwoDecimals(currencyToDecimal(updatedPrice))); const updatedPriceWithCurrency = getSymbol(currency) + numberWithCommas(formatToTwoDecimals(currencyToDecimal(updatedPrice)));
return { return {