| @@ -1643,25 +1643,45 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form, "fill_3k0_3", commonField.getIncomeDividentsLastYear()); | |||
| setValueIfPresent(form, "fill_k33_3", commonField.getIncomeRentals()); | |||
| setValueIfPresent(form, "fill_34_2", commonField.getIncomeRentalsLastYear()); | |||
| if("INVESTMENT INCOME".equals(StringUtils.trimToEmpty(commonField.getIncomeOther()).toUpperCase())){ | |||
| setValueIfPresent(form, "fill_2k1_5", commonField.getIncomeOther()); | |||
| setValueIfPresent(form, "fill_2k2_5", commonField.getIncomeOtherLastYear()); | |||
| if(StringUtils.trimToEmpty(commonField.getOthers().get("incomeUnearnedOtherDesc")).toUpperCase().contains("INVESTMENT")){ | |||
| setValueIfPresent(form, "fill_2k1_5", commonField.getOthers().get("incomeUnearnedOther")); | |||
| setValueIfPresent(form, "fill_2k2_5", commonField.getOthers().get("incomeUnearnedOtherLastYear")); | |||
| }else{ | |||
| setValueIfPresent(form, "fill_k37_2", commonField.getIncomeOther()); | |||
| setValueIfPresent(form, "fill_38_2", commonField.getIncomeOtherLastYear()); | |||
| setValueIfPresent(form, "fill_k37_2", commonField.getOthers().get("incomeUnearnedOther")); | |||
| setValueIfPresent(form, "fill_38_2", commonField.getOthers().get("incomeUnearnedOtherLastYear")); | |||
| } | |||
| //setValueIfPresent(form, "fill_37_2", commonField.getTotalAnnualIncome()); | |||
| setValueIfPresent(form, "fill_37_2", addNums(commonField.getOthers().get("totalEarnedIncome"), commonField.getOthers().get("totalUnearnedIncome"))); | |||
| setValueIfPresent(form, "fill_38_222", addNums(commonField.getOthers().get("totalEarnedIncomeLastYear"), commonField.getOthers().get("totalUnearnedIncomeLastYear"))); | |||
| //setValueIfPresent(form, "fill_37_2", addNums(commonField.getOthers().get("totalEarnedIncome"), commonField.getOthers().get("totalUnearnedIncome"))); | |||
| //setValueIfPresent(form, "fill_38_222", addNums(commonField.getOthers().get("totalEarnedIncomeLastYear"), commonField.getOthers().get("totalUnearnedIncomeLastYear"))); | |||
| //income sum | |||
| setValueIfPresent(form, "fill_37_2", addNums(form.getField("fill_9_6").getValueAsString(), form.getField("fill_13_4").getValueAsString(),form.getField("fill_17_7").getValueAsString(),form.getField("fill_2k9_3").getValueAsString(), form.getField("fill_k33_3").getValueAsString(), form.getField("fill_2k1_5").getValueAsString(), form.getField("fill_k37_2").getValueAsString())); | |||
| //income sum last year | |||
| setValueIfPresent(form, "fill_38_222", addNums(form.getField("fill_1k0_5").getValueAsString(), form.getField("fill_14_4").getValueAsString(),form.getField("fill_18_6").getValueAsString(),form.getField("fill_3k0_3").getValueAsString(), form.getField("fill_34_2").getValueAsString(), form.getField("fill_2k2_5").getValueAsString(), form.getField("fill_38_2").getValueAsString())); | |||
| setValueIfPresent(form, "fill_39_2", commonField.getFna_c1b_amount()); | |||
| //expense sum | |||
| setValueIfPresent(form, "fill_39_2", addNums(form.getField("fill_1k1_5").getValueAsString(), form.getField("fill_15_8").getValueAsString(), form.getField("fill_19_4").getValueAsString(), form.getField("fill_2k3_5").getValueAsString(), form.getField("fill_3k1_3").getValueAsString(), form.getField("fill_35_2").getValueAsString(), form.getField("fill_39_212").getValueAsString())); | |||
| //setValueIfPresent(form, "fill_39_2", commonField.getFna_c1b_amount()); | |||
| setValueIfPresent(form, "fill_4114", commonField.getAssetCash()); | |||
| setValueIfPresent(form, "fill_4916", commonField.getAssetRealEstate()); | |||
| setValueIfPresent(form, "fill_5720", commonField.getAssetInvestment()); | |||
| setValueIfPresent(form, "fill_5318", commonField.getAssetProperties()); | |||
| setValueIfPresent(form, "fill_111130", commonField.getFna_c2a_amount()); | |||
| setValueIfPresent(form, "fill_1111", commonField.getFna_c2b_amount()); | |||
| //setValueIfPresent(form, "fill_111130", commonField.getFna_c2a_amount()); | |||
| //setValueIfPresent(form, "fill_1111", commonField.getFna_c2b_amount()); | |||
| //assets sum | |||
| setValueIfPresent(form, "fill_111130", addNums(form.getField("fill_4114").getValueAsString(), form.getField("fill_4916").getValueAsString(), form.getField("fill_5318").getValueAsString(), form.getField("fill_5720").getValueAsString(), form.getField("fill_6123").getValueAsString(), form.getField("fill_6526").getValueAsString(), form.getField("fill_6928").getValueAsString() )); | |||
| setValueIfPresent(form, "fill_41", commonField.getLiaLoan()); | |||
| setValueIfPresent(form, "fill_49", commonField.getLiaMortgage()); | |||
| setValueIfPresent(form, "fill_53", commonField.getLiaMargin()); | |||
| setValueIfPresent(form, "fill_57", commonField.getLiaLoanGurantee()); | |||
| setValueIfPresent(form, "fill_65", commonField.getLiaOther()); | |||
| //liabilities sum | |||
| setValueIfPresent(form, "fill_1111", addNums(form.getField("fill_41").getValueAsString(), form.getField("fill_49").getValueAsString(), form.getField("fill_53").getValueAsString(), form.getField("fill_57").getValueAsString(), form.getField("fill_61").getValueAsString(), form.getField("fill_65").getValueAsString(), form.getField("fill_69").getValueAsString() )); | |||
| /* Page13 End */ | |||
| /* Page14 Start */ | |||
| setValueIfPresent(form, "fill_73_1", commonField.getOthers().get("realEstateAddress1_1")); | |||
| @@ -1674,6 +1694,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form, "fill_78", commonField.getRealEstatePurchaseDate2()); | |||
| setValueIfPresent(form, "fill_82", commonField.getRealEstatePurchaseDate3()); | |||
| setValueIfPresent(form, "Text26001", commonField.getBankruptDesc()); | |||
| /* Page14 End */ | |||
| setValueIfPresent(form, "fill_4_12", commonField.getFna_a_retire()); | |||
| @@ -2165,21 +2187,28 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form, "7_2a_dividends", commonField.getIncomeDividents()); | |||
| setValueIfPresent(form, "7_2a_dividends_24", commonField.getIncomeDividentsLastYear()); | |||
| setValueIfPresent(form, "7_2a_rental", commonField.getIncomeRentals()); | |||
| if("INVESTMENT INCOME".equals(StringUtils.trimToEmpty(commonField.getIncomeOther()).toUpperCase())){ | |||
| setValueIfPresent(form, "7_2a_invest", commonField.getIncomeOther()); | |||
| setValueIfPresent(form, "7_2a_invest_24", commonField.getIncomeOtherLastYear()); | |||
| logger.info("commonField.getOthers().get(\"incomeUnearnedOtherDesc\"):" + commonField.getOthers().get("incomeUnearnedOtherDesc")); | |||
| if(StringUtils.trimToEmpty(commonField.getOthers().get("incomeUnearnedOtherDesc")).toUpperCase().contains("INVESTMENT")){ | |||
| setValueIfPresent(form, "7_2a_invest", commonField.getOthers().get("incomeUnearnedOther")); | |||
| setValueIfPresent(form, "7_2a_invest_24", commonField.getOthers().get("incomeUnearnedOtherLastYear")); | |||
| logger.info("commonField.getOthers().get(\"incomeUnearnedOtherDesc\"): true"); | |||
| }else{ | |||
| //setValueIfPresent(form, "fill_k37_2", commonField.getIncomeOther()); | |||
| //setValueIfPresent(form, "fill_38_2", commonField.getIncomeOtherLastYear()); | |||
| setValueIfPresent(form, "7_2c_other_desc", commonField.getOthers().get("incomeUnearnedOtherDesc")); | |||
| setValueIfPresent(form, "7_2c_other", commonField.getOthers().get("incomeUnearnedOther")); | |||
| setValueIfPresent(form, "7_2c_other_24", commonField.getOthers().get("incomeUnearnedOtherLastYear")); | |||
| logger.info("commonField.getOthers().get(\"incomeUnearnedOtherDesc\"): false"); | |||
| } | |||
| setValueIfPresent(form, "7_2a_sum", addNums(form.getField("7_2a_salary").getValueAsString(), form.getField("7_2a_bonuses").getValueAsString(),form.getField("7_2a_invest").getValueAsString(),form.getField("7_2a_dividends").getValueAsString(), form.getField("7_2a_rental").getValueAsString(), form.getField("7_2a_invest").getValueAsString())); | |||
| setValueIfPresent(form, "7_2a_sum_24", addNums(form.getField("7_2a_salary_24").getValueAsString(), form.getField("7_2a_bonuses_24").getValueAsString(),form.getField("7_2a_invest_24").getValueAsString(),form.getField("7_2a_dividends_24").getValueAsString(), form.getField("7_2a_rental_24").getValueAsString(), form.getField("7_2a_invest_24").getValueAsString())); | |||
| //sum income | |||
| setValueIfPresent(form, "7_2a_sum", addNums(form.getField("7_2a_salary").getValueAsString(), form.getField("7_2a_bonuses").getValueAsString(),form.getField("7_2a_company").getValueAsString(),form.getField("7_2a_dividends").getValueAsString(), form.getField("7_2a_rental").getValueAsString(), form.getField("7_2a_invest").getValueAsString())); | |||
| setValueIfPresent(form, "7_2a_sum_24", addNums(form.getField("7_2a_salary_24").getValueAsString(), form.getField("7_2a_bonuses_24").getValueAsString(),form.getField("7_2a_company_24").getValueAsString(),form.getField("7_2a_dividends_24").getValueAsString(), form.getField("7_2a_rental_24").getValueAsString(), form.getField("7_2a_invest_24").getValueAsString())); | |||
| setValueIfPresent(form, "7_2c_cash", commonField.getAssetCash()); | |||
| setValueIfPresent(form, "7_2c_real", commonField.getAssetRealEstate()); | |||
| setValueIfPresent(form, "7_2c_stocks", commonField.getAssetInvestment()); | |||
| setValueIfPresent(form, "7_2c_high", commonField.getAssetProperties()); | |||
| //sum asset | |||
| setValueIfPresent(form, "7_2c_total", addNums(form.getField("7_2c_cash").getValueAsString(), form.getField("7_2c_real").getValueAsString(), form.getField("7_2c_stocks").getValueAsString(), form.getField("7_2c_high").getValueAsString(), form.getField("7_2c_business").getValueAsString(), form.getField("7_2c_other").getValueAsString())); | |||
| setValueIfPresent(form, "7_2c_lia_loan", commonField.getLiaLoan()); | |||
| @@ -2187,6 +2216,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form, "7_2c_lia_margin", commonField.getLiaMargin()); | |||
| setValueIfPresent(form, "7_2c_lia_loan", commonField.getLiaLoanGurantee()); | |||
| setValueIfPresent(form, "7_2c_lia_other", commonField.getLiaOther()); | |||
| //sum liabilities | |||
| setValueIfPresent(form, "7_2c_lia_total", addNums(form.getField("7_2c_lia_loan").getValueAsString(), form.getField("7_2c_lia_mortgages").getValueAsString(), form.getField("7_2c_lia_margin").getValueAsString(), form.getField("7_2c_lia_loan").getValueAsString(), form.getField("7_2c_lia_other").getValueAsString())); | |||
| setValueIfPresent(form, "7_2d_address1_1", commonField.getOthers().get("realEstateAddress1_1")); | |||
| @@ -2798,6 +2828,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| case "incomeSalaryLastYear" -> 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<Pdf, Long, PdfReposito | |||
| case "incomeDividentsLastYear" -> 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<Pdf, Long, PdfReposito | |||
| return sum; | |||
| } | |||
| private static double convertWithSuffix(String s) { | |||
| if (s == null || s.trim().isEmpty()) { | |||
| return 0.0; | |||
| } | |||
| String trimmed = s.trim().toUpperCase(); | |||
| double multiplier = 1.0; | |||
| String baseNumber = s; | |||
| // Check for suffixes and set multiplier | |||
| if (trimmed.endsWith("K")) { | |||
| multiplier = 1000.0; | |||
| baseNumber = s.substring(0, s.length() - 1); | |||
| } else if (trimmed.endsWith("M")) { | |||
| multiplier = 1000000.0; | |||
| baseNumber = s.substring(0, s.length() - 1); | |||
| } | |||
| // Use the original convertStringToNum on the base number part | |||
| double value = convertStringToNum(baseNumber); | |||
| return value * multiplier; | |||
| } | |||
| public static String addNums(String... strings) { | |||
| double totalSum = 0.0; | |||
| boolean withSymbol = false; | |||
| // 1. Calculate the total sum | |||
| for (String s : strings) { | |||
| // Assuming convertStringToNum(s) returns a double from the string | |||
| // You'll need to ensure this utility function is available. | |||
| totalSum += convertStringToNum(s); | |||
| if(s != null && (s.toUpperCase().contains("M") || s.toUpperCase().contains("K"))){ | |||
| withSymbol = true; | |||
| } | |||
| totalSum += convertWithSuffix(s); | |||
| } | |||
| // 2. Format the result | |||
| // Use NumberFormat.getNumberInstance() with a specific locale | |||
| // to get the correct grouping and decimal separators for that region. | |||
| // Example uses US locale (comma separator, period decimal). | |||
| NumberFormat formatter = NumberFormat.getNumberInstance(Locale.US); | |||
| // Cast the formatter to DecimalFormat to set the number of decimal places | |||
| DecimalFormat decimalFormatter = (DecimalFormat) formatter; | |||
| // Set the format pattern: #,##0.00 ensures: | |||
| // - Thousands grouping (,) | |||
| // - At least one digit before the decimal (0) | |||
| // - Exactly two digits after the decimal (.00) | |||
| decimalFormatter.applyPattern("#,##0"); | |||
| return decimalFormatter.format(totalSum); | |||
| } | |||
| return formatScaledNumber(withSymbol, totalSum); | |||
| } | |||
| public static String substractNums(String a, String b) { | |||
| double aValue = convertStringToNum(a); | |||
| double bValue = convertStringToNum(b); | |||
| double aValue = convertWithSuffix(a); | |||
| double bValue = convertWithSuffix(b); | |||
| boolean withSymbol = false; | |||
| if(a != null && (a.toUpperCase().contains("M") || a.toUpperCase().contains("K"))){ | |||
| withSymbol = true; | |||
| } | |||
| if (aValue >= 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<String, String> getCountryAndPhoneNo(String contactNo){ | |||
| String countryCode = ""; | |||