FINERACT-2075: (chore) introduce lombok annotations to LoanProduct class.

- remove the redundant getters/setters methods from LoanProduct class.
- replace the non-standard methods with the convenient ones.
- modify other files that were depending on the old naming.
This commit is contained in:
zeyad2003
2024-05-23 15:01:02 +02:00
committed by Adam Saghy
parent d0e71ed7d6
commit f59ae64222
14 changed files with 44 additions and 237 deletions
@@ -107,7 +107,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
public void validateGuarantorBusinessRules(Loan loan) {
LoanProduct loanProduct = loan.loanProduct();
BigDecimal principal = loan.getPrincipal().getAmount();
if (loanProduct.isHoldGuaranteeFundsEnabled()) {
if (loanProduct.isHoldGuaranteeFunds()) {
LoanProductGuaranteeDetails guaranteeData = loanProduct.getLoanProductGuaranteeDetails();
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
BigDecimal mandatoryAmount = principal.multiply(guaranteeData.getMandatoryGuarantee()).divide(BigDecimal.valueOf(100));
@@ -313,7 +313,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
*
*/
private void holdGuarantorFunds(final Loan loan) {
if (loan.loanProduct().isHoldGuaranteeFundsEnabled()) {
if (loan.loanProduct().isHoldGuaranteeFunds()) {
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
List<GuarantorFundingDetails> guarantorFundingDetailList = new ArrayList<>();
List<DepositAccountOnHoldTransaction> onHoldTransactions = new ArrayList<>();
@@ -123,7 +123,7 @@ public class GuarantorWritePlatformServiceJpaRepositoryIImpl implements Guaranto
GuarantorFundStatusType.ACTIVE.getValue(), guarantorCommand.getAmount());
guarantorFundingDetails.add(fundingDetails);
if (loan.isDisbursed()
|| (loan.isApproved() && (loan.getGuaranteeAmount() != null || loan.loanProduct().isHoldGuaranteeFundsEnabled()))) {
|| (loan.isApproved() && (loan.getGuaranteeAmount() != null || loan.loanProduct().isHoldGuaranteeFunds()))) {
this.guarantorDomainService.assignGuarantor(fundingDetails, DateUtils.getBusinessLocalDate());
loan.updateGuaranteeAmount(fundingDetails.getAmount());
}
@@ -1004,7 +1004,7 @@ public class LoanScheduleAssembler {
private void extractLoanTermVariations(final Loan loan, final String json, final List<LoanTermVariations> loanTermVariations) {
final JsonElement element = this.fromApiJsonHelper.parse(json);
if (loan.loanProduct().allowVariabeInstallments()) {
if (loan.loanProduct().isAllowVariabeInstallments()) {
if (element.isJsonObject() && this.fromApiJsonHelper.parameterExists(LoanApiConstants.exceptionParamName, element)) {
final JsonObject topLevelJsonElement = element.getAsJsonObject();
final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(topLevelJsonElement);
@@ -118,7 +118,7 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
if (loanProduct.useBorrowerCycle()) {
if (loanProduct.isUseBorrowerCycle()) {
final Long clientId = this.fromJsonHelper.extractLongNamed("clientId", query.parsedJson());
final Long groupId = this.fromJsonHelper.extractLongNamed("groupId", query.parsedJson());
Integer cycleNumber = 0;
@@ -517,7 +517,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
}
if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)) {
if (!(loanProduct.canDefineInstallmentAmount() || loanProduct.isMultiDisburseLoan())) {
if (!(loanProduct.isCanDefineInstallmentAmount() || loanProduct.isMultiDisburseLoan())) {
List<String> unsupportedParameterList = new ArrayList<>();
unsupportedParameterList.add(LoanApiConstants.emiAmountParameterName);
throw new UnsupportedParameterException(unsupportedParameterList);
@@ -536,7 +536,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
.ignoreIfNull().positiveAmount();
}
if (loanProduct.canUseForTopup() && this.fromApiJsonHelper.parameterExists(LoanApiConstants.isTopup, element)) {
if (loanProduct.isCanUseForTopup() && this.fromApiJsonHelper.parameterExists(LoanApiConstants.isTopup, element)) {
final Boolean isTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanApiConstants.isTopup, element);
baseDataValidator.reset().parameter(LoanApiConstants.isTopup).value(isTopup).validateForBooleanValue();
@@ -1079,7 +1079,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
}
if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)) {
if (!(loanProduct.canDefineInstallmentAmount() || loanProduct.isMultiDisburseLoan())) {
if (!(loanProduct.isCanDefineInstallmentAmount() || loanProduct.isMultiDisburseLoan())) {
List<String> unsupportedParameterList = new ArrayList<>();
unsupportedParameterList.add(LoanApiConstants.emiAmountParameterName);
throw new UnsupportedParameterException(unsupportedParameterList);
@@ -1099,7 +1099,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
.ignoreIfNull().positiveAmount();
}
if (loanProduct.canUseForTopup() && this.fromApiJsonHelper.parameterExists(LoanApiConstants.isTopup, element)) {
if (loanProduct.isCanUseForTopup() && this.fromApiJsonHelper.parameterExists(LoanApiConstants.isTopup, element)) {
final Boolean isTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanApiConstants.isTopup, element);
baseDataValidator.reset().parameter(LoanApiConstants.isTopup).value(isTopup).ignoreIfNull().validateForBooleanValue();
@@ -1422,7 +1422,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
.failWithCode("not.supported.for.selected.interest.calcualtion.type");
}
if (loanProduct.allowVariabeInstallments()) {
if (loanProduct.isAllowVariabeInstallments()) {
baseDataValidator.reset().parameter(LoanProductConstants.allowVariableInstallmentsParamName)
.failWithCode("not.supported.for.selected.interest.calcualtion.type");
}
@@ -85,7 +85,7 @@ public class VariableLoanScheduleFromApiJsonValidator {
}
final JsonElement element = this.fromApiJsonHelper.parse(json);
if (loan.loanProduct().allowVariabeInstallments()) {
if (loan.loanProduct().isAllowVariabeInstallments()) {
if (element.isJsonObject() && this.fromApiJsonHelper.parameterExists(LoanApiConstants.exceptionParamName, element)) {
final JsonObject topLevelJsonElement = element.getAsJsonObject();
final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(topLevelJsonElement);
@@ -235,7 +235,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
if (loanProduct.useBorrowerCycle()) {
if (loanProduct.isUseBorrowerCycle()) {
Integer cycleNumber = 0;
if (clientId != null) {
cycleNumber = this.loanReadPlatformService.retriveLoanCounter(clientId, loanProduct.getId());
@@ -264,7 +264,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final LoanProductRelatedDetail productRelatedDetail = newLoanApplication.repaymentScheduleDetail();
if (loanProduct.getLoanProductConfigurableAttributes() != null) {
if (loanProduct.getLoanConfigurableAttributes() != null) {
updateProductRelatedDetails(productRelatedDetail, newLoanApplication);
}
@@ -273,7 +273,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
productRelatedDetail.getRepayEvery(), productRelatedDetail.getRepaymentPeriodFrequencyType().getValue(),
newLoanApplication);
if (loanProduct.canUseForTopup() && clientId != null) {
if (loanProduct.isCanUseForTopup() && clientId != null) {
final Boolean isTopup = command.booleanObjectValueOfParameterNamed(LoanApiConstants.isTopup);
if (null == isTopup) {
newLoanApplication.setIsTopup(false);
@@ -553,7 +553,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
activeLoansLoanProductIds = this.loanRepositoryWrapper.findActiveLoansLoanProductIdsByClient(loan.getClientId(),
LoanStatus.ACTIVE.getValue());
}
checkForProductMixRestrictions(activeLoansLoanProductIds, productId, loan.loanProduct().productName());
checkForProductMixRestrictions(activeLoansLoanProductIds, productId, loan.loanProduct().getName());
}
private void checkForProductMixRestrictions(final List<Long> activeLoansLoanProductIds, final Long productId,
@@ -574,15 +574,15 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
}
private void updateProductRelatedDetails(LoanProductRelatedDetail productRelatedDetail, Loan loan) {
final Boolean amortization = loan.loanProduct().getLoanProductConfigurableAttributes().getAmortizationBoolean();
final Boolean arrearsTolerance = loan.loanProduct().getLoanProductConfigurableAttributes().getArrearsToleranceBoolean();
final Boolean graceOnArrearsAging = loan.loanProduct().getLoanProductConfigurableAttributes().getGraceOnArrearsAgingBoolean();
final Boolean interestCalcPeriod = loan.loanProduct().getLoanProductConfigurableAttributes().getInterestCalcPeriodBoolean();
final Boolean interestMethod = loan.loanProduct().getLoanProductConfigurableAttributes().getInterestMethodBoolean();
final Boolean graceOnPrincipalAndInterestPayment = loan.loanProduct().getLoanProductConfigurableAttributes()
final Boolean amortization = loan.loanProduct().getLoanConfigurableAttributes().getAmortizationBoolean();
final Boolean arrearsTolerance = loan.loanProduct().getLoanConfigurableAttributes().getArrearsToleranceBoolean();
final Boolean graceOnArrearsAging = loan.loanProduct().getLoanConfigurableAttributes().getGraceOnArrearsAgingBoolean();
final Boolean interestCalcPeriod = loan.loanProduct().getLoanConfigurableAttributes().getInterestCalcPeriodBoolean();
final Boolean interestMethod = loan.loanProduct().getLoanConfigurableAttributes().getInterestMethodBoolean();
final Boolean graceOnPrincipalAndInterestPayment = loan.loanProduct().getLoanConfigurableAttributes()
.getGraceOnPrincipalAndInterestPaymentBoolean();
final Boolean repaymentEvery = loan.loanProduct().getLoanProductConfigurableAttributes().getRepaymentEveryBoolean();
final Boolean transactionProcessingStrategy = loan.loanProduct().getLoanProductConfigurableAttributes()
final Boolean repaymentEvery = loan.loanProduct().getLoanConfigurableAttributes().getRepaymentEveryBoolean();
final Boolean transactionProcessingStrategy = loan.loanProduct().getLoanConfigurableAttributes()
.getTransactionProcessingStrategyBoolean();
if (!amortization) {
@@ -609,9 +609,9 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
productRelatedDetail.setRepayEvery(loan.loanProduct().getLoanProductRelatedDetail().getRepayEvery());
}
if (!transactionProcessingStrategy) {
loan.updateTransactionProcessingStrategy(loan.loanProduct().getRepaymentStrategy(),
this.loanRepaymentScheduleTransactionProcessorFactory.determineProcessor(loan.loanProduct().getRepaymentStrategy())
.getName());
loan.updateTransactionProcessingStrategy(loan.loanProduct().getTransactionProcessingStrategyCode(),
this.loanRepaymentScheduleTransactionProcessorFactory
.determineProcessor(loan.loanProduct().getTransactionProcessingStrategyCode()).getName());
}
}
@@ -807,7 +807,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
}
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
if (newLoanProduct.useBorrowerCycle()) {
if (newLoanProduct.isUseBorrowerCycle()) {
final Long clientId = this.fromJsonHelper.extractLongNamed("clientId", command.parsedJson());
final Long groupId = this.fromJsonHelper.extractLongNamed("groupId", command.parsedJson());
Integer cycleNumber = 0;
@@ -838,11 +838,11 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
validateSubmittedOnDate(existingLoanApplication);
final LoanProductRelatedDetail productRelatedDetail = existingLoanApplication.repaymentScheduleDetail();
if (existingLoanApplication.loanProduct().getLoanProductConfigurableAttributes() != null) {
if (existingLoanApplication.loanProduct().getLoanConfigurableAttributes() != null) {
updateProductRelatedDetails(productRelatedDetail, existingLoanApplication);
}
if (existingLoanApplication.getLoanProduct().canUseForTopup() && existingLoanApplication.getClientId() != null) {
if (existingLoanApplication.getLoanProduct().isCanUseForTopup() && existingLoanApplication.getClientId() != null) {
final Boolean isTopup = command.booleanObjectValueOfParameterNamed(LoanApiConstants.isTopup);
if (command.isChangeInBooleanParameterNamed(LoanApiConstants.isTopup, existingLoanApplication.isTopup())) {
existingLoanApplication.setIsTopup(isTopup);
@@ -164,7 +164,7 @@ public class LoanAssembler {
}
List<LoanDisbursementDetails> disbursementDetails = new ArrayList<>();
BigDecimal fixedEmiAmount = null;
if (loanProduct.isMultiDisburseLoan() || loanProduct.canDefineInstallmentAmount()) {
if (loanProduct.isMultiDisburseLoan() || loanProduct.isCanDefineInstallmentAmount()) {
fixedEmiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element);
}
BigDecimal maxOutstandingLoanBalance = null;
@@ -1676,7 +1676,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
if (!backdatePenalties && !isDueToday) {
continue;
}
Optional<Charge> penaltyCharge = loan.getLoanProduct().getLoanProductCharges().stream()
Optional<Charge> penaltyCharge = loan.getLoanProduct().getCharges().stream()
.filter((e) -> ChargeTimeType.OVERDUE_INSTALLMENT.getValue().equals(e.getChargeTimeType()) && e.isLoanCharge())
.findFirst();
@@ -347,7 +347,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// validate ActualDisbursement Date Against Expected Disbursement Date
LoanProduct loanProduct = loan.loanProduct();
if (loanProduct.syncExpectedWithDisbursementDate()) {
if (loanProduct.isSyncExpectedWithDisbursementDate()) {
syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate);
}
@@ -725,7 +725,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// validate ActualDisbursement Date Against Expected Disbursement
// Date
LoanProduct loanProduct = loan.loanProduct();
if (loanProduct.syncExpectedWithDisbursementDate()) {
if (loanProduct.isSyncExpectedWithDisbursementDate()) {
syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate);
}
checkClientOrGroupActive(loan);
@@ -1556,7 +1556,7 @@ public final class LoanProductDataValidator {
baseDataValidator);
// Guarantee Funds
Boolean holdGuaranteeFunds = loanProduct.isHoldGuaranteeFundsEnabled();
Boolean holdGuaranteeFunds = loanProduct.isHoldGuaranteeFunds();
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.holdGuaranteeFundsParamName, element)) {
holdGuaranteeFunds = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.holdGuaranteeFundsParamName, element);
baseDataValidator.reset().parameter(LoanProductConstants.holdGuaranteeFundsParamName).value(holdGuaranteeFunds).notNull()
@@ -2378,7 +2378,7 @@ public final class LoanProductDataValidator {
variableInstallments = this.fromApiJsonHelper
.extractBooleanNamed(LoanProductConstants.allowVariableInstallmentsParamName, element);
} else if (loanProduct != null) {
variableInstallments = loanProduct.allowVariabeInstallments();
variableInstallments = loanProduct.isAllowVariabeInstallments();
}
if (variableInstallments != null && variableInstallments) {
baseDataValidator.reset().parameter(LoanProductConstants.allowVariableInstallmentsParamName)
@@ -205,7 +205,7 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
if (changes.containsKey("fundId")) {
final Long fundId = (Long) changes.get("fundId");
final Fund fund = findFundByIdIfProvided(fundId);
product.update(fund);
product.setFund(fund);
}
if (changes.containsKey("delinquencyBucketId")) {
@@ -253,7 +253,7 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
// accounting related changes
final boolean accountingTypeChanged = changes.containsKey("accountingRule");
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService
.updateLoanProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType());
.updateLoanProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingRule());
changes.putAll(accountingMappingChanges);
if (changes.containsKey(LoanProductConstants.RATES_PARAM_NAME)) {