feat(guarantor): enrich guarantor accounts API with loan health and borrower details

- Add borrower name, savings account, guaranteed/released/remaining amounts, loan timeline, and overdue info to GuarantorAccountSummaryData
- Fix duplicate rows in GuarantorLoanAccountSummaryDataMapper by joining savings account via guarantor funding details instead of client ID
- Fix NPE in GuarantorDomainServiceImpl when loan product guarantee details are null

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-24 13:15:25 +05:30
co-authored by Claude Sonnet 4.6
parent 1eba2c50ed
commit fc80869d4b
7 changed files with 2537 additions and 2446 deletions
@@ -1,116 +1,150 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.infrastructure.core.serialization; package org.apache.fineract.infrastructure.core.serialization;
import com.google.gson.ExclusionStrategy; import com.google.gson.ExclusionStrategy;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import java.time.LocalDate; import com.google.gson.TypeAdapter;
import java.time.LocalDateTime; import com.google.gson.TypeAdapterFactory;
import java.time.LocalTime; import com.google.gson.reflect.TypeToken;
import java.time.MonthDay; import com.google.gson.stream.JsonReader;
import java.time.OffsetDateTime; import com.google.gson.stream.JsonWriter;
import java.time.ZonedDateTime; import java.io.IOException;
import java.util.ArrayList; import java.time.LocalDate;
import java.util.HashSet; import java.time.LocalDateTime;
import java.util.Set; import java.time.LocalTime;
import org.apache.fineract.infrastructure.core.api.DateAdapter; import java.time.MonthDay;
import org.apache.fineract.infrastructure.core.api.ExternalIdAdapter; import java.time.OffsetDateTime;
import org.apache.fineract.infrastructure.core.api.JodaDateTimeAdapter; import java.time.ZonedDateTime;
import org.apache.fineract.infrastructure.core.api.JodaMonthDayAdapter; import java.util.ArrayList;
import org.apache.fineract.infrastructure.core.api.LocalDateAdapter; import java.util.HashSet;
import org.apache.fineract.infrastructure.core.api.LocalDateTimeAdapter; import java.util.Set;
import org.apache.fineract.infrastructure.core.api.LocalTimeAdapter; import org.apache.fineract.infrastructure.core.api.DateAdapter;
import org.apache.fineract.infrastructure.core.api.OffsetDateTimeAdapter; import org.apache.fineract.infrastructure.core.api.ExternalIdAdapter;
import org.apache.fineract.infrastructure.core.api.ParameterListExclusionStrategy; import org.apache.fineract.infrastructure.core.api.JodaDateTimeAdapter;
import org.apache.fineract.infrastructure.core.api.ParameterListInclusionStrategy; import org.apache.fineract.infrastructure.core.api.JodaMonthDayAdapter;
import org.apache.fineract.infrastructure.core.domain.ExternalId; import org.apache.fineract.infrastructure.core.api.LocalDateAdapter;
import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException; import org.apache.fineract.infrastructure.core.api.LocalDateTimeAdapter;
import org.springframework.stereotype.Service; import org.apache.fineract.infrastructure.core.api.LocalTimeAdapter;
import org.apache.fineract.infrastructure.core.api.OffsetDateTimeAdapter;
/** import org.apache.fineract.infrastructure.core.api.ParameterListExclusionStrategy;
* Helper class for serialization of Java objects into JSON using Google's GSON. import org.apache.fineract.infrastructure.core.api.ParameterListInclusionStrategy;
*/ import org.apache.fineract.infrastructure.core.domain.ExternalId;
@Service import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException;
public final class GoogleGsonSerializerHelper { import org.springframework.stereotype.Service;
public Gson createGsonBuilderForPartialResponseFiltering(final Set<String> responseParameters) { /**
final ExclusionStrategy strategy = new ParameterListInclusionStrategy(responseParameters); * Helper class for serialization of Java objects into JSON using Google's GSON.
*/
final GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy); @Service
registerTypeAdapters(builder); public final class GoogleGsonSerializerHelper {
return builder.create();
} public Gson createGsonBuilderForPartialResponseFiltering(final Set<String> responseParameters) {
final ExclusionStrategy strategy = new ParameterListInclusionStrategy(responseParameters);
public Gson createGsonBuilderWithParameterExclusionSerializationStrategy(final Set<String> supportedParameters,
final Set<String> responseParameters) { final GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy);
registerTypeAdapters(builder);
final Set<String> parameterNamesToSkip = new HashSet<>(); return builder.create();
}
if (!responseParameters.isEmpty()) {
// strip out all known support parameters from expected response to public Gson createGsonBuilderWithParameterExclusionSerializationStrategy(final Set<String> supportedParameters,
// see if unsupported parameters requested for response. final Set<String> responseParameters) {
final Set<String> differentParametersDetectedSet = new HashSet<>(responseParameters);
differentParametersDetectedSet.removeAll(supportedParameters); final Set<String> parameterNamesToSkip = new HashSet<>();
if (!differentParametersDetectedSet.isEmpty()) { if (!responseParameters.isEmpty()) {
throw new UnsupportedParameterException(new ArrayList<>(differentParametersDetectedSet)); // strip out all known support parameters from expected response to
} // see if unsupported parameters requested for response.
final Set<String> differentParametersDetectedSet = new HashSet<>(responseParameters);
parameterNamesToSkip.addAll(supportedParameters); differentParametersDetectedSet.removeAll(supportedParameters);
parameterNamesToSkip.removeAll(responseParameters);
} if (!differentParametersDetectedSet.isEmpty()) {
throw new UnsupportedParameterException(new ArrayList<>(differentParametersDetectedSet));
final ExclusionStrategy strategy = new ParameterListExclusionStrategy(parameterNamesToSkip); }
final GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy); parameterNamesToSkip.addAll(supportedParameters);
registerTypeAdapters(builder); parameterNamesToSkip.removeAll(responseParameters);
return builder.create(); }
}
final ExclusionStrategy strategy = new ParameterListExclusionStrategy(parameterNamesToSkip);
public String serializedJsonFrom(final Gson serializer, final Object[] dataObjects) {
return serializer.toJson(dataObjects); final GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy);
} registerTypeAdapters(builder);
return builder.create();
public String serializedJsonFrom(final Gson serializer, final Object singleDataObject) { }
return serializer.toJson(singleDataObject);
} public String serializedJsonFrom(final Gson serializer, final Object[] dataObjects) {
return serializer.toJson(dataObjects);
public static Gson createSimpleGson() { }
return createGsonBuilder().create();
} public String serializedJsonFrom(final Gson serializer, final Object singleDataObject) {
return serializer.toJson(singleDataObject);
public static GsonBuilder createGsonBuilder() { }
final GsonBuilder builder = new GsonBuilder();
registerTypeAdapters(builder); public static Gson createSimpleGson() {
return builder; return createGsonBuilder().create();
} }
public static void registerTypeAdapters(final GsonBuilder builder) { public static GsonBuilder createGsonBuilder() {
builder.registerTypeAdapter(java.util.Date.class, new DateAdapter()); final GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(LocalDate.class, new LocalDateAdapter()); registerTypeAdapters(builder);
// NOTE: was missing, necessary for GSON serialization with JDK 21's restrictive module access return builder;
builder.registerTypeAdapter(LocalTime.class, new LocalTimeAdapter()); }
builder.registerTypeAdapter(ZonedDateTime.class, new JodaDateTimeAdapter());
builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter()); public static void registerTypeAdapters(final GsonBuilder builder) {
builder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter()); builder.registerTypeAdapter(java.util.Date.class, new DateAdapter());
builder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter()); builder.registerTypeAdapter(LocalDate.class, new LocalDateAdapter());
builder.registerTypeAdapter(ExternalId.class, new ExternalIdAdapter()); // NOTE: was missing, necessary for GSON serialization with JDK 21's restrictive module access
} builder.registerTypeAdapter(LocalTime.class, new LocalTimeAdapter());
} builder.registerTypeAdapter(ZonedDateTime.class, new JodaDateTimeAdapter());
builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter());
builder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter());
builder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter());
builder.registerTypeAdapter(ExternalId.class, new ExternalIdAdapter());
// Use runtime type when serializing interface-typed fields (e.g. Collection<? extends IGuarantor>)
builder.registerTypeAdapterFactory(new TypeAdapterFactory() {
@Override
@SuppressWarnings("unchecked")
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> type) {
if (!type.getRawType().isInterface()) {
return null;
}
final TypeAdapterFactory self = this;
return new TypeAdapter<T>() {
@Override
public void write(final JsonWriter out, final T value) throws IOException {
if (value == null) {
out.nullValue();
return;
}
TypeAdapter<T> delegate = (TypeAdapter<T>) gson.getDelegateAdapter(self,
TypeToken.get((Class<T>) value.getClass()));
delegate.write(out, value);
}
@Override
public T read(final JsonReader in) throws IOException {
return null;
}
};
}
});
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.accountdetails.data; package org.apache.fineract.portfolio.accountdetails.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.loanaccount.data.LoanStatusEnumData; import org.apache.fineract.portfolio.loanaccount.data.LoanStatusEnumData;
@@ -44,12 +45,26 @@ public class GuarantorAccountSummaryData {
private final Boolean isActive; private final Boolean isActive;
private final String relationship; private final String relationship;
private final BigDecimal onHoldAmount; private final BigDecimal onHoldAmount;
private final String savingsAccountNo;
private final BigDecimal amountReleased;
private final String borrowerName;
private final BigDecimal totalOverdue;
private final LocalDate overdueSinceDate;
private final LocalDate submittedOnDate;
private final LocalDate approvedOnDate;
private final LocalDate disbursedOnDate;
private final LocalDate expectedMaturityDate;
private final BigDecimal amountRemaining;
private final BigDecimal savingsBalance;
public GuarantorAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId, public GuarantorAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
final String loanProductName, final String shortLoanProductName, final LoanStatusEnumData loanStatus, final String loanProductName, final String shortLoanProductName, final LoanStatusEnumData loanStatus,
final EnumOptionData loanType, final Integer loanCycle, final Boolean inArrears, final BigDecimal originalLoan, final EnumOptionData loanType, final Integer loanCycle, final Boolean inArrears, final BigDecimal originalLoan,
final BigDecimal loanBalance, final BigDecimal amountPaid, final Boolean isActive, final String relationship, final BigDecimal loanBalance, final BigDecimal amountPaid, final Boolean isActive, final String relationship,
final BigDecimal onHoldAmount) { final BigDecimal onHoldAmount, final String savingsAccountNo, final BigDecimal amountReleased,
final String borrowerName, final BigDecimal totalOverdue, final LocalDate overdueSinceDate,
final LocalDate submittedOnDate, final LocalDate approvedOnDate, final LocalDate disbursedOnDate,
final LocalDate expectedMaturityDate, final BigDecimal amountRemaining, final BigDecimal savingsBalance) {
this.id = id; this.id = id;
this.accountNo = accountNo; this.accountNo = accountNo;
this.externalId = externalId; this.externalId = externalId;
@@ -66,5 +81,16 @@ public class GuarantorAccountSummaryData {
this.isActive = isActive; this.isActive = isActive;
this.relationship = relationship; this.relationship = relationship;
this.onHoldAmount = onHoldAmount; this.onHoldAmount = onHoldAmount;
this.savingsAccountNo = savingsAccountNo;
this.amountReleased = amountReleased;
this.borrowerName = borrowerName;
this.totalOverdue = totalOverdue;
this.overdueSinceDate = overdueSinceDate;
this.submittedOnDate = submittedOnDate;
this.approvedOnDate = approvedOnDate;
this.disbursedOnDate = disbursedOnDate;
this.expectedMaturityDate = expectedMaturityDate;
this.amountRemaining = amountRemaining;
this.savingsBalance = savingsBalance;
} }
} }
@@ -725,7 +725,10 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
builder.append("c.alternate_dip_verified as alternateDipVerified, "); builder.append("c.alternate_dip_verified as alternateDipVerified, ");
builder.append("c.alternate_dip_lookup_log_id as alternateDipLookupLogId, "); builder.append("c.alternate_dip_lookup_log_id as alternateDipLookupLogId, ");
builder.append("c.alternate_dip_timestamp as alternateDipTimestamp, "); builder.append("c.alternate_dip_timestamp as alternateDipTimestamp, ");
builder.append("c.dip_lookup_log_id as dipLookupLogId, ");
builder.append("c.dip_timestamp as dipTimestamp, ");
builder.append("c.name_verified as nameVerified, "); builder.append("c.name_verified as nameVerified, ");
builder.append("c.screening_log_id as screeningLogId, ");
builder.append("c.submittedon_date as submittedOnDate, "); builder.append("c.submittedon_date as submittedOnDate, ");
builder.append("sbu.username as submittedByUsername, "); builder.append("sbu.username as submittedByUsername, ");
@@ -1,214 +1,215 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.portfolio.loanaccount.guarantor.data; package org.apache.fineract.portfolio.loanaccount.guarantor.data;
import java.io.Serial; import java.io.Serial;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.organisation.staff.data.StaffData; import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.portfolio.account.data.PortfolioAccountData; import org.apache.fineract.portfolio.account.data.PortfolioAccountData;
import org.apache.fineract.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientData;
import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType; import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType;
import org.apache.fineract.portfolio.loanaccount.guarantor.service.GuarantorEnumerations; import org.apache.fineract.portfolio.loanaccount.guarantor.service.GuarantorEnumerations;
@Getter @Getter
public class GuarantorData implements IGuarantor { public class GuarantorData implements IGuarantor {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final Long id; private final Long id;
private final Long loanId; private final Long loanId;
private final CodeValueData clientRelationshipType; private final CodeValueData clientRelationshipType;
private final EnumOptionData guarantorType; private final EnumOptionData guarantorType;
private final String firstname; private final String firstname;
private final String lastname; private final String lastname;
/*** Fields for current customers/staff serving as guarantors **/ /*** Fields for current customers/staff serving as guarantors **/
private final Long entityId; private final Long entityId;
private final String externalId; private final String externalId;
private final String officeName; private final String officeName;
private final LocalDate joinedDate; private final LocalDate joinedDate;
/*** Fields for external persons serving as guarantors ***/ /*** Fields for external persons serving as guarantors ***/
private final String addressLine1; private final String addressLine1;
private final String addressLine2; private final String addressLine2;
private final String city; private final String city;
private final String state; private final String state;
private final String zip; private final String zip;
private final String country; private final String country;
private final String mobileNumber; private final String mobileNumber;
private final String housePhoneNumber; private final String housePhoneNumber;
private final String comment; private final String comment;
private final LocalDate dob; private final LocalDate dob;
private final Collection<GuarantorFundingData> guarantorFundingDetails; private final Collection<GuarantorFundingData> guarantorFundingDetails;
private final boolean status; private final boolean status;
// template // template
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final List<EnumOptionData> guarantorTypeOptions; private final List<EnumOptionData> guarantorTypeOptions;
private final Collection<CodeValueData> allowedClientRelationshipTypes; private final Collection<CodeValueData> allowedClientRelationshipTypes;
private final Collection<PortfolioAccountData> accountLinkingOptions; private final Collection<PortfolioAccountData> accountLinkingOptions;
// import fields // import fields
private Integer guarantorTypeId; private Integer guarantorTypeId;
private Integer clientRelationshipTypeId; private Integer clientRelationshipTypeId;
private Integer savingsId; private Integer savingsId;
private BigDecimal amount; private BigDecimal amount;
private transient Long accountId; private transient Long accountId;
private transient Integer rowIndex; private transient Integer rowIndex;
private String dateFormat; private String dateFormat;
private String locale; private String locale;
public static GuarantorData importInstance(Integer guarantorTypeId, Integer clientRelationshipTypeId, Long entityId, String firstname, public static GuarantorData importInstance(Integer guarantorTypeId, Integer clientRelationshipTypeId, Long entityId, String firstname,
String lastname, String addressLine1, String addressLine2, String city, LocalDate dob, String zip, Integer savingsId, String lastname, String addressLine1, String addressLine2, String city, LocalDate dob, String zip, Integer savingsId,
BigDecimal amount, Integer rowIndex, Long accountId, String locale, String dateFormat) { BigDecimal amount, Integer rowIndex, Long accountId, String locale, String dateFormat) {
return new GuarantorData(guarantorTypeId, clientRelationshipTypeId, entityId, firstname, lastname, addressLine1, addressLine2, city, return new GuarantorData(guarantorTypeId, clientRelationshipTypeId, entityId, firstname, lastname, addressLine1, addressLine2, city,
dob, zip, savingsId, amount, rowIndex, accountId, locale, dateFormat); dob, zip, savingsId, amount, rowIndex, accountId, locale, dateFormat);
} }
private GuarantorData(Integer guarantorTypeId, Integer clientRelationshipTypeId, Long entityId, String firstname, String lastname, private GuarantorData(Integer guarantorTypeId, Integer clientRelationshipTypeId, Long entityId, String firstname, String lastname,
String addressLine1, String addressLine2, String city, LocalDate dob, String zip, Integer savingsId, BigDecimal amount, String addressLine1, String addressLine2, String city, LocalDate dob, String zip, Integer savingsId, BigDecimal amount,
Integer rowIndex, Long accountId, String locale, String dateFormat) { Integer rowIndex, Long accountId, String locale, String dateFormat) {
this.rowIndex = rowIndex; this.rowIndex = rowIndex;
this.firstname = firstname; this.firstname = firstname;
this.lastname = lastname; this.lastname = lastname;
this.entityId = entityId; this.entityId = entityId;
this.addressLine1 = addressLine1; this.addressLine1 = addressLine1;
this.addressLine2 = addressLine2; this.addressLine2 = addressLine2;
this.city = city; this.city = city;
this.zip = zip; this.zip = zip;
this.dob = dob; this.dob = dob;
this.guarantorTypeId = guarantorTypeId; this.guarantorTypeId = guarantorTypeId;
this.clientRelationshipTypeId = clientRelationshipTypeId; this.clientRelationshipTypeId = clientRelationshipTypeId;
this.savingsId = savingsId; this.savingsId = savingsId;
this.amount = amount; this.amount = amount;
this.accountId = accountId; this.accountId = accountId;
this.dateFormat = dateFormat; this.dateFormat = dateFormat;
this.locale = locale; this.locale = locale;
this.clientRelationshipType = null; this.clientRelationshipType = null;
this.guarantorType = null; this.guarantorType = null;
this.id = null; this.id = null;
this.loanId = null; this.loanId = null;
this.externalId = null; this.externalId = null;
this.officeName = null; this.officeName = null;
this.joinedDate = null; this.joinedDate = null;
this.state = null; this.state = null;
this.country = null; this.country = null;
this.mobileNumber = null; this.mobileNumber = null;
this.housePhoneNumber = null; this.housePhoneNumber = null;
this.comment = null; this.comment = null;
this.guarantorFundingDetails = null; this.guarantorFundingDetails = null;
this.status = false; this.status = false;
this.guarantorTypeOptions = null; this.guarantorTypeOptions = null;
this.allowedClientRelationshipTypes = null; this.allowedClientRelationshipTypes = null;
this.accountLinkingOptions = null; this.accountLinkingOptions = null;
} }
public static GuarantorData template(final List<EnumOptionData> guarantorTypeOptions, public static GuarantorData template(final List<EnumOptionData> guarantorTypeOptions,
final Collection<CodeValueData> allowedClientRelationshipTypes, Collection<PortfolioAccountData> accountLinkingOptions) { final Collection<CodeValueData> allowedClientRelationshipTypes, Collection<PortfolioAccountData> accountLinkingOptions) {
final Collection<GuarantorFundingData> guarantorFundingDetails = null; final Collection<GuarantorFundingData> guarantorFundingDetails = null;
final boolean status = false; final boolean status = false;
return new GuarantorData(null, null, null, null, GuarantorEnumerations.guarantorType(GuarantorType.CUSTOMER), null, null, null, return new GuarantorData(null, null, null, null, GuarantorEnumerations.guarantorType(GuarantorType.CUSTOMER), null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, status, guarantorFundingDetails, null, null, null, null, null, null, null, null, null, null, null, null, status, guarantorFundingDetails,
guarantorTypeOptions, allowedClientRelationshipTypes, accountLinkingOptions); guarantorTypeOptions, allowedClientRelationshipTypes, accountLinkingOptions);
} }
public static GuarantorData templateOnTop(final GuarantorData guarantorData, final List<EnumOptionData> guarantorTypeOptions, public static GuarantorData templateOnTop(final GuarantorData guarantorData, final List<EnumOptionData> guarantorTypeOptions,
final Collection<CodeValueData> allowedClientRelationshipTypes, Collection<PortfolioAccountData> accountLinkingOptions) { final Collection<CodeValueData> allowedClientRelationshipTypes, Collection<PortfolioAccountData> accountLinkingOptions) {
return new GuarantorData(guarantorData.id, guarantorData.loanId, guarantorData.clientRelationshipType, guarantorData.entityId, return new GuarantorData(guarantorData.id, guarantorData.loanId, guarantorData.clientRelationshipType, guarantorData.entityId,
guarantorData.guarantorType, guarantorData.firstname, guarantorData.lastname, guarantorData.dob, guarantorData.addressLine1, guarantorData.guarantorType, guarantorData.firstname, guarantorData.lastname, guarantorData.dob, guarantorData.addressLine1,
guarantorData.addressLine2, guarantorData.city, guarantorData.state, guarantorData.zip, guarantorData.country, guarantorData.addressLine2, guarantorData.city, guarantorData.state, guarantorData.zip, guarantorData.country,
guarantorData.mobileNumber, guarantorData.housePhoneNumber, guarantorData.comment, guarantorData.officeName, guarantorData.mobileNumber, guarantorData.housePhoneNumber, guarantorData.comment, guarantorData.officeName,
guarantorData.joinedDate, guarantorData.externalId, guarantorData.status, guarantorData.guarantorFundingDetails, guarantorData.joinedDate, guarantorData.externalId, guarantorData.status, guarantorData.guarantorFundingDetails,
guarantorTypeOptions, allowedClientRelationshipTypes, accountLinkingOptions); guarantorTypeOptions, allowedClientRelationshipTypes, accountLinkingOptions);
} }
public static GuarantorData mergeClientData(final ClientData clientData, final GuarantorData guarantorData) { public static GuarantorData mergeClientData(final ClientData clientData, final GuarantorData guarantorData) {
return new GuarantorData(guarantorData.id, guarantorData.loanId, guarantorData.clientRelationshipType, guarantorData.entityId, return new GuarantorData(guarantorData.id, guarantorData.loanId, guarantorData.clientRelationshipType, guarantorData.entityId,
guarantorData.guarantorType, clientData.getFirstname(), clientData.getLastname(), null, null, null, null, null, null, null, guarantorData.guarantorType, clientData.getFirstname(), clientData.getLastname(), null, null, null, null, null, null, null,
null, null, null, clientData.getOfficeName(), clientData.getActivationDate(), clientData.getExternalId().getValue(), null, null, null, clientData.getOfficeName(), clientData.getActivationDate(),
guarantorData.status, guarantorData.guarantorFundingDetails, null, guarantorData.allowedClientRelationshipTypes, clientData.getExternalId() != null ? clientData.getExternalId().getValue() : null,
guarantorData.accountLinkingOptions); guarantorData.status, guarantorData.guarantorFundingDetails, null, guarantorData.allowedClientRelationshipTypes,
} guarantorData.accountLinkingOptions);
}
public static GuarantorData mergeStaffData(final StaffData staffData, final GuarantorData guarantorData) {
return new GuarantorData(guarantorData.id, guarantorData.loanId, guarantorData.clientRelationshipType, guarantorData.entityId, public static GuarantorData mergeStaffData(final StaffData staffData, final GuarantorData guarantorData) {
guarantorData.guarantorType, staffData.getFirstname(), staffData.getLastname(), null, null, null, null, null, null, null, return new GuarantorData(guarantorData.id, guarantorData.loanId, guarantorData.clientRelationshipType, guarantorData.entityId,
null, null, null, staffData.getOfficeName(), null, null, guarantorData.status, guarantorData.guarantorFundingDetails, null, guarantorData.guarantorType, staffData.getFirstname(), staffData.getLastname(), null, null, null, null, null, null, null,
guarantorData.allowedClientRelationshipTypes, guarantorData.accountLinkingOptions); null, null, null, staffData.getOfficeName(), null, null, guarantorData.status, guarantorData.guarantorFundingDetails, null,
} guarantorData.allowedClientRelationshipTypes, guarantorData.accountLinkingOptions);
}
public GuarantorData(final Long id, final Long loanId, final CodeValueData clientRelationshipType, final Long entityId,
final EnumOptionData guarantorType, final String firstname, final String lastname, final LocalDate dob, public GuarantorData(final Long id, final Long loanId, final CodeValueData clientRelationshipType, final Long entityId,
final String addressLine1, final String addressLine2, final String city, final String state, final String zip, final EnumOptionData guarantorType, final String firstname, final String lastname, final LocalDate dob,
final String country, final String mobileNumber, final String housePhoneNumber, final String comment, final String officeName, final String addressLine1, final String addressLine2, final String city, final String state, final String zip,
final LocalDate joinedDate, final String externalId, final boolean status, final String country, final String mobileNumber, final String housePhoneNumber, final String comment, final String officeName,
Collection<GuarantorFundingData> guarantorFundingDetails, final List<EnumOptionData> guarantorTypeOptions, final LocalDate joinedDate, final String externalId, final boolean status,
final Collection<CodeValueData> allowedClientRelationshipTypes, final Collection<PortfolioAccountData> accountLinkingOptions) { Collection<GuarantorFundingData> guarantorFundingDetails, final List<EnumOptionData> guarantorTypeOptions,
this.id = id; final Collection<CodeValueData> allowedClientRelationshipTypes, final Collection<PortfolioAccountData> accountLinkingOptions) {
this.loanId = loanId; this.id = id;
this.clientRelationshipType = clientRelationshipType; this.loanId = loanId;
this.guarantorType = guarantorType; this.clientRelationshipType = clientRelationshipType;
this.entityId = entityId; this.guarantorType = guarantorType;
this.firstname = firstname; this.entityId = entityId;
this.lastname = lastname; this.firstname = firstname;
this.dob = dob; this.lastname = lastname;
this.addressLine1 = addressLine1; this.dob = dob;
this.addressLine2 = addressLine2; this.addressLine1 = addressLine1;
this.city = city; this.addressLine2 = addressLine2;
this.state = state; this.city = city;
this.zip = zip; this.state = state;
this.country = country; this.zip = zip;
this.mobileNumber = mobileNumber; this.country = country;
this.housePhoneNumber = housePhoneNumber; this.mobileNumber = mobileNumber;
this.comment = comment; this.housePhoneNumber = housePhoneNumber;
this.officeName = officeName; this.comment = comment;
this.joinedDate = joinedDate; this.officeName = officeName;
this.externalId = externalId; this.joinedDate = joinedDate;
this.status = status; this.externalId = externalId;
this.guarantorFundingDetails = guarantorFundingDetails; this.status = status;
this.guarantorTypeOptions = guarantorTypeOptions; this.guarantorFundingDetails = guarantorFundingDetails;
this.allowedClientRelationshipTypes = allowedClientRelationshipTypes; this.guarantorTypeOptions = guarantorTypeOptions;
this.accountLinkingOptions = accountLinkingOptions; this.allowedClientRelationshipTypes = allowedClientRelationshipTypes;
} this.accountLinkingOptions = accountLinkingOptions;
}
public boolean isExternalGuarantor() {
return GuarantorType.EXTERNAL.getValue().equals(this.guarantorType.getId().intValue()); public boolean isExternalGuarantor() {
} return GuarantorType.EXTERNAL.getValue().equals(this.guarantorType.getId().intValue());
}
public boolean isExistingClient() {
return GuarantorType.CUSTOMER.getValue().equals(this.guarantorType.getId().intValue()); public boolean isExistingClient() {
} return GuarantorType.CUSTOMER.getValue().equals(this.guarantorType.getId().intValue());
}
public boolean isStaffMember() {
return GuarantorType.STAFF.getValue().equals(this.guarantorType.getId().intValue()); public boolean isStaffMember() {
} return GuarantorType.STAFF.getValue().equals(this.guarantorType.getId().intValue());
}
public boolean isExistingGroup() {
return GuarantorType.GROUP.getValue().equals(this.guarantorType.getId().intValue()); public boolean isExistingGroup() {
} return GuarantorType.GROUP.getValue().equals(this.guarantorType.getId().intValue());
} }
}