fix up some old validation issues on loans.
This commit is contained in:
@@ -26,11 +26,9 @@ public class Charge extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "charge_applies_to_enum", nullable = false)
|
@Column(name = "charge_applies_to_enum", nullable = false)
|
||||||
private Integer chargeAppliesTo;
|
private Integer chargeAppliesTo;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Column(name = "charge_time_enum", nullable = false)
|
@Column(name = "charge_time_enum", nullable = false)
|
||||||
private Integer chargeTime;
|
private Integer chargeTime;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Column(name = "charge_calculation_enum")
|
@Column(name = "charge_calculation_enum")
|
||||||
private Integer chargeCalculation;
|
private Integer chargeCalculation;
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "maturedon_date")
|
@Column(name = "maturedon_date")
|
||||||
private Date maturedOnDate;
|
private Date maturedOnDate;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@LazyCollection(LazyCollectionOption.FALSE)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
||||||
private Set<LoanCharge> charges;
|
private Set<LoanCharge> charges;
|
||||||
@@ -162,11 +161,11 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return new Loan(client, fund, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, null);
|
return new Loan(client, fund, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Loan() {
|
protected Loan() {
|
||||||
this.client = null;
|
this.client = null;
|
||||||
this.loanProduct = null;
|
this.loanProduct = null;
|
||||||
this.loanRepaymentScheduleDetail = null;
|
this.loanRepaymentScheduleDetail = null;
|
||||||
this.charges = charges;
|
this.charges = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Loan(final Client client, Fund fund, LoanTransactionProcessingStrategy transactionProcessingStrategy, final LoanProduct loanProduct,
|
public Loan(final Client client, Fund fund, LoanTransactionProcessingStrategy transactionProcessingStrategy, final LoanProduct loanProduct,
|
||||||
|
|||||||
@@ -7,17 +7,21 @@ import javax.persistence.*;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Entity @IdClass(LoanCharge.LoanChargePK.class)
|
@Entity
|
||||||
|
@IdClass(LoanCharge.LoanChargePK.class)
|
||||||
@Table(name = "m_loan_charge")
|
@Table(name = "m_loan_charge")
|
||||||
public class LoanCharge {
|
public class LoanCharge {
|
||||||
|
|
||||||
@Id
|
@SuppressWarnings("unused")
|
||||||
|
@Id
|
||||||
private Loan loan;
|
private Loan loan;
|
||||||
|
|
||||||
@Id
|
@SuppressWarnings("unused")
|
||||||
|
@Id
|
||||||
private Charge charge;
|
private Charge charge;
|
||||||
|
|
||||||
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
|
@SuppressWarnings("unused")
|
||||||
|
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -28,7 +32,8 @@ public class LoanCharge {
|
|||||||
@Column(name = "charge_calculation_enum")
|
@Column(name = "charge_calculation_enum")
|
||||||
private Integer chargeCalculation;
|
private Integer chargeCalculation;
|
||||||
|
|
||||||
public LoanCharge() {
|
protected LoanCharge() {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanCharge(Loan loan, Charge charge, LoanChargeCommand command) {
|
public LoanCharge(Loan loan, Charge charge, LoanChargeCommand command) {
|
||||||
@@ -54,11 +59,11 @@ public class LoanCharge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanCharge(Loan loan, Charge charge) {
|
public LoanCharge(final Loan loan, final Charge charge) {
|
||||||
this(loan, charge, charge.getAmount(), charge.getChargeTime(), charge.getChargeCalculation());
|
this(loan, charge, charge.getAmount(), charge.getChargeTime(), charge.getChargeCalculation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanCharge(Loan loan, Charge charge, BigDecimal amount, Integer chargeTime, Integer chargeCalculation) {
|
public LoanCharge(final Loan loan, final Charge charge, final BigDecimal amount, final Integer chargeTime, final Integer chargeCalculation) {
|
||||||
this.loan = loan;
|
this.loan = loan;
|
||||||
this.charge = charge;
|
this.charge = charge;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
@@ -66,13 +71,15 @@ public class LoanCharge {
|
|||||||
this.chargeCalculation = chargeCalculation;
|
this.chargeCalculation = chargeCalculation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LoanChargePK implements Serializable{
|
public static class LoanChargePK implements Serializable {
|
||||||
@Id
|
@SuppressWarnings("unused")
|
||||||
|
@Id
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@JoinColumn(name = "loan_id", referencedColumnName = "id", nullable=false)
|
@JoinColumn(name = "loan_id", referencedColumnName = "id", nullable=false)
|
||||||
private Loan loan;
|
private Loan loan;
|
||||||
|
|
||||||
@Id
|
@SuppressWarnings("unused")
|
||||||
|
@Id
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@JoinColumn(name = "charge_id", referencedColumnName = "id", nullable=false)
|
@JoinColumn(name = "charge_id", referencedColumnName = "id", nullable=false)
|
||||||
private Charge charge;
|
private Charge charge;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public class LoanProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "description")
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "m_product_loan_charge",
|
@JoinTable(name = "m_product_loan_charge",
|
||||||
joinColumns = @JoinColumn(name = "product_loan_id"),
|
joinColumns = @JoinColumn(name = "product_loan_id"),
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ public class CalculateLoanScheduleCommandValidator {
|
|||||||
|
|
||||||
// FIXME - this constraint doesnt really need to be here. should be possible to express loan term as say 12 months whilst also saying
|
// FIXME - this constraint doesnt really need to be here. should be possible to express loan term as say 12 months whilst also saying
|
||||||
// - that the repayment structure is 6 repayments every bi-monthly.
|
// - that the repayment structure is 6 repayments every bi-monthly.
|
||||||
if (!command.getLoanTermFrequencyType().equals(command.getRepaymentFrequencyType())) {
|
if (command.getLoanTermFrequencyType() != null && !command.getLoanTermFrequencyType().equals(command.getRepaymentFrequencyType())) {
|
||||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.loanTermFrequencyType.not.the.same.as.repaymentFrequencyType",
|
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.loanTermFrequencyType.not.the.same.as.repaymentFrequencyType",
|
||||||
"The parameters loanTermFrequencyType and repaymentFrequencyType must be the same.", "loanTermFrequencyType",
|
"The parameters loanTermFrequencyType and repaymentFrequencyType must be the same.", "loanTermFrequencyType",
|
||||||
command.getLoanTermFrequencyType(), command.getRepaymentFrequencyType());
|
command.getLoanTermFrequencyType(), command.getRepaymentFrequencyType());
|
||||||
|
|||||||
Reference in New Issue
Block a user