Skip to content

Commit

Permalink
FINERACT-2075: (chore) introduce lombok annotations to LoanProduct
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Zeyad2003 authored and adamsaghy committed May 23, 2024
1 parent d0e71ed commit f59ae64
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ public Map<String, Object> loanApplicationModification(final JsonCommand command
this.disbursementDetails.clear();
}

if (loanProduct.isMultiDisburseLoan() || loanProduct.canDefineInstallmentAmount()) {
if (loanProduct.isMultiDisburseLoan() || loanProduct.isCanDefineInstallmentAmount()) {
if (command.isChangeInBigDecimalParameterNamed(LoanApiConstants.emiAmountParameterName, this.fixedEmiAmount)) {
this.fixedEmiAmount = command.bigDecimalValueOfParameterNamed(LoanApiConstants.emiAmountParameterName);
actualChanges.put(LoanApiConstants.emiAmountParameterName, this.fixedEmiAmount);
Expand Down Expand Up @@ -2561,7 +2561,7 @@ public void regenerateScheduleOnDisbursement(final ScheduleGeneratorDTO schedule
final LocalDate actualDisbursementDate, BigDecimal emiAmount, LocalDate nextPossibleRepaymentDate,
LocalDate rescheduledRepaymentDate) {
boolean isEmiAmountChanged = false;
if ((this.loanProduct.isMultiDisburseLoan() || this.loanProduct.canDefineInstallmentAmount()) && emiAmount != null
if ((this.loanProduct.isMultiDisburseLoan() || this.loanProduct.isCanDefineInstallmentAmount()) && emiAmount != null
&& emiAmount.compareTo(retriveLastEmiAmount()) != 0) {
if (this.loanProduct.isMultiDisburseLoan()) {
final LocalDate dateValue = null;
Expand Down Expand Up @@ -5057,7 +5057,7 @@ private void validateActivityNotBeforeClientOrGroupTransferDate(final LoanEvent
}

private void validateActivityNotBeforeLastTransactionDate(final LoanEvent event, final LocalDate activityDate) {
if (!(this.repaymentScheduleDetail().isInterestRecalculationEnabled() || this.loanProduct().isHoldGuaranteeFundsEnabled())) {
if (!(this.repaymentScheduleDetail().isInterestRecalculationEnabled() || this.loanProduct().isHoldGuaranteeFunds())) {
return;
}
LocalDate lastTransactionDate = getLastUserTransactionDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
Expand Down Expand Up @@ -77,6 +79,8 @@
* They allow for constraints to be added at product level.
*/
@Entity
@Getter
@Setter
@Table(name = "m_product_loan", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "unq_name"),
@UniqueConstraint(columnNames = { "external_id" }, name = "external_id_UNIQUE"),
@UniqueConstraint(columnNames = { "short_name" }, name = "unq_short_name") })
Expand Down Expand Up @@ -844,26 +848,6 @@ public MonetaryCurrency getCurrency() {
return this.loanProductRelatedDetail.getCurrency();
}

public void update(final Fund fund) {
this.fund = fund;
}

public void setTransactionProcessingStrategyCode(final String transactionProcessingStrategyCode) {
this.transactionProcessingStrategyCode = transactionProcessingStrategyCode;
}

public String getTransactionProcessingStrategyCode() {
return this.transactionProcessingStrategyCode;
}

public void setTransactionProcessingStrategyName(final String transactionProcessingStrategyName) {
this.transactionProcessingStrategyName = transactionProcessingStrategyName;
}

public String getRepaymentStrategy() {
return this.transactionProcessingStrategyCode;
}

public boolean hasCurrencyCodeOf(final String currencyCode) {
return this.loanProductRelatedDetail.hasCurrencyCodeOf(currencyCode);
}
Expand Down Expand Up @@ -910,30 +894,6 @@ public boolean updateRates(final List<Rate> newProductRates) {
return updated;
}

public Integer getAccountingType() {
return this.accountingRule;
}

public List<Charge> getLoanProductCharges() {
return this.charges;
}

public List<LoanProductPaymentAllocationRule> getPaymentAllocationRules() {
return this.paymentAllocationRules;
}

public List<LoanProductCreditAllocationRule> getCreditAllocationRules() {
return this.creditAllocationRules;
}

public void update(final LoanProductConfigurableAttributes loanConfigurableAttributes) {
this.loanConfigurableAttributes = loanConfigurableAttributes;
}

public LoanProductConfigurableAttributes getLoanProductConfigurableAttributes() {
return this.loanConfigurableAttributes;
}

public Map<String, Object> update(final JsonCommand command, final AprCalculator aprCalculator, FloatingRate floatingRate) {

final Map<String, Object> actualChanges = this.loanProductRelatedDetail.update(command, aprCalculator);
Expand Down Expand Up @@ -1395,10 +1355,6 @@ public boolean isCashBasedAccountingEnabled() {
return AccountingRuleType.CASH_BASED.getValue().equals(this.accountingRule);
}

public boolean isAccrualBasedAccountingEnabled() {
return isUpfrontAccrualAccountingEnabled() || isPeriodicAccrualAccountingEnabled();
}

public boolean isUpfrontAccrualAccountingEnabled() {
return AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(this.accountingRule);
}
Expand Down Expand Up @@ -1457,30 +1413,6 @@ public LoanProductMinMaxConstraints loanProductMinMaxConstraints() {
return this.loanProductMinMaxConstraints;
}

public boolean isIncludeInBorrowerCycle() {
return this.includeInBorrowerCycle;
}

public LocalDate getStartDate() {
return this.startDate;
}

public LocalDate getCloseDate() {
return this.closeDate;
}

public String productName() {
return this.name;
}

public ExternalId getExternalId() {
return this.externalId;
}

public boolean useBorrowerCycle() {
return this.useBorrowerCycle;
}

public boolean isMultiDisburseLoan() {
return this.loanProductTrancheDetails.isMultiDisburseLoan();
}
Expand Down Expand Up @@ -1512,14 +1444,6 @@ public LoanProductBorrowerCycleVariations fetchLoanProductBorrowerCycleVariation
return borrowerCycleVariation;
}

public boolean syncExpectedWithDisbursementDate() {
return syncExpectedWithDisbursementDate;
}

public void setSyncExpectedWithDisbursementDate(boolean syncExpectedWithDisbursementDate) {
this.syncExpectedWithDisbursementDate = syncExpectedWithDisbursementDate;
}

public Map<String, BigDecimal> fetchBorrowerCycleVariationsForCycleNumber(final Integer cycleNumber) {
Map<String, BigDecimal> borrowerCycleVariations = new HashMap<>();
borrowerCycleVariations.put(LoanProductConstants.PRINCIPAL, this.loanProductRelatedDetail.getPrincipal().getAmount());
Expand Down Expand Up @@ -1627,26 +1551,6 @@ public DaysInYearType fetchDaysInYearType() {
return this.loanProductRelatedDetail.fetchDaysInYearType();
}

public LoanProductInterestRecalculationDetails getProductInterestRecalculationDetails() {
return this.productInterestRecalculationDetails;
}

public boolean isHoldGuaranteeFundsEnabled() {
return this.holdGuaranteeFunds;
}

public LoanProductGuaranteeDetails getLoanProductGuaranteeDetails() {
return this.loanProductGuaranteeDetails;
}

public String getShortName() {
return this.shortName;
}

public BigDecimal getPrincipalThresholdForLastInstallment() {
return this.principalThresholdForLastInstallment;
}

public boolean isArrearsBasedOnOriginalSchedule() {
boolean isBasedOnOriginalSchedule = false;
if (getProductInterestRecalculationDetails() != null) {
Expand All @@ -1655,14 +1559,6 @@ public boolean isArrearsBasedOnOriginalSchedule() {
return isBasedOnOriginalSchedule;
}

public boolean canDefineInstallmentAmount() {
return this.canDefineInstallmentAmount;
}

public Integer getInstallmentAmountInMultiplesOf() {
return this.installmentAmountInMultiplesOf;
}

public LoanPreClosureInterestCalculationStrategy preCloseInterestCalculationStrategy() {
LoanPreClosureInterestCalculationStrategy preCloseInterestCalculationStrategy = LoanPreClosureInterestCalculationStrategy.NONE;
if (this.isInterestRecalculationEnabled()) {
Expand All @@ -1671,18 +1567,6 @@ public LoanPreClosureInterestCalculationStrategy preCloseInterestCalculationStra
return preCloseInterestCalculationStrategy;
}

public LoanProductRelatedDetail getLoanProductRelatedDetail() {
return loanProductRelatedDetail;
}

public boolean isLinkedToFloatingInterestRate() {
return this.isLinkedToFloatingInterestRate;
}

public LoanProductFloatingRates getFloatingRates() {
return this.floatingRates;
}

public Collection<FloatingRatePeriodData> fetchInterestRates(final FloatingRateDTO floatingRateDTO) {
Collection<FloatingRatePeriodData> applicableRates = new ArrayList<>(1);
if (isLinkedToFloatingInterestRate()) {
Expand All @@ -1691,92 +1575,15 @@ public Collection<FloatingRatePeriodData> fetchInterestRates(final FloatingRateD
return applicableRates;
}

public boolean allowVariabeInstallments() {
return this.allowVariabeInstallments;
}

public boolean canUseForTopup() {
return this.canUseForTopup;
}

public boolean isEqualAmortization() {
return loanProductRelatedDetail.isEqualAmortization();
}

public List<Rate> getRates() {
return rates;
}

public void setRates(List<Rate> rates) {
this.rates = rates;
}

public BigDecimal getFixedPrincipalPercentagePerInstallment() {
return fixedPrincipalPercentagePerInstallment;
}

public boolean isDisallowExpectedDisbursements() {
return disallowExpectedDisbursements;
}

public boolean isAllowApprovedDisbursedAmountsOverApplied() {
return allowApprovedDisbursedAmountsOverApplied;
}

public String getOverAppliedCalculationType() {
return overAppliedCalculationType;
}

public Integer getOverAppliedNumber() {
return overAppliedNumber;
}

public void setDisallowExpectedDisbursements(boolean disallowExpectedDisbursements) {
this.disallowExpectedDisbursements = disallowExpectedDisbursements;
}

public void setAllowApprovedDisbursedAmountsOverApplied(boolean allowApprovedDisbursedAmountsOverApplied) {
this.allowApprovedDisbursedAmountsOverApplied = allowApprovedDisbursedAmountsOverApplied;
}

public void setOverAppliedCalculationType(String overAppliedCalculationType) {
this.overAppliedCalculationType = overAppliedCalculationType;
}

public void setOverAppliedNumber(Integer overAppliedNumber) {
this.overAppliedNumber = overAppliedNumber;
}

public void setLoanProductTrancheDetails(LoanProductTrancheDetails loanProducTrancheDetails) {
this.loanProductTrancheDetails = loanProducTrancheDetails;
}

public DelinquencyBucket getDelinquencyBucket() {
return delinquencyBucket;
}

public void setDelinquencyBucket(DelinquencyBucket delinquencyBucket) {
this.delinquencyBucket = delinquencyBucket;
}

public Integer getDueDaysForRepaymentEvent() {
return this.dueDaysForRepaymentEvent;
}

public Integer getOverDueDaysForRepaymentEvent() {
return this.overDueDaysForRepaymentEvent;
}

public RepaymentStartDateType getRepaymentStartDateType() {
return this.repaymentStartDateType == null ? RepaymentStartDateType.INVALID : this.repaymentStartDateType;
}

public boolean isEnableInstallmentLevelDelinquency() {
return enableInstallmentLevelDelinquency;
}

public void updateEnableInstallmentLevelDelinquency(boolean enableInstallmentLevelDelinquency) {
this.enableInstallmentLevelDelinquency = enableInstallmentLevelDelinquency;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void addListeners() {
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));
Expand Down Expand Up @@ -313,7 +313,7 @@ private void reverseAllFundTransaction(final Loan loan) {
*
*/
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<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private CommandProcessingResult createGuarantor(final Loan loan, final JsonComma
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ private List<LoanTermVariations> adjustExistingVariations(List<LoanTermVariation

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public LoanScheduleModel calculateLoanSchedule(final JsonQuery query, Boolean va
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;
Expand Down
Loading

0 comments on commit f59ae64

Please sign in to comment.