Explorar el Código

no message

master
[email protected] hace 2 meses
padre
commit
c80ac1d666
Se han modificado 4 ficheros con 445 adiciones y 211 borrados
  1. +101
    -2
      src/main/java/com/ffii/lioner/modules/lioner/client/entity/Client.java
  2. +91
    -3
      src/main/java/com/ffii/lioner/modules/lioner/client/req/UpdateClientReq.java
  3. +239
    -206
      src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java
  4. +14
    -0
      src/main/resources/db/changelog/changes/31_client_address_fields/01_add_address.sql

+ 101
- 2
src/main/java/com/ffii/lioner/modules/lioner/client/entity/Client.java Ver fichero

@@ -1,7 +1,6 @@
package com.ffii.lioner.modules.lioner.client.entity;

import java.time.LocalDate;
import java.time.LocalDateTime;

import com.ffii.core.entity.BaseEntity;

@@ -11,7 +10,6 @@ import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

/** @author Jason Lam */
@Entity
@@ -53,6 +51,33 @@ public class Client extends BaseEntity<Long>{

@Column
private Integer consultantId;

@Column
private String crAddressRoom;

@Column
private String crAddressFloor;

@Column
private String crAddressBlock;

@Column
private String crAddressBuilding;

@Column
private String crAddressStreet;

@Column
private String crAddressArea;

@Column
private String crAddressCity;

@Column
private String crAddressCountry;

@Column
private String crAddressPostalCode;
public String getClientCode() {
@@ -142,5 +167,79 @@ public class Client extends BaseEntity<Long>{
public void setConsultantId(Integer consultantId) {
this.consultantId = consultantId;
}

public String getCrAddressRoom() {
return crAddressRoom;
}

public void setCrAddressRoom(String crAddressRoom) {
this.crAddressRoom = crAddressRoom;
}

public String getCrAddressFloor() {
return crAddressFloor;
}

public void setCrAddressFloor(String crAddressFloor) {
this.crAddressFloor = crAddressFloor;
}

public String getCrAddressBlock() {
return crAddressBlock;
}

public void setCrAddressBlock(String crAddressBlock) {
this.crAddressBlock = crAddressBlock;
}

public String getCrAddressBuilding() {
return crAddressBuilding;
}

public void setCrAddressBuilding(String crAddressBuilding) {
this.crAddressBuilding = crAddressBuilding;
}

public String getCrAddressStreet() {
return crAddressStreet;
}

public void setCrAddressStreet(String crAddressStreet) {
this.crAddressStreet = crAddressStreet;
}

public String getCrAddressArea() {
return crAddressArea;
}

public void setCrAddressArea(String crAddressArea) {
this.crAddressArea = crAddressArea;
}

public String getCrAddressCity() {
return crAddressCity;
}

public void setCrAddressCity(String crAddressCity) {
this.crAddressCity = crAddressCity;
}

public String getCrAddressCountry() {
return crAddressCountry;
}

public void setCrAddressCountry(String crAddressCountry) {
this.crAddressCountry = crAddressCountry;
}

public String getCrAddressPostalCode() {
return crAddressPostalCode;
}

public void setCrAddressPostalCode(String crAddressPostalCode) {
this.crAddressPostalCode = crAddressPostalCode;
}

}


+ 91
- 3
src/main/java/com/ffii/lioner/modules/lioner/client/req/UpdateClientReq.java Ver fichero

@@ -1,11 +1,9 @@
package com.ffii.lioner.modules.lioner.client.req;

import java.util.List;
import java.time.LocalDate;

import jakarta.validation.constraints.Size;

import java.time.LocalDate;

public class UpdateClientReq {
private Long id;
@@ -39,6 +37,24 @@ public class UpdateClientReq {

Integer consultantId;

String crAddressRoom;

String crAddressFloor;

String crAddressBlock;

String crAddressBuilding;

String crAddressStreet;

String crAddressArea;

String crAddressCity;

String crAddressCountry;

String crAddressPostalCode;

public Long getId() {
return id;
}
@@ -135,4 +151,76 @@ public class UpdateClientReq {
this.consultantId = consultantId;
}

public String getCrAddressRoom() {
return crAddressRoom;
}

public void setCrAddressRoom(String crAddressRoom) {
this.crAddressRoom = crAddressRoom;
}

public String getCrAddressFloor() {
return crAddressFloor;
}

public void setCrAddressFloor(String crAddressFloor) {
this.crAddressFloor = crAddressFloor;
}

public String getCrAddressBlock() {
return crAddressBlock;
}

public void setCrAddressBlock(String crAddressBlock) {
this.crAddressBlock = crAddressBlock;
}

public String getCrAddressBuilding() {
return crAddressBuilding;
}

public void setCrAddressBuilding(String crAddressBuilding) {
this.crAddressBuilding = crAddressBuilding;
}

public String getCrAddressStreet() {
return crAddressStreet;
}

public void setCrAddressStreet(String crAddressStreet) {
this.crAddressStreet = crAddressStreet;
}

public String getCrAddressArea() {
return crAddressArea;
}

public void setCrAddressArea(String crAddressArea) {
this.crAddressArea = crAddressArea;
}

public String getCrAddressCity() {
return crAddressCity;
}

public void setCrAddressCity(String crAddressCity) {
this.crAddressCity = crAddressCity;
}

public String getCrAddressCountry() {
return crAddressCountry;
}

public void setCrAddressCountry(String crAddressCountry) {
this.crAddressCountry = crAddressCountry;
}

public String getCrAddressPostalCode() {
return crAddressPostalCode;
}

public void setCrAddressPostalCode(String crAddressPostalCode) {
this.crAddressPostalCode = crAddressPostalCode;
}

}

+ 239
- 206
src/main/java/com/ffii/lioner/modules/lioner/pdf/service/PdfService.java Ver fichero

@@ -4,12 +4,15 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -434,7 +437,8 @@ 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", 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"));
setValueIfPresent(form, "fill_7", commonField.getNameChi());
@@ -455,11 +459,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "fill_17", commonField.getContactNo());
setValueIfPresent(form, "fill_18", commonField.getEmail());
setValueIfPresent(form, "fill_19", commonField.getOthers().get("address1"));
setValueIfPresent(form, "fill_19_1", commonField.getOthers().get("address2"));
setValueIfPresent(form, "fill_23", commonField.getOthers().get("crAddress1"));
setValueIfPresent(form, "fill_23_1", commonField.getOthers().get("crAddress2"));
setValueIfPresent(form, "fill_19", getCrAddress1(client));
setValueIfPresent(form, "fill_19_1", getCrAddress2(client));
//setValueIfPresent(form, "fill_23", commonField.getOthers().get("crAddress1"));
//setValueIfPresent(form, "fill_23_1", commonField.getOthers().get("crAddress2"));
/* Page1 End */
/* Page2 Start */
setValueIfPresent(form, "own_income", commonField.getOwn_income());
@@ -562,6 +566,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page9 Start */
//setValueIfPresent(form, "fill_26_4", commonField.getFna_c1a_amount());
setValueIfPresent(form, "totalAnnualIncome", commonField.getTotalAnnualIncome());
setValueIfPresent(form, "fill_26_4", commonField.getOthers().get("totalEarnedIncome"));
setValueIfPresent(form, "fill_27_4", commonField.getOthers().get("totalEarnedIncomeLastYear"));
setValueIfPresent(form, "fill_28_4", commonField.getOthers().get("totalUnearnedIncome"));
setValueIfPresent(form, "fill_29_4", commonField.getOthers().get("totalUnearnedIncomeLastYear"));
setValueIfPresent(form, "total_asset", commonField.getFna_c2a_amount());
setValueIfPresent(form, "totalLiquidLia", commonField.getFna_c2b_amount());
@@ -611,7 +619,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
}
setValueIfPresent(form, "Name of Client", commonField.getName());
setValueIfPresent(form, "Name of Client", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
//setValueIfPresent(form, "Name of Client1", commonField.getOthers().get("name1"));
//setValueIfPresent(form, "Name of Client2", commonField.getOthers().get("name2"));

@@ -634,7 +642,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page3 Start */
setValueIfPresent(form2, "toggle_3_2", commonField.getBankruptYes());
setValueIfPresent(form2, "toggle_6_2", commonField.getBankruptNo());
setValueIfPresent(form2, "toggle_4_2", commonField.getBankruptNo());
/* Page3 End */
/* Page5 Start */
setValueIfPresent(form2, "toggle_3_4", commonField.getOthers().get("pendingChargeYes"));
@@ -692,7 +700,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void FNA_textBox(PdfAcroForm form, CommonField commonField, Client client){
//logger.info("Processing FNA form (ID: 2)");
/* Page1 Start */
setValueIfPresent(form, "fna_a_name", commonField.getName());
//setValueIfPresent(form, "fna_a_name", commonField.getName());
setValueIfPresent(form, "fna_a_name", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
//setValueIfPresent(form, "fna_a_name_1", commonField.getOthers().get("name1"));
//setValueIfPresent(form, "fna_a_name_2", commonField.getOthers().get("name2"));
setValueIfPresent(form, "fna_a_birth", commonField.getDateOfBirth());
@@ -789,8 +799,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
}
setValueIfPresent(form, "fna_name_policyowner", commonField.getName());
setValueIfPresent(form, "fna_name_policyowner", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
}

private void FNA_checkBox(PDAcroForm form2, CommonField commonField){
@@ -844,6 +854,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "fna_c3a_20", commonField.getFna_c3a_20());
setValueIfPresent(form2, "fna_c3a_life", commonField.getFna_c3a_life());
setValueIfPresent(form2, "fna_c3a_single_pay", commonField.getFna_c3a_single_pay());
setValueIfPresent(form2, "fna_c3a_single_pay_max", commonField.getOthers().get("singlePayAmount"));
setValueIfPresent(form2, "fna_c3b_salary", commonField.getFna_c3b_salary());
setValueIfPresent(form2, "fna_c3b_income", commonField.getFna_c3b_income());
@@ -861,7 +872,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void HSBCFIN_textBox(PdfAcroForm form, CommonField commonField, Client client){
//logger.info("Processing HSBCFIN form (ID: 3)");
/* Page1 Start */
setValueIfPresent(form, "fill_3", commonField.getName());
setValueIfPresent(form, "fill_3", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
//setValueIfPresent(form, "fill_3_1", commonField.getOthers().get("name1"));
//setValueIfPresent(form, "fill_3_2", commonField.getOthers().get("name2"));
setValueIfPresent(form, "fill_4", commonField.getNameChi());
@@ -920,7 +932,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
}
setValueIfPresent(form, "fill_1_2", commonField.getName());
setValueIfPresent(form, "fill_1_2", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
}

private void HSBCFIN_checkBox(PDAcroForm form2, CommonField commonField){
@@ -991,7 +1004,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

private void MLFNA_EN_textBox(PdfAcroForm form, CommonField commonField, Client client){
/* Page1 Start */
setValueIfPresent(form, "part1", commonField.getName());
setValueIfPresent(form, "part1", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
setValueIfPresent(form, "part2_1a_amount", commonField.getFna_b1_a_amount());
setValueIfPresent(form, "part2_1c_amount", commonField.getFna_b1_d_amount());
@@ -1020,10 +1034,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "Full Name of Advisor", consultant.getName());
}
}
setValueIfPresent(form, "Full Name of Applicants", commonField.getName());
//setValueIfPresent(form, "Full Name of Applicants1", commonField.getOthers().get("name1"));
//setValueIfPresent(form, "Full Name of Applicants2", commonField.getOthers().get("name2"));
setValueIfPresent(form, "Full Name of Applicants", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
}

@@ -1096,10 +1107,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

private void SLFNA_EN_textBox(PdfAcroForm form, CommonField commonField, Client client){
/* Page1 Start */
setValueIfPresent(form, "name", commonField.getName());
setValueIfPresent(form, "name", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
setValueIfPresent(form, "date_of_birth", commonField.getDateOfBirth());
setValueIfPresent(form, "address1", commonField.getOthers().get("address1"));
setValueIfPresent(form, "address2", commonField.getOthers().get("address2"));
setValueIfPresent(form, "address1", getCrAddress1(client));
setValueIfPresent(form, "address2", getCrAddress2(client));
setValueIfPresent(form, "contact", commonField.getContactNo());
setValueIfPresent(form, "email", commonField.getEmail());
setValueIfPresent(form, "occupation", commonField.getOccupationTitle());
@@ -1109,13 +1121,15 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

/* Page1 End */
/* Page2 Start */
setValueIfPresent(form, "4a1", commonField.getFna_c1d_amount());
setValueIfPresent(form, "4a3", commonField.getFna_c1d_amount());
setValueIfPresent(form, "4b1", commonField.getFna_c2a_amount());
setValueIfPresent(form, "4b2", commonField.getFna_c2a_desc());
setValueIfPresent(form, "4b3", commonField.getFna_c2b_amount());
setValueIfPresent(form, "4b5", substractNums(commonField.getFna_c2a_amount(), commonField.getFna_c2b_amount()));
//tick cb4c7
setValueIfPresent(form, "4c3", commonField.getFna_c1d_amount());
/* Page2 End */
/* Page4 Start */
@@ -1188,10 +1202,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "consultant_name_and_num", consultant.getName());
}
}
setValueIfPresent(form, "applicant_name", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));
setValueIfPresent(form, "applicant_name", commonField.getName());
//setValueIfPresent(form, "applicant_name1", commonField.getOthers().get("name1"));
//setValueIfPresent(form, "applicant_name2", commonField.getOthers().get("name2"));
}
private void SLFNA_EN_checkBox(PDAcroForm form2, CommonField commonField){
@@ -1246,7 +1258,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form2, "cb4c4", commonField.getFna_c3a_16_20());
setValueIfPresent(form2, "cb4c5", commonField.getFna_c3a_life());
setValueIfPresent(form2, "cb4c6", commonField.getFna_c3a_single_pay());

setValueIfPresent(form2, "4c3", commonField.getOthers().get("singlePayAmount"));
setValueIfPresent(form2, "cb4d1", commonField.getFna_c1e_10());
setValueIfPresent(form2, "cb4d2", commonField.getFna_c1e_10_20());
setValueIfPresent(form2, "cb4d3", commonField.getFna_c1e_21_30());
@@ -1319,17 +1332,20 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "ch1_13_corr_street", commonField.getCorAddressStreet());
setValueIfPresent(form, "ch1_13_corr_zip", commonField.getCorAddressPostalCode());
*/
setValueIfPresent(form, "ch1_13_rm", commonField.getOthers().get("crAddressRoom"));
setValueIfPresent(form, "ch1_13_floor", commonField.getOthers().get("crAddressFloor"));
setValueIfPresent(form, "ch1_13_block", commonField.getOthers().get("crAddressBlock"));
setValueIfPresent(form, "ch1_13_building", commonField.getOthers().get("crAddressBuilding"));
setValueIfPresent(form, "ch1_13_street", commonField.getOthers().get("crAddressStreet"));
setValueIfPresent(form, "ch1_13_country", commonField.getOthers().get("crAddressCountry"));
setValueIfPresent(form, "1_13_zip", commonField.getOthers().get("crAddressPostalCode"));
setValueIfPresent(form, "ch1_13_hk", commonField.getOthers().get("crAddressHk"));
setValueIfPresent(form, "ch1_13_kln", commonField.getOthers().get("crAddressKln"));
setValueIfPresent(form, "ch1_13_nt", commonField.getOthers().get("crAddressNt"));
setValueIfPresent(form, "ch1_13_rm", client.getCrAddressRoom());
setValueIfPresent(form, "ch1_13_floor", client.getCrAddressFloor());
setValueIfPresent(form, "ch1_13_block", client.getCrAddressBlock());
setValueIfPresent(form, "ch1_13_building", client.getCrAddressBuilding());
setValueIfPresent(form, "ch1_13_street", client.getCrAddressStreet());
setValueIfPresent(form, "ch1_13_country", client.getCrAddressCountry());
setValueIfPresent(form, "1_13_zip", client.getCrAddressPostalCode());
if("HK".equals(client.getCrAddressArea()))
setValueIfPresent(form, "ch1_13_hk", "Yes");
if("KLN".equals(client.getCrAddressArea()) || "KL".equals(client.getCrAddressArea()) || "KWOLOON".equals(client.getCrAddressArea()))
setValueIfPresent(form, "ch1_13_kln", "Yes");
if("NT".equals(client.getCrAddressArea()))
setValueIfPresent(form, "ch1_13_nt", "Yes");

setValueIfPresent(form, "ch1_13_corr_rm", commonField.getOthers().get("corAddressRoom"));
setValueIfPresent(form, "ch1_13_corr_floor", commonField.getOthers().get("corAddressFloor"));
setValueIfPresent(form, "ch1_13_corr_block", commonField.getOthers().get("corAddressBlock"));
@@ -1396,7 +1412,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if(commonField.getPassportNo() != null && !commonField.getPassportNo().isBlank()){
setValueIfPresent(form2, "1_10_6", "Yes");
}
/*
if(!form2.getField("1_14d_tax1").getValueAsString().isBlank()){
setValueIfPresent(form2, "ch1_14d_reason1_b", "On");
setValueIfPresent(form2, "ch1_14d_reason1_b", "On");
@@ -1442,6 +1458,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if("C".equals(commonField.getTaxReason3())){
setValueIfPresent(form2, "ch1_14d_reason3_c", "Yes");
}
*/
setValueIfPresent(form2, "ch2_5_1p", commonField.getEduPri());
setValueIfPresent(form2, "ch2_5_1s", commonField.getEduSec());
@@ -1539,13 +1556,9 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void HSBCA31_textBox(PdfAcroForm form, CommonField commonField, Client client){
/* Page1 Start */
setValueIfPresent(form, "fill_15", commonField.getFirstName());
setValueIfPresent(form, "fill_16", commonField.getGivenName());

if(form.getField("fill_15").getValueAsString().isBlank()
&& form.getField("fill_16").getValueAsString().isBlank() ){
setValueIfPresent(form, "fill_15", commonField.getName());
}
setValueIfPresent(form, "fill_15", StringUtils.trimToEmpty(client.getFirstname()));
setValueIfPresent(form, "fill_16", StringUtils.trimToEmpty(client.getLastname()));
//setValueIfPresent(form, "applicant_name", StringUtils.trimToEmpty(StringUtils.trimToEmpty(client.getLastname()) + " " + StringUtils.trimToEmpty(client.getFirstname())));

setValueIfPresent(form, "fill_17", commonField.getNameChi());
setValueIfPresent(form, "Text1", commonField.getIdCard());
@@ -1558,11 +1571,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "fill_20", commonField.getPlaceOfBirth());
/* Page1 End */
/* Page2 Start */
setValueIfPresent(form, "Text16_1", commonField.getOthers().get("crAddress1"));
setValueIfPresent(form, "Text16_2", commonField.getOthers().get("crAddress2"));
setValueIfPresent(form, "Text16_1", getCrAddress1(client));
setValueIfPresent(form, "Text16_2", getCrAddress2(client));

setValueIfPresent(form, "address1", commonField.getOthers().get("address1"));
setValueIfPresent(form, "address2", commonField.getOthers().get("address2"));
//setValueIfPresent(form, "address1", commonField.getOthers().get("address1"));
//setValueIfPresent(form, "address2", commonField.getOthers().get("address2"));
Map<String, String> d = getCountryAndPhoneNo(commonField.getContactNo());
if(d.get("countryCode") != null)
@@ -1620,14 +1633,22 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "fill_14_4", commonField.getIncomeBonusLastYear());
setValueIfPresent(form, "fill_17_7", commonField.getIncomeInterest());
setValueIfPresent(form, "fill_18_6", commonField.getIncomeInterestLastYear());
setValueIfPresent(form, "fill_2k1_5", commonField.getAssetInvestment());
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());
setValueIfPresent(form, "fill_k37_2", commonField.getIncomeOther());
setValueIfPresent(form, "fill_38_2", commonField.getIncomeOtherLastYear());
setValueIfPresent(form, "fill_37_2", commonField.getTotalAnnualIncome());
if("INVESTMENT INCOME".equals(StringUtils.trimToEmpty(commonField.getIncomeOther()).toUpperCase())){
setValueIfPresent(form, "fill_2k1_5", commonField.getIncomeOther());
setValueIfPresent(form, "fill_2k2_5", commonField.getIncomeOtherLastYear());
}else{
setValueIfPresent(form, "fill_k37_2", commonField.getIncomeOther());
setValueIfPresent(form, "fill_38_2", commonField.getIncomeOtherLastYear());
}

//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_39_2", commonField.getFna_c1b_amount());
setValueIfPresent(form, "fill_4114", commonField.getAssetCash());
setValueIfPresent(form, "fill_4916", commonField.getAssetRealEstate());
@@ -1721,13 +1742,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

private void MLB03S_textBox(PdfAcroForm form, CommonField commonField, Client client){
/* Page1 Start */
setValueIfPresent(form, "SurName1", commonField.getFirstName());
setValueIfPresent(form, "GivenName1", commonField.getGivenName());
if(form.getField("SurName1").getValueAsString().isBlank()
&& form.getField("GivenName1").getValueAsString().isBlank() ){
setValueIfPresent(form, "SurName1", commonField.getName());
}
setValueIfPresent(form, "SurName1", StringUtils.trimToEmpty(client.getFirstname()));
setValueIfPresent(form, "GivenName1", StringUtils.trimToEmpty(client.getLastname()));

setValueIfPresent(form, "ChineseName1", commonField.getNameChi());

@@ -1748,15 +1764,15 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "Income1", addNums(commonField.getIncomeSalary(), commonField.getIncomeBonus()) );

setValueIfPresent(form, "JobNature1", commonField.getOthers().get("crAddressRoom"));
setValueIfPresent(form, "Floor1", commonField.getOthers().get("crAddressRoom"));
setValueIfPresent(form, "Block1", commonField.getOthers().get("crAddressBlock"));
setValueIfPresent(form, "Block1", commonField.getOthers().get("crAddressBlock"));
setValueIfPresent(form, "Block1", commonField.getOthers().get("crAddressStreet"));
setValueIfPresent(form, "City1", commonField.getOthers().get("crAddressCity"));
setValueIfPresent(form, "District1", commonField.getOthers().get("crAddressDistrict"));
setValueIfPresent(form, "Country1", commonField.getOthers().get("crAddressCountry"));
setValueIfPresent(form, "Country1", commonField.getOthers().get("crAddressPostalCode"));
setValueIfPresent(form, "JobNature1", client.getCrAddressRoom());
setValueIfPresent(form, "Floor1", client.getCrAddressFloor());
setValueIfPresent(form, "Block1", client.getCrAddressBlock());
setValueIfPresent(form, "Building1", client.getCrAddressBuilding());
setValueIfPresent(form, "Street1", client.getCrAddressStreet());
setValueIfPresent(form, "City1", client.getCrAddressCity());
setValueIfPresent(form, "District1", client.getCrAddressArea());
setValueIfPresent(form, "Country1", client.getCrAddressCity());
setValueIfPresent(form, "PostalCode1", client.getCrAddressPostalCode());
/* Page1 End */
/* Page2 Start */
@@ -1838,13 +1854,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

private void SLGII_textBox(PdfAcroForm form, CommonField commonField, Client client){
/* Page1 Start */
setValueIfPresent(form, "surname", commonField.getFirstName());
setValueIfPresent(form, "given_name", commonField.getGivenName());

if(form.getField("surname").getValueAsString().isBlank()
&& form.getField("given_name").getValueAsString().isBlank()){
setValueIfPresent(form, "surname", commonField.getName());
}
setValueIfPresent(form, "surname", StringUtils.trimToEmpty(client.getFirstname()));
setValueIfPresent(form, "given_name", StringUtils.trimToEmpty(client.getLastname()));

setValueIfPresent(form, "ChineseName1", commonField.getNameChi());

@@ -1883,15 +1894,18 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "1_12_nature_1", commonField.getCompanyNature1());
setValueIfPresent(form, "1_12_nature_2", commonField.getCompanyNature2());

setValueIfPresent(form, "1_13a_rm", commonField.getOthers().get("crAddressRoom"));
setValueIfPresent(form, "1_13a_floor", commonField.getOthers().get("crAddressFloor"));
setValueIfPresent(form, "1_13a_block", commonField.getOthers().get("crAddressBlock"));
setValueIfPresent(form, "1_13a_district", commonField.getOthers().get("crAddressCountry"));
setValueIfPresent(form, "1_13a_zip", commonField.getOthers().get("crAddressPostalCode"));
setValueIfPresent(form, "ch1_13a_hk", commonField.getOthers().get("crAddressHK"));
setValueIfPresent(form, "ch1_13a_kln", commonField.getOthers().get("crAddressKln"));
setValueIfPresent(form, "ch1_13a_nt", commonField.getOthers().get("crAddressNt"));

setValueIfPresent(form, "1_13a_rm", client.getCrAddressRoom());
setValueIfPresent(form, "1_13a_floor", client.getCrAddressFloor());
setValueIfPresent(form, "1_13a_block", client.getCrAddressBlock());
setValueIfPresent(form, "1_13a_district", client.getCrAddressArea());
setValueIfPresent(form, "1_13a_zip", client.getCrAddressPostalCode());
if("HK".equals(client.getCrAddressArea()))
setValueIfPresent(form, "ch1_13a_hk", "Yes");
if("KLN".equals(client.getCrAddressArea()) || "KL".equals(client.getCrAddressArea()) || "KWOLOON".equals(client.getCrAddressArea()))
setValueIfPresent(form, "ch1_13a_kln", "Yes");
if("NT".equals(client.getCrAddressArea()))
setValueIfPresent(form, "ch1_13a_nt", "Yes");
setValueIfPresent(form, "1_13bc_rm", commonField.getOthers().get("corAddressRoom"));
setValueIfPresent(form, "1_13bc_floor", commonField.getOthers().get("corAddressFloor"));
setValueIfPresent(form, "1_13bc_block", commonField.getOthers().get("corAddressBlock"));
@@ -1915,6 +1929,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "1_14d_tax_num2", commonField.getTaxPin2());
setValueIfPresent(form, "1_14d_tax_num3", commonField.getTaxPin3());

/*
if(commonField.getTaxResidency1() != null && !commonField.getTaxResidency1().isBlank()){
setValueIfPresent(form, "ch1_14d_reason1_a", "On");
setValueIfPresent(form, "ch1_14d_reason1_b", "On");
@@ -1930,7 +1945,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
setValueIfPresent(form, "ch1_14d_reason3_b", "On");
setValueIfPresent(form, "ch1_14d_reason3_c", "On");
}
if("A".equals(commonField.getTaxReason1())){
setValueIfPresent(form, "ch1_14d_reason1_a", "OFF");
}
@@ -1958,6 +1973,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if("C".equals(commonField.getTaxReason3())){
setValueIfPresent(form, "ch1_14d_reason3_c", "OFF");
}
*/

setValueIfPresent(form, "1_14d_explain1", commonField.getTaxReasonB1());
setValueIfPresent(form, "1_14d_explain2", commonField.getTaxReasonB2());
@@ -2075,21 +2091,14 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page7 End */
/* Page10 Start */
int i = 1;
if("Father".equals(commonField.getOthers().get("relateFatherRelation"))){
if("Father".equals(commonField.getOthers().get("relateFatherRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateFatherName")) != 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++;
}
if("Mother".equals(commonField.getOthers().get("relateMotherRelation"))){
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("Mother".equals(commonField.getOthers().get("relateMotherRelation"))){
if("Mother".equals(commonField.getOthers().get("relateMotherRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateMotherName")) != 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"));
@@ -2103,21 +2112,21 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

i++;
}
if(i <= 4 && "Son".equals(commonField.getOthers().get("relateSonRelation"))){
if(i <= 4 && "Son".equals(commonField.getOthers().get("relateSonRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateSonName")) != 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(i <= 4 && "Bother".equals(commonField.getOthers().get("relateBotherRelation"))){
if(i <= 4 && "Bother".equals(commonField.getOthers().get("relateBotherRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateBotherName")) != 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(i <= 4 && "Sister".equals(commonField.getOthers().get("relateSisterRelation"))){
if(i <= 4 && "Sister".equals(commonField.getOthers().get("relateSisterRelation")) && StringUtils.trimToNull(commonField.getOthers().get("relateSisterName")) != 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"));
@@ -2135,24 +2144,37 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* 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_invest", commonField.getIncomeInterest());
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());
setValueIfPresent(form, "7_2a_invest", commonField.getIncomeOther());
if("INVESTMENT INCOME".equals(StringUtils.trimToEmpty(commonField.getIncomeOther()).toUpperCase())){
setValueIfPresent(form, "7_2a_invest", commonField.getIncomeOther());
setValueIfPresent(form, "7_2a_invest_24", commonField.getIncomeOtherLastYear());
}else{
//setValueIfPresent(form, "fill_k37_2", commonField.getIncomeOther());
//setValueIfPresent(form, "fill_38_2", commonField.getIncomeOtherLastYear());
}
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()));

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_total", commonField.getFna_c2a_amount());
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());
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_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"));
setValueIfPresent(form, "7_2d_address1_2", commonField.getOthers().get("realEstateAddress1_2"));
@@ -2194,7 +2216,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page2 End */
/* Page3 Start */
/*
if(commonField.getTaxResidency1() != null && !commonField.getTaxResidency1().isBlank()){
setValueIfPresent(form2, "ch1_14d_reason1_a", "On");
setValueIfPresent(form2, "ch1_14d_reason1_b", "On");
@@ -2238,7 +2260,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
if("C".equals(commonField.getTaxReason3())){
setValueIfPresent(form2, "ch1_14d_reason3_c", "OFF");
}
*/
/* Page3 End */
/* Page6 Start */
//f(commonField.getInsuranceSumInsured1() != null && !commonField.getInsuranceSumInsured1().isBlank()){
@@ -2480,7 +2502,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void IDA(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "fill_6" -> commonField.setName(fieldValue);
case "fill_7" -> commonField.setNameChi(fieldValue);
case "fill_11" -> commonField.setIdCard(fieldValue);
case "fill_12" -> commonField.setCountryOfIssue(fieldValue);
@@ -2508,10 +2529,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

case "fill_17" -> commonField.setContactNo(fieldValue);
case "fill_18" -> commonField.setEmail(fieldValue);
case "fill_19" -> commonField.getOthers().put("address1", fieldValue);
case "fill_19_1" -> commonField.getOthers().put("address2", fieldValue);
case "fill_23" -> commonField.getOthers().put("crAddress1", fieldValue);
case "fill_23_1" -> commonField.getOthers().put("crAddress2", fieldValue);
//case "fill_19" -> commonField.getOthers().put("address1", fieldValue);
//case "fill_19_1" -> commonField.getOthers().put("address2", fieldValue);
//case "fill_23" -> commonField.getOthers().put("crAddress1", fieldValue);
//case "fill_23_1" -> commonField.getOthers().put("crAddress2", fieldValue);
case "edu_pri" -> commonField.setEduPri(fieldValue);
case "edu_sec" -> commonField.setEduSec(fieldValue);
@@ -2565,8 +2586,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page2 End */
/* Page3 Start */
case "toggle_3_2" -> commonField.setBankruptYes(fieldValue);
case "toggle_6_2" -> commonField.setBankruptNo(fieldValue);
case "fill_18_1" -> commonField.setBankruptNo(fieldValue);
case "toggle_4_2" -> commonField.setBankruptNo(fieldValue);
case "fill_18_1" -> commonField.setBankruptDesc(fieldValue);

case "fill_3_3" -> commonField.getOthers().put("travelCity1",fieldValue);
case "fill_6_3" -> commonField.getOthers().put("travelCity2",fieldValue);
@@ -2752,7 +2773,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page9 Start */
//case "fill_26_4" -> commonField.setFna_c1a_amount(fieldValue);
case "totalAnnualIncome" -> commonField.setTotalAnnualIncome(fieldValue);
case "fill_26_4" -> commonField.getOthers().put("totalEarnedIncome", fieldValue);
case "fill_27_4" -> commonField.getOthers().put("totalEarnedIncomeLastYear", fieldValue);
case "fill_28_4" -> commonField.getOthers().put("totalUnearnedIncome", fieldValue);
case "fill_29_4" -> commonField.getOthers().put("totalUnearnedIncomeLastYear", fieldValue);

case "totalLiquidAsset" -> commonField.setFna_c2a_amount(fieldValue);
case "totalLiquidLia" -> commonField.setFna_c2b_amount(fieldValue);

@@ -2768,6 +2793,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "incomeDividentsLastYear" -> commonField.setIncomeDividentsLastYear(fieldValue);
case "incomeRentals" -> commonField.setIncomeRentals(fieldValue);
case "incomeRentalsLastYear" -> commonField.setIncomeRentalsLastYear(fieldValue);
case "assetCash" -> commonField.setAssetCash(fieldValue);
case "assetInvestment" -> commonField.setAssetInvestment(fieldValue);
case "assetRealEstate" -> commonField.setAssetRealEstate(fieldValue);
@@ -2822,10 +2848,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void FNA(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "fna_a_name" -> commonField.setName(fieldValue);
//case "fna_a_name_1" -> commonField.getOthers().put("name1", fieldValue);
//case "fna_a_name_2" -> commonField.getOthers().put("name2", fieldValue);

case "fna_a_birth" -> commonField.setDateOfBirth(fieldValue);
case "fna_a_id_card" -> commonField.setIdCard(fieldValue);
case "fna_a_occupation" -> commonField.setOccupationTitle(fieldValue);
@@ -2913,6 +2935,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "fna_c3a_20" -> commonField.setFna_c3a_20(fieldValue);
case "fna_c3a_life" -> commonField.setFna_c3a_life(fieldValue);
case "fna_c3a_single_pay" -> commonField.setFna_c3a_single_pay(fieldValue);
case "fna_c3a_single_pay_max" -> commonField.getOthers().put("singlePayAmount", fieldValue);
case "fna_a_retire" -> commonField.setFna_a_retire(fieldValue);
case "fna_c3b_salary" -> commonField.setFna_c3b_salary(fieldValue);
case "fna_c3b_income" -> commonField.setFna_c3b_income(fieldValue);
@@ -2942,7 +2966,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "fna_d_name_1_2" -> commonField.getOthers().put("recProd1_2", fieldValue);
case "fna_d_name_2" -> commonField.getOthers().put("recProd2_1", fieldValue);
case "fna_d_name_2_2" -> commonField.getOthers().put("recProd2_2", fieldValue);
case "fna_d_name_3" -> commonField.getOthers().put("recProd3_2", fieldValue);
case "fna_d_name_3" -> commonField.getOthers().put("recProd3_1", fieldValue);
case "fna_d_name_3_2" -> commonField.getOthers().put("recProd3_2", fieldValue);
case "fna_d_name_4" -> commonField.getOthers().put("recProd4_1", fieldValue);
case "fna_d_name_4_2" -> commonField.getOthers().put("recProd4_2", fieldValue);
@@ -2970,9 +2994,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void HSBCFIN(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "fill_3" -> commonField.setName(fieldValue);
//case "fill_3_1" -> commonField.getOthers().put("name1", fieldValue);
//case "fill_3_2" -> commonField.getOthers().put("name2", fieldValue);
case "fill_4" -> commonField.setNameChi(fieldValue);
case "fill_5" -> commonField.setGender(fieldValue);
case "fill_6" -> commonField.setDateOfBirth(fieldValue);
@@ -3054,7 +3075,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
/* Page4 End */
/* Page5 Start */
case "toggle_1f" -> {commonField.setFna_c3b_income(fieldValue); commonField.setFna_c3b_salary(fieldValue);}
//since it will tick both income and salary and make SLHK income and salary ticked
//case "toggle_1f" -> {commonField.setFna_c3b_income(fieldValue); commonField.setFna_c3b_salary(fieldValue);}
case "toggle_1g" -> {commonField.setFna_c3b_saving(fieldValue); commonField.setFna_c3b_investments(fieldValue);}
//case "toggle_1h" -> commonField.setFna_c3b_policy(fieldValue);
case "toggle_1i56" -> commonField.setFna_c3b_others(fieldValue);
@@ -3081,8 +3103,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void MLB03S(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "SurName1" -> commonField.setFirstName(fieldValue);
case "GivenName1" -> commonField.setGivenName(fieldValue);
case "ChineseName1" -> commonField.setNameChi(fieldValue);

case "male" -> commonField.setGenderMale(fieldValue);
@@ -3113,16 +3133,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "JobNature1" -> commonField.setOccupationTitle(fieldValue);

//Income1 = IDA commonField.getIncomeSalary() + commonField.getIncomeBonus() ??? beware of it may have , and english P.A. or even USD
case "Room1" -> commonField.getOthers().put("crAddressRoom", fieldValue);
case "Floor1" -> commonField.getOthers().put("crAddressFloor", fieldValue);
case "Block1" -> commonField.getOthers().put("crAddressBlock", fieldValue);
case "Building1" -> commonField.getOthers().put("crAddressBuilding", fieldValue);
case "Street1" -> commonField.getOthers().put("crAddressStreet", fieldValue);
case "City1" -> commonField.getOthers().put("crAddressCity", fieldValue);
case "District1" -> commonField.getOthers().put("crAddressDistrict", fieldValue);
case "Country1" -> commonField.getOthers().put("crAddressCountry", fieldValue);
case "PostalCode1" -> commonField.getOthers().put("crAddressPostalCode", fieldValue);
case "Checkbox_Y" -> commonField.setTobarccoYes(fieldValue);
case "Checkbox_N" -> commonField.setTobarccoNo(fieldValue);
/* Page1 End */
@@ -3179,7 +3189,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void MLFNA_EN(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "part1" -> commonField.setName(fieldValue);
case "part2_1a" -> commonField.setFna_b1_a(fieldValue);
case "part2_1a_amount" -> commonField.setFna_b1_a_amount(fieldValue);

@@ -3259,11 +3268,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void SLFNA_EN(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "name" -> commonField.setName(fieldValue);
case "date_of_birth" -> commonField.setDateOfBirth(fieldValue);
case "occupation" -> commonField.setOccupationTitle(fieldValue);
case "address1" -> commonField.getOthers().put("address1", fieldValue);
case "address2" -> commonField.getOthers().put("address2", fieldValue);
//case "address1" -> commonField.getOthers().put("address1", fieldValue);
//case "address2" -> commonField.getOthers().put("address2", fieldValue);
case "contact" -> commonField.setContactNo(fieldValue);
case "email" -> commonField.setEmail(fieldValue);

@@ -3424,33 +3432,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "1_12_8_1" -> commonField.setCompanyNature1(fieldValue);
case "1_12_8_2" -> commonField.setCompanyNature2(fieldValue);

/*
case "ch1_13_rm" -> commonField.setCrAddressRoom(fieldValue);
case "ch1_13_floor" -> commonField.setCrAddressFloor(fieldValue);
case "ch1_13_block" -> commonField.setCrAddressBlock(fieldValue);
case "ch1_13_building" -> commonField.setCrAddressBuilding(fieldValue);
case "ch1_13_street" -> commonField.setCrAddressStreet(fieldValue);
case "ch1_13_country" -> commonField.setCrAddressCountry(fieldValue);
case "1_13_zip" -> commonField.setCrAddressPostalCode(fieldValue);
case "ch1_13_corr_rm" -> commonField.setCorAddressRoom(fieldValue);
case "ch1_13_corr_floor" -> commonField.setCorAddressFloor(fieldValue);
case "ch1_13_corr_block" -> commonField.setCorAddressBlock(fieldValue);
case "ch1_13_corr_building" -> commonField.setCorAddressBuilding(fieldValue);
case "ch1_13_corr_street" -> commonField.setCorAddressStreet(fieldValue);
case "ch1_13_corr_zip" -> commonField.setCorAddressPostalCode(fieldValue);
*/
case "ch1_13_rm" -> commonField.getOthers().put("crAddressRoom", fieldValue);
case "ch1_13_floor" -> commonField.getOthers().put("crAddressFloor", fieldValue);
case "ch1_13_block" -> commonField.getOthers().put("crAddressBlock", fieldValue);
case "ch1_13_building" -> commonField.getOthers().put("crAddressBuilding", fieldValue);
case "ch1_13_street" -> commonField.getOthers().put("crAddressStreet", fieldValue);
case "ch1_13_country" -> commonField.getOthers().put("crAddressCountry", fieldValue);
case "1_13_zip" -> commonField.getOthers().put("crAddressPostalCode", fieldValue);
case "ch1_13_hk" -> commonField.getOthers().put("crAddressHk", fieldValue);
case "ch1_13_kln" -> commonField.getOthers().put("crAddressKln", fieldValue);
case "ch1_13_nt" -> commonField.getOthers().put("crAddressNt", fieldValue);

case "ch1_13_corr_rm" -> commonField.getOthers().put("corAddressRoom", fieldValue);
case "ch1_13_corr_floor" -> commonField.getOthers().put("corAddressFloor", fieldValue);
case "ch1_13_corr_block" -> commonField.getOthers().put("corAddressBlock", fieldValue);
@@ -3466,23 +3447,23 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

case "1_14d_tax1" -> commonField.setTaxResidency1(fieldValue);
case "1_14d_tax_num1" -> commonField.setTaxPin1(fieldValue);
case "ch1_14d_reason1_a" -> commonField.setTaxReason1("A");
case "ch1_14d_reason1_b" -> commonField.setTaxReason1("B");
case "ch1_14d_reason1_c" -> commonField.setTaxReason1("C");
//case "ch1_14d_reason1_a" -> commonField.setTaxReason1("A");
//case "ch1_14d_reason1_b" -> commonField.setTaxReason1("B");
//case "ch1_14d_reason1_c" -> commonField.setTaxReason1("C");
case "1_14d_explain1" -> commonField.setTaxReasonB1(fieldValue);

case "1_14d_tax2" -> commonField.setTaxResidency2(fieldValue);
case "1_14d_tax_num2" -> commonField.setTaxPin2(fieldValue);
case "ch1_14d_reason2_a" -> commonField.setTaxReason2("A");
case "ch1_14d_reason2_b" -> commonField.setTaxReason2("B");
case "ch1_14d_reason2_c" -> commonField.setTaxReason2("C");
//case "ch1_14d_reason2_a" -> commonField.setTaxReason2("A");
//case "ch1_14d_reason2_b" -> commonField.setTaxReason2("B");
//case "ch1_14d_reason2_c" -> commonField.setTaxReason2("C");
case "1_14d_explain2" -> commonField.setTaxReasonB2(fieldValue);

case "1_14d_tax3" -> commonField.setTaxResidency3(fieldValue);
case "1_14d_tax_num3" -> commonField.setTaxPin3(fieldValue);
case "ch1_14d_reason3_a" -> commonField.setTaxReason3("A");
case "ch1_14d_reason3_b" -> commonField.setTaxReason3("B");
case "ch1_14d_reason3_c" -> commonField.setTaxReason3("C");
//case "ch1_14d_reason3_a" -> commonField.setTaxReason3("A");
//case "ch1_14d_reason3_b" -> commonField.setTaxReason3("B");
//case "ch1_14d_reason3_c" -> commonField.setTaxReason3("C");
case "1_14d_explain3" -> commonField.setTaxReasonB3(fieldValue);

case "ch2_5_1p" -> commonField.setEduPri(fieldValue);
@@ -3652,9 +3633,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void HSBCA31(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "fill_15" -> commonField.setFirstName(fieldValue);
case "fill_16" -> commonField.setGivenName(fieldValue);
case "fill_17" -> commonField.setNameChi(fieldValue);
case "Text1" -> commonField.setIdCard(fieldValue);
@@ -3668,11 +3646,11 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "fill_20" -> commonField.setPlaceOfBirth(fieldValue);
/* Page1 End */
/* Page2 Start */
case "Text16_1" -> commonField.getOthers().put("crAddress1", fieldValue);
case "Text16_2" -> commonField.getOthers().put("crAddress2", fieldValue);
//case "Text16_1" -> commonField.getOthers().put("crAddress1", fieldValue);
//case "Text16_2" -> commonField.getOthers().put("crAddress2", fieldValue);

case "address1" -> commonField.getOthers().put("address1", fieldValue);
case "address2" -> commonField.getOthers().put("address2", fieldValue);
//case "address1" -> commonField.getOthers().put("address1", fieldValue);
//case "address2" -> commonField.getOthers().put("address2", fieldValue);

//case "undefined_6" -> commonField.setContactNo(fieldValue);

@@ -3734,6 +3712,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "Check Box74_1ah" -> commonField.getOthers().put("futureAddressNo", fieldValue);
/* Page12 End */
/* Page13 Start */
/*
case "fill_9_6" -> commonField.setIncomeSalary(fieldValue);
case "fill_1k0_5" -> commonField.setIncomeSalaryLastYear(fieldValue);
case "fill_13_4" -> commonField.setIncomeBonus(fieldValue);
@@ -3748,8 +3727,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "fill_34_2" -> commonField.setIncomeRentalsLastYear(fieldValue);
case "fill_k37_2" -> commonField.setIncomeOther(fieldValue);
case "fill_38_2" -> commonField.setIncomeOtherLastYear(fieldValue);
//case "fill_37_2" -> commonField.setTotalAnnualIncome(fieldValue);

case "fill_39_2" -> commonField.setFna_c1b_amount(fieldValue);

case "fill_4114" -> commonField.setAssetCash(fieldValue);
@@ -3759,6 +3737,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito

case "fill_111130" -> commonField.setFna_c2a_amount(fieldValue);
case "fill_1111" -> commonField.setFna_c2b_amount(fieldValue);
*/

/* Page13 End */
/* Page14 Start */
case "fill_73_1" -> commonField.getOthers().put("realEstateAddress1_1", fieldValue);
@@ -3791,8 +3771,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
private void SLGII(String fieldName, String fieldValue, CommonField commonField,PDAcroForm acroForm){
switch (fieldName) {
/* Page1 Start */
case "surname" -> commonField.setFirstName(fieldValue);
case "given_name" -> commonField.setGivenName(fieldValue);
case "ChineseName1" -> commonField.setNameChi(fieldValue);

case "ch1_4_m" -> commonField.setGenderMale(fieldValue);
@@ -3835,16 +3813,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "1_12_nature_1" -> commonField.setCompanyNature1(fieldValue);
case "1_12_nature_2" -> commonField.setCompanyNature2(fieldValue);
case "1_13a_rm" -> commonField.getOthers().put("crAddressRoom", fieldValue);
case "1_13a_floor" -> commonField.getOthers().put("crAddressFloor", fieldValue);
case "1_13a_block" -> commonField.getOthers().put("crAddressBlock", fieldValue);
case "1_13a_building" -> commonField.getOthers().put("crAddressBuilding", fieldValue);
case "1_13a_district" -> commonField.getOthers().put("crAddressCountry", fieldValue);
case "1_13a_zip" -> commonField.getOthers().put("crAddressPostalCode", fieldValue);
case "ch1_13a_hk" -> commonField.getOthers().put("crAddressHK", fieldValue);
case "ch1_13a_kln" -> commonField.getOthers().put("crAddressKln", fieldValue);
case "ch1_13a_nt" -> commonField.getOthers().put("crAddressNt", fieldValue);
case "1_13bc_rm" -> commonField.getOthers().put("corAddressRoom", fieldValue);
case "1_13bc_floor" -> commonField.getOthers().put("corAddressFloor", fieldValue);
case "1_13bc_block" -> commonField.getOthers().put("corAddressBlock", fieldValue);
@@ -3866,6 +3834,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
case "1_14d_tax_num1" -> commonField.setTaxPin1(fieldValue);
case "1_14d_tax_num2" -> commonField.setTaxPin2(fieldValue);
case "1_14d_tax_num3" -> commonField.setTaxPin3(fieldValue);
/*
case "ch1_14d_reason1_a" -> {
if("Off".equals(fieldValue)){
commonField.setTaxReason1("A");
@@ -3911,6 +3880,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
commonField.setTaxReason3("C");
}
}
*/
case "1_14d_explain1" -> commonField.setTaxReasonB1(fieldValue);
case "1_14d_explain2" -> commonField.setTaxReasonB2(fieldValue);
case "1_14d_explain3" -> commonField.setTaxReasonB3(fieldValue);
@@ -4206,6 +4176,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
}
public static double convertStringToNum(String inputString) {
inputString = inputString.replaceAll(",", "");

if (inputString == null || inputString.trim().isEmpty()) {
return 0.0;
}
@@ -4236,29 +4208,55 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
return sum;
}

/**
* Adds the numerical values from two or more strings.
* This method uses varargs to accept a variable number of String arguments.
*
* @param strings An array of strings to be parsed.
* @return The total sum of all numerical values found in all strings.
*/
public static String addNums(String... strings) {
double totalSum = 0.0;
// 1. Calculate the total sum
for (String s : strings) {
totalSum += convertStringToNum(s);
// Assuming convertStringToNum(s) returns a double from the string
// You'll need to ensure this utility function is available.
totalSum += convertStringToNum(s);
}
return String.valueOf(totalSum);
}

// 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.00");

return decimalFormatter.format(totalSum);
}
public static String substractNums(String a, String b) {
double aValue = convertStringToNum(a);
double bValue = convertStringToNum(b);

if(aValue >= bValue)
return String.valueOf(aValue - bValue);
else
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.00");

// 3. Format and return the difference
return decimalFormatter.format(difference);
} else {
// Return an empty string if aValue is less than bValue
return "";
}
}

public static Map<String, String> getCountryAndPhoneNo(String contactNo){
@@ -4326,4 +4324,39 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito
);
return jdbcDao.queryForMap(sql.toString(), Map.of("id", id)).orElse(null);
}

public String getCrAddress1(Client client){
String value = "";
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressRoom()))){
value += StringUtils.trimToEmpty(client.getCrAddressRoom()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressFloor()))){
value += StringUtils.trimToEmpty(client.getCrAddressFloor()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressBlock()))){
value += StringUtils.trimToEmpty(client.getCrAddressBlock()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressBuilding()))){
value += StringUtils.trimToEmpty(client.getCrAddressBuilding()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressStreet()))){
value += StringUtils.trimToEmpty(client.getCrAddressStreet()) + " ";
}
return StringUtils.trimToEmpty(value);
}

public String getCrAddress2(Client client){
String value = "";
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressArea()))){
value += StringUtils.trimToEmpty(client.getCrAddressArea()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressCity()))){
value += StringUtils.trimToEmpty(client.getCrAddressCity()) + " ";
}
if(!"".equals(StringUtils.trimToEmpty(client.getCrAddressCountry()))){
value += StringUtils.trimToEmpty(client.getCrAddressCountry()) + " ";
}
return StringUtils.trimToEmpty(value);
}

}

+ 14
- 0
src/main/resources/db/changelog/changes/31_client_address_fields/01_add_address.sql Ver fichero

@@ -0,0 +1,14 @@
--liquibase formatted sql

--changeset vin:add address fields

ALTER TABLE `lionerdb`.`client`
ADD COLUMN `crAddressRoom` VARCHAR(50) NULL,
ADD COLUMN `crAddressFloor` VARCHAR(50) NULL,
ADD COLUMN `crAddressBlock` VARCHAR(50) NULL,
ADD COLUMN `crAddressBuilding` VARCHAR(100) NULL,
ADD COLUMN `crAddressStreet` VARCHAR(100) NULL,
ADD COLUMN `crAddressArea` VARCHAR(30) NULL,
ADD COLUMN `crAddressCity` VARCHAR(100) NULL,
ADD COLUMN `crAddressCountry` VARCHAR(100) NULL,
ADD COLUMN `crAddressPostalCode` VARCHAR(20) NULL;

Cargando…
Cancelar
Guardar