diff --git a/src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java b/src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java index ee0776c..1eec366 100644 --- a/src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java +++ b/src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java @@ -1643,25 +1643,45 @@ public class PdfService extends AbstractBaseEntityService commonField.setIncomeSalaryLastYear(fieldValue); case "incomeBonus" -> commonField.setIncomeBonus(fieldValue); case "incomeBonusLastYear" -> commonField.setIncomeBonusLastYear(fieldValue); + + case "earned_income_other" -> commonField.getOthers().put("incomeOtherDesc", fieldValue); case "incomeOther" -> commonField.setIncomeOther(fieldValue); case "incomeOtherLastYear" -> commonField.setIncomeOtherLastYear(fieldValue); case "incomeInterest" -> commonField.setIncomeInterest(fieldValue); @@ -2806,6 +2838,10 @@ public class PdfService extends AbstractBaseEntityService commonField.setIncomeDividentsLastYear(fieldValue); case "incomeRentals" -> commonField.setIncomeRentals(fieldValue); case "incomeRentalsLastYear" -> commonField.setIncomeRentalsLastYear(fieldValue); + + case "unearned_income_other" -> commonField.getOthers().put("incomeUnearnedOtherDesc", fieldValue); + case "fill_24_4" -> commonField.getOthers().put("incomeUnearnedOther", fieldValue); + case "fill_25_4" -> commonField.getOthers().put("incomeUnearnedOtherLastYear", fieldValue); case "assetCash" -> commonField.setAssetCash(fieldValue); case "assetInvestment" -> commonField.setAssetInvestment(fieldValue); @@ -4221,56 +4257,91 @@ public class PdfService extends AbstractBaseEntityService= bValue) { double difference = aValue - bValue; - - // --- Formatting the result --- - // 1. Get a formatter instance (using US locale for comma thousands separator and period decimal) - NumberFormat formatter = NumberFormat.getNumberInstance(Locale.US); - DecimalFormat decimalFormatter = (DecimalFormat) formatter; - - // 2. Apply the desired pattern: #,##0.00 - decimalFormatter.applyPattern("#,##0"); - - // 3. Format and return the difference - return decimalFormatter.format(difference); + return formatScaledNumber(withSymbol, difference); } else { - // Return an empty string if aValue is less than bValue return ""; } } + + private static String formatScaledNumber(boolean withSymbol, double value) { + if (value == 0.0) { + return "0"; + } + + String suffix = ""; + double scaledValue = value; + + // Determine the most appropriate scaling factor and suffix + if (Math.abs(value) >= 1000000) { + suffix = "M"; + scaledValue = value / 1000000.0; + } else if (Math.abs(value) >= 1000) { + suffix = "K"; + scaledValue = value / 1000.0; + } + + if (withSymbol) { + // For K/M output, use precision (up to two decimals, dropping trailing zeros) + DecimalFormat formatter = new DecimalFormat("#,##0"); + return formatter.format(scaledValue) + suffix; + } else { + // For numbers < 1000, return the number with standard separator and mandatory two decimals + NumberFormat numberFormatter = NumberFormat.getNumberInstance(Locale.US); + DecimalFormat decimalFormatter = (DecimalFormat) numberFormatter; + decimalFormatter.applyPattern("#,##0"); + + return decimalFormatter.format(value); + } + } public static Map getCountryAndPhoneNo(String contactNo){ String countryCode = "";