From 22df0d963e09520339dfa9c681caeaaec790df8e Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Wed, 2 Apr 2025 13:33:34 -0400 Subject: Added check to checkout to stop checking out decimal values for physical needs --- .../src/main/java/com/ufund/api/ufundapi/service/CupboardService.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ufund-api') diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index 993e7c1..859194a 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -119,6 +119,9 @@ public class CupboardService { if (checkoutAmount <= 0) { throw new IllegalArgumentException("Amount must be greater than 0"); } + if ((checkoutAmount % 1 != 0) && (cupboardDAO.getNeed(id).getType() == Need.GoalType.PHYSICAL)) { + throw new IllegalArgumentException("Physical amounts must be whole numbers"); + } authService.keyIsValid(key); Need need = cupboardDAO.getNeed(id); need.incrementCurrent(checkoutAmount); -- cgit v1.2.3