Use BigDecimal#compareTo for numeric equality testing

This commit is contained in:
Ehren Kret
2022-04-29 14:20:09 -05:00
parent 7b7d309105
commit 058caadf4f

View File

@@ -527,7 +527,7 @@ public class SubscriptionController {
}
if (request.level == giftConfiguration.level()) {
BigDecimal amountConfigured = giftConfiguration.currencies().get(request.currency.toLowerCase(Locale.ROOT));
if (amountConfigured == null || !stripeManager.convertConfiguredAmountToStripeAmount(request.currency, amountConfigured).equals(BigDecimal.valueOf(request.amount))) {
if (amountConfigured == null || stripeManager.convertConfiguredAmountToStripeAmount(request.currency, amountConfigured).compareTo(BigDecimal.valueOf(request.amount)) != 0) {
throw new WebApplicationException(Response.status(Status.CONFLICT).entity(Map.of("error", "level_amount_mismatch")).build());
}
}