From a3800cd2f80cb2b0a95d8c4082b8a5d75955ee5b Mon Sep 17 00:00:00 2001 From: rajesh Date: Tue, 29 Jul 2025 17:44:07 +0530 Subject: [PATCH] Fixed issue of formula calculation in application --- .../gepafin/tendermanagement/dao/ApplicationDao.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 21522588..9875f4ac 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -1792,10 +1792,14 @@ public class ApplicationDao { String expression = formula; for (String variable : variables) { Double value = variableValues.get(variable); - if (value != null) { - // Replace {variable} with its corresponding value in the formula - expression = expression.replace("{" + variable + "}", String.valueOf(value)); - } + String placeholder = "{" + variable + "}"; + + // If value is null, use 0 instead + String replacement = String.valueOf(value != null ? value : 0); + expression = expression.replace(placeholder, replacement); + } + if (expression.matches(".*\\{.*\\}.*")) { + return 0; } // Step 4: Evaluate the mathematical expression