From 7b5ef30c7d16a790d2f61e4eed963b31fdc66e25 Mon Sep 17 00:00:00 2001 From: rajesh Date: Tue, 29 Jul 2025 17:33:17 +0530 Subject: [PATCH] Fixed formula calculation issue in application --- .../tendermanagement/dao/ApplicationDao.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 198a4ede..a0ae0651 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -1786,12 +1786,15 @@ 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 return Utils.evaluateExpression(expression); }