Skip to content

Commit

Permalink
FINERACT-2075: (chore) refactor some classes under loanproduct pack…
Browse files Browse the repository at this point in the history
…age in loan module.

- Remove Getters, Setters, and constructors from `LoanProductMinMaxConstraints` & `LoanProductVariableInstallmentConfig`.
  • Loading branch information
Zeyad2003 authored and adamsaghy committed Apr 16, 2024
1 parent 0761c39 commit 457be1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.api.JsonCommand;

/**
* LoanProductMinMaxConstraints encapsulates all the Min and Max details of a {@link LoanProduct}.
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class LoanProductMinMaxConstraints {

Expand All @@ -49,29 +57,6 @@ public class LoanProductMinMaxConstraints {
@Column(name = "max_number_of_repayments")
private Integer maxNumberOfRepayments;

public static LoanProductMinMaxConstraints createFrom(final BigDecimal minPrincipal, final BigDecimal maxPrincipal,
final BigDecimal minNominalInterestRatePerPeriod, final BigDecimal maxNominalInterestRatePerPeriod,
final Integer minNumberOfRepayments, final Integer maxNumberOfRepayments) {

return new LoanProductMinMaxConstraints(minPrincipal, maxPrincipal, minNominalInterestRatePerPeriod,
maxNominalInterestRatePerPeriod, minNumberOfRepayments, maxNumberOfRepayments);
}

protected LoanProductMinMaxConstraints() {
//
}

public LoanProductMinMaxConstraints(final BigDecimal defaultMinPrincipal, final BigDecimal defaultMaxPrincipal,
final BigDecimal defaultMinNominalInterestRatePerPeriod, final BigDecimal defaultMaxNominalInterestRatePerPeriod,
final Integer defaultMinNumberOfRepayments, final Integer defaultMaxNumberOfRepayments) {
this.minPrincipal = defaultMinPrincipal;
this.maxPrincipal = defaultMaxPrincipal;
this.minNominalInterestRatePerPeriod = defaultMinNominalInterestRatePerPeriod;
this.maxNominalInterestRatePerPeriod = defaultMaxNominalInterestRatePerPeriod;
this.minNumberOfRepayments = defaultMinNumberOfRepayments;
this.maxNumberOfRepayments = defaultMaxNumberOfRepayments;
}

public Map<String, Object> update(final JsonCommand command) {

final Map<String, Object> actualChanges = new LinkedHashMap<>(20);
Expand Down Expand Up @@ -131,14 +116,6 @@ public Map<String, Object> update(final JsonCommand command) {
return actualChanges;
}

public BigDecimal getMinPrincipal() {
return this.minPrincipal;
}

public BigDecimal getMaxPrincipal() {
return this.maxPrincipal;
}

public BigDecimal getMinNominalInterestRatePerPeriod() {
return this.minNominalInterestRatePerPeriod == null ? null
: BigDecimal.valueOf(Double.parseDouble(this.minNominalInterestRatePerPeriod.stripTrailingZeros().toString()));
Expand All @@ -149,24 +126,8 @@ public BigDecimal getMaxNominalInterestRatePerPeriod() {
: BigDecimal.valueOf(Double.parseDouble(this.maxNominalInterestRatePerPeriod.stripTrailingZeros().toString()));
}

public Integer getMinNumberOfRepayments() {
return this.minNumberOfRepayments;
}

public Integer getMaxNumberOfRepayments() {
return this.maxNumberOfRepayments;
}

public void updateForFloatingInterestRates() {
this.minNominalInterestRatePerPeriod = null;
this.maxNominalInterestRatePerPeriod = null;
}

public void setMinNominalInterestRatePerPeriod(BigDecimal minNominalInterestRatePerPeriod) {
this.minNominalInterestRatePerPeriod = minNominalInterestRatePerPeriod;
}

public void setMaxNominalInterestRatePerPeriod(BigDecimal maxNominalInterestRatePerPeriod) {
this.maxNominalInterestRatePerPeriod = maxNominalInterestRatePerPeriod;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@
import jakarta.persistence.Table;
import java.util.LinkedHashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.portfolio.loanproduct.LoanProductConstants;

@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "m_product_loan_variable_installment_config")
public class LoanProductVariableInstallmentConfig extends AbstractPersistableCustom {

@Setter
@OneToOne
@JoinColumn(name = "loan_product_id", nullable = false)
private LoanProduct loanProduct;
Expand All @@ -43,20 +51,6 @@ public class LoanProductVariableInstallmentConfig extends AbstractPersistableCus
@Column(name = "maximum_gap")
private Integer maximumGap;

protected LoanProductVariableInstallmentConfig() {

}

public LoanProductVariableInstallmentConfig(final LoanProduct loanProduct, final Integer minimumGap, final Integer maximumGap) {
this.loanProduct = loanProduct;
this.minimumGap = minimumGap;
this.maximumGap = maximumGap;
}

public void setLoanProduct(final LoanProduct loanProduct) {
this.loanProduct = loanProduct;
}

public Map<? extends String, ?> update(JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<>(3);

Expand All @@ -74,13 +68,4 @@ public void setLoanProduct(final LoanProduct loanProduct) {

return actualChanges;
}

public Integer getMinimumGap() {
return this.minimumGap;
}

public Integer getMaximumGap() {
return this.maximumGap;
}

}

0 comments on commit 457be1a

Please sign in to comment.