Bladeren bron

no message

master
[email protected] 1 maand geleden
bovenliggende
commit
9bbdca7056
1 gewijzigde bestanden met toevoegingen van 256 en 180 verwijderingen
  1. +256
    -180
      src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java

+ 256
- 180
src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java Bestand weergeven

@@ -259,7 +259,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
logger.info("form set start:");
byte[] modifiedPdfBytes = pdfBytes;

try (ByteArrayInputStream inputStream = new ByteArrayInputStream(pdfBytes);
@@ -270,8 +270,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
PdfDocument pdfDoc = new PdfDocument(reader, writer);
PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true);

logger.info("form:" + (form != null));
if (form != null) {
logger.info("sourceForm:" + (sourceForm != null));
/* START of copying the source fields if exist */
if(sourceForm != null){
for (Map.Entry<String, PdfFormField> entry : sourceForm.getFormFields().entrySet()) {
@@ -316,36 +317,40 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

if(commonField == null){
//logger.info("No common field data found for clientId: " + clientId);
// do nothing
} else {
// It's highly recommended to check if the field exists before setting its value
// This prevents NullPointerExceptions if a field is missing in a template
//temp using the remarks as form code
if("IDA".equals(formCode)){ // This is IDA
IDA_textBox(form, commonField, client);
} else if("FNA".equals(formCode)){ // This is FNA
FNA_textBox(form, commonField, client);
} else if("HSBCFIN".equals(formCode)){ // This is HSBCFIN
HSBCFIN_textBox(form, commonField, client);
}else if ("MLB03S".equals(formCode)) {
MLB03S_textBox(form, commonField, client);
} else if("MLFNA_EN".equals(formCode)){ // This is ML FNA EN
MLFNA_EN_textBox(form, commonField, client);
} else if("MLFNA_CHI".equals(formCode)){ // This is ML FNA CHI
MLFNA_EN_textBox(form, commonField, client);
} else if("SLFNA_EN".equals(formCode)){ // This is SL FNA EN
SLFNA_EN_textBox(form, commonField, client);
} else if("SLFNA_CHI".equals(formCode)){ // This is SL FNA CHI
SLFNA_EN_textBox(form, commonField, client);
}else if("SLAPP".equals(formCode)){
SLAPP_textBox(form, commonField, client);
}else if("HSBCA31".equals(formCode)){ // This is HSBC A31
HSBCA31_textBox(form, commonField, client);
}else if("SLGII".equals(formCode)){
SLGII_textBox(form, commonField, client);
}
commonField = new CommonField();
commonField.setClientId(clientId);
commonFieldService.save(commonField);
}

logger.info(formCode);
// It's highly recommended to check if the field exists before setting its value
// This prevents NullPointerExceptions if a field is missing in a template
//temp using the remarks as form code
if("IDA".equals(formCode)){ // This is IDA
IDA_textBox(form, commonField, client);
} else if("FNA".equals(formCode)){ // This is FNA
FNA_textBox(form, commonField, client);
} else if("HSBCFIN".equals(formCode)){ // This is HSBCFIN
HSBCFIN_textBox(form, commonField, client);
}else if ("MLB03S".equals(formCode)) {
MLB03S_textBox(form, commonField, client);
} else if("MLFNA_EN".equals(formCode)){ // This is ML FNA EN
MLFNA_EN_textBox(form, commonField, client);
} else if("MLFNA_CHI".equals(formCode)){ // This is ML FNA CHI
MLFNA_EN_textBox(form, commonField, client);
} else if("SLFNA_EN".equals(formCode)){ // This is SL FNA EN
SLFNA_EN_textBox(form, commonField, client);
} else if("SLFNA_CHI".equals(formCode)){ // This is SL FNA CHI
SLFNA_EN_textBox(form, commonField, client);
}else if("SLAPP".equals(formCode)){
SLAPP_textBox(form, commonField, client);
}else if("HSBCA31".equals(formCode)){ // This is HSBC A31
HSBCA31_textBox(form, commonField, client);
}else if("SLGII".equals(formCode)){
SLGII_textBox(form, commonField, client);
}

//form.flattenFields(); // Flatten fields after setting all values

} else {
@@ -443,10 +448,12 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

private void IDA_textBox(PdfAcroForm form, CommonField commonField, Client client){
logger.info("Processing IDA form (ID: 1)");
//setValueIfPresent(form, "fill_6", commonField.getName());
setValueIfPresent(form, "fill_6", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
//setValueIfPresent(form, "fill_6_1", commonField.getOthers().get("name1"));
//setValueIfPresent(form, "fill_6_2", commonField.getOthers().get("name2"));
/* Page1 Start */
setValueIfPresent(form, "gender_m", commonField.getGenderMale());
setValueIfPresent(form, "gender_f", commonField.getGenderFemale());
setValueIfPresent(form, "fill_6", StringUtils.trimToEmpty(client.getLastname()));
setValueIfPresent(form, "fill_7", StringUtils.trimToEmpty(client.getFirstname()));
setValueIfPresent(form, "fill_7", commonField.getNameChi());
setValueIfPresent(form, "fill_11", commonField.getIdCard());
setValueIfPresent(form, "fill_12", commonField.getCountryOfIssue());
@@ -455,10 +462,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "fill_15", commonField.getPlaceOfBirth());
setValueIfPresent(form, "fill_16", commonField.getCountryOfCitizenship());

/* Page1 Start */
setValueIfPresent(form, "gender_m", commonField.getGenderMale());
setValueIfPresent(form, "gender_f", commonField.getGenderFemale());

setValueIfPresent(form, "date_dd", commonField.getDdDateOfBirth());
setValueIfPresent(form, "date_mm", commonField.getMmDateOfBirth());
setValueIfPresent(form, "date_yyyy", commonField.getYyyyDateOfBirth());
@@ -571,7 +575,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page8 End */
/* Page9 Start */
//setValueIfPresent(form, "fill_26_4", commonField.getFna_c1a_amount());
setValueIfPresent(form, "fill_30_4", commonField.getOthers().get("realEstateAddress1_1"));
setValueIfPresent(form, "fill_30_4_1", commonField.getOthers().get("realEstateAddress1_2"));
setValueIfPresent(form, "fill_35_2", commonField.getOthers().get("realEstateAddress2_1"));
@@ -687,14 +690,12 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "totalNet", substractNums(client.getTotalAssetsCurrent(), client.getTotalLiabilitiesCurrent()));

/* Page11 End */
}

private void IDA_checkBox(PDAcroForm form2, CommonField commonField){
setValueIfPresent(form2, "gender_m", commonField.getGenderMale());
setValueIfPresent(form2, "gender_f", commonField.getGenderFemale());

setValueIfPresent(form2, "ch_hkid", commonField.getOthers().get("hkidPerm"));
setValueIfPresent(form2, "ch_hkid_non", commonField.getOthers().get("hkidNon"));
setValueIfPresent(form2, "ch_prcid", commonField.getOthers().get("prcId"));
@@ -710,7 +711,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "premium_financing", commonField.getPremium_financing());
setValueIfPresent(form2, "others_funds", commonField.getOthers_funds());
setValueIfPresent(form2, "others_funds_desc", commonField.getOthers_funds_desc());
/* Page3 Start */
setValueIfPresent(form2, "toggle_3_2", commonField.getBankruptYes());
setValueIfPresent(form2, "toggle_4_2", commonField.getBankruptNo());
@@ -743,7 +743,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "toggle_17_3", commonField.getInsuranceCritical3());
setValueIfPresent(form2, "toggle_18_2", commonField.getInsuranceOther3());
//}

setValueIfPresent(form2, "declinedYes", commonField.getDeclinedYes());
setValueIfPresent(form2, "declinedNo", commonField.getDeclinedNo());

@@ -758,6 +757,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "investor", commonField.getInvestor());
setValueIfPresent(form2, "retired", commonField.getRetired());
/* Page 8 End */
logger.info("12");
/* Page10 Start */
setValueIfPresent(form2, "fill_41_2", commonField.getOthers().get("sourceIncome"));
setValueIfPresent(form2, "toggle_3_7", commonField.getOthers().get("sourceIncome"));
@@ -766,6 +766,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "undefined_33", commonField.getOthers().get("sourceInheritance"));
setValueIfPresent(form2, "toggle_7_5", commonField.getOthers().get("sourceOther"));
/* Page10 End */
/* Page11 Start */
setValueIfPresent(form2, "emp_other_benefits_yes", commonField.getOthers().get("empOtherBenefitsYes"));
setValueIfPresent(form2, "emp_other_benefits_no", commonField.getOthers().get("empOtherBenefitsNo"));
/* Page11 End */
}

private void FNA_textBox(PdfAcroForm form, CommonField commonField, Client client){
@@ -1377,6 +1382,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

setValueIfPresent(form, "1_7_country", commonField.getPlaceOfBirth());
setValueIfPresent(form, "1_8", commonField.getCountryOfCitizenship());

//page 2
setValueIfPresent(form, "1_12_3", commonField.getOthers().get("workHighDesc"));
if("Yes".equals(commonField.getOthers().get("hkIdPerm")) || "Yes".equals(commonField.getOthers().get("hkidNon")))
setValueIfPresent(form, "1_10_id_num", commonField.getIdCard());
@@ -1509,6 +1518,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if("yes".equals(commonField.getOthers().get("passportYes")) || "yes".equals(commonField.getOthers().get("travelDocYes"))){
setValueIfPresent(form2, "1_10_6", "Yes");
}

//page 2
setValueIfPresent(form2, "ch1_12_yes", commonField.getOthers().get("workHighYes"));
setValueIfPresent(form2, "ch1_12_no", commonField.getOthers().get("workHighNo"));
/*
if(!form2.getField("1_14d_tax1").getValueAsString().isBlank()){
@@ -1650,6 +1663,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "ch1_13_corr_kln", commonField.getOthers().get("corAddressKln"));
setValueIfPresent(form2, "ch1_13_corr_nt", commonField.getOthers().get("corAddressNt"));
setValueIfPresent(form2, "de_yes", commonField.getReplaceInsuranceYes());
setValueIfPresent(form2, "de_no", commonField.getReplaceInsuranceNo());
setValueIfPresent(form2, "de_not", commonField.getOthers().get("replaceInsuranceNotYet"));
}
private void HSBCA31_textBox(PdfAcroForm form, CommonField commonField, Client client){
@@ -1700,6 +1717,12 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page3 Start */
//setValueIfPresent(form, "undefined_51", commonField.getContactNo());
/* Page3 End */
/* Page10 Start */
setValueIfPresent(form, "Text164", commonField.getOthers().get("empCompanyName"));
setValueIfPresent(form, "Text163", StringUtils.trimToNull(StringUtils.trimToEmpty(StringUtils.trimToEmpty(commonField.getOthers().get("empNatureA")) + " " + StringUtils.trimToEmpty(commonField.getOthers().get("empNatureB")))));
setValueIfPresent(form, "fill_14", commonField.getOthers().get("empPosition"));
setValueIfPresent(form, "fill_15_3", commonField.getOthers().get("empCompanyAddress"));
/* Page10 End */
/* Page12 Start */
setValueIfPresent(form, "undefined_17ha_1", commonField.getInsuranceCompany1_1());
setValueIfPresent(form, "undefined_17ha_2", commonField.getInsuranceCompany1_2());
@@ -1730,56 +1753,75 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "fill_2_6e", commonField.getDeclinedDesc());
setValueIfPresent(form, "fill_15_7y", commonField.getDeclinedDesc());
setValueIfPresent(form, "fill_15_7", commonField.getOthers().get("workHighDesc"));
/* Page12 End */
/* Page13 Start */
setValueIfPresent(form, "fill_9_6", commonField.getIncomeSalary());
setValueIfPresent(form, "fill_1k0_5", commonField.getIncomeSalaryLastYear());
setValueIfPresent(form, "fill_13_4", commonField.getIncomeBonus());
setValueIfPresent(form, "fill_14_4", commonField.getIncomeBonusLastYear());
setValueIfPresent(form, "fill_17_7", commonField.getIncomeInterest());
setValueIfPresent(form, "fill_18_6", commonField.getIncomeInterestLastYear());
setValueIfPresent(form, "fill_2k9_3", commonField.getIncomeDividents());
setValueIfPresent(form, "fill_3k0_3", commonField.getIncomeDividentsLastYear());
setValueIfPresent(form, "fill_k33_3", commonField.getIncomeRentals());
setValueIfPresent(form, "fill_34_2", commonField.getIncomeRentalsLastYear());
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.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")));
//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()));
//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());
//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() ));
setValueIfPresent(form, "fill_9_6", client.getSalaryCurrent());
setValueIfPresent(form, "fill_1k0_5", client.getSalaryLast());
setValueIfPresent(form, "fill_13_4", client.getBonusCurrent());
setValueIfPresent(form, "fill_14_4", client.getBonusLast());
setValueIfPresent(form, "fill_17_7", client.getCompanyInterestCurrent());
setValueIfPresent(form, "fill_18_6", client.getCompanyInterestLast());
setValueIfPresent(form, "fill_2k9_3", client.getDividendsCurrent());
setValueIfPresent(form, "fill_3k0_3", client.getDividendsLast());
setValueIfPresent(form, "fill_k33_3", client.getRentalsCurrent());
setValueIfPresent(form, "fill_34_2", client.getRentalsLast());
setValueIfPresent(form, "fill_k37_2", client.getOtherUnearnedCurrent());
setValueIfPresent(form, "fill_38_2", client.getOtherUnearnedLast());
setValueIfPresent(form, "fill_37_2", client.getTotalUnearnedCurrent());
setValueIfPresent(form, "fill_38_222", client.getTotalUnearnedLast());
setValueIfPresent(form, "fill_1k1_5", client.getMortgageCurrent());
setValueIfPresent(form, "fill_12_511", client.getMortgageLast());
setValueIfPresent(form, "fill_15_8", client.getRentalsCurrent());
setValueIfPresent(form, "fill_16_7", client.getRentalsLast());
setValueIfPresent(form, "fill_19_4", client.getSchoolingCurrent());
setValueIfPresent(form, "fill_2k0_4", client.getSchoolingLast());
setValueIfPresent(form, "fill_2k3_5", client.getMembershipsCurrent());
setValueIfPresent(form, "fill_24_5", client.getMembershipsLast());
setValueIfPresent(form, "fill_3k1_3", addNums(client.getOtherExpenditureCurrent(), client.getOtherPrefFinanceCurrent()));
setValueIfPresent(form, "fill_32_2", addNums(client.getOtherExpenditureLast(), client.getOtherPrefFinanceLast()));
setValueIfPresent(form, "fill_35_2", client.getInterestCurrent());
setValueIfPresent(form, "fill_36_2", client.getInterestLast());
setValueIfPresent(form, "fill_39_212", client.getPrincipalCurrent());
setValueIfPresent(form, "fill_36_2", client.getPrincipalLast());
setValueIfPresent(form, "fill_39_2", client.getTotalExpenditureCurrent());
setValueIfPresent(form, "fill_40", client.getTotalExpenditureLast());

setValueIfPresent(form, "fill_4114", client.getCashDepositsCurrent());
setValueIfPresent(form, "fill_4215", client.getCashDepositsLast());
setValueIfPresent(form, "fill_5318", client.getPersonalPropertiesCurrent());
setValueIfPresent(form, "fill_5419", client.getPersonalPropertiesLast());
setValueIfPresent(form, "fill_5720", client.getInvestmentsCurrent());
setValueIfPresent(form, "fill_5419", client.getInvestmentsLast());
setValueIfPresent(form, "fill_6123", client.getOtherLiquidCurrent());
setValueIfPresent(form, "fill_6224", client.getOtherLiquidLast());
setValueIfPresent(form, "fill_6526", client.getOtherNonLiquidCurrent());
setValueIfPresent(form, "fill_6627", client.getOtherNonLiquidLast());
setValueIfPresent(form, "fill_6928", client.getNetBusinessInterestCurrent());
setValueIfPresent(form, "fill_7029", client.getNetBusinessInterestLast());
setValueIfPresent(form, "fill_111130", client.getTotalAssetsCurrent());
setValueIfPresent(form, "fill_111231", client.getTotalAssetsLast());

setValueIfPresent(form, "fill_41", client.getPersonalLoansCurrent());
setValueIfPresent(form, "fill_42", client.getPersonalLoansLast());
setValueIfPresent(form, "fill_49", client.getMortgageCurrent());
setValueIfPresent(form, "fill_50", client.getMortgageLast());
setValueIfPresent(form, "fill_53", client.getMarginAccountCurrent());
setValueIfPresent(form, "fill_54", client.getMarginAccountLast());
setValueIfPresent(form, "fill_57", client.getLoanGuaranteesCurrent());
setValueIfPresent(form, "fill_58", client.getLoanGuaranteesLast());
setValueIfPresent(form, "fill_61", client.getBankingFacilityCurrent());
setValueIfPresent(form, "fill_62", client.getBankingFacilityLast());
//other 1
setValueIfPresent(form, "fill_65", client.getPrincipalCurrent());
setValueIfPresent(form, "fill_66", client.getPrincipalLast());
setValueIfPresent(form, "fill_69", client.getOtherPrefFinanceCurrent());
setValueIfPresent(form, "fill_70", client.getOtherPrefFinanceLast());

setValueIfPresent(form, "fill_1111", client.getTotalLiabilitiesCurrent());
setValueIfPresent(form, "fill_1112", client.getTotalLiabilitiesLast());
/* Page13 End */
/* Page14 Start */
@@ -1869,7 +1911,19 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

setValueIfPresent(form2, "Check Box74bc", commonField.getOthers().get("futureAddressYes"));
setValueIfPresent(form2, "Check Box74_1ah", commonField.getOthers().get("futureAddressNo"));
setValueIfPresent(form2, "Check Box74be", commonField.getOthers().get("workHighYes"));
setValueIfPresent(form2, "Check Box74_1aj", commonField.getOthers().get("workHighNo"));
setValueIfPresent(form2, "Check Box74bd", commonField.getOthers().get("hazardYes"));
setValueIfPresent(form2, "Check Box74_1ai", commonField.getOthers().get("hazardNo"));
setValueIfPresent(form2, "fill_15_7y", commonField.getHazardousActivity());
/* Page12 End */
/* Page13 Start */
setValueIfPresent(form2, "Check Box81", commonField.getOthers().get("empOtherBenefitsYes"));
setValueIfPresent(form2, "Check Box82", commonField.getOthers().get("empOtherBenefitsNo"));
/* Page13 End */
/* Page14 Start */
setValueIfPresent(form2, "Check Box65f", commonField.getOwn_income());
setValueIfPresent(form2, "Check Box65d", commonField.getPremium_financing());
@@ -1877,6 +1931,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "Check Box65b", commonField.getBankruptYes());
setValueIfPresent(form2, "Check Box83", commonField.getBankruptNo());
/* Page14 End */
/* Page25 Start */
setValueIfPresent(form2, "Check Box18211", commonField.getReplaceInsuranceYes());
setValueIfPresent(form2, "Check Box18222", commonField.getReplaceInsuranceNo());
setValueIfPresent(form2, "Check Box18233", commonField.getOthers().get("replaceInsuranceNotYet"));
/* Page25 End */
/* Page27 Start */
setValueIfPresent(form2, "toggle_7_47", commonField.getFna_c3a_single_pay());
/* Page27 End */
@@ -2030,8 +2089,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "1_10id", commonField.getIdCard());
}else if("Yes".equals(commonField.getOthers().get("prcId"))){
setValueIfPresent(form, "1_10prc", commonField.getPassportNo());
//setValueIfPresent(form, "fill_14_date", commonField.getOthers().get("passportExpiryDate"));
}else if("Yes".equals(commonField.getOthers().get("passportYes")) || "Yes".equals(commonField.getOthers().get("travelDocYes")) ){
setValueIfPresent(form, "1_10passport", commonField.getPassportNo());
}
@@ -2045,12 +2103,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "ch1_12_part", commonField.getHomemaker());
setValueIfPresent(form, "ch1_12_retired", commonField.getBankruptNo());

setValueIfPresent(form, "1_12_occupation", commonField.getOccupation());
setValueIfPresent(form, "1_12_exact_duty", commonField.getOccupationTitle());

setValueIfPresent(form, "1_12_employer", commonField.getCompanyName());
setValueIfPresent(form, "1_12_employer_address_1", commonField.getOthers().get("companyAddress1"));
setValueIfPresent(form, "1_12_employer_address_2", commonField.getOthers().get("companyAddress2"));
setValueIfPresent(form, "1_12_occupation", commonField.getOthers().get("empPosition"));
setValueIfPresent(form, "1_12_exact_duty", commonField.getOthers().get("empDuties"));
setValueIfPresent(form, "1_12_employer", commonField.getOthers().get("empCompanyName"));
setValueIfPresent(form, "1_12_employer_address_1", commonField.getOthers().get("empCompanyAddress"));
//setValueIfPresent(form, "1_12_employer_address_2", commonField.getOthers().get("companyAddress2"));

setValueIfPresent(form, "1_12_nature_1", commonField.getCompanyNature1());
setValueIfPresent(form, "1_12_nature_2", commonField.getCompanyNature2());
@@ -2252,56 +2309,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "ch5_6_no", commonField.getOthers().get("pendingChargeNo"));
/* Page7 End */
/* Page10 Start */
int i = 1;
if("Father".equals(commonField.getOthers().get("relateFatherRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateFatherAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateFatherName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateFatherAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateFatherRelation"));

i++;
for(int i=1; i<=4; i++){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relate" + i + "_name"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relate" + i + "_age"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relate" + i + "_relationship"));
}
if("Mother".equals(commonField.getOthers().get("relateMotherRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateMotherAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateMotherName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateMotherAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateMotherRelation"));

i++;
}
if("Spouse".equals(commonField.getOthers().get("relateSpouseRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateSpouseAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateSpouseName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateSpouseAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateSpouseRelation"));

i++;
}
if("Son".equals(commonField.getOthers().get("relateSonRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateSonAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateSonName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateSonAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateSonRelation"));

i++;
}
if("Daughter".equals(commonField.getOthers().get("relateDaughterRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateDaughterAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateDaughterName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateDaughterAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateDaughterRelation"));

i++;
}
if("Bother".equals(commonField.getOthers().get("relateBotherRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateBotherAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateBotherName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateBotherAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateBotherRelation"));

i++;
}
if("Sister".equals(commonField.getOthers().get("relateSisterRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateSisterAge")) != null ){
setValueIfPresent(form, "7_1a_name" + i, commonField.getOthers().get("relateSisterName"));
setValueIfPresent(form, "7_1a_age" + i, commonField.getOthers().get("relateSisterAge"));
setValueIfPresent(form, "7_1a_relation" + i, commonField.getOthers().get("relateSisterRelation"));

i++;
}
if(commonField.getOthers().get("companyStartYear") != null && commonField.getOthers().get("companyEndYear") != null
&& !commonField.getOthers().get("companyStartYear").isBlank() && !commonField.getOthers().get("companyEndYear").isBlank()){
setValueIfPresent(form, "7_1b", commonField.getOthers().get("companyStartYear") + " - " + commonField.getOthers().get("companyEndYear"));
@@ -2312,46 +2326,56 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "7_1d", commonField.getOthers().get("businessOwnerNoEmployee"));
/* Page10 End */

setValueIfPresent(form, "7_2a_salary", commonField.getIncomeSalary());
setValueIfPresent(form, "7_2a_salary_24", commonField.getIncomeSalaryLastYear());
setValueIfPresent(form, "7_2a_bonuses", commonField.getIncomeBonus());
setValueIfPresent(form, "7_2a_bonuses_24", commonField.getIncomeBonusLastYear());
setValueIfPresent(form, "7_2a_company", commonField.getIncomeInterest());
setValueIfPresent(form, "7_2a_company_24", commonField.getIncomeInterestLastYear());
setValueIfPresent(form, "7_2a_dividends", commonField.getIncomeDividents());
setValueIfPresent(form, "7_2a_dividends_24", commonField.getIncomeDividentsLastYear());
setValueIfPresent(form, "7_2a_rental", commonField.getIncomeRentals());
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, "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_salary", client.getSalaryCurrent());
setValueIfPresent(form, "7_2a_salary_24", client.getSalaryLast());
setValueIfPresent(form, "7_2a_bonuses", client.getBonusCurrent());
setValueIfPresent(form, "7_2a_bonuses_24", client.getBonusLast());
setValueIfPresent(form, "7_2a_company", client.getCompanyInterestCurrent());
setValueIfPresent(form, "7_2a_company_24", client.getCompanyInterestLast());
setValueIfPresent(form, "7_2a_dividends", client.getDividendsCurrent());
setValueIfPresent(form, "7_2a_dividends_24", client.getDividendsLast());
setValueIfPresent(form, "7_2a_rental", client.getRentalsCurrent());
setValueIfPresent(form, "7_2a_rental_24", client.getRentalsLast());
setValueIfPresent(form, "7_2a_other", addNums(client.getOtherEarnedCurrent(), client.getOtherUnearnedCurrent()));
setValueIfPresent(form, "7_2a_other_24", addNums(client.getOtherEarnedLast(),client.getOtherUnearnedLast()));
//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_2a_sum", client.getTotalIncomeCurrent());
setValueIfPresent(form, "7_2a_sum_24", client.getTotalIncomeLast());

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());
setValueIfPresent(form, "7_2c_cash", client.getCashDepositsCurrent());
setValueIfPresent(form, "7_2c_cash_24", client.getCashDepositsLast());
setValueIfPresent(form, "7_2c_real", client.getPersonalPropertiesCurrent());
setValueIfPresent(form, "7_2c_real_24", client.getPersonalPropertiesLast());
setValueIfPresent(form, "7_2c_stocks", client.getInvestmentsCurrent());
setValueIfPresent(form, "7_2c_stocks_24", client.getInvestmentsLast());
setValueIfPresent(form, "7_2c_high", client.getPersonalPropertiesCurrent());
setValueIfPresent(form, "7_2c_high_24", client.getPersonalPropertiesLast());
setValueIfPresent(form, "7_2c_other", addNums(client.getOtherLiquidCurrent(), client.getOtherNonLiquidCurrent()));
setValueIfPresent(form, "7_2c_other_24", addNums(client.getOtherLiquidLast(), client.getOtherNonLiquidLast()));

//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_total_24", addNums(form.getField("7_2c_cash_24").getValueAsString(), form.getField("7_2c_real_24").getValueAsString(), form.getField("7_2c_stocks_24").getValueAsString(), form.getField("7_2c_high_24").getValueAsString(), form.getField("7_2c_business_24").getValueAsString(), form.getField("7_2c_other_24").getValueAsString()));

setValueIfPresent(form, "7_2c_lia_loan", commonField.getLiaLoan());
setValueIfPresent(form, "7_2c_lia_mortgages", commonField.getLiaMortgage());
setValueIfPresent(form, "7_2c_lia_margin", commonField.getLiaMargin());
setValueIfPresent(form, "7_2c_lia_loan", commonField.getLiaLoanGurantee());
setValueIfPresent(form, "7_2c_lia_other", commonField.getLiaOther());
setValueIfPresent(form, "7_2c_lia_loan", client.getPersonalLoansCurrent());
setValueIfPresent(form, "7_2c_lia_loan_24", client.getPersonalLoansLast());
setValueIfPresent(form, "7_2c_lia_mortgages", client.getMortgageCurrent());
setValueIfPresent(form, "7_2c_lia_mortgages", client.getMortgageLast());
setValueIfPresent(form, "7_2c_lia_margin", client.getMarginAccountCurrent());
setValueIfPresent(form, "7_2c_lia_margin_24", client.getMarginAccountLast());
setValueIfPresent(form, "7_2c_lia_loan", client.getLoanGuaranteesCurrent());
setValueIfPresent(form, "7_2c_lia_margin_24", client.getLoanGuaranteesLast());
setValueIfPresent(form, "7_2c_lia_banking", client.getBankingFacilityCurrent());
setValueIfPresent(form, "7_2c_lia_margin_24", client.getBankingFacilityLast());
setValueIfPresent(form, "7_2c_lia_other", addNums(client.getOtherPrefFinanceCurrent(), client.getPrincipalCurrent()));
setValueIfPresent(form, "7_2c_lia_other_24", addNums(client.getOtherPrefFinanceLast(), client.getPrincipalLast()));
//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_2c_lia_total", addNums(form.getField("7_2c_lia_loan_24").getValueAsString(), form.getField("7_2c_lia_mortgages_24").getValueAsString(), form.getField("7_2c_lia_margin_24").getValueAsString(), form.getField("7_2c_lia_loan_24").getValueAsString(), form.getField("7_2c_lia_other_24").getValueAsString()));

setValueIfPresent(form, "7_2d_address1_1", commonField.getOthers().get("realEstateAddress1_1"));
setValueIfPresent(form, "7_2d_address1_2", commonField.getOthers().get("realEstateAddress1_2"));
@@ -2376,6 +2400,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "ch1_4_m", commonField.getGenderMale());
setValueIfPresent(form2, "ch1_4_f", commonField.getGenderFemale());
if("Yes".equals(commonField.getOthers().get("hkIdPerm")) || "Yes".equals(commonField.getOthers().get("hkidNon")))
setValueIfPresent(form2, "ch1_10birth", "Yes");
else if("Yes".equals(commonField.getOthers().get("prcId")))
setValueIfPresent(form2, "ch1_10orc", commonField.getIdCard());
else if("Yes".equals(commonField.getOthers().get("passportYes")) || "Yes".equals(commonField.getOthers().get("travelDocYes")) )
setValueIfPresent(form2, "ch1_10passport", "Yes");
/* Page1 End */
/* Page2 Start */
setValueIfPresent(form2, "ch1_11_s", commonField.getOthers().get("maritalStatusSingle"));
@@ -2502,7 +2533,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "ch5_3_no", commonField.getDeclinedNo());
setValueIfPresent(form2, "ch5_6_yes", commonField.getOthers().get("pendingChargeYes"));
setValueIfPresent(form2, "ch5_6_no", commonField.getOthers().get("pendingChargeNo"));

/* Page7 End */

/* Page10 Start */
setValueIfPresent(form2, "7_2b_yes", commonField.getOthers().get("empOtherBenefitsYes"));
setValueIfPresent(form2, "6_2b_no", commonField.getOthers().get("empOtherBenefitsNo"));
/* Page10 End */
}

@@ -2808,9 +2845,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "tobaccoYes" -> commonField.setTobarccoYes(fieldValue);
case "tobaccoNo" -> commonField.setTobarccoNo(fieldValue);
case "hazardousActivity" -> commonField.setHazardousActivity(fieldValue);

/* Page5 End */
/* Page6 Start */
case "fill_8_country_1" -> commonField.setTaxResidency1(fieldValue);
@@ -2825,6 +2859,24 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "fill_7_6" -> commonField.setTaxPin3(fieldValue);
case "fill_8_6" -> commonField.setTaxReason3(fieldValue);
case "fill_9_6" -> commonField.setTaxReasonB3(fieldValue);
case "ch_high_yes" -> commonField.getOthers().put("workHighYes", fieldValue);
case "ch_high_no" -> commonField.getOthers().put("workHighNo", fieldValue);
case "fill_high" -> commonField.getOthers().put("workHighDesc", fieldValue);
case "ch_hazard_yes" -> commonField.getOthers().put("hazardYes", fieldValue);
case "ch_hazard_no" -> commonField.getOthers().put("hazardNo", fieldValue);
case "toggle_17_2" -> commonField.getOthers().put("hazardAviation", fieldValue);
case "toggle_18" -> commonField.getOthers().put("hazardSky", fieldValue);
case "toggle_19" -> commonField.getOthers().put("hazardScuba", fieldValue);
case "toggle_20" -> commonField.getOthers().put("hazardPowerboat", fieldValue);
case "toggle_21" -> commonField.getOthers().put("hazardSportsCar", fieldValue);
case "toggle_22" -> commonField.getOthers().put("hazardMotocycle", fieldValue);
case "toggle_23" -> commonField.getOthers().put("hazardRock", fieldValue);
case "undefined_20" -> commonField.getOthers().put("hazardOther", fieldValue);
case "hazardousActivity" -> commonField.setHazardousActivity(fieldValue);
/* Page6 End */
/* Page7 Start */
case "fill_11_7" -> commonField.setInsuranceCompany1_1(fieldValue);
case "fill_11_7_1" -> commonField.setInsuranceCompany1_2(fieldValue);
@@ -2928,7 +2980,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

case "replaceInsuranceYes" -> commonField.setReplaceInsuranceYes(fieldValue);
case "replaceInsuranceNo" -> commonField.setReplaceInsuranceNo(fieldValue);
case "replaceInsuranceNotYet" -> commonField.getOthers().put("replaceInsuranceNotYet", fieldValue);
case "fill_10_7" -> commonField.getOthers().put("replaceInsuranceDesc", fieldValue);
/* Page7 End */
/* Page8 Start */
case "employed" -> commonField.setEmployed(fieldValue);
@@ -3003,6 +3056,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page9 End */

/* Page10 Start */
case "emp1_position" -> commonField.getOthers().put("empPosition", fieldValue);
case "emp1_company_name" -> commonField.getOthers().put("empCompanyName", fieldValue);
case "emp1_duties" -> commonField.getOthers().put("empDuties", fieldValue);
case "emp1_company_address" -> commonField.getOthers().put("empCompanyAddress", fieldValue);
case "emp1_natureA" -> commonField.getOthers().put("empNatureA", fieldValue);
case "emp1_natureB" -> commonField.getOthers().put("empNatureB", fieldValue);

case "toggle_3_7" -> commonField.getOthers().put("sourceIncome", fieldValue);
case "toggle_4_6" -> commonField.getOthers().put("sourceBusiness", fieldValue);
case "toggle_6_5" -> commonField.getOthers().put("sourceInvestment", fieldValue);
@@ -3010,6 +3070,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "toggle_7_5" -> commonField.getOthers().put("sourceOther", fieldValue);
case "fill_2_9" -> commonField.getOthers().put("sourceOtherDesc", fieldValue);
/* Page10 End */

/* Page11 Start */
case "emp_other_benefits_yes" -> commonField.getOthers().put("empOtherBenefitsYes", fieldValue);
case "emp_other_benefits_no" -> commonField.getOthers().put("empOtherBenefitsNo", fieldValue);


/* Page11 End */
}

/* Special logic Start */
@@ -3811,6 +3878,12 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
}

/* Page13 Start */
case "ch7e_1_yes" -> commonField.getOthers().put("travelYes", fieldValue);
case "ch7e_1_no" -> commonField.getOthers().put("travelNo", fieldValue);

/* Page13 End */
}
}

@@ -4360,6 +4433,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
public static double convertStringToNum(String inputString) {
if(inputString == null)
return 0;
inputString = inputString.replaceAll(",", "");

if (inputString == null || inputString.trim().isEmpty()) {


Laden…
Annuleren
Opslaan